# prasannakulal/failorpass architecture

> Architecture diagram of the GitHub repository prasannakulal/failorpass, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prasannakulal/failorpass
- Repository: https://github.com/prasannakulal/failorpass

## Overview

#### Purpose and Entry Points
FailOrWin is a VS Code extension that monitors integrated-terminal output and emits audio alerts for configured success or failure text patterns. The authored extension entry point is `src/extension.ts`; the distributable compiled entry is `out/extension.js`, packaged as `terminal-sound-alert-0.0.1.vsix`. Extension commands, settings contributions, and activation metadata are expected in `package.json`.

#### VS Code Integration Layer
The extension runs in the VS Code extension host and integrates with:
- Integrated terminal output observation and lifecycle events.
- Command Palette commands for cue selection, alert-mode changes, toggling, quick switching, and imports.
- An Activity Bar/sidebar control surface for interactive configuration.
- VS Code configuration APIs for the `terminalSound.*` settings namespace.

The primary implementation boundary is `src/extension.ts`, which connects VS Code APIs, detection logic, configuration, and playback.

#### Detection and Alert Control
Terminal text is evaluated against independently configurable success and error keyword lists. Detection is gated by a master enable switch and separate success/error trigger switches. A cooldown prevents repetitive playback from noisy or repeated terminal output; configuration defines a minimum delay of 500 ms. Alert mode selection and quick switching provide a user-facing control path distinct from raw keyword configuration.

Relevant implementation and package-definition paths: `src/extension.ts`, `package.json`, `out/extension.js`.

#### Audio Cue Resolution and Playback
Playback supports MP3, WAV, and OGG files. Cue selection can resolve explicit configured paths—absolute, workspace-relative, or home-relative—or bundled preset names. The extension includes general fallback cues in `sounds/success.mp3` and `sounds/error.mp3`, plus selectable bundled media under `default/`, such as `default/chala-ja-bsdk.mp3`.

A TypeScript declaration at `src/types/play-sound.d.ts` indicates playback is mediated through a sound-playing dependency/API rather than browser audio. Volume is requested through settings, subject to the capabilities of the underlying playback runtime and host OS.

#### Data and Control Flow
1. VS Code activates the extension and registers terminal listeners, commands, sidebar integration, and configuration access from `src/extension.ts`.
2. Terminal output enters the keyword-detection stage.
3. Enable flags, alert mode, trigger category, and cooldown decide whether an event can fire.
4. The selected success/failure cue is resolved from custom path, preset, or bundled asset.
5. The playback adapter invokes local audio playback; optional debug logging is routed through the extension’s VS Code output/logging facilities.

No remote backend is indicated: terminal data, settings, imported cues, and playback remain local to the VS Code/Node extension-host environment.

#### Build and Distribution Boundary
TypeScript source in `src/extension.ts` is compiled into `out/extension.js` with source mapping in `out/extension.js.map`. `package.json`, `tsconfig.json`, and `package-lock.json` define the Node/TypeScript build and dependency boundary. The resulting VS Code package artifact is `terminal-sound-alert-0.0.1.vsix`, while bundled audio directories (`sounds/` and `default/`) are extension-local runtime assets.

Main entry points: [`out/extension.js`](https://github.com/prasannakulal/failorpass/blob/main/out/extension.js) (Compiled extension), [`src/extension.ts`](https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts) (Cue resolver), [`package.json`](https://github.com/prasannakulal/failorpass/blob/main/package.json) (terminalSound settings), [`terminal-sound-alert-0.0.1.vsix`](https://github.com/prasannakulal/failorpass/blob/main/terminal-sound-alert-0.0.1.vsix) (VSIX package)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["VS Code extension host"]
  node_vscode{{"VS Code<br/>editor platform"}}
  node_manifest["Extension manifest<br/>VS Code contributions<br/>[package.json]"]
  node_extension["Extension integration<br/>TypeScript entry point<br/>[extension.ts]"]
  node_terminal["Integrated terminal<br/>terminal output"]
  node_controls["Commands and sidebar<br/>control surface"]
end

subgraph group_runtime["Alert runtime"]
  node_settings["terminalSound settings<br/>configuration<br/>[package.json]"]
  node_detector["Keyword detection<br/>alert classifier<br/>[extension.ts]"]
  node_gate["Alert gate<br/>trigger policy<br/>[extension.ts]"]
  node_cue_resolver["Cue resolver<br/>asset selection<br/>[extension.ts]"]
  node_playback["Playback adapter<br/>Node audio dependency<br/>[play-sound.d.ts]"]
  node_logging["VS Code output logging<br/>debug output<br/>[extension.ts]"]
end

subgraph group_assets["Local audio assets"]
  node_fallback_cues["Fallback cues<br/>bundled MP3 assets<br/>[success.mp3]"]
  node_preset_cues["Preset cues<br/>bundled media"]
end

subgraph group_build["Build and distribution"]
  node_compiled["Compiled extension<br/>JavaScript runtime entry<br/>[extension.js]"]
  node_source_map["Source map<br/>debug artifact<br/>[extension.js.map]"]
  node_tsconfig["TypeScript build config<br/>compiler configuration<br/>[tsconfig.json]"]
  node_lockfile["Dependency lockfile<br/>Node dependency lock<br/>[package-lock.json]"]
  node_vsix["VSIX package<br/>distribution artifact"]
end

node_manifest -->|"contributes to"| node_vscode
node_vscode -->|"activates"| node_compiled
node_compiled -.->|"compiled from"| node_extension
node_extension -->|"observes output and lifecycle"| node_terminal
node_extension -->|"registers"| node_controls
node_controls -->|"updates"| node_settings
node_terminal -->|"output text"| node_detector
node_settings -->|"success/error keywords"| node_detector
node_detector -->|"matched category"| node_gate
node_settings -->|"mode, switches, cooldown"| node_gate
node_gate -->|"permitted alert"| node_cue_resolver
node_settings -->|"cue and path selection"| node_cue_resolver
node_fallback_cues -->|"fallback assets"| node_cue_resolver
node_preset_cues -->|"preset assets"| node_cue_resolver
node_cue_resolver -->|"resolved local cue"| node_playback
node_playback -.->|"debug status"| node_logging
node_tsconfig -->|"compiles"| node_compiled
node_compiled -.->|"maps to source"| node_source_map
node_lockfile -.->|"pins dependencies"| node_compiled
node_manifest -->|"packaged with"| node_vsix
node_compiled -->|"included in"| node_vsix
node_fallback_cues -->|"bundled in"| node_vsix
node_preset_cues -->|"bundled in"| node_vsix

click node_manifest "https://github.com/prasannakulal/failorpass/blob/main/package.json"
click node_extension "https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts"
click node_settings "https://github.com/prasannakulal/failorpass/blob/main/package.json"
click node_detector "https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts"
click node_gate "https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts"
click node_cue_resolver "https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts"
click node_playback "https://github.com/prasannakulal/failorpass/blob/main/src/types/play-sound.d.ts"
click node_logging "https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts"
click node_fallback_cues "https://github.com/prasannakulal/failorpass/blob/main/sounds/success.mp3"
click node_compiled "https://github.com/prasannakulal/failorpass/blob/main/out/extension.js"
click node_source_map "https://github.com/prasannakulal/failorpass/blob/main/out/extension.js.map"
click node_tsconfig "https://github.com/prasannakulal/failorpass/blob/main/tsconfig.json"
click node_lockfile "https://github.com/prasannakulal/failorpass/blob/main/package-lock.json"
click node_vsix "https://github.com/prasannakulal/failorpass/blob/main/terminal-sound-alert-0.0.1.vsix"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_vscode,node_manifest,node_extension,node_terminal,node_controls toneBlue
class node_settings,node_detector,node_gate,node_cue_resolver,node_playback,node_logging toneAmber
class node_fallback_cues,node_preset_cues toneMint
class node_compiled,node_source_map,node_tsconfig,node_lockfile,node_vsix toneRose
```

## Components

### VS Code extension host

- **VS Code**: editor platform
- [Extension manifest](https://github.com/prasannakulal/failorpass/blob/main/package.json): VS Code contributions · Defines activation, commands, and terminalSound settings. · `package.json`
- [Extension integration](https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts): TypeScript entry point · Registers VS Code integrations and connects the alert flow. · `src/extension.ts`
- **Integrated terminal**: terminal output
- **Commands and sidebar**: control surface

### Alert runtime

- [terminalSound settings](https://github.com/prasannakulal/failorpass/blob/main/package.json): configuration · Controls keywords, modes, switches, cooldown, paths, and volume. · `package.json`
- [Keyword detection](https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts): alert classifier · Classifies terminal text as configured success or error matches. · `src/extension.ts`
- [Alert gate](https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts): trigger policy · Applies enable flags, alert mode, category switches, and cooldown. · `src/extension.ts`
- [Cue resolver](https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts): asset selection · Resolves custom absolute, workspace, home, preset, or fallback cues. · `src/extension.ts`
- [Playback adapter](https://github.com/prasannakulal/failorpass/blob/main/src/types/play-sound.d.ts): Node audio dependency · Invokes host-local audio playback. · `src/types/play-sound.d.ts`
- [VS Code output logging](https://github.com/prasannakulal/failorpass/blob/main/src/extension.ts): debug output · `src/extension.ts`

### Local audio assets

- [Fallback cues](https://github.com/prasannakulal/failorpass/blob/main/sounds/success.mp3): bundled MP3 assets · `sounds/success.mp3`
- **Preset cues**: bundled media

### Build and distribution

- [Compiled extension](https://github.com/prasannakulal/failorpass/blob/main/out/extension.js): JavaScript runtime entry · `out/extension.js`
- [Source map](https://github.com/prasannakulal/failorpass/blob/main/out/extension.js.map): debug artifact · `out/extension.js.map`
- [TypeScript build config](https://github.com/prasannakulal/failorpass/blob/main/tsconfig.json): compiler configuration · `tsconfig.json`
- [Dependency lockfile](https://github.com/prasannakulal/failorpass/blob/main/package-lock.json): Node dependency lock · `package-lock.json`
- [VSIX package](https://github.com/prasannakulal/failorpass/blob/main/terminal-sound-alert-0.0.1.vsix): distribution artifact · `terminal-sound-alert-0.0.1.vsix`

## Connections

- Extension manifest → VS Code: contributes to
- VS Code → Compiled extension: activates
- Compiled extension → Extension integration: compiled from
- Extension integration → Integrated terminal: observes output and lifecycle
- Extension integration → Commands and sidebar: registers
- Commands and sidebar → terminalSound settings: updates
- Integrated terminal → Keyword detection: output text
- terminalSound settings → Keyword detection: success/error keywords
- Keyword detection → Alert gate: matched category
- terminalSound settings → Alert gate: mode, switches, cooldown
- Alert gate → Cue resolver: permitted alert
- terminalSound settings → Cue resolver: cue and path selection
- Fallback cues → Cue resolver: fallback assets
- Preset cues → Cue resolver: preset assets
- Cue resolver → Playback adapter: resolved local cue
- Playback adapter → VS Code output logging: debug status
- TypeScript build config → Compiled extension: compiles
- Compiled extension → Source map: maps to source
- Dependency lockfile → Compiled extension: pins dependencies
- Extension manifest → VSIX package: packaged with
- Compiled extension → VSIX package: included in
- Fallback cues → VSIX package: bundled in
- Preset cues → VSIX package: bundled in
