Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project is a high-performance web-based Keybinding Management Suite designe
3. **Intelligent Conflict Detection**: Distinguishes between harmless overlaps in mutually exclusive flight/ground modes and fatal collisions using temporal state machine analysis (`multiTap`, `activationMode`, Master Modes SCM/NAV).
4. **Hardware Listening**: HTML5 Gamepad API listener to detect physical button/axis presses in real time and jump straight to the relevant binding in the UI.
5. **Native Go Extraction Daemon (`sc-daemon`)**: Direct Zip64 central directory streamer and CryEngine cipher decryptor to extract default bindings and localization strings directly from Star Citizen's 90GB+ `Data.p4k` archive without high RAM consumption.
6. **WebMCP Browser AI Agent Integration (`useWebMCP.ts`)**: Exposes 9 structured, JSON-Schema-typed tools on `document.modelContext` / `navigator.modelContext` so browser-embedded AI agents can audit conflicts, search the 50-map catalog, find unused stick buttons, re-index `jsX_` devices, and modify bindings client-side without fragile DOM scraping.

Detailed specifications, mathematical formulas, and cipher routines are documented in [docs/ARCHITECTURE_BLUEPRINT.md](docs/ARCHITECTURE_BLUEPRINT.md).

Expand Down Expand Up @@ -47,7 +48,7 @@ sc-mapping/
│ └── src/
│ ├── components/ # DeviceRack.tsx, ReferralCodeCard.tsx, MonetizationSlot.tsx, etc.
│ ├── data/ # referralCodes.ts (community supporter referral pool)
│ ├── hooks/ # useGamepadListener.ts (HTML5 Gamepad API hook)
│ ├── hooks/ # useGamepadListener.ts (HTML5 Gamepad API), useWebMCP.ts (W3C WebMCP tools)
│ └── App.tsx # Main workspace UI
├── e2e/ # Playwright End-to-End browser UX test suite
│ └── app-workflow.spec.ts # Complete user journey tests (presets, matrix, modals, XML export)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Configuring complex HOTAS, HOSAS, pedals, and button boxes in Star Citizen's nat
- **Intelligent 4-Tier Conflict Diagnostics**: Differentiates harmless overlaps in mutually exclusive flight/ground modes from lethal collisions. Analyzes temporal mechanics (`multiTap`, `press`, `hold`, Master Modes SCM/NAV) and warns you before accidental inputs trigger fatal actions like Self-Destruct, Eject, or Jettison Cargo.
- **Live Hardware Listening Mode**: Powered by the HTML5 Gamepad API. Press any physical button or deflect any analog stick or pedal on your desk, and the UI immediately detects the input and filters to the corresponding binding.
- **Lossless CryEngine XML Round-Tripping**: Never discards device `<options>` blocks (axis inversions, sensitivity curves, product GUIDs) and preserves concurrent secondary `<addbind>` inputs alongside primary `<rebind>` overrides.
- **WebMCP Browser AI Agent Ready (`document.modelContext`)**: Exposes 9 structured client-side tools (`get_profile_summary`, `audit_conflicts`, `search_bindings_and_catalog`, `find_unused_joystick_inputs`, `set_action_binding`, `auto_fix_obsolete_conflicts`, `remap_joystick_instances`, `configure_joystick_options`, and `workspace_control`) so W3C WebMCP-compatible browser AI assistants can audit, search, and configure flight profiles deterministically in memory.

---

Expand Down
111 changes: 111 additions & 0 deletions apps/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from './components/MonetizationSlot';
import { ReferralCodeCard } from './components/ReferralCodeCard';
import { useGamepadListener } from './hooks/useGamepadListener';
import { useWebMCP } from './hooks/useWebMCP';
import {
Upload,
Download,
Expand Down Expand Up @@ -391,6 +392,52 @@ export const App: React.FC = () => {
}
};

// WebMCP Browser AI Agent Integration (document.modelContext / navigator.modelContext)
const {
registeredTools: webMcpTools,
isNativeSupport: isWebMcpNative,
lastToolCall: lastWebMcpCall,
executeRegisteredTool: executeWebMcpTool
} = useWebMCP({
doc,
activePreset,
gameVersion,
gameBranch,
gameBuildDate,
suiteVersion,
hardwareMapping,
conflictReport,
deviceScope,
activeTab,
searchQuery,
onSetActiveTab: setActiveTab,
onSetSearchQuery: setSearchQuery,
onSetDeviceScope: setDeviceScope,
onSetHardwareMapping: setHardwareMapping,
onApplyDeviceOptions: handleApplyDeviceOptions,
onSaveActionInputs: handleSaveActionInputs,
onAutoFixConflict: handleAutoFix,
onLoadSamplePreset: handleLoadSamplePreset
});

const [selectedWebMcpTool, setSelectedWebMcpTool] = useState<string>('get_profile_summary');
const [webMcpTestOutput, setWebMcpTestOutput] = useState<string | null>(null);

const handleRunWebMcpDiagnostic = async (toolName: string) => {
try {
const sampleInputs: Record<string, Record<string, unknown>> = {
get_profile_summary: {},
audit_conflicts: { deviceScope: 'js', severity: 'all', limit: 10 },
search_bindings_and_catalog: { query: 'eject', limit: 5 },
find_unused_joystick_inputs: { deviceInstance: 1, maxButtons: 16 }
};
const result = await executeWebMcpTool(toolName, sampleInputs[toolName] || {});
setWebMcpTestOutput(JSON.stringify(result, null, 2));
} catch (err: any) {
setWebMcpTestOutput(JSON.stringify({ error: err.message }, null, 2));
}
};

return (
<div className="w-full max-w-7xl mx-auto px-4 py-8">
{/* Pilot Safety & XML Backup Advisory Banner */}
Expand Down Expand Up @@ -440,6 +487,17 @@ export const App: React.FC = () => {
<Info className="w-3 h-3 text-[#94a3b8]" />
</button>
<span className="text-[11px] text-[#64748b] font-mono">• Build: {gameBuildDate}</span>
<span className="text-[11px] text-[#64748b] font-mono">•</span>
<button
type="button"
data-testid="webmcp-header-badge"
onClick={() => setIsContributorToolsOpen(true)}
className="flex items-center gap-1.5 px-2 py-0.5 rounded bg-[rgba(0,255,136,0.08)] border border-[#00ff88]/40 text-[#00ff88] hover:bg-[rgba(0,255,136,0.18)] transition-colors text-[11px] font-mono cursor-pointer"
title="W3C WebMCP Supported: Click to inspect or test the 9 browser AI agent tools exposed on navigator.modelContext / document.modelContext"
>
<Sparkles className="w-3 h-3 text-[#00ff88]" />
<span>WebMCP: <strong>{webMcpTools.length} AI Tools</strong> ({isWebMcpNative ? 'Native' : 'Ready'})</span>
</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -886,6 +944,59 @@ git commit -am "chore(catalog): update actions & tokens for Star Citizen 4.x"`}
"Preview Bundled LIVE Data" tests the static catalog committed to git. "Local Dev Sync" is strictly an optional diagnostic when testing the Go daemon before writing files.
</p>
</div>

{/* WebMCP Browser AI Agent Bridge Diagnostic Panel */}
<div
data-testid="webmcp-bridge-panel"
className="p-3 rounded bg-[#090d15] border border-[#2d415f] space-y-2"
>
<div className="flex items-center justify-between text-[11px]">
<span className="text-[#00f0ff] font-semibold flex items-center gap-1.5">
<Cpu className="w-3.5 h-3.5" />
WebMCP AI Agent Bridge (<code className="text-[#00f0ff]">document.modelContext</code>)
</span>
<span className="font-mono text-[10px] text-[#00ff88]">
{webMcpTools.length} Tools Ready ({isWebMcpNative ? 'Native W3C' : 'Polyfill Active'})
</span>
</div>
<p className="text-[10px] text-[#94a3b8]">
Exposes structured client-side tools so browser-embedded AI agents can audit conflicts, search the 50-map catalog, re-index <code className="text-[#00f0ff]">jsX_</code> sticks, and edit bindings without DOM scraping.
</p>
<div className="flex items-center gap-2 pt-1">
<select
aria-label="Select WebMCP tool to test"
value={selectedWebMcpTool}
onChange={(e) => setSelectedWebMcpTool(e.target.value)}
className="bg-[#0b111e] border border-[#2d415f] rounded px-2 py-1 text-[11px] font-mono text-white flex-1"
>
{webMcpTools.map((t) => (
<option key={t.name} value={t.name}>
{t.name} {t.readOnlyHint ? '(read)' : '(write)'}
</option>
))}
</select>
<button
type="button"
onClick={() => handleRunWebMcpDiagnostic(selectedWebMcpTool)}
className="btn-sci-fi text-[#00ff88] border-[#00ff88] hover:bg-[rgba(0,255,136,0.12)] text-[11px] py-1 px-2.5"
>
Run Tool
</button>
</div>
{lastWebMcpCall && (
<div className="text-[10px] font-mono text-[#94a3b8]">
Last Invocation: <strong className="text-white">{lastWebMcpCall.toolName}</strong> ({lastWebMcpCall.status})
</div>
)}
{webMcpTestOutput && (
<pre
data-testid="webmcp-test-output"
className="p-2 rounded bg-black/60 border border-[#2d415f] text-[10px] font-mono text-[#00ff88] max-h-36 overflow-y-auto"
>
{webMcpTestOutput}
</pre>
)}
</div>
</div>

<div className="pt-2 flex flex-col sm:flex-row items-center justify-between gap-3 border-t border-[#2d415f]/60">
Expand Down
Loading
Loading