# Project export: Premonition

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: OpenAI Build Week
- Tagline: Copy an error, and the fix is already waiting.
- Devpost: https://devpost.com/software/premonition
- GitHub: https://github.com/tcballard/Premonition
- Demo: https://github.com/tcballard/Premonition/releases/tag/v0.1.0
- Video: https://www.youtube.com/embed/odmKazkHqUc?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 1 GitHub contributor(s) — Tom Ballard (17 commits)

## Devpost submission (written by the team)

### Inspiration

I often found that when debugging, a loop starts which immediately becomes a chain of context switches - especially when not coding in a native AI IDE: copy the error, find the right repo, open an AI tool, explain context, wait for suggested fix, and then work out if the patch is safe to try. The idea of Premonition is to explore a smaller interface at that moment: what if copying an error were enough to prepare a reviewable fix, whilst the developer kept the final decision?

### What it does

Premonition is a native macOS menu-bar app and ambient layer for Codex. It watches the clipboard locally, but ordinary clipboard content stops before any model call. A deterministic heuristic first checks for a supported error shape, then resolves extracted paths only against Git repositories the developer explicitly allowlists. Only after those checks pass does Premonition send the copied error verbatim to Codex, pinned to GPT-5.6 Sol. Sol drafts one bounded unified diff inside an ephemeral, read-only, no-approval sandbox. Premonition parses and bounds the diff, rejects out-of-repository or malformed changes, and runs git apply --check without modifying the working tree. If the candidate is mechanically applicable, the menu-bar eye changes state and the developer can review a focused semantic diff and a short Sol rationale. The only outcomes are explicit: Apply, Copy Patch, or Dismiss. Apply rechecks that the worktree is literally clean and then uses git apply; the edit remains unstaged. Premonition never auto-applies, stages, commits, runs tests, invokes repository hooks, or executes post-apply commands. How I built it with Codex and GPT-5.6 GPT-5.6 Sol has two inspectable roles in Premonition. At runtime, every real patch and rationale call is made through the Codex CLI with the model pinned to gpt-5.6-sol. The runtime contract is deliberately narrow: read-only speculation, one candidate, canonical diff validation and a human decision before any repository mutation. During Build Week, Codex with GPT-5.6 Sol was also the build partner for the specification-led implementation: architecture, privacy and threat-model reviews, SwiftUI/AppKit implementation, tests, native UX refinement, fixture replay, signing and release evidence, and submission preparation. I retained the product-scope, privacy, acceptance and publication decisions. The durable record is visible in PREMONITION_SPEC.md, BUILDLOG.md, DEVLOG.md and docs/build-week/sol-ledger.md, with phase and session trailers in material commits. Outside this, I leveraged a purpose-build set of Skills in a Codex Toolkit plugin that aided the progress of the build, and kept it on track. These included $build-premonition which was called nearly 100 times over the 5 days I worked on this. Safety and privacy boundary Premonition's safety spine is local gate → allowlisted repository → admission cap → read-only Sol speculation → one bounded candidate → mechanical validation → explicit human decision. A ready patch expires after ten minutes, and tracked or untracked worktree changes block Apply. The limits are as important as the mechanism. The gate is heuristic. An admitted error is sent verbatim to Codex and may contain secrets; v0.1 has no secret-redaction pass and makes no claim about provider-side retention. git apply --check proves mechanical applicability, not correctness, security or completeness. Live model output can vary. A judge-runnable path The public v0.1.0 release is a signed, notarised and stapled Apple Silicon app for macOS 14+. Judges can download it without rebuilding. The repository also contains deterministic shallow and deep fixtures for demo purposes without needing to expose their own repos. Replay Fixture replaces only the model hop and is visibly labelled; the real gate, repository resolver, admission checks, diff parser, bounds validator, git apply --check, review UI and human action still run without network access. Prior work and what is new Premonition had specification v1.1 planning on 12 July 2026, before the Submission Period - I started working on this the moment that the challenge was announced, of course trying out the various Sol, Terra and Luna models. GPT-5.6 Sol-assisted specification and workflow refinement is recorded on 13 July through commit 2e83e84. Implementation began on 14 July with S0 commit 3422b0c. No application implementation is attributed to the pre-period plan; the dated boundary and direct commit links are documented in docs/build-week/prior-new-boundary.md. What I learned The interesting problem was not merely obtaining a plausible patch. It was designing the admission, validation, privacy and interaction boundaries around speculation so the experience could feel ambient without becoming autonomous. The deterministic fixture path also proved useful beyond demos: it makes the complete product loop inspectable even when network access or live model variability would otherwise get in the way.

### What's next

Premonition v0.1 intentionally stops at one local, reviewable candidate. Future work may explore bi-directional MCP integration and a direct OpenAI API executor, but neither is present in this submission. Automatic mutation, generic error comprehension, secret redaction and IDE integration are not implied roadmap commitments.

## README (from the GitHub repository)

# Premonition

**Copy an error, and the fix is already waiting.**

Premonition is a native macOS menu-bar app and ambient interface layer for
Codex. It watches the local clipboard for error-shaped text, resolves the
error only against Git repositories you explicitly allowlist, asks Codex
pinned to GPT-5.6 Sol for one bounded patch, validates that the patch applies,
and waits for your decision.

The v0.1 source, offline demo and signed, notarised judge artifact are complete
and owner-approved. This repository is public for judging, and the verified
[Premonition 0.1.0 release](https://github.com/tcballard/Premonition/releases/tag/v0.1.0)
provides the signed archive.

Owner-review explainer (ChatGPT sign-in required):
<https://premonition-field-guide.tom-ballard08574345.chatgpt.site>

## How the loop works

```text
clipboard → gate → allowlisted repository → admission → Sol → validation → review → human decision
```

1. Premonition polls the pasteboard locally twice per second. Concealed,
   transient and auto-generated items are skipped before their content is read.
2. A deterministic heuristic gate admits only supported, multi-line error
   shapes. Ordinary clipboard content stops locally.
3. Extracted paths must resolve to an existing Git repository beneath a root
   you added in Settings. Single-flight and the daily candidate cap are then
   checked.
4. Codex runs in an ephemeral, read-only, no-approval sandbox with the model
   pinned to `gpt-5.6-sol`.
5. One canonical parser rejects malformed, binary and out-of-repository diffs.
   `git apply --check` verifies mechanical applicability without changing the
   repository.
6. Premonition presents the diagnosis, semantic diff and optional Sol
   rationale. You choose **Apply**, **Copy Patch** or **Dismiss**.

Premonition never auto-applies, stages, commits, runs tests, invokes repository
hooks, or runs post-apply commands. Apply rechecks that the worktree is clean
and uses `git apply`; the resulting edit is unstaged.

## Privacy constitution

> Watches your clipboard locally. Nothing leaves this machine unless it is error-shaped text resolving to a Git repository you explicitly allowlist. If admitted, the copied error is sent verbatim to Codex using GPT-5.6 Sol. Premonition does not redact it, store it or auto-apply the result. You always review the patch first.

Copied errors are untrusted input and may contain secrets. v0.1 has no secret
redaction pass. After gate, allowlist and cap admission, the copied error is
sent verbatim to Codex. Premonition makes no claim about provider-side
retention.

An admitted candidate can make at most three model calls:

- one initial Sol patch attempt;
- one Sol escalation if execution or validation fails;
- one optional Sol rationale after a patch has validated.

Normal operation persists only configuration, date/count state and
content-free operational verdicts. It does not persist clipboard text,
prompts, diffs, rationales, model output or subprocess stderr.

## Requirements

- macOS 14 or later;
- Apple Silicon or a local Swift 5.10+ toolchain for source builds;
- an installed and authenticated Codex CLI for live speculation. The default
  path is `/opt/homebrew/bin/codex` and can be changed in the configuration;
- an explicitly allowlisted local Git repository.

Premonition has no third-party runtime dependencies.

## Install the signed release

Download
[`Premonition-0.1.0.zip`](https://github.com/tcballard/Premonition/releases/download/v0.1.0/Premonition-0.1.0.zip),
extract it, move `Premonition.app` to `/Applications`, and open the app. The
archive is signed with Developer ID, notarised by Apple and stapled. Its
SHA-256 is:

```text
3d48e5b06342ce8bd11dddf0fa7f8b318e7273dd3e453177b6a2b47ef8d03178
```

## Build and run from source

The repository-owned developer entry point builds the app bundle and launches
it:

```bash
script/build_and_run.sh
```

For a launch verification without attaching a debugger:

```bash
script/build_and_run.sh --verify
```

The first launch opens Settings. Choose **Add Root…** and select a directory
containing repositories you permit Premonition to resolve. Settings shows the
Codex CLI status, the pinned GPT-5.6 Sol runtime, the daily count, and the
fixture-replay controls. No JSON editing is required for onboarding.

The local source-build bundle is not the signed judge artifact. Use the
published v0.1.0 release above when evaluating the distributed build.

## Offline demo mode

Create the deterministic demo repository:

```bash
scripts/make-demo-repo.sh /tmp/Premonition-Demo
```

Add `/tmp/Premonition-Demo` as an allowlisted root in Settings, enable the demo
panel, then choose **Replay Fixture**. Replay replaces only the model hop: the
real gate, repository resolver, admission, diff parser, bounds validator,
`git apply --check`, presentation and human decision still run. It requires no
network access and is visibly labelled **Fixture replay**.

For the live shallow failure, run `make break` inside that repository and copy
the traceback. `make break-deep` provides the deterministic cross-file failure.

## Safety and current limitations

- The error gate is heuristic. It can miss unfamiliar traces or admit false
  positives; it is not generic error comprehension.
- `git apply --check` proves only that a patch applies to the current tree. It
  does not prove that the patch is correct, secure or complete.
- Large patches are summarised rather than rendered without bound. **Copy
  Patch** remains available.
- Tracked or untracked worktree changes block Apply. The clean-tree and patch
  checks run again when Apply is clicked.
- One candidate may be active at a time; later candidates are dropped rather
  than queued. Ready fixes expire after ten minutes.
- Live Sol output can vary. Fixture replay is the deterministic evaluation
  route.
- v0.1 is macOS-only and has no telemetry, updater, clipboard history, secret
  redaction, IDE extension, model picker or automatic repository commands.

See [SECURITY.md](SECURITY.md) for the reporting path and the complete safety
boundary.

## Sol provenance and Build Week boundary

Sol has two explicit roles:

1. **Runtime engine:** every real v0.1 patch and rationale call is Codex pinned
   to GPT-5.6 Sol.
2. **Build partner:** the product decisions, architecture, implementation,
   tests, design reviews and release preparation were developed and reviewed
   in a durable GPT-5.6 Sol-selected Codex session, with the owner retaining
   final scope and acceptance decisions.

The evidence trail is in [PREMONITION_SPEC.md](PREMONITION_SPEC.md),
[BUILDLOG.md](BUILDLOG.md), [DEVLOG.md](DEVLOG.md), and
[docs/build-week/sol-ledger.md](docs/build-week/sol-ledger.md).

The boundary is dated and explicit: specification v1.1 planning predates the
Submission Period on 12 July 2026; Sol-assisted specification and workflow
planning is recorded through [commit `2e83e84`](https://github.com/tcballard/Premonition/commit/2e83e846d9bbe8764dce82a2e0869ce5655ea24c)
on 13 July; new application implementation begins with [S0 commit `3422b0c`](https://github.com/tcballard/Premonition/commit/3422b0c4100f3ea156eab11fd91f9a251f2f9cac)
on 14 July. See
[docs/build-week/prior-new-boundary.md](docs/build-week/prior-new-boundary.md).

## Roadmap

Bi-directional MCP integration and a direct OpenAI API executor are roadmap
items. They are not present in v0.1. CodexToolkit skills used during the build
are external workflow infrastructure, not shipped app or runtime dependencies.

## Licence

Premonition is available under the [MIT Licence](LICENSE).


## Detected evidence (automated analysis)

Indexed codebase: 91 recognized source files, 627 KB.
- CSS (language) — detected in the code
- HTML (language) — detected in the code
- JavaScript (language) — detected in the code
- Python (language) — detected in the code
- Ruby (language) — detected in the code
- Swift (language) — detected in the code
- AI coding agent: Codex — evidence: config files committed to the repository

## Codebase structure (from repository index)

### Files (104 of 104)

```
.codex/environments/environment.toml
.gitignore
AGENTS.md
BUILDLOG.md
CHANGELOG.md
DEVLOG.md
docs/architecture.md
docs/build-week/prior-new-boundary.md
docs/build-week/provenance-exceptions.md
docs/build-week/s3-ux-remediation-plan.md
docs/build-week/s4-implementation-plan.md
docs/build-week/s5-acceptance-register.md
docs/build-week/s5-implementation-plan.md
docs/build-week/s5-sol-review.md
docs/build-week/s6-implementation-plan.md
docs/build-week/sites-explainer-handoff.md
docs/build-week/sol-ledger.md
docs/codex-contract.md
docs/prompts/rationale-v1.md
docs/prompts/speculation-v1.md
docs/threat-model.md
Fixtures/shallow/error.txt
Fixtures/shallow/events.jsonl
Fixtures/shallow/final.diff
Fixtures/shallow/fixture.json
launch-pack/ASSET_INVENTORY.md
launch-pack/CHANNEL_MATRIX.md
launch-pack/CLAIMS_LEDGER.md
launch-pack/HANDOFF.md
launch-pack/LAUNCH_BRIEF.md
launch-pack/RELEASE_CHECKLIST.md
LICENSE
Package.swift
packaging/entitlements.plist
packaging/homebrew/premonition.rb
packaging/Info.plist
PREMONITION_SPEC.md
README.md
script/build_and_run.sh
scripts/bootstrap.sh
scripts/build-app.sh
scripts/check_buildlog.py
scripts/check-provenance.py
scripts/make-demo-repo.sh
scripts/measure-sol.py
scripts/measure-sol.sh
scripts/sign-and-notarise.sh
scripts/test-demo-repo.py
scripts/test-measure-sol.py
scripts/test-release-tools.sh
scripts/test.sh
scripts/verify-release.sh
SECURITY.md
site/.gitignore
site/.openai/hosting.json
site/index.html
site/package.json
site/README.md
site/scripts/prepare-sites-build.js
site/scripts/verify-site.mjs
site/src/main.js
site/src/style.css
Sources/PremonitionApp/AppController.swift
Sources/PremonitionApp/AppDelegate.swift
Sources/PremonitionApp/DemoPanelController.swift
Sources/PremonitionApp/DemoPresentation.swift
Sources/PremonitionApp/PasteboardWatcher.swift
Sources/PremonitionApp/PremonitionApp.swift
Sources/PremonitionApp/PresentationModel.swift
Sources/PremonitionApp/SettingsWindowController.swift
Sources/PremonitionApp/Strings.swift
Sources/PremonitionApp/UI/DemoPanelView.swift
Sources/PremonitionApp/UI/FixReadyView.swift
Sources/PremonitionApp/UI/MonitoringView.swift
Sources/PremonitionApp/UI/PopoverChrome.swift
Sources/PremonitionApp/UI/PopoverView.swift
Sources/PremonitionApp/UI/PremonitionDesign.swift
Sources/PremonitionApp/UI/SemanticDiffView.swift
Sources/PremonitionApp/UI/SettingsPlaceholderView.swift
Sources/PremonitionCore/Clipboard/ClipboardCandidateFilter.swift
Sources/PremonitionCore/Clipboard/ClipboardDebouncer.swift
Sources/PremonitionCore/Configuration/DailyCap.swift
Sources/PremonitionCore/Configuration/PremonitionConfiguration.swift
Sources/PremonitionCore/Diff/DiffPresentation.swift
Sources/PremonitionCore/Diff/PatchApplier.swift
Sources/PremonitionCore/Diff/UnifiedDiff.swift
Sources/PremonitionCore/Executor/CodexExecutor.swift
Sources/PremonitionCore/Executor/CodexJSONLParser.swift
Sources/PremonitionCore/Executor/Executor.swift
Sources/PremonitionCore/Executor/FixtureExecutor.swift
Sources/PremonitionCore/Gate/ErrorGate.swift
Sources/PremonitionCore/Logging/VerdictLogger.swift
Sources/PremonitionCore/PremonitionCore.swift
Sources/PremonitionCore/Process/ProcessRunner.swift
Sources/PremonitionCore/Resolver/RepositoryResolver.swift
Sources/PremonitionCore/Speculation/CandidateStateMachine.swift
Sources/PremonitionCore/Speculation/FixtureSpeculator.swift
Sources/PremonitionCore/Speculation/PromptBuilder.swift
Sources/PremonitionCore/Speculation/SpeculationPipeline.swift
Tests/AcceptanceTests/S0ScaffoldTests.swift
Tests/AcceptanceTests/SafetyCoreAcceptanceTests.swift
Tests/PremonitionAppTests/MonitoringPresentationTests.swift
Tests/PremonitionCoreTests/PremonitionCoreTests.swift
Tests/PremonitionCoreTests/S2ExecutorTests.swift
```

### Dependencies

- site/package.json: vite@^7.0.5

### Recent commits (newest first)

- docs(release): document public v0.1.0 route [issue:#24] (#26)
- docs(submission): establish S6 evidence pack [issue:#24] (#25)
- docs(release): record Homebrew audit deferral [issue:#17] (#23)
- chore(release): prepare signed v0.1.0 candidate [issue:#17] (#22)
- feat(submission): add private Sites explainer preview [issue:#20] (#21)
- docs(release): record merged S5 hardening [issue:#17] (#19)
- feat(release): harden v0.1 release candidate [issue:#17] (#18)
- feat(demo): add filmable offline replay [issue:#15] (#16)
- feat(menu-bar): author popover hierarchy [issue:#13] (#14)
- feat(menu-bar): complete S3 acceptance [issue:#10] (#12)
- feat(menu-bar): connect functional speculation loop [issue:#10] (#11)
- feat(executor): implement real Sol pipeline [issue:#8] (#9)
- feat(safety): implement headless safety core [issue:#6] (#7)
- chore(scaffold): complete S0 foundation [issue:#4] (#5)
- docs(project): establish Premonition project records [issue:#2]
- revert: remove prematurely published project records
- docs: establish Premonition project records
- Initial commit

## Key source files (fetched from GitHub, selected and truncated for size)

### CHANGELOG.md

```markdown
# Changelog

All notable Premonition changes are recorded here. The project follows
semantic versioning once the first release is published.

## [Unreleased]

## [0.1.0] - 2026-07-20

### Added

- Native macOS 14+ menu-bar monitoring, paused, speculating and fix-ready
  states with keyboard, VoiceOver and Reduce Motion support.
- Local deterministic clipboard gate, allowlisted repository resolution,
  single-flight admission and persistent daily candidate cap.
- Codex execution pinned to GPT-5.6 Sol with one Low-effort attempt, one bounded
  Medium escalation and an optional post-validation rationale.
- Canonical unified-diff parsing, bounded path validation and non-mutating
  `git apply --check` verification.
- Explicit clean-tree Apply, Copy Patch, Dismiss and ten-minute expiry actions.
- Deterministic demo repository and offline fixture replay through the real
  gate, resolver, admission, validation and presentation pipeline.
- Specification-led Build Week provenance through paired BUILDLOG/DEVLOG
  entries and the Sol ledger.

### Security

- Concealed, transient and auto-generated pasteboard types are rejected before
  content reads.
- Normal persistence excludes clipboard text, prompts, diffs, rationales,
  model output and stderr.
- Candidate rationale execution is cancelled when Pause or any terminal
  review action releases the candidate.

### Release status

- The signed, notarised and stapled Apple Silicon archive is published through
  the GitHub `v0.1.0` release.
- The prepared Homebrew cask remains unpublished; strict cask audit was
  explicitly deferred under the specification's cut order.

```

### AGENTS.md

```markdown
# Premonition repository guidance

`PREMONITION_SPEC.md` is product authority. Before editing, read the current
`BUILDLOG.md` entry, the active S0–S6 session in §11 and settled decisions in
§13. `DEVLOG.md` is human context only.

## Invariants

- Execute only the earliest incomplete phase; do not add later-phase behaviour.
- Preserve C1–C5 and §13. No model call precedes gate, allowlist and cap admission.
- Never persist clipboard text, prompts, diffs, model output or stderr in normal operation.
- Pin `gpt-5.6-sol`; speculation is ephemeral, read-only and no-approval.
- One candidate, one canonical diff parser and explicit clean-tree Apply via `git apply` only.
- Never auto-apply, stage, commit, run post-apply commands or add telemetry.
- Do not publish, release, submit, merge or enable auto-merge without explicit owner authority.

## Workflow

1. Inspect existing issues before creating one. An issue needs Objective, Scope and testable Acceptance criteria.
2. Work on `codex/issue-<number>-<slug>`, never directly on `main` or another protected branch.
3. Use a Conventional Commit subject suffixed with `[issue:#<number>]`.
4. Material Sol commits include `Co-developed-with`, `Sol-Session`, `Sol-Phase` and `Build-Log-Entry` trailers.
5. Open a draft PR with Summary; Included/Excluded Scope; decisions; relevant user contract; exact verification; covered behaviours; review path; and reviewer notes.
6. The owner reviews and merges.

## S0 commands

- `swift build`
- `swift test`
- `scripts/test.sh`
- `scripts/build-app.sh release`
- `script/build_and_run.sh --verify`
- `python3 scripts/check_buildlog.py BUILDLOG.md --devlog DEVLOG.md`
- `python3 scripts/check-provenance.py`

Use `script/build_and_run.sh` as the only developer launch entrypoint. It must
delegate deterministic bundle assembly to `scripts/build-app.sh`.

```

### site/package.json

```
{
  "name": "premonition-field-guide",
  "private": true,
  "version": "0.1.0",
  "type": "module",
  "scripts": {
    "dev": "vite --host 127.0.0.1",
    "build": "vite build && node scripts/prepare-sites-build.js",
    "preview": "vite preview --host 127.0.0.1",
    "verify": "node scripts/verify-site.mjs"
  },
  "devDependencies": {
    "vite": "^7.0.5"
  }
}

```

### site/src/main.js

```javascript
import './style.css';

const tickRoot = document.querySelector('[data-dial-ticks]');

if (tickRoot) {
  for (let index = 0; index < 48; index += 1) {
    const tick = document.createElement('span');
    tick.style.setProperty('--tick-index', index);
    tick.classList.toggle('is-signal', index >= 3 && index <= 9);
    tickRoot.append(tick);
  }
}

```

### Package.swift

```swift
// swift-tools-version: 5.10
import PackageDescription

let package = Package(
    name: "Premonition",
    platforms: [.macOS(.v14)],
    products: [
        .library(name: "PremonitionCore", targets: ["PremonitionCore"]),
        .executable(name: "Premonition", targets: ["PremonitionApp"]),
    ],
    targets: [
        .target(name: "PremonitionCore"),
        .executableTarget(
            name: "PremonitionApp",
            dependencies: ["PremonitionCore"],
            path: "Sources/PremonitionApp"
        ),
        .testTarget(name: "PremonitionCoreTests", dependencies: ["PremonitionCore"]),
        .testTarget(name: "AcceptanceTests", dependencies: ["PremonitionCore"]),
        .testTarget(name: "PremonitionAppTests", dependencies: ["PremonitionApp"]),
    ]
)

```

### scripts/measure-sol.sh

```shell
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
exec python3 "$ROOT_DIR/scripts/measure-sol.py" "$@"

```

### scripts/bootstrap.sh

```shell
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
swift package --package-path "$ROOT_DIR" resolve
"$ROOT_DIR/scripts/test.sh"

```

### scripts/test.sh

```shell
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
swift test --package-path "$ROOT_DIR"
python3 "$ROOT_DIR/scripts/test-demo-repo.py"
python3 "$ROOT_DIR/scripts/test-measure-sol.py"
"$ROOT_DIR/scripts/test-release-tools.sh"

```

### scripts/build-app.sh

```shell
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CONFIGURATION="${1:-release}"
case "$CONFIGURATION" in
  debug|release) ;;
  *) echo "usage: $0 [debug|release]" >&2; exit 2 ;;
esac

swift build --package-path "$ROOT_DIR" -c "$CONFIGURATION" --product Premonition >&2
BIN_DIR="$(swift build --package-path "$ROOT_DIR" -c "$CONFIGURATION" --show-bin-path 2>/dev/null)"
APP_BUNDLE="$ROOT_DIR/dist/Premonition.app"
CONTENTS="$APP_BUNDLE/Contents"

rm -rf "$APP_BUNDLE"
mkdir -p "$CONTENTS/MacOS" "$CONTENTS/Resources"
cp "$BIN_DIR/Premonition" "$CONTENTS/MacOS/Premonition"
cp "$ROOT_DIR/packaging/Info.plist" "$CONTENTS/Info.plist"
cp -R "$ROOT_DIR/Fixtures" "$CONTENTS/Resources/Fixtures"
chmod +x "$CONTENTS/MacOS/Premonition"
plutil -lint "$CONTENTS/Info.plist" >/dev/null
printf '%s\n' "$APP_BUNDLE"

```

### script/build_and_run.sh

```shell
#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
MODE="${1:-run}"
pkill -x Premonition >/dev/null 2>&1 || true

case "$MODE" in
  run|--verify|verify|--logs|logs|--debug|debug) ;;
  *) echo "usage: $0 [run|--verify|--logs|--debug]" >&2; exit 2 ;;
esac

APP_BUNDLE="$("$ROOT_DIR/scripts/build-app.sh" debug)"
APP_BINARY="$APP_BUNDLE/Contents/MacOS/Premonition"

case "$MODE" in
  run)
    /usr/bin/open -n "$APP_BUNDLE"
    ;;
  --verify|verify)
    /usr/bin/open -n "$APP_BUNDLE"
    for _ in {1..20}; do
      pgrep -x Premonition >/dev/null && exit 0
      sleep 0.1
    done
    echo "Premonition did not remain running" >&2
    exit 1
    ;;
  --logs|logs)
    /usr/bin/open -n "$APP_BUNDLE"
    /usr/bin/log stream --info --style compact --predicate 'process == "Premonition"'
    ;;
  --debug|debug)
    lldb -- "$APP_BINARY"
    ;;
esac

```

[77 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]