# GT - GhostOS Terminal

`GT - GhostOS Terminal` is the VS Code client for `GhostTerminal`.

Licensing:

- product license: `C:\Users\Bullshit Lab\Desktop\ghostOS\GT\LICENSE.txt`
- product EULA: `C:\Users\Bullshit Lab\Desktop\ghostOS\GT\EULA.md`
- extension package license: `C:\Users\Bullshit Lab\Desktop\ghostOS\GT\vscode\LICENSE.txt`

## Current Capabilities

- launch `ghostterm_host` commands from the Command Palette and Explorer
- appear in the VS Code terminal profile picker as `GT - GhostOS Terminal`
- start a fresh headless `ghostOS` runtime before attach, so the profile binds to the newest packaged kernel instead of a stale VM session
- auto-detect the local `ghostOS` repository from the current workspace, or use the `ghostterminal.repoRoot` setting when needed
- fall back to a GT-managed bundled `ghostOS` runtime pack when the local developer repo is not present
- let the mobile kernel auto-bring up route publication and bootstrap after wallet unlock + network-up, so operators usually only need to connect to a peer instead of manually re-running `announce` / `bootstrap` every session
- open GT-managed mobile build, ISO, VMware, selfhost, serial, and ghostOS shell sessions
- run a captured mobile build and publish compiler warnings and errors into the Problems panel
- explore generated `.gbir` files under `mobile/out`
- open GBIR summaries inside VS Code through a virtual document view
- query live `ghostOS` runtime state through `ghostos status`, `ghostos ping`, `ghostos ui`, `ghostos wifi details`, and `ghostos send`
- package GT as a public runtime + installer bundle instead of depending only on a local repo checkout

## GT Command Reference

These are the current user-facing commands that GT ships today.

### Host-Side GT Commands

Run these from:

`C:\Users\Bullshit Lab\Desktop\ghostOS`

```powershell
.\GT\bin\ghostterm_host.exe help
.\GT\bin\ghostterm_host.exe doctor
.\GT\bin\ghostterm_host.exe status
.\GT\bin\ghostterm_host.exe runtime status
.\GT\bin\ghostterm_host.exe runtime package
.\GT\bin\ghostterm_host.exe profile list
.\GT\bin\ghostterm_host.exe profile use ghostos-vm
.\GT\bin\ghostterm_host.exe session list
.\GT\bin\ghostterm_host.exe session status
.\GT\bin\ghostterm_host.exe mobile build
.\GT\bin\ghostterm_host.exe mobile iso
.\GT\bin\ghostterm_host.exe mobile vmware
.\GT\bin\ghostterm_host.exe mobile clean
.\GT\bin\ghostterm_host.exe selfhost run --jobs 1
.\GT\bin\ghostterm_host.exe selfhost clean
.\GT\bin\ghostterm_host.exe serial tail 80
.\GT\bin\ghostterm_host.exe serial follow
.\GT\bin\ghostterm_host.exe node start
.\GT\bin\ghostterm_host.exe node stop
.\GT\bin\ghostterm_host.exe node status
.\GT\bin\ghostterm_host.exe enter ghostos --shell --headless --restart-vm
.\GT\bin\ghostterm_host.exe enter serial
.\GT\bin\ghostterm_host.exe enter selfhost --jobs 1
.\GT\bin\ghostterm_host.exe ghostos status
.\GT\bin\ghostterm_host.exe ghostos ping
.\GT\bin\ghostterm_host.exe ghostos ui
.\GT\bin\ghostterm_host.exe ghostos serial
.\GT\bin\ghostterm_host.exe ghostos wifi status
.\GT\bin\ghostterm_host.exe ghostos wifi details
.\GT\bin\ghostterm_host.exe ghostos p2p address
.\GT\bin\ghostterm_host.exe ghostos p2p stack
.\GT\bin\ghostterm_host.exe ghostos p2p announce
.\GT\bin\ghostterm_host.exe ghostos p2p bootstrap
.\\GT\\bin\\ghostterm_host.exe bootstrap-node serve --bind 0.0.0.0 --port 4001 --seed-host seed1.imagine-freedom.net --seed-port 4001
.\GT\bin\ghostterm_host.exe ghostos wifi scan
.\GT\bin\ghostterm_host.exe ghostos wifi get 0
.\GT\bin\ghostterm_host.exe ghostos wifi connect 0 MyPassword
.\GT\bin\ghostterm_host.exe ghostos wifi disconnect
.\GT\bin\ghostterm_host.exe ghostos reset onboarding --confirm
.\GT\bin\ghostterm_host.exe ghostos send STATUS
.\GT\bin\ghostterm_host.exe vscode package
.\GT\bin\ghostterm_host.exe vscode install
.\GT\bin\ghostterm_host.exe vscode publish
.\GT\bin\ghostterm_host.exe open vmware
.\GT\bin\ghostterm_host.exe open serial
.\GT\bin\ghostterm_host.exe open gt
.\GT\bin\ghostterm_host.exe open vscode
```

### In-Shell ghostOS Commands

Open the GT terminal profile or run:

```powershell
.\GT\bin\ghostterm_host.exe enter ghostos --shell --headless --restart-vm
```

Inside the attached `ghostOS` shell, use:

```text
ghost help
ghost status
ghost onboarding
ghost whoami
ghost ui
ghost serial
ghost os-serial
ghost wallet
ghost node
ghost multinodes
ghost login
ghost register
ghost logout
ghost reset onboarding
ghost wifi status
ghost wifi details
ghost wifi scan
ghost wifi list
ghost wifi connect <index> [password]
ghost wifi disconnect
ghost p2p
ghost p2p address
ghost p2p stack
ghost p2p announce
ghost p2p bootstrap
ghost p2p contacts
ghost p2p add <alias> <wallet> [ip:port]
ghost p2p remove <slot|alias>
ghost p2p use <slot|alias>
ghost p2p connect <slot|alias>
ghost p2p sendto <slot|alias> <message>
ghost p2p send <wallet> <message>
ghost p2p status
ghost p2p list
ghost clear
ghost send <raw GhostTransport command>
exit
```

## GT Runtime Verification

### Inspect Connected Network Details

From the host:

```powershell
.\GT\bin\ghostterm_host.exe ghostos wifi details
```

From inside the attached shell:

```text
ghost wifi details
```

The current details view reports the live kernel-backed values that GT can read from `ghostOS`, including:
- interface name
- interface type
- IP address
- subnet
- gateway
- DNS servers
- MTU
- interface MAC
- connected SSID
- BSSID
- security mode
- signal strength
- channel
- frequency

### View MultiNodes Visible In The Network

From inside the attached shell:

```text
ghost multinodes
```

This viewer reports:
- currently connected MultiNodes
- DHT-discovered MultiNodes visible from the current runtime
- total visible network size from this node's perspective
- bootstrap progress
- active interface
- public route context

### Validate P2P Through GT

1. Start or attach a real guest shell:

```powershell
.\GT\bin\ghostterm_host.exe enter ghostos --shell --headless --restart-vm
```

2. Inside the shell, verify your own identity:

```text
ghost p2p address
ghost p2p stack
```

The mobile kernel now auto-attempts route publish + bootstrap on its own after wallet unlock and network-up. In VMware-backed sessions that means the driver will infer and stage the local host-assisted seed automatically; once real public seeds are pinned, the same kernel path will prefer those public seeds instead.

If you want to inspect or force the steps manually, you can still run:

```text
ghost p2p announce
ghost p2p bootstrap
```

3. Add a known peer by wallet address only:

```text
ghost p2p add alice Ghost0x0123456789abcdef0123456789abcdef01234567
ghost p2p contacts
```

4. Let ghostOS auto-resolve and prepare the route:

```text
ghost p2p connect alice
ghost p2p stack
```

If you already know a public endpoint and want to pin or override it manually, you can still do:

```text
ghost p2p add alice Ghost0x0123456789abcdef0123456789abcdef01234567 203.0.113.10:4001
```

5. Queue and inspect a message:

```text
ghost p2p sendto alice hello-from-gt
ghost p2p list
ghost p2p status
```

6. For raw automation, use:

```powershell
.\GT\bin\ghostterm_host.exe ghostos send "P2P ADDRESS"
.\GT\bin\ghostterm_host.exe ghostos send "P2P STACK STATUS"
.\GT\bin\ghostterm_host.exe ghostos p2p announce
.\GT\bin\ghostterm_host.exe ghostos p2p bootstrap
.\GT\bin\ghostterm_host.exe ghostos send "P2P CONTACT ADD alice Ghost0x0123456789abcdef0123456789abcdef01234567 203.0.113.10:4001"
.\GT\bin\ghostterm_host.exe ghostos send "P2P CONTACT CONNECT 0"
.\GT\bin\ghostterm_host.exe ghostos send "P2P CONTACT SEND 0 hello-from-gt"
.\GT\bin\ghostterm_host.exe ghostos send "P2P GET 0"
```

Important:
- GT commands are talking to the real `ghostOS` runtime, not mock data.
- P2P transport, ICE signaling, relay fallback, and discovery are now implemented in the kernel-side stack.
- Wide live matrix validation across multiple peers and NAT combinations is still an operational test step, not a documentation claim.

## Run A Public FreedomNet Bootstrap Node

The first real public FreedomNet bootstrap node now exists and speaks the same wire protocol the mobile kernel already defines.

Current production seed:

```text
213.188.193.151:4001
```

The kernel can now ship that public seed as part of the runtime. Normal operators should not need to stand up their own bootstrap daemon just to use `P2P`.

If you need to maintain or redeploy the public bootstrap service itself, the GT repo now carries a Fly deployment path:

```powershell
.\GT\deploy_public_bootstrap_fly.ps1 -AppName ghostos-bootstrap-seed -PrimaryRegion fra -SeedHost 213.188.193.151
```

That public adapter is still only an ingress layer. The message types, bootstrap policy, discovery logic, and relay envelope remain kernel-owned in `mobile`.

You can now drive that flow through GT itself:

```powershell
.\GT\bin\ghostterm_host.exe bootstrap-node bundle
.\GT\bin\ghostterm_host.exe bootstrap-node install --seed-host 213.188.193.151 --port 4001
.\GT\bin\ghostterm_host.exe bootstrap-node status
.\GT\bin\ghostterm_host.exe bootstrap-node pin --seed-host 213.188.193.151 --port 4001 --rebuild-public
```

Once GT is installed publicly, the same flow is available from the installed launcher too:

```powershell
%LOCALAPPDATA%\ImagineTech\GT\gt_host.cmd bootstrap-node install --seed-host 213.188.193.151 --port 4001
%LOCALAPPDATA%\ImagineTech\GT\gt_host.cmd bootstrap-node status
%LOCALAPPDATA%\ImagineTech\GT\gt_host.cmd bootstrap-node uninstall --port 4001
```

1. Build or use the bundled bootstrap-node package:

```powershell
.\GT\build_bootstrap_node_bundle.ps1
```

2. On a public Windows host, extract `freedomnet-bootstrap-node-current.zip` and run:

```powershell
.\install_bootstrap_service.ps1 -SeedHost 213.188.193.151 -Port 4001
```

3. Pin that same public seed into the mobile kernel config:

```powershell
.\GT\pin_public_bootstrap_seed.ps1 -SeedHost 213.188.193.151 -Port 4001 -RebuildPublic
```

4. Rebuild the mobile runtime and GT bundle so the kernel ships with a real public seed:

```powershell
.\mobile\deploy_mobile.ps1 --surface-x64 build
.\GT\build_runtime_bundle.ps1 -RebuildOS
.\GT\build_public_release.ps1 -RebuildHost -RebuildRuntime -RebuildVsix
.\GT\build_public_installer_exe.ps1
```

5. Validate two operators from different NATs:

```text
ghost p2p connect <alias>
ghost p2p sendto <alias> hello
```

Notes:
- `bootstrap-node serve` is a host-side network adapter only. The message types, bootstrap policy, and relay envelope still come from the `mobile` kernel headers.
- Use the same `seed-host:seed-port` pair in the daemon command and in `mobile/config/freedomnet_bootstrap_nodes.txt`, so the bootstrap identity that the kernel derives stays stable.
- Once a real public seed is pinned into the mobile runtime, the kernel will start preferring that public fabric automatically during its own bring-up tick. GT only falls back to host-assisted bootstrap when the kernel reports that no public-capable seed exists.
- The public GT installer now carries the bootstrap-node payload under `releases/bootstrap/current`, so installed operators can manage the host-side bootstrap service from GT itself instead of downloading a second helper package.

## GT Runtime Bundle

GT can now ship a bundled runtime pack for operators who do not carry a full local `ghostOS` source checkout.

Build the bundle from a developer machine:

```powershell
cd C:\Users\Bullshit Lab\Desktop\ghostOS
.\GT\bin\ghostterm_host.exe runtime package
```

That flow packages the current `ghostOS` runtime into:

- `GT\releases\runtime\current\ghostos_mobile.iso`
- `GT\releases\runtime\current\ghostos_mobile.elf`
- `GT\releases\runtime\current\ghostos_mobile.bin`
- `GT\releases\runtime\current\runtime_manifest.txt`

Operators can then use GT in bundled-runtime mode without a full local developer repo, while GT still verifies the manifest, ISO hash, and runtime profile before preparing the VM session.

## Public Distribution Bundle

GT can now be packaged as a public operator bundle instead of assuming a local repo checkout.

Build the public release:

```powershell
cd C:\Users\Bullshit Lab\Desktop\ghostOS
powershell -ExecutionPolicy Bypass -File .\GT\build_public_release.ps1 -RebuildHost -RebuildRuntime -RebuildVsix
```

That produces:

- `GT\releases\public\<version>\install_gt.ps1`
- `GT\releases\public\<version>\payload\bin\ghostterm_host.exe`
- `GT\releases\public\<version>\payload\runtime\sealed\ghostos_mobile.iso.gtr`
- `GT\releases\public\<version>\payload\vscode\dist\gt-ghostos-terminal-<version>.vsix`
- `GT\releases\public\gt-public-<version>.zip`

The public bundle does not ship the raw `ghostOS` source tree. It ships the compiled runtime ISO in sealed form, and the installer stores it locally as a DPAPI-protected payload under `releases\runtime\current`. GT only stages a runnable ISO into the VM workspace on demand.

Install from the extracted release bundle:

```powershell
powershell -ExecutionPolicy Bypass -File .\install_gt.ps1 -InstallVsCodeExtension
```

The installer places GT under:

- `%LOCALAPPDATA%\ImagineTech\GT`

and creates:

- `%LOCALAPPDATA%\ImagineTech\GT\gt.cmd`

so the public operator package no longer depends on the full developer repository being present on the target machine.

To sync the latest GT public bundle into the public website download area:

```powershell
cd C:\Users\Bullshit Lab\Desktop\ghostOS
powershell -ExecutionPolicy Bypass -File .\GT\sync_public_release_to_imagine_web.ps1
```

## Development

The extension root is:

`C:\Users\Bullshit Lab\Desktop\ghostOS\GT\vscode`

Syntax check:

```powershell
cd C:\Users\Bullshit Lab\Desktop\ghostOS\GT\vscode
node --check .\extension.js
```

VSIX packaging:

```powershell
cd C:\Users\Bullshit Lab\Desktop\ghostOS\GT\vscode
powershell -ExecutionPolicy Bypass -File .\build_vsix.ps1
```

The packaged file will be written under:

`C:\Users\Bullshit Lab\Desktop\ghostOS\GT\vscode\dist`

GT-native package flow:

```powershell
cd C:\Users\Bullshit Lab\Desktop\ghostOS
.\GT\bin\ghostterm_host.exe vscode package
```

GT-native install flow:

```powershell
cd C:\Users\Bullshit Lab\Desktop\ghostOS
.\GT\bin\ghostterm_host.exe vscode install
```

The extension expects:

- `GT\bin\ghostterm_host.exe`
- either the canonical repo layout under `C:\Users\Bullshit Lab\Desktop\ghostOS` or a GT bundled runtime under `GT\releases\runtime\current`
- `mobile\out\**\*.gbir` for GBIR exploration

## Marketplace Publish Checklist

1. Create or confirm your Visual Studio Marketplace publisher id.
2. Make sure the `publisher` field in `package.json` matches that publisher id exactly.
3. Package the extension:

```powershell
cd C:\Users\Bullshit Lab\Desktop\ghostOS\GT\vscode
powershell -ExecutionPolicy Bypass -File .\build_vsix.ps1
```

4. Sign in with `vsce`:

```powershell
vsce login Imagine
```

5. Publish:

```powershell
vsce publish
```

Or use the GT-native publish flow:

```powershell
cd C:\Users\Bullshit Lab\Desktop\ghostOS
$env:VSCE_PAT = "<your_marketplace_token>"
.\GT\bin\ghostterm_host.exe vscode publish
```

## Notes

- interactive shell and serial flows are launched in an integrated VS Code terminal
- captured diagnostics use `ghostterm_host mobile build` and parse compiler-style messages into Problems
- passive runtime inspection can use the live serial marker path even when the GhostTransport shell is not open
- release notes: `CHANGELOG.md`
- support notes: `SUPPORT.md`
