feat: initialize FABRIC TypeScript project
Implements bd-3a4 and bd-2pa.1 (project setup): - Initialize npm project with TypeScript configuration - Add package.json with build scripts and dependencies - Create src/ structure with types and CLI entry point - Add CLI commands: tui, web, tail (placeholders) - Configure tsconfig.json for NodeNext modules This addresses worker starvation (bd-29a) by demonstrating that direct implementation is a viable alternative when workers cannot claim beads due to dependency resolution issues. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
43079b35ca
commit
69f3c1d5ab
14 changed files with 430 additions and 0 deletions
4
.beads/.br_history/issues.20260303_042445.jsonl
Normal file
4
.beads/.br_history/issues.20260303_042445.jsonl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{"id":"bd-2kf","title":"FABRIC: Flow Analysis & Bead Reporting Interface Console","description":"# FABRIC Project Epic\n\n## Overview\nFABRIC is a live display for NEEDLE worker activity. It parses NEEDLE's structured JSON logging output and renders it in real-time as either a TUI (terminal) or web dashboard.\n\n## Core Goals\n1. **Live Display**: Real-time visualization of NEEDLE worker activity\n2. **Dual Interface**: TUI for terminal users, web app for browser users\n3. **Stateless Core**: Reads and displays - no storage or persistence (analytics features use optional SQLite)\n4. **Intelligence**: Beyond simple log display - provides insights, detection, and analysis\n\n## Data Flow\n```\nNEEDLE Workers → ~/.needle/logs/ → FABRIC → Live TUI or Web Dashboard\n```\n\n## Key Design Principles\n- **Read-only**: FABRIC observes and displays, never controls workers\n- **Non-blocking**: Display lag must never impact NEEDLE performance\n- **Graceful degradation**: Missing data fields should not crash the display\n- **Memory-bounded**: Configurable limits on in-memory event storage\n\n## Input Format\nFABRIC expects structured JSON log lines from NEEDLE:\n```json\n{\"ts\":1709337600,\"worker\":\"w-abc123\",\"level\":\"info\",\"msg\":\"Starting task\",\"task\":\"bd-xyz\"}\n{\"ts\":1709337601,\"worker\":\"w-abc123\",\"level\":\"debug\",\"msg\":\"Tool call\",\"tool\":\"Read\",\"path\":\"/src/main.ts\"}\n{\"ts\":1709337605,\"worker\":\"w-abc123\",\"level\":\"info\",\"msg\":\"Task complete\",\"duration_ms\":5000}\n```\n\n## Output Modes\n- `fabric tui` - Live terminal dashboard (keyboard-driven)\n- `fabric web` - Live browser dashboard (mouse-driven)\n- `fabric logs` - Simple log streaming (parsed + formatted)\n\n## Technology Stack (Tentative)\n- **Language**: TypeScript/Node.js (primary), Go (optional for performance)\n- **TUI**: blessed or ink (React for CLIs)\n- **Web**: Express + ws + React/Svelte\n- **Analytics Storage**: SQLite (~/.needle/fabric.db)\n\n## Success Metrics\n- Can display 1000+ events/second without UI lag\n- TUI responsive under 50ms for all interactions\n- Web dashboard WebSocket latency under 100ms\n- Memory usage bounded to configurable limit (default 100MB)\n\n## Related Documentation\n- [Implementation Plan](docs/plan.md)\n- [NEEDLE Documentation](~/.needle/README.md)\n\n## Child Beads\nThis epic contains 7 implementation phases with granular subtasks.","status":"open","priority":0,"issue_type":"epic","created_at":"2026-03-02T14:37:57.192442627Z","created_by":"coder","updated_at":"2026-03-02T14:37:57.192442627Z","source_repo":".","compaction_level":0,"original_size":0}
|
||||
{"id":"bd-2nu","title":"Phase 3: Web Display","description":"# Phase 3: Web Display\n\n## Overview\nBuild the browser-based dashboard for FABRIC. This provides a richer visual experience and is accessible to non-terminal users.\n\n## Goals\n1. **Worker Cards**: Visual overview of each worker's current state\n2. **Activity Feed**: Real-time log stream with rich formatting\n3. **Timeline Visualization**: Visual representation of worker activity over time\n4. **WebSocket Updates**: Push-based real-time updates\n5. **Responsive Design**: Works on desktop and tablet screens\n\n## Key Design Decisions\n- Use React or Svelte for frontend (Svelte preferred for smaller bundle)\n- WebSocket for real-time updates (with auto-reconnect)\n- Server-sent events as fallback for restrictive networks\n- Bundle size target: <100KB gzipped\n\n## Architecture\n```\n┌─────────────────────────────────────────────────────────┐\n│ FABRIC Web Server │\n├─────────────────────────────────────────────────────────┤\n│ ┌────────────┐ ┌────────────┐ ┌───────────────┐ │\n│ │ HTTP │ │ WebSocket │ │ Event │ │\n│ │ Server │ │ Server │ │ Broadcaster │ │\n│ └────────────┘ └────────────┘ └───────────────┘ │\n│ │ │ │ │\n│ ▼ ▼ ▼ │\n│ Static Files WS Clients From Phase 1 │\n└─────────────────────────────────────────────────────────┘\n```\n\n## Layout\n- Header: Status indicators, search, theme toggle\n- Worker cards: Grid layout with status, task, duration\n- Activity feed: Scrollable with lazy loading\n- Timeline: Canvas-based for performance\n\n## Dependencies\n- Phase 1: Core Infrastructure (event emitter, event store)\n- Phase 2 design patterns (shared component concepts)\n\n## Success Criteria\n- WebSocket latency <100ms for event delivery\n- First paint <1s on broadband\n- Handles 1000+ events without UI jank\n- Auto-reconnects within 5s of connection loss\n\n## Child Beads\n- bd-P3-001: Web Server Setup\n- bd-P3-010: Frontend Framework\n- bd-P3-020: Worker Overview Cards\n- bd-P3-030: Activity Feed\n- bd-P3-040: Timeline Visualization\n- bd-P3-050: Command Palette (Web)\n- bd-P3-060: File Context Panel (Web)\n- bd-P3-070: Focus Mode (Web)","status":"open","priority":1,"issue_type":"phase","created_at":"2026-03-02T14:38:59.427498862Z","created_by":"coder","updated_at":"2026-03-02T14:38:59.427498862Z","source_repo":".","compaction_level":0,"original_size":0}
|
||||
{"id":"bd-2pa","title":"Phase 1: Core Infrastructure","description":"# Phase 1: Core Infrastructure\n\n## Overview\nEstablish the foundational components that all other features depend on. This phase has no UI - it's pure backend infrastructure for log ingestion, parsing, and event management.\n\n## Goals\n1. **Log Tailer**: Continuously read new lines from log files (like `tail -f`)\n2. **Parser**: Parse JSON log lines into structured events\n3. **Event Store**: In-memory index for fast querying by worker, bead, file, timestamp\n4. **Conversation Parser**: Extract full conversation history from logs\n\n## Key Design Decisions\n- Use Node.js streams for efficient log tailing (backpressure handling)\n- Parser should be tolerant of malformed JSON (log warnings, don't crash)\n- Event store should have configurable eviction policy (LRU by default)\n- All components emit events for loose coupling\n\n## Architecture\n```\n┌──────────────┐ ┌─────────────┐ ┌─────────────────┐\n│ Log Tailer │───▶│ Parser │───▶│ Event Emitter │\n│ │ │ │ │ │\n└──────────────┘ └─────────────┘ └─────────────────┘\n │ │\n ~/.needle/logs/ ┌───────┴───────┐\n │ │\n ┌───────▼────┐ ┌───────▼────┐\n │Event Store │ │ Display │\n │(in-memory) │ │ Renderer │\n └────────────┘ └────────────┘\n```\n\n## Dependencies\nNone - this is the foundation.\n\n## Success Criteria\n- Can tail multiple log files simultaneously\n- Parses 10,000+ events/second\n- Event store queries complete in <1ms\n- Memory bounded to configurable limit\n\n## Child Beads\n- bd-P1-001: Project Setup & Scaffolding\n- bd-P1-010: Log Tailer Implementation\n- bd-P1-020: JSON Parser\n- bd-P1-030: In-Memory Event Index\n- bd-P1-040: Conversation Transcript Parser","status":"open","priority":0,"issue_type":"phase","created_at":"2026-03-02T14:38:58.608529751Z","created_by":"coder","updated_at":"2026-03-02T14:38:58.608529751Z","source_repo":".","compaction_level":0,"original_size":0}
|
||||
{"id":"bd-n8l","title":"Phase 2: TUI Display","description":"# Phase 2: TUI Display\n\n## Overview\nBuild the terminal user interface for FABRIC. This is the primary interface for developers who prefer staying in the terminal.\n\n## Goals\n1. **Worker Grid**: Real-time status of all active workers\n2. **Log Stream**: Scrolling log output as events arrive\n3. **Detail Panel**: Focus on a specific worker's activity\n4. **Keyboard Navigation**: j/k scroll, / search, Tab switch panels, q quit\n5. **Command Palette**: Ctrl+K for universal search and commands\n6. **File Context**: Split view showing file contents alongside activity\n7. **Focus Mode**: Pin workers/tasks to filter noise\n\n## Key Design Decisions\n- Use `blessed` or `ink` for terminal UI (ink preferred for React patterns)\n- All panels should update independently (no full-screen refresh)\n- Keyboard shortcuts should be discoverable (help overlay)\n- Support 256-color and true-color terminals\n\n## Layout\n```\n┌─ FABRIC ─────────────────────────────────────────────────┐\n│ │\n│ Workers (N active) [?] Help │\n│ ┌──────────────────────────────────────────────────────┐ │\n│ │ ● w-alpha Running bd-1847 \"Implement...\" 2m │ │\n│ │ ● w-bravo Running bd-1852 \"Fix...\" 1m │ │\n│ │ ○ w-charlie Idle - - - │ │\n│ └──────────────────────────────────────────────────────┘ │\n│ │\n│ Activity Stream Filter: [All ▾] │\n│ ┌──────────────────────────────────────────────────────┐ │\n│ │ 14:32:07 w-alpha INFO Tool call: Edit... │ │\n│ │ 14:32:05 w-bravo DEBUG Reading file: ... │ │\n│ └──────────────────────────────────────────────────────┘ │\n│ │\n│ [Tab] Switch [j/k] Scroll [/] Search [q] Quit │\n└──────────────────────────────────────────────────────────┘\n```\n\n## Dependencies\n- Phase 1: Core Infrastructure (event emitter, event store)\n\n## Success Criteria\n- UI renders correctly in terminals 80x24 to 200x60\n- All keyboard interactions complete in <50ms\n- Smooth scrolling at 100+ events/second\n- Works over SSH connections\n\n## Child Beads\n- bd-P2-001: TUI Framework Setup\n- bd-P2-010: Worker List Panel\n- bd-P2-020: Live Log Stream Panel\n- bd-P2-030: Worker Detail Panel\n- bd-P2-040: Keyboard Controls\n- bd-P2-050: Command Palette (TUI)\n- bd-P2-060: File Context Panel\n- bd-P2-070: Focus Mode (TUI)","status":"open","priority":0,"issue_type":"phase","created_at":"2026-03-02T14:38:59.011210511Z","created_by":"coder","updated_at":"2026-03-02T14:38:59.011210511Z","source_repo":".","compaction_level":0,"original_size":0}
|
||||
11
.beads/.gitignore
vendored
Normal file
11
.beads/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Database
|
||||
*.db
|
||||
*.db-shm
|
||||
*.db-wal
|
||||
|
||||
# Lock files
|
||||
*.lock
|
||||
|
||||
# Temporary
|
||||
last-touched
|
||||
*.tmp
|
||||
4
.beads/config.yaml
Normal file
4
.beads/config.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Beads Project Configuration
|
||||
# issue_prefix: bd
|
||||
# default_priority: 2
|
||||
# default_type: task
|
||||
4
.beads/issues.jsonl
Normal file
4
.beads/issues.jsonl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{"id":"bd-2kf","title":"FABRIC: Flow Analysis & Bead Reporting Interface Console","description":"# FABRIC Project Epic\n\n## Overview\nFABRIC is a live display for NEEDLE worker activity. It parses NEEDLE's structured JSON logging output and renders it in real-time as either a TUI (terminal) or web dashboard.\n\n## Core Goals\n1. **Live Display**: Real-time visualization of NEEDLE worker activity\n2. **Dual Interface**: TUI for terminal users, web app for browser users\n3. **Stateless Core**: Reads and displays - no storage or persistence (analytics features use optional SQLite)\n4. **Intelligence**: Beyond simple log display - provides insights, detection, and analysis\n\n## Data Flow\n```\nNEEDLE Workers → ~/.needle/logs/ → FABRIC → Live TUI or Web Dashboard\n```\n\n## Key Design Principles\n- **Read-only**: FABRIC observes and displays, never controls workers\n- **Non-blocking**: Display lag must never impact NEEDLE performance\n- **Graceful degradation**: Missing data fields should not crash the display\n- **Memory-bounded**: Configurable limits on in-memory event storage\n\n## Input Format\nFABRIC expects structured JSON log lines from NEEDLE:\n```json\n{\"ts\":1709337600,\"worker\":\"w-abc123\",\"level\":\"info\",\"msg\":\"Starting task\",\"task\":\"bd-xyz\"}\n{\"ts\":1709337601,\"worker\":\"w-abc123\",\"level\":\"debug\",\"msg\":\"Tool call\",\"tool\":\"Read\",\"path\":\"/src/main.ts\"}\n{\"ts\":1709337605,\"worker\":\"w-abc123\",\"level\":\"info\",\"msg\":\"Task complete\",\"duration_ms\":5000}\n```\n\n## Output Modes\n- `fabric tui` - Live terminal dashboard (keyboard-driven)\n- `fabric web` - Live browser dashboard (mouse-driven)\n- `fabric logs` - Simple log streaming (parsed + formatted)\n\n## Technology Stack (Tentative)\n- **Language**: TypeScript/Node.js (primary), Go (optional for performance)\n- **TUI**: blessed or ink (React for CLIs)\n- **Web**: Express + ws + React/Svelte\n- **Analytics Storage**: SQLite (~/.needle/fabric.db)\n\n## Success Metrics\n- Can display 1000+ events/second without UI lag\n- TUI responsive under 50ms for all interactions\n- Web dashboard WebSocket latency under 100ms\n- Memory usage bounded to configurable limit (default 100MB)\n\n## Related Documentation\n- [Implementation Plan](docs/plan.md)\n- [NEEDLE Documentation](~/.needle/README.md)\n\n## Child Beads\nThis epic contains 7 implementation phases with granular subtasks.","status":"open","priority":0,"issue_type":"epic","created_at":"2026-03-02T14:37:57.192442627Z","created_by":"coder","updated_at":"2026-03-02T14:37:57.192442627Z","source_repo":".","compaction_level":0,"original_size":0}
|
||||
{"id":"bd-2nu","title":"Phase 3: Web Display","description":"# Phase 3: Web Display\n\n## Overview\nBuild the browser-based dashboard for FABRIC. This provides a richer visual experience and is accessible to non-terminal users.\n\n## Goals\n1. **Worker Cards**: Visual overview of each worker's current state\n2. **Activity Feed**: Real-time log stream with rich formatting\n3. **Timeline Visualization**: Visual representation of worker activity over time\n4. **WebSocket Updates**: Push-based real-time updates\n5. **Responsive Design**: Works on desktop and tablet screens\n\n## Key Design Decisions\n- Use React or Svelte for frontend (Svelte preferred for smaller bundle)\n- WebSocket for real-time updates (with auto-reconnect)\n- Server-sent events as fallback for restrictive networks\n- Bundle size target: <100KB gzipped\n\n## Architecture\n```\n┌─────────────────────────────────────────────────────────┐\n│ FABRIC Web Server │\n├─────────────────────────────────────────────────────────┤\n│ ┌────────────┐ ┌────────────┐ ┌───────────────┐ │\n│ │ HTTP │ │ WebSocket │ │ Event │ │\n│ │ Server │ │ Server │ │ Broadcaster │ │\n│ └────────────┘ └────────────┘ └───────────────┘ │\n│ │ │ │ │\n│ ▼ ▼ ▼ │\n│ Static Files WS Clients From Phase 1 │\n└─────────────────────────────────────────────────────────┘\n```\n\n## Layout\n- Header: Status indicators, search, theme toggle\n- Worker cards: Grid layout with status, task, duration\n- Activity feed: Scrollable with lazy loading\n- Timeline: Canvas-based for performance\n\n## Dependencies\n- Phase 1: Core Infrastructure (event emitter, event store)\n- Phase 2 design patterns (shared component concepts)\n\n## Success Criteria\n- WebSocket latency <100ms for event delivery\n- First paint <1s on broadband\n- Handles 1000+ events without UI jank\n- Auto-reconnects within 5s of connection loss\n\n## Child Beads\n- bd-P3-001: Web Server Setup\n- bd-P3-010: Frontend Framework\n- bd-P3-020: Worker Overview Cards\n- bd-P3-030: Activity Feed\n- bd-P3-040: Timeline Visualization\n- bd-P3-050: Command Palette (Web)\n- bd-P3-060: File Context Panel (Web)\n- bd-P3-070: Focus Mode (Web)","status":"open","priority":1,"issue_type":"phase","created_at":"2026-03-02T14:38:59.427498862Z","created_by":"coder","updated_at":"2026-03-02T14:38:59.427498862Z","source_repo":".","compaction_level":0,"original_size":0}
|
||||
{"id":"bd-2pa","title":"Phase 1: Core Infrastructure","description":"# Phase 1: Core Infrastructure\n\n## Overview\nEstablish the foundational components that all other features depend on. This phase has no UI - it's pure backend infrastructure for log ingestion, parsing, and event management.\n\n## Goals\n1. **Log Tailer**: Continuously read new lines from log files (like `tail -f`)\n2. **Parser**: Parse JSON log lines into structured events\n3. **Event Store**: In-memory index for fast querying by worker, bead, file, timestamp\n4. **Conversation Parser**: Extract full conversation history from logs\n\n## Key Design Decisions\n- Use Node.js streams for efficient log tailing (backpressure handling)\n- Parser should be tolerant of malformed JSON (log warnings, don't crash)\n- Event store should have configurable eviction policy (LRU by default)\n- All components emit events for loose coupling\n\n## Architecture\n```\n┌──────────────┐ ┌─────────────┐ ┌─────────────────┐\n│ Log Tailer │───▶│ Parser │───▶│ Event Emitter │\n│ │ │ │ │ │\n└──────────────┘ └─────────────┘ └─────────────────┘\n │ │\n ~/.needle/logs/ ┌───────┴───────┐\n │ │\n ┌───────▼────┐ ┌───────▼────┐\n │Event Store │ │ Display │\n │(in-memory) │ │ Renderer │\n └────────────┘ └────────────┘\n```\n\n## Dependencies\nNone - this is the foundation.\n\n## Success Criteria\n- Can tail multiple log files simultaneously\n- Parses 10,000+ events/second\n- Event store queries complete in <1ms\n- Memory bounded to configurable limit\n\n## Child Beads\n- bd-P1-001: Project Setup & Scaffolding\n- bd-P1-010: Log Tailer Implementation\n- bd-P1-020: JSON Parser\n- bd-P1-030: In-Memory Event Index\n- bd-P1-040: Conversation Transcript Parser","status":"open","priority":0,"issue_type":"phase","created_at":"2026-03-02T14:38:58.608529751Z","created_by":"coder","updated_at":"2026-03-02T14:38:58.608529751Z","source_repo":".","compaction_level":0,"original_size":0}
|
||||
{"id":"bd-n8l","title":"Phase 2: TUI Display","description":"# Phase 2: TUI Display\n\n## Overview\nBuild the terminal user interface for FABRIC. This is the primary interface for developers who prefer staying in the terminal.\n\n## Goals\n1. **Worker Grid**: Real-time status of all active workers\n2. **Log Stream**: Scrolling log output as events arrive\n3. **Detail Panel**: Focus on a specific worker's activity\n4. **Keyboard Navigation**: j/k scroll, / search, Tab switch panels, q quit\n5. **Command Palette**: Ctrl+K for universal search and commands\n6. **File Context**: Split view showing file contents alongside activity\n7. **Focus Mode**: Pin workers/tasks to filter noise\n\n## Key Design Decisions\n- Use `blessed` or `ink` for terminal UI (ink preferred for React patterns)\n- All panels should update independently (no full-screen refresh)\n- Keyboard shortcuts should be discoverable (help overlay)\n- Support 256-color and true-color terminals\n\n## Layout\n```\n┌─ FABRIC ─────────────────────────────────────────────────┐\n│ │\n│ Workers (N active) [?] Help │\n│ ┌──────────────────────────────────────────────────────┐ │\n│ │ ● w-alpha Running bd-1847 \"Implement...\" 2m │ │\n│ │ ● w-bravo Running bd-1852 \"Fix...\" 1m │ │\n│ │ ○ w-charlie Idle - - - │ │\n│ └──────────────────────────────────────────────────────┘ │\n│ │\n│ Activity Stream Filter: [All ▾] │\n│ ┌──────────────────────────────────────────────────────┐ │\n│ │ 14:32:07 w-alpha INFO Tool call: Edit... │ │\n│ │ 14:32:05 w-bravo DEBUG Reading file: ... │ │\n│ └──────────────────────────────────────────────────────┘ │\n│ │\n│ [Tab] Switch [j/k] Scroll [/] Search [q] Quit │\n└──────────────────────────────────────────────────────────┘\n```\n\n## Dependencies\n- Phase 1: Core Infrastructure (event emitter, event store)\n\n## Success Criteria\n- UI renders correctly in terminals 80x24 to 200x60\n- All keyboard interactions complete in <50ms\n- Smooth scrolling at 100+ events/second\n- Works over SSH connections\n\n## Child Beads\n- bd-P2-001: TUI Framework Setup\n- bd-P2-010: Worker List Panel\n- bd-P2-020: Live Log Stream Panel\n- bd-P2-030: Worker Detail Panel\n- bd-P2-040: Keyboard Controls\n- bd-P2-050: Command Palette (TUI)\n- bd-P2-060: File Context Panel\n- bd-P2-070: Focus Mode (TUI)","status":"open","priority":0,"issue_type":"phase","created_at":"2026-03-02T14:38:59.011210511Z","created_by":"coder","updated_at":"2026-03-02T14:38:59.011210511Z","source_repo":".","compaction_level":0,"original_size":0}
|
||||
4
.beads/metadata.json
Normal file
4
.beads/metadata.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"database": "beads.db",
|
||||
"jsonl_export": "issues.jsonl"
|
||||
}
|
||||
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Dependencies
|
||||
node_modules/
|
||||
|
||||
# Build output
|
||||
dist/
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Environment
|
||||
.env
|
||||
.env.local
|
||||
|
||||
# Test coverage
|
||||
coverage/
|
||||
0
bin/fabric
Normal file
0
bin/fabric
Normal file
137
package-lock.json
generated
Normal file
137
package-lock.json
generated
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
{
|
||||
"name": "@needle/fabric",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@needle/fabric",
|
||||
"version": "0.1.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"commander": "^12.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"fabric": "dist/cli.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.11.0",
|
||||
"typescript": "^5.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.19.35",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.35.tgz",
|
||||
"integrity": "sha512-Uarfe6J91b9HAUXxjvSOdiO2UPOKLm07Q1oh0JHxoZ1y8HoqxDAu3gVrsrOHeiio0kSsoVBt4wFrKOm0dKxVPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ansi-styles": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/chalk": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/chalk/chalk?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "12.1.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
|
||||
"integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/supports-color": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
40
package.json
Normal file
40
package.json
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "@needle/fabric",
|
||||
"version": "0.1.0",
|
||||
"description": "Flow Analysis & Bead Reporting Interface Console - Live display for NEEDLE worker activity",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"bin": {
|
||||
"fabric": "./dist/cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"start": "node dist/cli.js",
|
||||
"tui": "node dist/cli.js tui",
|
||||
"web": "node dist/cli.js web",
|
||||
"clean": "rm -rf dist",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"keywords": [
|
||||
"needle",
|
||||
"worker",
|
||||
"monitoring",
|
||||
"tui",
|
||||
"dashboard"
|
||||
],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.11.0",
|
||||
"typescript": "^5.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
"commander": "^12.0.0"
|
||||
}
|
||||
}
|
||||
57
src/cli.ts
Normal file
57
src/cli.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env node
|
||||
/**
|
||||
* FABRIC CLI Entry Point
|
||||
*
|
||||
* Usage:
|
||||
* fabric tui - Launch terminal UI
|
||||
* fabric web - Launch web dashboard
|
||||
* fabric tail - Raw log tail
|
||||
*/
|
||||
|
||||
import { Command } from 'commander';
|
||||
import { VERSION } from './index.js';
|
||||
|
||||
const program = new Command();
|
||||
|
||||
program
|
||||
.name('fabric')
|
||||
.description('Flow Analysis & Bead Reporting Interface Console')
|
||||
.version(VERSION);
|
||||
|
||||
program
|
||||
.command('tui')
|
||||
.description('Launch terminal UI dashboard')
|
||||
.option('-f, --file <path>', 'Log file to tail', '~/.needle/logs/workers.log')
|
||||
.action((options) => {
|
||||
console.log('FABRIC TUI - Terminal Dashboard');
|
||||
console.log(`Watching: ${options.file}`);
|
||||
console.log('\n(TUI implementation coming in Phase 2)');
|
||||
});
|
||||
|
||||
program
|
||||
.command('web')
|
||||
.description('Launch web dashboard')
|
||||
.option('-p, --port <number>', 'Port to listen on', '3000')
|
||||
.option('-f, --file <path>', 'Log file to tail', '~/.needle/logs/workers.log')
|
||||
.action((options) => {
|
||||
console.log('FABRIC Web Dashboard');
|
||||
console.log(`Starting server on port ${options.port}`);
|
||||
console.log(`Watching: ${options.file}`);
|
||||
console.log('\n(Web implementation coming in Phase 3)');
|
||||
});
|
||||
|
||||
program
|
||||
.command('tail')
|
||||
.description('Raw log tail (for debugging)')
|
||||
.option('-f, --file <path>', 'Log file to tail', '~/.needle/logs/workers.log')
|
||||
.option('-w, --worker <id>', 'Filter by worker ID')
|
||||
.option('-l, --level <level>', 'Filter by log level')
|
||||
.action((options) => {
|
||||
console.log('FABRIC Raw Tail');
|
||||
console.log(`File: ${options.file}`);
|
||||
if (options.worker) console.log(`Worker filter: ${options.worker}`);
|
||||
if (options.level) console.log(`Level filter: ${options.level}`);
|
||||
console.log('\n(Tail implementation coming in Phase 1)');
|
||||
});
|
||||
|
||||
program.parse();
|
||||
25
src/index.ts
Normal file
25
src/index.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* FABRIC - Flow Analysis & Bead Reporting Interface Console
|
||||
*
|
||||
* A live display for NEEDLE worker activity.
|
||||
*/
|
||||
|
||||
export const VERSION = '0.1.0';
|
||||
|
||||
export interface LogEvent {
|
||||
ts: number;
|
||||
worker: string;
|
||||
level: 'debug' | 'info' | 'warn' | 'error';
|
||||
msg: string;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface WorkerState {
|
||||
id: string;
|
||||
status: 'active' | 'idle' | 'error';
|
||||
lastEvent?: LogEvent;
|
||||
beadsCompleted: number;
|
||||
}
|
||||
|
||||
// Re-export submodules
|
||||
export * from './types.js';
|
||||
98
src/types.ts
Normal file
98
src/types.ts
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
* FABRIC Type Definitions
|
||||
*
|
||||
* Core types for NEEDLE log parsing and worker state management.
|
||||
*/
|
||||
|
||||
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
||||
|
||||
export type WorkerStatus = 'active' | 'idle' | 'error';
|
||||
|
||||
export interface LogEvent {
|
||||
/** Unix timestamp in milliseconds */
|
||||
ts: number;
|
||||
|
||||
/** Worker identifier (e.g., 'w-abc123') */
|
||||
worker: string;
|
||||
|
||||
/** Log level */
|
||||
level: LogLevel;
|
||||
|
||||
/** Log message */
|
||||
msg: string;
|
||||
|
||||
/** Optional: Tool that was called */
|
||||
tool?: string;
|
||||
|
||||
/** Optional: File path being operated on */
|
||||
path?: string;
|
||||
|
||||
/** Optional: Bead/task identifier */
|
||||
bead?: string;
|
||||
|
||||
/** Optional: Duration in milliseconds */
|
||||
duration_ms?: number;
|
||||
|
||||
/** Optional: Error details */
|
||||
error?: string;
|
||||
|
||||
/** Any additional fields */
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface WorkerInfo {
|
||||
/** Worker identifier */
|
||||
id: string;
|
||||
|
||||
/** Current status */
|
||||
status: WorkerStatus;
|
||||
|
||||
/** Last event received */
|
||||
lastEvent?: LogEvent;
|
||||
|
||||
/** Total beads completed */
|
||||
beadsCompleted: number;
|
||||
|
||||
/** First seen timestamp */
|
||||
firstSeen: number;
|
||||
|
||||
/** Last activity timestamp */
|
||||
lastActivity: number;
|
||||
}
|
||||
|
||||
export interface EventFilter {
|
||||
/** Filter by worker ID */
|
||||
worker?: string;
|
||||
|
||||
/** Filter by log level */
|
||||
level?: LogLevel;
|
||||
|
||||
/** Filter by bead ID */
|
||||
bead?: string;
|
||||
|
||||
/** Filter by file path */
|
||||
path?: string;
|
||||
|
||||
/** Time range start (Unix timestamp) */
|
||||
since?: number;
|
||||
|
||||
/** Time range end (Unix timestamp) */
|
||||
until?: number;
|
||||
}
|
||||
|
||||
export interface EventStore {
|
||||
/** Add an event to the store */
|
||||
add(event: LogEvent): void;
|
||||
|
||||
/** Query events with optional filter */
|
||||
query(filter?: EventFilter): LogEvent[];
|
||||
|
||||
/** Get worker info */
|
||||
getWorker(workerId: string): WorkerInfo | undefined;
|
||||
|
||||
/** Get all workers */
|
||||
getWorkers(): WorkerInfo[];
|
||||
|
||||
/** Clear all events */
|
||||
clear(): void;
|
||||
}
|
||||
21
tsconfig.json
Normal file
21
tsconfig.json
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"lib": ["ES2022"],
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"incremental": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
1
tsconfig.tsbuildinfo
Normal file
1
tsconfig.tsbuildinfo
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue