| export const EVENT_TYPES = Object.freeze({ | |
| PLAYER_MOVE: 'player.move', | |
| SELECT_DISTRICT: 'district.selected', | |
| SELECT_FILE: 'file.selected', | |
| SELECT_COLLECTION: 'collection.selected', | |
| SELECT_RECORD: 'record.selected', | |
| OPEN_INSPECTOR: 'inspector.opened', | |
| CLOSE_INSPECTOR: 'inspector.closed', | |
| OPEN_TERMINAL: 'terminal.opened', | |
| CLOSE_TERMINAL: 'terminal.closed', | |
| RUN_COMMAND: 'terminal.command', | |
| USE_TOOL: 'tool.used', | |
| ENTER_DISTRICT: 'district.entered', | |
| TICK: 'world.tick', | |
| AGENT_PROGRESS: 'agent.progress', | |
| CONSTRUCTION: 'construction.updated', | |
| BUILD_STARTED: 'build.started', | |
| BUILD_COMPLETED: 'build.completed', | |
| TEST_STARTED: 'test.started', | |
| TEST_COMPLETED: 'test.completed', | |
| DEPLOYMENT_STARTED: 'deployment.started', | |
| DEPLOYMENT_COMPLETED: 'deployment.completed', | |
| COMMIT: 'repository.commit', | |
| ISSUE: 'repository.issue', | |
| PULL_REQUEST: 'repository.pull_request' | |
| }); | |
| export const TOOLBELT = Object.freeze([ | |
| { id: 'terminal', key: '1', icon: '▣', name: 'Terminal Phone', verb: 'Open shell', color: '#69f6cf' }, | |
| { id: 'bash', key: '2', icon: '⚒', name: 'Bash Hammer', verb: 'Run operation', color: '#ffbd69' }, | |
| { id: 'git', key: '3', icon: '◈', name: 'Git Backpack', verb: 'View history', color: '#ff7ac8' }, | |
| { id: 'docker', key: '4', icon: '▦', name: 'Docker Box', verb: 'Open container', color: '#6dafff' }, | |
| { id: 'code', key: '5', icon: '⌘', name: 'Code Tablet', verb: 'Read source', color: '#b79cff' }, | |
| { id: 'ssh', key: '6', icon: '⚿', name: 'SSH Key', verb: 'Unlock gate', color: '#ffdd67' }, | |
| { id: 'database', key: '7', icon: '▤', name: 'Database Vault', verb: 'Inspect data', color: '#9fe870' }, | |
| { id: 'deploy', key: '8', icon: '↗', name: 'Deploy Rocket', verb: 'Launch build', color: '#ff8b62' } | |
| ]); | |
| export const EVENT_LABELS = Object.freeze({ | |
| [EVENT_TYPES.AGENT_PROGRESS]: 'agent progress', | |
| [EVENT_TYPES.CONSTRUCTION]: 'construction update', | |
| [EVENT_TYPES.BUILD_STARTED]: 'build started', | |
| [EVENT_TYPES.BUILD_COMPLETED]: 'build completed', | |
| [EVENT_TYPES.TEST_STARTED]: 'tests started', | |
| [EVENT_TYPES.TEST_COMPLETED]: 'tests passed', | |
| [EVENT_TYPES.DEPLOYMENT_STARTED]: 'deployment queued', | |
| [EVENT_TYPES.DEPLOYMENT_COMPLETED]: 'deployment complete', | |
| [EVENT_TYPES.COMMIT]: 'commit landed', | |
| [EVENT_TYPES.ISSUE]: 'issue quest', | |
| [EVENT_TYPES.PULL_REQUEST]: 'pull request gate' | |
| }); | |
| export const COLLECTIONS = Object.freeze(['files', 'commits', 'issues', 'prs', 'build']); | |
| export const clamp = (value, min, max) => Math.min(max, Math.max(min, value)); | |
| export function formatTime(tick) { | |
| const seconds = String((tick * 7) % 60).padStart(2, '0'); | |
| const minutes = String(Math.floor(tick * 7 / 60)).padStart(2, '0'); | |
| return `00:${minutes}:${seconds}`; | |
| } | |
| export function clone(value) { | |
| return JSON.parse(JSON.stringify(value)); | |
| } | |
| export function makeEvent(type, tick, detail = {}) { | |
| return { | |
| id: `${type}-${tick}`, | |
| type, | |
| tick, | |
| at: formatTime(tick), | |
| detail | |
| }; | |
| } | |
| export function commandTranscript(command, state) { | |
| const prompt = '$'; | |
| const selected = state.selectedFileId || 'README.md'; | |
| const lines = { | |
| ls: ['src/', 'tests/', 'docs/', '.github/', 'Cargo.toml', 'README.md'], | |
| 'git status': ['On branch main', 'Your branch is up to date with origin/main.', 'working tree clean'], | |
| 'git log': ['8f3a9c1 Fix kernel bounds', '2h4d7e2 Add proof sketch', '9ac1bd9 Update docs'], | |
| 'cargo test': ['Compiling pax-coder v0.8.2', 'running 142 tests', 'test result: ok. 142 passed; 0 failed'], | |
| './build.sh': ['[world] assembling repository tower', '[ci] verifying artifacts', 'BUILD #812 completed successfully'], | |
| help: ['Try: ls, git status, git log, cargo test, ./build.sh'] | |
| }; | |
| const output = lines[command] || [`command not found: ${command}`, 'Try `help` for local commands.']; | |
| return [`${prompt} ${command}`, ...output, `${prompt} _`]; | |
| } | |