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
26 changes: 18 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

interface WarStatus {
[key: string]: any

Check warning on line 17 in src/App.tsx

View workflow job for this annotation

GitHub Actions / test-and-build (18.x)

Unexpected any. Specify a different type

Check warning on line 17 in src/App.tsx

View workflow job for this annotation

GitHub Actions / test-and-build (20.x)

Unexpected any. Specify a different type
}

const INSPIRATIONAL_QUOTES = [
Expand Down Expand Up @@ -159,7 +159,7 @@
<span className="stat-label">MISSIONS WON</span>
<span className="stat-value">{warStatus.statistics?.missionsWon?.toLocaleString() || 'N/A'}</span>
</div>
{warStatus?.statistics?.factionStats && Object.entries(warStatus.statistics.factionStats).map(([faction, data]: [string, any]) => (

Check warning on line 162 in src/App.tsx

View workflow job for this annotation

GitHub Actions / test-and-build (18.x)

Unexpected any. Specify a different type

Check warning on line 162 in src/App.tsx

View workflow job for this annotation

GitHub Actions / test-and-build (20.x)

Unexpected any. Specify a different type
<div key={faction} className="stat-item faction-item">
<span className="stat-label">{faction.toUpperCase().substring(0, 8)}</span>
<span className="stat-value">{(data.kills ? Math.floor(data.kills / 1e9) : 0)}B</span>
Expand Down Expand Up @@ -240,15 +240,25 @@
<h2>💻 DATA CONSOLE</h2>
<p>Command the strategic warfare using the Data Console. Input natural language commands and our AI democracy officer will execute MCP tools to gather intelligence and execute operations.</p>

<h3>Available Commands:</h3>
<h3>Available Commands</h3>
<p>Outcome-based (what to do):</p>
<ul>
<li><strong>War Status:</strong> "What's the current war status?" / "Show me the war situation"</li>
<li><strong>Planet Data:</strong> "What planets are we fighting on?" / "Show active planets"</li>
<li><strong>Major Orders:</strong> "What are the major orders?" / "Show current objectives"</li>
<li><strong>Faction Stats:</strong> "Show faction information" / "What factions are active?"</li>
<li><strong>Biome Data:</strong> "Show biome information" / "What biomes exist?"</li>
<li><strong>Statistics:</strong> "Show global statistics" / "What are our stats?"</li>
<li><strong>Planet Details:</strong> "Status of planet 0" / "Tell me about planet X"</li>
<li><strong>War summary:</strong> &quot;What&apos;s the state of the war?&quot; / &quot;War summary&quot;</li>
<li><strong>Where to deploy:</strong> &quot;Where should I deploy?&quot; / &quot;Where to fight?&quot;</li>
<li><strong>Liberation priority:</strong> &quot;What to liberate first?&quot; / &quot;Liberation priority&quot;</li>
<li><strong>Mission efficiency:</strong> &quot;How are we doing on missions?&quot; / &quot;Mission efficiency&quot;</li>
</ul>
<p>Analytics (efficiency and stats):</p>
<ul>
<li><strong>Mission analytics:</strong> &quot;Mission analytics&quot; / &quot;Success rate&quot; / &quot;Bug kills&quot;</li>
<li><strong>War analytics:</strong> &quot;War analytics&quot; / &quot;Time left in war&quot;</li>
<li><strong>Planet analytics:</strong> &quot;Which sectors need help?&quot; / &quot;Planet analytics&quot;</li>
</ul>
<p>Raw data (for custom questions):</p>
<ul>
<li><strong>War / planets / statistics:</strong> &quot;War status&quot; / &quot;Show planets&quot; / &quot;Statistics&quot;</li>
<li><strong>Major orders / factions / biomes:</strong> &quot;Major orders&quot; / &quot;Factions&quot; / &quot;Biomes&quot;</li>
<li><strong>Planet details:</strong> &quot;Status of planet 0&quot;</li>
</ul>

<h3>H.E.L.L. System Overview:</h3>
Expand Down
52 changes: 44 additions & 8 deletions src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,24 @@ class HighCommandAPI {
})

const data = await this.handleResponse(response)

// Extract text from MCP response format
if (data.result?.content?.[0]?.text) {
return data.result.content[0].text
const rawText = data.result?.content?.[0]?.text
if (!rawText) return data.result?.message || 'No response received'

// Outcome/analytics tools return JSON with summary; show summary for readability when possible
try {
const parsed = JSON.parse(rawText) as { summary?: string; status?: string; error?: string }
if (parsed.summary && parsed.status === 'success') {
return parsed.summary + (parsed.error ? `\n\nError: ${parsed.error}` : '')
}
if (parsed.summary && parsed.status === 'error') {
return parsed.summary + (parsed.error ? `\n${parsed.error}` : '')
}
} catch {
// Not JSON or no summary; return as-is
}

return data.result?.message || 'No response received'
return rawText
} catch (error) {
console.error('Command error:', error)
throw new Error(`Failed to execute command: ${error instanceof Error ? error.message : 'Unknown error'}`)
Expand All @@ -100,15 +111,40 @@ class HighCommandAPI {

private interpretPrompt(prompt: string): string {
const lower = prompt.toLowerCase()


// Outcome-based: "where should I deploy?" / "where to fight?"
if (lower.includes('where to deploy') || lower.includes('where should i deploy') ||
lower.includes('where to fight') || lower.includes('reinforce')) return 'get_where_to_deploy'
// Outcome: "what to liberate first?" / "liberation priority"
if (lower.includes('liberation priority') || lower.includes('what to liberate') ||
lower.includes('liberate first')) return 'get_liberation_priority'
// Outcome: "how are we doing?" / "mission efficiency"
if (lower.includes('mission efficiency') || lower.includes('how are we doing') ||
lower.includes('doing on missions')) return 'get_mission_efficiency_snapshot'
// Outcome: "war summary" / "state of the war"
if (lower.includes('war summary') || lower.includes('state of the war') ||
(lower.includes('war') && lower.includes('summary'))) return 'get_war_summary'

// Analytics: "which sectors need help?" / "planet analytics"
if (lower.includes('sectors need help') || lower.includes('planet analytics') ||
lower.includes('which sector')) return 'get_planet_analytics'
// Analytics: "mission analytics" / "efficiency"
if (lower.includes('mission analytics') || lower.includes('efficiency') && lower.includes('mission')) return 'get_mission_analytics'
// Analytics: "war analytics"
if (lower.includes('war analytics') || lower.includes('time left') && lower.includes('war')) return 'get_war_analytics'
// Analytics (mission stats / kills): single-call answers without arguments
if (lower.includes('mission success rate') || lower.includes('success rate') ||
lower.includes('bug kill') || lower.includes('terminid kill') ||
lower.includes('automaton kill') || lower.includes('mission analytics')) return 'get_mission_analytics'

// Raw / legacy
if (lower.includes('war') || lower.includes('status')) return 'get_war_status'
if (lower.includes('planet')) return 'get_planets'
if (lower.includes('major order') || lower.includes('orders')) return 'get_campaign_info'
if (lower.includes('faction')) return 'get_factions'
if (lower.includes('biome')) return 'get_biomes'
if (lower.includes('statistic') || lower.includes('stats')) return 'get_statistics'

// Default to war status if unsure

return 'get_war_status'
}

Expand Down
Loading