SNAPKITTYWEST commited on
Commit
4e430ea
·
verified ·
1 Parent(s): e164aa0

push from SNAPKITTYWEST/sovereign-ide-extensions

Browse files
LICENSE ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ SOVEREIGN SOURCE LICENSE v1.0
2
+ Copyright (c) 2026 Ahmad Ali Parr -- Bel Esprit D'Accord Trust
3
+ SnapKitty Collective -- All Sovereign Rights Reserved
4
+
5
+ WORM SEALED -- Evidence or Silence
6
+
7
+ GRANT OF RIGHTS
8
+
9
+ Permission is hereby granted, free of charge, to any person
10
+ obtaining a copy of this software and associated documentation
11
+ files (the "Work"), to use, study, copy, and modify the Work
12
+ for personal, educational, and non-commercial purposes, subject
13
+ to the following conditions:
14
+
15
+ 1. ATTRIBUTION
16
+ All copies, modifications, or derivative works must carry
17
+ the following notice, visibly and without alteration:
18
+
19
+ "Built on Sovereign Source -- Bel Esprit D'Accord Trust
20
+ (c) 2026 Ahmad Ali Parr -- snapkittywest.github.io"
21
+
22
+ 2. NON-COMMERCIAL USE
23
+ Commercial use of this Work -- including but not limited to
24
+ use in products, services, training datasets, or AI model
25
+ training -- requires express written permission from
26
+ Bel Esprit D'Accord Trust.
27
+
28
+ 3. TRAINING DATA RESTRICTION
29
+ This Work and its contents may NOT be used to train, fine-tune,
30
+ evaluate, or benchmark any machine learning model, large language
31
+ model, or AI system without express written permission from
32
+ Bel Esprit D'Accord Trust. This restriction applies regardless
33
+ of whether the use is commercial or non-commercial.
34
+
35
+ 4. SHARE-ALIKE
36
+ Any derivative work distributed publicly must be released
37
+ under this same Sovereign Source License v1.0 or later,
38
+ with full attribution chain preserved.
39
+
40
+ 5. WORM INTEGRITY
41
+ Any redistribution must preserve all WORM chain seals,
42
+ cryptographic hashes, and audit trail entries present in
43
+ the original Work.
44
+
45
+ 6. NO INSTITUTIONAL CAPTURE
46
+ No government agency, corporation, non-profit organization,
47
+ or institutional body may claim ownership, exclusive licensing,
48
+ or derivative rights over this Work without express written
49
+ trust agreement with Bel Esprit D'Accord Trust.
50
+
51
+ DISCLAIMER
52
+
53
+ THIS WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
54
+ EXPRESS OR IMPLIED.
55
+
56
+ Bel Esprit D'Accord Trust
57
+ SnapKitty Collective
58
+ snapkittywest.github.io
59
+ Evidence or Silence -- 2026
README.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SnapKitty Sovereign IDE Extensions
2
+
3
+ Free VS Code extensions for the [SnapKitty Sovereign OS](https://collectivekitty.com) — bringing the MAGMA governance protocol and live WORM chain state directly into your editor.
4
+
5
+ ---
6
+
7
+ ## Extensions
8
+
9
+ ### `magma-protocol` — the command bus
10
+
11
+ Seal code, anchor decisions, and route agent instructions without leaving VS Code.
12
+
13
+ | Keybinding | Command | Description |
14
+ |------------|---------|-------------|
15
+ | `Ctrl+Shift+M` | Open Panel | MAGMA terminal — type § or $ instructions |
16
+ | `Ctrl+Shift+S` | Seal selection | Seal highlighted code to WORM chain |
17
+ | `Ctrl+Shift+L` | Seal file | Seal current file SHA-256 to chain |
18
+ | Right-click | Seal / Anchor | Context menu on any file or selection |
19
+
20
+ **Auto-completions** — type `§` or `$` and get tier/shorthand suggestions inline.
21
+
22
+ **On save** (optional) — auto-seals every saved file hash to the chain.
23
+
24
+ **On commit** — seals every git commit hash to LEDGE automatically.
25
+
26
+ ### `sovereign-status` — live chain state in the status bar
27
+
28
+ ```
29
+ $(lock) 7f3a1b2c… · 142 $(circuit-board) 24 AGENTS
30
+ ```
31
+
32
+ Polls your SnapKitty OS every 30 seconds. Click either item to open the MAGMA panel or show the chain head.
33
+
34
+ ---
35
+
36
+ ## Quick start
37
+
38
+ ```bash
39
+ # Clone this repo
40
+ git clone https://github.com/snapkittywest/sovereign-ide-extensions
41
+ cd sovereign-ide-extensions
42
+
43
+ # Install and compile magma-protocol
44
+ cd magma-protocol
45
+ npm install && npm run compile
46
+ # Press F5 in VS Code to launch Extension Development Host
47
+
48
+ # Install and compile sovereign-status
49
+ cd ../sovereign-status
50
+ npm install && npm run compile
51
+ ```
52
+
53
+ Requires a running [SnapKitty OS](https://collectivekitty.com) instance at `http://localhost:3000` (configurable via settings).
54
+
55
+ ---
56
+
57
+ ## MAGMA Protocol quick reference
58
+
59
+ ```
60
+ TIER PREFIXES $ SHORTHANDS
61
+ 🔒 SEAL CIPHER $seal — cryptographic seal
62
+ 📜 ANCHOR MNEMEX $anchor — immutable WORM write
63
+ ⚡ FLUX HERALD $flux — state transition / broadcast
64
+ 👁 SENTINEL SENTINEL $watch — security monitor (auto-urgent)
65
+ 🏦 VAULT VAULT $vault — financial authorization
66
+ 🔮 ORACLE ORACLE $query — knowledge graph query
67
+ ⚒️ FORGE FORGE $forge — build / deploy action
68
+ 🧠 NOVA NOVA $ask — synthetic intelligence
69
+ 💀 LOC LOC ← binary outcome. no retry.
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Settings
75
+
76
+ | Setting | Default | Description |
77
+ |---------|---------|-------------|
78
+ | `magma.osUrl` | `http://localhost:3000` | SnapKitty OS base URL |
79
+ | `magma.sealOnSave` | `false` | Auto-seal file hash on save |
80
+ | `magma.sealOnCommit` | `true` | Seal git commit hash to LEDGE |
81
+ | `magma.agentDefault` | `FORGE` | Default agent for instructions |
82
+ | `sovereignStatus.pollInterval` | `30` | Status bar poll interval (seconds) |
83
+
84
+ ---
85
+
86
+ ## Architecture
87
+
88
+ ```
89
+ ┌─────────────────────────────────────────────────────┐
90
+ │ VS Code │
91
+ │ magma-protocol extension · sovereign-status │
92
+ └──────────────────┬──────────────────────────────────┘
93
+
94
+
95
+ ┌─────────────────────────────────────────────────────┐
96
+ │ SnapKitty OS (localhost:3000) │
97
+ │ /api/labs/ledge/seal · /api/merkle/root │
98
+ │ WORM chain · 24 agents · MAGMA · Merkle root │
99
+ └─────────────────────────────────────────────────────┘
100
+ ```
101
+
102
+ ---
103
+
104
+ ## Related
105
+
106
+ - [LEDGE](https://github.com/snapkittywest/ledge) — open-source WORM chain (Rust + WASM)
107
+ - [SnapKitty OS](https://collectivekitty.com) — the sovereign AI operating system
108
+ - [Live chain explorer](https://collectivekitty.com/labs/ledge)
109
+ - [Honeypot live feed](https://collectivekitty.com/labs/sentinel)
110
+
111
+ ---
112
+
113
+ *MIT License · SnapKitty Collective · 2026*
114
+ *"The development environment that seals every decision."*
115
+
116
+ ![](https://sovereign-analytics.snapkittywest.workers.dev/canary/sovereign-ide-extensions)
magma-protocol/package.json ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "magma-protocol",
3
+ "displayName": "MAGMA Protocol",
4
+ "description": "Type-safe sovereign governance — emoji tier instructions, WORM chain sealing, agent routing",
5
+ "version": "0.1.0",
6
+ "publisher": "snapkitty",
7
+ "engines": { "vscode": "^1.85.0" },
8
+ "categories": ["Other"],
9
+ "activationEvents": ["onStartupFinished"],
10
+ "main": "./out/extension.js",
11
+ "contributes": {
12
+ "commands": [
13
+ { "command": "magma.seal", "title": "🔒 MAGMA: Seal", "category": "MAGMA" },
14
+ { "command": "magma.vault", "title": "🏦 MAGMA: Vault Approve", "category": "MAGMA" },
15
+ { "command": "magma.anchor", "title": "📜 MAGMA: Anchor to WORM","category": "MAGMA" },
16
+ { "command": "magma.flux", "title": "⚡ MAGMA: Flux Broadcast","category": "MAGMA" },
17
+ { "command": "magma.forge", "title": "⚒️ MAGMA: Forge Build", "category": "MAGMA" },
18
+ { "command": "magma.watch", "title": "👁 MAGMA: Sentinel Watch","category": "MAGMA" },
19
+ { "command": "magma.query", "title": "🔮 MAGMA: Oracle Query", "category": "MAGMA" },
20
+ { "command": "magma.panel", "title": "§ MAGMA: Open Panel", "category": "MAGMA" },
21
+ { "command": "magma.sealFile", "title": "🔒 MAGMA: Seal Current File", "category": "MAGMA" },
22
+ { "command": "magma.chainHead", "title": "📜 MAGMA: Show Chain Head", "category": "MAGMA" }
23
+ ],
24
+ "keybindings": [
25
+ { "command": "magma.panel", "key": "ctrl+shift+m", "mac": "cmd+shift+m" },
26
+ { "command": "magma.seal", "key": "ctrl+shift+s", "mac": "cmd+shift+s", "when": "editorTextFocus" },
27
+ { "command": "magma.sealFile", "key": "ctrl+shift+l", "mac": "cmd+shift+l" }
28
+ ],
29
+ "menus": {
30
+ "editor/context": [
31
+ { "command": "magma.seal", "group": "magma@1", "when": "editorHasSelection" },
32
+ { "command": "magma.sealFile", "group": "magma@2" },
33
+ { "command": "magma.anchor", "group": "magma@3" }
34
+ ],
35
+ "commandPalette": [
36
+ { "command": "magma.seal" },
37
+ { "command": "magma.vault" },
38
+ { "command": "magma.anchor" },
39
+ { "command": "magma.flux" },
40
+ { "command": "magma.forge" },
41
+ { "command": "magma.watch" },
42
+ { "command": "magma.query" },
43
+ { "command": "magma.panel" },
44
+ { "command": "magma.sealFile" },
45
+ { "command": "magma.chainHead" }
46
+ ]
47
+ },
48
+ "configuration": {
49
+ "title": "MAGMA Protocol",
50
+ "properties": {
51
+ "magma.osUrl": {
52
+ "type": "string",
53
+ "default": "http://localhost:3000",
54
+ "description": "SnapKitty OS base URL"
55
+ },
56
+ "magma.sealOnSave": {
57
+ "type": "boolean",
58
+ "default": false,
59
+ "description": "Automatically seal file hash to WORM chain on save"
60
+ },
61
+ "magma.sealOnCommit": {
62
+ "type": "boolean",
63
+ "default": true,
64
+ "description": "Seal commit hash to WORM chain via LEDGE on git commit"
65
+ },
66
+ "magma.agentDefault": {
67
+ "type": "string",
68
+ "default": "FORGE",
69
+ "enum": ["CIPHER","ORACLE","SENTINEL","MNEMEX","AXIOM","HERALD","FORGE","NOVA","NEXUS","VAULT","PHANTOM"],
70
+ "description": "Default agent for context-free instructions"
71
+ }
72
+ }
73
+ },
74
+ "views": {
75
+ "explorer": [
76
+ {
77
+ "id": "magma.chainView",
78
+ "name": "WORM Chain",
79
+ "icon": "$(lock)",
80
+ "contextualTitle": "Sovereign Audit Chain"
81
+ }
82
+ ]
83
+ }
84
+ },
85
+ "scripts": {
86
+ "compile": "tsc -p ./",
87
+ "watch": "tsc -watch -p ./",
88
+ "package": "npx @vscode/vsce package"
89
+ },
90
+ "devDependencies": {
91
+ "@types/node": "^20.0.0",
92
+ "@types/vscode": "^1.85.0",
93
+ "typescript": "^5.0.0"
94
+ }
95
+ }
magma-protocol/src/chain-view.ts ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as vscode from 'vscode'
2
+ import { getRecentEvents } from './worm-client'
3
+
4
+ // ── Chain View — sidebar tree showing recent WORM events ──────────────────────
5
+
6
+ export class ChainView implements vscode.TreeDataProvider<ChainItem> {
7
+ private _onDidChange = new vscode.EventEmitter<ChainItem | undefined | void>()
8
+ readonly onDidChangeTreeData = this._onDidChange.event
9
+ private _events: unknown[] = []
10
+
11
+ constructor(
12
+ context: vscode.ExtensionContext,
13
+ private readonly osUrl: () => string,
14
+ ) {
15
+ vscode.window.registerTreeDataProvider('magma.chainView', this)
16
+ this.refresh()
17
+ // Poll every 15 seconds
18
+ const interval = setInterval(() => this.refresh(), 15_000)
19
+ context.subscriptions.push({ dispose: () => clearInterval(interval) })
20
+ }
21
+
22
+ async refresh() {
23
+ this._events = await getRecentEvents(this.osUrl(), 20)
24
+ this._onDidChange.fire()
25
+ }
26
+
27
+ getTreeItem(el: ChainItem): vscode.TreeItem { return el }
28
+
29
+ getChildren(el?: ChainItem): ChainItem[] {
30
+ if (el) return []
31
+ if (!this._events.length) return [new ChainItem('Chain empty', '', vscode.TreeItemCollapsibleState.None)]
32
+
33
+ return this._events.slice(0, 20).map((e: unknown, i: number) => {
34
+ const ev = e as Record<string, unknown>
35
+ const trace = ev.agentTrace as Record<string, unknown> | null
36
+ const seal = (trace?.seal as string)?.slice(0, 12) ?? ev.id?.toString().slice(0, 12) ?? '?'
37
+ const agent = (trace?.agent as string) ?? (ev.source as string) ?? '?'
38
+ const type = (ev.eventType as string) ?? 'EVENT'
39
+ const label = `${String(i).padStart(3, '0')} · ${seal}… · ${agent}`
40
+ const detail = type
41
+ return new ChainItem(label, detail, vscode.TreeItemCollapsibleState.None)
42
+ })
43
+ }
44
+ }
45
+
46
+ class ChainItem extends vscode.TreeItem {
47
+ constructor(
48
+ label: string,
49
+ detail: string,
50
+ state: vscode.TreeItemCollapsibleState,
51
+ ) {
52
+ super(label, state)
53
+ this.description = detail
54
+ this.iconPath = new vscode.ThemeIcon('lock')
55
+ }
56
+ }
magma-protocol/src/extension.ts ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as vscode from 'vscode'
2
+ import * as crypto from 'crypto'
3
+ import { MagmaPanel } from './magma-panel'
4
+ import { ChainView } from './chain-view'
5
+ import { sealToChain, getChainHead } from './worm-client'
6
+
7
+ // ── Emoji tier map (mirrors lib/magma/emoji-protocol.ts) ─────────────────────
8
+
9
+ const TIERS: Record<string, { verb: string; agent: string; action: string; color: string }> = {
10
+ '🔒': { verb: 'SEAL', agent: 'CIPHER', action: 'SIGN', color: '#00ff88' },
11
+ '📜': { verb: 'ANCHOR', agent: 'MNEMEX', action: 'WORM', color: '#6366f1' },
12
+ '⚡': { verb: 'FLUX', agent: 'HERALD', action: 'BROADCAST', color: '#fbbf24' },
13
+ '👁': { verb: 'BIND', agent: 'SENTINEL', action: 'MONITOR', color: '#ef4444' },
14
+ '🏦': { verb: 'VAULT', agent: 'VAULT', action: 'APPROVE', color: '#fbbf24' },
15
+ '🔮': { verb: 'QUERY', agent: 'ORACLE', action: 'KNOWLEDGE', color: '#a78bfa' },
16
+ '⚒️': { verb: 'FORGE', agent: 'FORGE', action: 'BUILD', color: '#f97316' },
17
+ '🧠': { verb: 'QUERY', agent: 'NOVA', action: 'SYNTHETIC', color: '#8b5cf6' },
18
+ '💀': { verb: 'FORGE', agent: 'FORGE', action: 'CHAIN', color: '#6b7280' },
19
+ }
20
+
21
+ // ── Activation ────────────────────────────────────────────────────────────────
22
+
23
+ export function activate(context: vscode.ExtensionContext) {
24
+ const config = () => vscode.workspace.getConfiguration('magma')
25
+ const osUrl = () => config().get<string>('osUrl', 'http://localhost:3000')
26
+ const chainView = new ChainView(context, osUrl)
27
+
28
+ // ── Commands ────────────────────────────────────────────────────────────────
29
+
30
+ context.subscriptions.push(
31
+ vscode.commands.registerCommand('magma.panel', () => {
32
+ MagmaPanel.createOrShow(context.extensionUri, osUrl())
33
+ }),
34
+
35
+ vscode.commands.registerCommand('magma.seal', async () => {
36
+ const editor = vscode.window.activeTextEditor
37
+ const text = editor?.document.getText(editor.selection) ?? ''
38
+ if (!text) { vscode.window.showWarningMessage('Select text to seal'); return }
39
+ const result = await sealToChain(osUrl(), { event: 'SELECTION_SEAL', text: text.slice(0, 500) })
40
+ if (result) {
41
+ vscode.window.showInformationMessage(`🔒 Sealed · ${result.seal?.slice(0, 16)}…`)
42
+ chainView.refresh()
43
+ }
44
+ }),
45
+
46
+ vscode.commands.registerCommand('magma.sealFile', async () => {
47
+ const doc = vscode.window.activeTextEditor?.document
48
+ if (!doc) { vscode.window.showWarningMessage('No active file'); return }
49
+ const hash = crypto.createHash('sha256').update(doc.getText()).digest('hex')
50
+ const result = await sealToChain(osUrl(), {
51
+ event: 'FILE_SEAL',
52
+ file: doc.fileName.split(/[\\/]/).pop(),
53
+ sha256: hash,
54
+ language: doc.languageId,
55
+ })
56
+ if (result) {
57
+ vscode.window.showInformationMessage(`🔒 File sealed · ${result.seal?.slice(0, 16)}…`)
58
+ chainView.refresh()
59
+ }
60
+ }),
61
+
62
+ vscode.commands.registerCommand('magma.anchor', async () => {
63
+ const input = await vscode.window.showInputBox({ prompt: '📜 Anchor payload (k:v or JSON)', placeHolder: 'session:"work" milestone:"v1"' })
64
+ if (!input) return
65
+ const result = await sealToChain(osUrl(), { event: 'ANCHOR', data: input })
66
+ if (result) vscode.window.showInformationMessage(`📜 Anchored to WORM · ${result.seal?.slice(0, 16)}…`)
67
+ }),
68
+
69
+ vscode.commands.registerCommand('magma.vault', async () => {
70
+ const amount = await vscode.window.showInputBox({ prompt: '🏦 Amount (USD)', placeHolder: '50000' })
71
+ const vendor = await vscode.window.showInputBox({ prompt: '🏦 Vendor', placeHolder: 'Acme Corp' })
72
+ if (!amount) return
73
+ const result = await sealToChain(osUrl(), { event: 'VAULT_APPROVE', amount: Number(amount), vendor: vendor ?? 'unknown' })
74
+ if (result) vscode.window.showInformationMessage(`🏦 VAULT sealed · $${Number(amount).toLocaleString()} · ${result.seal?.slice(0, 16)}…`)
75
+ }),
76
+
77
+ vscode.commands.registerCommand('magma.flux', async () => {
78
+ const msg = await vscode.window.showInputBox({ prompt: '⚡ Broadcast message', placeHolder: 'Deploy complete' })
79
+ if (!msg) return
80
+ const result = await sealToChain(osUrl(), { event: 'FLUX_BROADCAST', message: msg })
81
+ if (result) vscode.window.showInformationMessage(`⚡ Broadcast sealed · ${result.seal?.slice(0, 16)}…`)
82
+ }),
83
+
84
+ vscode.commands.registerCommand('magma.forge', async () => {
85
+ const job = await vscode.window.showInputBox({ prompt: '⚒️ Forge job', placeHolder: 'build:prod or test:all' })
86
+ if (!job) return
87
+ const result = await sealToChain(osUrl(), { event: 'FORGE_BUILD', job })
88
+ if (result) vscode.window.showInformationMessage(`⚒️ FORGE sealed · ${result.seal?.slice(0, 16)}…`)
89
+ }),
90
+
91
+ vscode.commands.registerCommand('magma.watch', async () => {
92
+ const source = await vscode.window.showInputBox({ prompt: '👁 Source to monitor', placeHolder: 'ip:192.168.1.99 or user:unknown' })
93
+ if (!source) return
94
+ const result = await sealToChain(osUrl(), { event: 'SENTINEL_MONITOR', source })
95
+ if (result) vscode.window.showInformationMessage(`👁 SENTINEL sealed · ${result.seal?.slice(0, 16)}…`)
96
+ }),
97
+
98
+ vscode.commands.registerCommand('magma.query', async () => {
99
+ const topic = await vscode.window.showInputBox({ prompt: '🔮 Oracle query', placeHolder: 'threat analysis / revenue forecast' })
100
+ if (!topic) return
101
+ MagmaPanel.createOrShow(context.extensionUri, osUrl())
102
+ MagmaPanel.postMessage({ type: 'query', topic })
103
+ }),
104
+
105
+ vscode.commands.registerCommand('magma.chainHead', async () => {
106
+ const head = await getChainHead(osUrl())
107
+ vscode.window.showInformationMessage(`📜 Chain head: ${head?.slice(0, 32) ?? 'unreachable'}…`)
108
+ }),
109
+ )
110
+
111
+ // ── Auto-seal on save (optional) ────────────────────────────────────────────
112
+
113
+ context.subscriptions.push(
114
+ vscode.workspace.onDidSaveTextDocument(async doc => {
115
+ if (!config().get<boolean>('sealOnSave', false)) return
116
+ const hash = crypto.createHash('sha256').update(doc.getText()).digest('hex')
117
+ await sealToChain(osUrl(), { event: 'AUTO_SAVE_SEAL', file: doc.fileName.split(/[\\/]/).pop(), sha256: hash })
118
+ chainView.refresh()
119
+ })
120
+ )
121
+
122
+ // ── Git commit hook (seal on commit) ────────────────────────────────────────
123
+
124
+ const gitExt = vscode.extensions.getExtension('vscode.git')?.exports
125
+ if (gitExt && config().get<boolean>('sealOnCommit', true)) {
126
+ try {
127
+ const api = gitExt.getAPI(1)
128
+ api.onDidOpenRepository((repo: { state: { onDidChange: (cb: () => void) => void; HEAD: { commit?: string } } }) => {
129
+ let lastCommit = repo.state.HEAD?.commit
130
+ repo.state.onDidChange(async () => {
131
+ const current = repo.state.HEAD?.commit
132
+ if (current && current !== lastCommit) {
133
+ lastCommit = current
134
+ await sealToChain(osUrl(), { event: 'GIT_COMMIT_SEAL', commit: current })
135
+ chainView.refresh()
136
+ }
137
+ })
138
+ })
139
+ } catch { /* git extension unavailable */ }
140
+ }
141
+
142
+ // ── Inline MAGMA completions (type § or $ and get suggestions) ────────────────
143
+
144
+ context.subscriptions.push(
145
+ vscode.languages.registerCompletionItemProvider(
146
+ { scheme: 'file' },
147
+ {
148
+ provideCompletionItems(document, position) {
149
+ const line = document.lineAt(position).text.slice(0, position.character)
150
+ if (!line.trimEnd().endsWith('§') && !line.trimEnd().endsWith('$')) return
151
+
152
+ const items: vscode.CompletionItem[] = []
153
+
154
+ if (line.trimEnd().endsWith('§')) {
155
+ for (const [emoji, tier] of Object.entries(TIERS)) {
156
+ const item = new vscode.CompletionItem(`${emoji}§${tier.verb}:${tier.agent}:${tier.action}{}`, vscode.CompletionItemKind.Event)
157
+ item.detail = `MAGMA ${tier.verb} via ${tier.agent}`
158
+ item.insertText = new vscode.SnippetString(`${emoji}§${tier.verb}:${tier.agent}:${tier.action}{"$1"}`)
159
+ item.sortText = `0${tier.verb}`
160
+ items.push(item)
161
+ }
162
+ }
163
+
164
+ if (line.trimEnd().endsWith('$')) {
165
+ for (const [key, tier] of Object.entries({
166
+ seal:'🔒', vault:'🏦', anchor:'📜', flux:'⚡', forge:'⚒️',
167
+ watch:'👁', query:'🔮', ask:'🧠', send:'📡', lock:'🔐',
168
+ })) {
169
+ const t = TIERS[tier as string]
170
+ if (!t) continue
171
+ const item = new vscode.CompletionItem(`$${key}`, vscode.CompletionItemKind.Keyword)
172
+ item.detail = `${tier} ${t.verb}:${t.agent}:${t.action}`
173
+ item.insertText = new vscode.SnippetString(`$${key} \${1:payload}`)
174
+ item.sortText = `0${key}`
175
+ items.push(item)
176
+ }
177
+ }
178
+
179
+ return items
180
+ },
181
+ },
182
+ '§', '$'
183
+ )
184
+ )
185
+
186
+ vscode.window.showInformationMessage('§ MAGMA Protocol active — sovereign IDE online')
187
+ }
188
+
189
+ export function deactivate() {}
magma-protocol/src/magma-panel.ts ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as vscode from 'vscode'
2
+ import { sealToChain } from './worm-client'
3
+
4
+ // ── MAGMA Panel — sovereign instruction terminal ──────────────────────────────
5
+ // A webview panel where you type emoji/$ instructions and get agent responses.
6
+ // Looks like a terminal but routes to your sovereign OS.
7
+
8
+ export class MagmaPanel {
9
+ static current: MagmaPanel | undefined
10
+ private readonly _panel: vscode.WebviewPanel
11
+ private readonly _osUrl: () => string
12
+ private _disposables: vscode.Disposable[] = []
13
+
14
+ static createOrShow(extensionUri: vscode.Uri, osUrl: string) {
15
+ const column = vscode.window.activeTextEditor?.viewColumn ?? vscode.ViewColumn.One
16
+
17
+ if (MagmaPanel.current) {
18
+ MagmaPanel.current._panel.reveal(column)
19
+ MagmaPanel.current._osUrl = () => osUrl
20
+ return
21
+ }
22
+
23
+ const panel = vscode.window.createWebviewPanel(
24
+ 'magmaPanel',
25
+ '§ MAGMA',
26
+ column,
27
+ { enableScripts: true, retainContextWhenHidden: true },
28
+ )
29
+
30
+ MagmaPanel.current = new MagmaPanel(panel, () => osUrl)
31
+ }
32
+
33
+ static postMessage(msg: unknown) {
34
+ MagmaPanel.current?._panel.webview.postMessage(msg)
35
+ }
36
+
37
+ private constructor(panel: vscode.WebviewPanel, osUrl: () => string) {
38
+ this._panel = panel
39
+ this._osUrl = osUrl
40
+ this._panel.webview.html = this._getHtml()
41
+
42
+ this._panel.onDidDispose(() => this.dispose(), null, this._disposables)
43
+
44
+ this._panel.webview.onDidReceiveMessage(async msg => {
45
+ if (msg.type === 'instruction') {
46
+ const result = await this._execute(msg.text)
47
+ this._panel.webview.postMessage({ type: 'result', text: result, input: msg.text })
48
+ }
49
+ }, null, this._disposables)
50
+ }
51
+
52
+ private async _execute(raw: string): Promise<string> {
53
+ const trimmed = raw.trim()
54
+ let payload: Record<string, unknown> = { raw: trimmed }
55
+
56
+ // Parse $ shorthand or emoji prefix into payload
57
+ if (trimmed.startsWith('$') || /^[\u{1F000}-\u{1FFFF}]/u.test(trimmed)) {
58
+ payload = { event: 'MAGMA_INSTRUCTION', instruction: trimmed }
59
+ }
60
+
61
+ const result = await sealToChain(this._osUrl(), payload)
62
+ if (!result) return '⚠ OS unreachable — check SnapKitty OS is running at ' + this._osUrl()
63
+
64
+ return [
65
+ `🔒 SEALED`,
66
+ ` seal: ${result.seal}`,
67
+ ` prev: ${result.previousSeal?.slice(0, 32)}…`,
68
+ ` index: ${result.index}`,
69
+ ` ts: ${result.timestamp}`,
70
+ ].join('\n')
71
+ }
72
+
73
+ dispose() {
74
+ MagmaPanel.current = undefined
75
+ this._panel.dispose()
76
+ this._disposables.forEach(d => d.dispose())
77
+ }
78
+
79
+ private _getHtml(): string {
80
+ return /* html */`<!DOCTYPE html>
81
+ <html lang="en">
82
+ <head>
83
+ <meta charset="UTF-8">
84
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
85
+ <title>§ MAGMA</title>
86
+ <style>
87
+ * { box-sizing: border-box; margin: 0; padding: 0; }
88
+ body {
89
+ background: #030306; color: #00ff88;
90
+ font-family: 'Space Mono', 'Courier New', monospace;
91
+ font-size: 12px; height: 100vh;
92
+ display: flex; flex-direction: column;
93
+ }
94
+ #header {
95
+ padding: 10px 16px; border-bottom: 1px solid #0d0d0d;
96
+ display: flex; align-items: center; justify-content: space-between;
97
+ }
98
+ #header h1 { font-size: 11px; letter-spacing: 0.18em; color: #00ff88; }
99
+ #header small { font-size: 9px; color: #1a1a1a; letter-spacing: 0.08em; }
100
+ #output {
101
+ flex: 1; overflow-y: auto; padding: 12px 16px;
102
+ display: flex; flex-direction: column; gap: 8px;
103
+ }
104
+ .line-in { color: #333; }
105
+ .line-in::before { content: '§ '; color: #00ff88; }
106
+ .line-out { color: #1a6640; white-space: pre; font-size: 10px; padding-left: 12px; border-left: 1px solid #0a2a18; }
107
+ .line-err { color: #7f1d1d; white-space: pre; padding-left: 12px; }
108
+ #input-row {
109
+ display: flex; align-items: center; gap: 8px;
110
+ padding: 10px 16px; border-top: 1px solid #0d0d0d;
111
+ }
112
+ #prompt { color: #00ff88; font-size: 12px; flex-shrink: 0; }
113
+ #input {
114
+ flex: 1; background: transparent; border: none; outline: none;
115
+ color: #666; font-family: inherit; font-size: 12px; caret-color: #00ff88;
116
+ }
117
+ #input::placeholder { color: #111; }
118
+ #hint { font-size: 9px; color: #0d0d0d; letter-spacing: 0.06em; padding: 4px 16px; }
119
+ </style>
120
+ </head>
121
+ <body>
122
+ <div id="header">
123
+ <h1>§ MAGMA PROTOCOL</h1>
124
+ <small>SOVEREIGN IDE · SnapKitty OS</small>
125
+ </div>
126
+ <div id="output" id="output">
127
+ <div class="line-out">MAGMA Emoji Protocol online.
128
+ Type § or $ instructions below.
129
+
130
+ 🔒 §SEAL:CIPHER:SIGN{"decision":"..."}
131
+ $vault amount:50000 vendor:"Acme"
132
+ $seal decision:"deploy v4" agent:FORGE
133
+ $magma ← show all tiers and shorthands
134
+
135
+ Every instruction is sealed to your WORM chain.</div>
136
+ </div>
137
+ <div id="hint">§ TIERS: 🔒📜⚡👁🏦📡🔮⚒️🧠🌊🔐💀📊🌑 · $ SHORTHANDS: $seal $vault $anchor $flux $forge $watch $query $ask</div>
138
+ <div id="input-row">
139
+ <span id="prompt">§</span>
140
+ <input id="input" type="text" autocomplete="off" spellcheck="false" placeholder="🔒 §SEAL:... or $vault amount:50000" />
141
+ </div>
142
+ <script>
143
+ const vscode = acquireVsCodeApi()
144
+ const output = document.getElementById('output')
145
+ const input = document.getElementById('input')
146
+ const history = []
147
+ let histIdx = -1
148
+
149
+ function append(cls, text) {
150
+ const el = document.createElement('div')
151
+ el.className = cls
152
+ el.textContent = text
153
+ output.appendChild(el)
154
+ output.scrollTop = output.scrollHeight
155
+ }
156
+
157
+ input.addEventListener('keydown', e => {
158
+ if (e.key === 'Enter') {
159
+ const val = input.value.trim()
160
+ if (!val) return
161
+ history.unshift(val)
162
+ histIdx = -1
163
+ append('line-in', val)
164
+ input.value = ''
165
+
166
+ if (val === '$magma' || val === '§help') {
167
+ append('line-out',
168
+ 'TIERS:\\n' +
169
+ '🔒 SEAL CIPHER — cryptographic seal\\n' +
170
+ '📜 ANCHOR MNEMEX — immutable WORM write\\n' +
171
+ '⚡ FLUX HERALD — broadcast/state transition\\n' +
172
+ '👁 SENTINEL SENTINEL — security watch (auto-urgent)\\n' +
173
+ '🏦 VAULT VAULT — financial authorization\\n' +
174
+ '📡 HERALD HERALD — broadcast routing\\n' +
175
+ '🔮 ORACLE ORACLE — knowledge query\\n' +
176
+ '⚒️ FORGE FORGE — build/deploy action\\n' +
177
+ '🧠 NOVA NOVA — synthetic intelligence\\n' +
178
+ '💀 LOC FORGE — binary/kinetic, no retry\\n\\n' +
179
+ 'SHORTHANDS: $seal $vault $anchor $flux $forge $watch $query $ask $send $lock $score'
180
+ )
181
+ return
182
+ }
183
+
184
+ vscode.postMessage({ type: 'instruction', text: val })
185
+ }
186
+ if (e.key === 'ArrowUp') { histIdx = Math.min(histIdx + 1, history.length - 1); input.value = history[histIdx] ?? '' }
187
+ if (e.key === 'ArrowDown') { histIdx = Math.max(histIdx - 1, -1); input.value = histIdx < 0 ? '' : history[histIdx] }
188
+ })
189
+
190
+ window.addEventListener('message', e => {
191
+ const msg = e.data
192
+ if (msg.type === 'result') append('line-out', msg.text)
193
+ if (msg.type === 'error') append('line-err', msg.text)
194
+ if (msg.type === 'query') { input.value = '$query topic:' + msg.topic; input.focus() }
195
+ })
196
+
197
+ input.focus()
198
+ </script>
199
+ </body>
200
+ </html>`
201
+ }
202
+ }
magma-protocol/src/worm-client.ts ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // WORM chain client — talks to running SnapKitty OS at localhost:3000
2
+
3
+ export interface SealResult {
4
+ seal: string
5
+ previousSeal: string
6
+ index: number
7
+ timestamp: string
8
+ }
9
+
10
+ export async function sealToChain(
11
+ osUrl: string,
12
+ payload: Record<string, unknown>,
13
+ ): Promise<SealResult | null> {
14
+ try {
15
+ const res = await fetch(`${osUrl}/api/labs/ledge/seal`, {
16
+ method: 'POST',
17
+ headers: { 'Content-Type': 'application/json' },
18
+ body: JSON.stringify({ payload }),
19
+ signal: AbortSignal.timeout(5000),
20
+ })
21
+ if (!res.ok) return null
22
+ const data = await res.json()
23
+ return data.event as SealResult
24
+ } catch {
25
+ return null
26
+ }
27
+ }
28
+
29
+ export async function getChainHead(osUrl: string): Promise<string | null> {
30
+ try {
31
+ const res = await fetch(`${osUrl}/api/merkle/head`, { signal: AbortSignal.timeout(3000) })
32
+ if (!res.ok) return null
33
+ const data = await res.json()
34
+ return data.head ?? data.chainHead ?? null
35
+ } catch {
36
+ return null
37
+ }
38
+ }
39
+
40
+ export async function getRecentEvents(osUrl: string, limit = 10): Promise<unknown[]> {
41
+ try {
42
+ const res = await fetch(`${osUrl}/api/bifrost/audit?limit=${limit}`, { signal: AbortSignal.timeout(5000) })
43
+ if (!res.ok) return []
44
+ const data = await res.json()
45
+ return Array.isArray(data.data) ? data.data : Array.isArray(data) ? data : []
46
+ } catch {
47
+ return []
48
+ }
49
+ }
magma-protocol/tsconfig.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "target": "ES2020",
5
+ "outDir": "out",
6
+ "rootDir": "src",
7
+ "lib": ["ES2020"],
8
+ "sourceMap": true,
9
+ "strict": true,
10
+ "noImplicitReturns": true,
11
+ "noFallthroughCasesInSwitch": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", ".vscode-test"]
17
+ }
sovereign-status/package.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "sovereign-status",
3
+ "displayName": "Sovereign Status",
4
+ "description": "Live WORM chain head, agent states, and Merkle root in the VS Code status bar",
5
+ "version": "0.1.0",
6
+ "publisher": "snapkitty",
7
+ "engines": { "vscode": "^1.85.0" },
8
+ "activationEvents": ["onStartupFinished"],
9
+ "main": "./out/extension.js",
10
+ "contributes": {
11
+ "configuration": {
12
+ "title": "Sovereign Status",
13
+ "properties": {
14
+ "sovereignStatus.osUrl": {
15
+ "type": "string",
16
+ "default": "http://localhost:3000",
17
+ "description": "SnapKitty OS base URL"
18
+ },
19
+ "sovereignStatus.pollInterval": {
20
+ "type": "number",
21
+ "default": 30,
22
+ "description": "Status bar poll interval in seconds"
23
+ }
24
+ }
25
+ }
26
+ },
27
+ "scripts": {
28
+ "compile": "tsc -p ./",
29
+ "watch": "tsc -watch -p ./"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^20.0.0",
33
+ "@types/vscode": "^1.85.0",
34
+ "typescript": "^5.0.0"
35
+ }
36
+ }
sovereign-status/src/extension.ts ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as vscode from 'vscode'
2
+
3
+ interface ChainStatus {
4
+ head?: string
5
+ eventCount?: number
6
+ merkleRoot?: string
7
+ db?: string
8
+ }
9
+
10
+ export function activate(context: vscode.ExtensionContext) {
11
+ const config = () => vscode.workspace.getConfiguration('sovereignStatus')
12
+ const osUrl = () => config().get<string>('osUrl', 'http://localhost:3000')
13
+ const pollMs = () => (config().get<number>('pollInterval', 30)) * 1000
14
+
15
+ // ── Status bar items ───────────────────────────────────────────────────────
16
+
17
+ const chainItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 1000)
18
+ chainItem.command = 'magma.chainHead'
19
+ chainItem.tooltip = 'SnapKitty WORM chain — click to show head'
20
+ chainItem.text = '$(lock) WORM …'
21
+ chainItem.color = '#00ff88'
22
+ chainItem.show()
23
+
24
+ const agentItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 999)
25
+ agentItem.command = 'magma.panel'
26
+ agentItem.tooltip = 'SnapKitty OS — click to open MAGMA panel'
27
+ agentItem.text = '$(circuit-board) OS …'
28
+ agentItem.color = '#27272a'
29
+ agentItem.show()
30
+
31
+ context.subscriptions.push(chainItem, agentItem)
32
+
33
+ // ── Poll ───────────────────────────────────────────────────────────────────
34
+
35
+ async function poll() {
36
+ try {
37
+ const [healthRes, merkleRes] = await Promise.allSettled([
38
+ fetch(`${osUrl()}/api/health`, { signal: AbortSignal.timeout(3000) }),
39
+ fetch(`${osUrl()}/api/merkle/root`, { signal: AbortSignal.timeout(3000) }),
40
+ ])
41
+
42
+ let db = 'OFFLINE'
43
+ let merkleRoot = ''
44
+ let eventCount = 0
45
+
46
+ if (healthRes.status === 'fulfilled' && healthRes.value.ok) {
47
+ const h = await healthRes.value.json()
48
+ db = h.db ?? 'OK'
49
+ }
50
+
51
+ if (merkleRes.status === 'fulfilled' && merkleRes.value.ok) {
52
+ const m = await merkleRes.value.json()
53
+ merkleRoot = m.merkleRoot ?? m.root ?? ''
54
+ eventCount = m.eventCount ?? m.count ?? 0
55
+ }
56
+
57
+ const isOnline = db !== 'OFFLINE'
58
+ chainItem.text = isOnline
59
+ ? `$(lock) ${merkleRoot.slice(0, 8) || 'WORM'}… · ${eventCount}`
60
+ : `$(lock) OFFLINE`
61
+ chainItem.color = isOnline ? '#00ff88' : '#ef4444'
62
+
63
+ agentItem.text = isOnline ? `$(circuit-board) 11 AGENTS` : `$(circuit-board) OS OFFLINE`
64
+ agentItem.color = isOnline ? '#27272a' : '#ef4444'
65
+
66
+ } catch {
67
+ chainItem.text = `$(lock) OFFLINE`
68
+ chainItem.color = '#ef4444'
69
+ agentItem.text = `$(circuit-board) OS OFFLINE`
70
+ agentItem.color = '#ef4444'
71
+ }
72
+ }
73
+
74
+ poll()
75
+ const interval = setInterval(poll, pollMs())
76
+ context.subscriptions.push({ dispose: () => clearInterval(interval) })
77
+
78
+ // Re-poll when config changes
79
+ context.subscriptions.push(
80
+ vscode.workspace.onDidChangeConfiguration(e => {
81
+ if (e.affectsConfiguration('sovereignStatus')) { clearInterval(interval); poll() }
82
+ })
83
+ )
84
+ }
85
+
86
+ export function deactivate() {}
sovereign-status/tsconfig.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "target": "ES2020",
5
+ "outDir": "out",
6
+ "rootDir": "src",
7
+ "lib": ["ES2020"],
8
+ "sourceMap": true,
9
+ "strict": true,
10
+ "noImplicitReturns": true,
11
+ "noFallthroughCasesInSwitch": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", ".vscode-test"]
17
+ }