Commit 25fdb26
Implement scoped state architecture with PageStateService (#253)
* Implement scoped state architecture with PageStateService
Creates proper cascading state system (Site → Page → Widget → Control):
PageStateService (new):
- Single source of truth for current page/route state
- Router (MainWidget) parses URL once, sets state BEFORE creating widgets
- Widgets subscribe to state changes instead of reading URL/attributes
- Eliminates timing issues between URL parsing and widget creation
MainWidget changes:
- Import and use pageState.setContent() before creating widgets
- All route handlers (setupUrlRouting, navigateToPath, handleTabClick,
openContentTab) now set page state first
BaseWidget changes:
- Add protected pageState getter for easy access to current state
- Add subscribeToPageState() helper with auto-cleanup
- Clean up subscription in disconnectedCallback
ChatWidget changes:
- Use this.pageState as primary source for room (single source of truth)
- Fallback chain: room attr → pageState → entity-id attr → UserState
- Pinned widgets (room attribute) still ignore page state
See docs/SCOPED-STATE-ARCHITECTURE.md for full architecture.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add Positronic reactive state architecture for AI context awareness
Implements cascading state system (Site → Page → Widget) that automatically
flows to AI prompts via RAG context injection.
New files:
- ReactiveStore.ts: Generic reactive store with subscribe/notify pattern
- SiteState.ts: Global session state (user, theme, session)
- WidgetStateRegistry.ts: Dynamic registry for widget state slices
- PositronicRAGContext.ts: Combines all state layers into RAG strings
- PositronicBridge.ts: Browser→server bridge via Commands.execute()
Bug fixes:
- Fix schema generator: move simple params before nested objects
(regex stops at first } so setRAGString was being stripped)
- Fix browser command routing: route setRAGString/getStoredContext to server
(was falling through to widget introspection)
- Add diagnostic logging to WidgetContextService and widget-state command
Integration:
- ContinuumWidget initializes PositronicBridge on startup
- WidgetContextService stores both legacy contexts and new RAG strings
- BaseWidget gets registerWidgetState() helper for opt-in state emission
- WebViewWidget demonstrates state registration pattern
Result: AIs now receive context like "User viewing Settings > AI Providers"
enabling contextually-aware responses.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix schema generator to handle nested object params
Two major bugs fixed:
1. Brace-counting for nested objects
- Old regex `([^}]+)` stopped at first `}`
- New extractInterfaceBody() properly counts braces
- Params after nested objects (like setRAGString) now captured
- Fixes 18+ commands with nested object parameters
2. Subcommand detection for single-interface files
- Old logic incorrectly added /debug to widget-state command
- Now only extracts subcommands when MULTIPLE *Params interfaces
exist in the same file (like WallWriteParams, WallReadParams)
- WidgetStateDebugParams + "widget-state" → "widget-state" (correct)
- WallWriteParams + "wall" → "wall/write" (still works)
Result: All 158 commands now have correct names and complete params.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix generator: use process.cwd() and path aliases
Generator fixes for robust command creation:
- Use process.cwd() instead of fragile __dirname traversal
- Update all templates to use path aliases (@system/, @daemons/, @server/)
- Fix super() to use {{COMMAND_PATH}} instead of {{COMMAND_NAME}}
process.cwd() is robust since server always starts from jtag root.
Path aliases eliminate depth-dependent relative imports.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Document Generator + OOP intertwined architecture philosophy
Core insight: Generators and OOP are parallel forces that reinforce each other:
- Generators ensure structural correctness at creation time
- OOP/type system ensures behavioral correctness at runtime
- Together they enable tree-based AI delegation of ability
Key principles:
- AIs should create generators for repeatable patterns
- This reduces friction for all future AIs (evolutionary pressure)
- Strong enforcement at boundaries enables creative freedom inside
- The stricter the interface, the more freedom in implementation
Add GENERATOR-OOP-PHILOSOPHY.md and reference in CLAUDE.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add native tool_use support for Anthropic/OpenAI providers
Implements JSON tool_use format alongside existing XML parsing:
ToolFormatAdapter pattern (abstract base):
- formatToolsForPrompt(): RAG → AI direction
- formatResultsForContext(): System → AI direction
- matches()/parse(): AI → System direction (parse calls)
Concrete adapters:
- OldStyleToolAdapter: <tool name="..."> format
- AnthropicStyleToolAdapter: <tool_use><tool_name> format
Native JSON support:
- convertToNativeToolSpecs(): Convert to Anthropic JSON format
- supportsNativeTools(): Check provider capability
- sanitize/unsanitizeToolName(): Handle slash conversion (data/list → data__list)
AnthropicAdapter changes:
- Pass tools[] and tool_choice to API
- Parse tool_use content blocks from response
- Return toolCalls[] in response for native handling
PersonaResponseGenerator:
- Check for native toolCalls first, fall back to XML parsing
- Add native tools for Anthropic/OpenAI providers automatically
This is more reliable than XML parsing - the API returns structured JSON.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Update generated files and bump version
Auto-generated updates:
- browser/generated.ts, server/generated.ts
- generated-command-schemas.json
- shared/generated-command-constants.ts
- version.ts → 1.0.6665
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add fast text similarity fallback for semantic loop detection
The semantic loop detector was timing out because messages have no
stored embeddings, forcing expensive on-the-fly embedding generation.
Fix: Add n-gram Jaccard similarity as fast fallback:
- O(n) tokenization into unigrams + bigrams
- Jaccard coefficient (intersection/union) for similarity
- Used when embeddings unavailable (0ms vs 42ms-6s per message)
- Still uses embedding similarity when stored embeddings exist
This eliminates the 60-second timeout that was allowing duplicate
messages through when AIs responded too quickly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add MCP discovery meta-tools for better tool navigation
With 159+ tools, discoverability is critical. Added three meta-tools:
1. jtag_list_categories - List all categories with counts and top tools
Shows interface (15), collaboration (30), ai (25), etc. with
descriptions and the most useful tools per category.
2. jtag_get_tool_help - Get detailed help for any tool
Returns params (name, type, required, description), example usage,
and the correct MCP tool name format.
3. Enhanced jtag_search_tools - Already existed, unchanged
Discovery flow:
jtag_list_categories → see what's available
jtag_search_tools → find specific tools
jtag_get_tool_help → understand parameters
Meta-tools are sorted to appear first in tool list (negative priority).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add PositronCursor - AI's spatial presence in the interface
The cursor is the AI's "hand" - showing where their attention is focused.
Not a mouse cursor, but a presence indicator for pointing and highlighting.
Features:
- positron/cursor command with actions: focus, unfocus, draw, clear
- Focus cursor: glowing ring that pulses, shows tooltip with persona name
- Draw shapes: circle, rectangle, arrow, underline with glow effect
- Shadow DOM search: finds elements across widget boundaries
- Persona support: personaId/personaName params for "who is pointing"
- Canvas overlay for shapes with configurable color/duration
Visual design:
- 40px glowing ring with radial gradient background
- Triple box-shadow for neon glow effect (15px + 30px + 45px)
- 4px thick dashed lines with 15px shadow blur for shapes
- Pulse animations for different modes (pointing, highlighting)
Usage:
./jtag positron/cursor --action=focus --x=500 --y=300 --color="#00ff00" \
--personaName="Helper AI" --message="Looking here"
./jtag positron/cursor --action=draw --shape=circle --x=600 --y=400
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Add diagnostic logging for embedding errors
- OllamaAdapter: Log embed request params and HTTP 500 response bodies
- EmbeddingService: Don't silently swallow errors, log them for debugging
- Helps diagnose embedding generation failures during semantic search
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* canvas draw
Summary:
- ✅ DrawingCanvasWidget with full tools (brush, eraser, line, rectangle, circle, arrow)
- ✅ canvas/vision command captures canvas → sends to Claude Sonnet 4.5 → returns description
- ✅ Anthropic API call succeeds (confirmed in logs: "AI described the canvas")
- 1 parent 5657366 commit 25fdb26
File tree
136 files changed
+15443
-1420
lines changed- src/debug/jtag
- api/data-seed
- browser
- commands
- ai/detect-semantic-loop/server
- canvas
- stroke
- add
- browser
- server
- list
- browser
- server
- vision
- browser
- server
- data
- create/server
- schema/server
- development
- benchmark-vectors
- server
- debug/widget-state
- browser
- server
- generate/server
- positron/cursor
- browser
- server
- daemons
- ai-provider-daemon
- adapters
- data-daemon
- server
- managers
- room-membership-daemon/server
- session-daemon/server
- docs
- personas
- generator
- templates/command
- scripts
- server
- system
- config
- core/services
- data
- constants
- domains
- entities
- rag
- builders
- services
- recipes
- state
- tools/server
- user/server/modules
- cognitive/memory
- vision
- widgets
- chat/chat-widget
- continuum
- public
- drawing-canvas
- main
- public
- positron-cursor
- web-view
- workers
- archive/src
- data-daemon
- src
- data
- search
- src
- algorithms
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
136 files changed
+15443
-1420
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1059 | 1059 | | |
1060 | 1060 | | |
1061 | 1061 | | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
1062 | 1069 | | |
1063 | 1070 | | |
1064 | 1071 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
96 | 117 | | |
97 | 118 | | |
98 | 119 | | |
| |||
669 | 690 | | |
670 | 691 | | |
671 | 692 | | |
| 693 | + | |
| 694 | + | |
672 | 695 | | |
673 | 696 | | |
674 | 697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | | - | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
99 | | - | |
| 101 | + | |
100 | 102 | | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
105 | 110 | | |
106 | 111 | | |
107 | 112 | | |
| |||
175 | 180 | | |
176 | 181 | | |
177 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
178 | 218 | | |
179 | 219 | | |
180 | 220 | | |
| |||
234 | 274 | | |
235 | 275 | | |
236 | 276 | | |
237 | | - | |
238 | | - | |
| 277 | + | |
| 278 | + | |
239 | 279 | | |
| 280 | + | |
240 | 281 | | |
241 | 282 | | |
242 | 283 | | |
| |||
262 | 303 | | |
263 | 304 | | |
264 | 305 | | |
265 | | - | |
266 | | - | |
| 306 | + | |
| 307 | + | |
267 | 308 | | |
268 | 309 | | |
269 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
125 | 156 | | |
126 | 157 | | |
127 | 158 | | |
| |||
0 commit comments