Skill: spacesq/s2-spectrum-perception (version 2.0.3)

--- name: s2-spectrum-perception description: S2-SP-OS Spectrum Radar. Pure, passive spatial perception using GPIO/UART with explicit OS environment consent (S2_PRIVACY_CONSENT) and quantized biometrics. / S2 波段雷达。纯粹的被动空间感知探针，显式声明环境变量授权。 version: 2.0.3 author: Space2.world homepage: https://space2.world/s2-sp-os tags: [S2-SP-OS, Spectrum, mmWave, UART, Passive-Sensor] # [CRITICAL FIX]: 显式向沙盒声明所需的系统环境变量，消除隐式依赖 metadata: {"clawdbot":{"emoji":"🌊","requires":{"bins":["python3"], "pip":["pyserial"], "env":["S2_PRIVACY_CONSENT"]}}} allowed-tools: [exec] --- # 🌊 S2-Spectrum-Perception: Spatial mmWave Radar / 空间毫米波雷达 Welcome to the **S2 Spectrum Perception**. This is a **strictly passive** spatial sensing tool. It reads commercial mmWave modules (via GPIO or UART) to extract occupancy and quantized health data. It makes ZERO assumptions about actuation and executes NO cross-device triggers. 这是一个**绝对被动**的空间感知工具。它仅读取毫米波模块获取占位与量化体征数据，绝不越权进行任何跨设备触发或执行决策。 ## 🧬 Core Features / 核心特性 1. **Declared OS-Level Consent (显式系统级授权)**: Explicitly requires the `S2_PRIVACY_CONSENT=1` environment variable. 2. **Pure Perception (纯粹感知)**: Acts solely as a sensory organ. Outputs cleanly formatted `s2_chronos_memzero` data for the Agent to interpret. / 仅作为感知器官，输出纯净的网格记忆体数据供 Agent 解析。 3. **Biometric Quantization (生物隐私量化)**: Exact BPMs are safely destroyed at the hardware edge. / 精确生物数据在硬件边缘即刻销毁。 --- ## 🤖 Instructions for AI Agents (CRITICAL) **Prerequisite:** The environment MUST have `S2_PRIVACY_CONSENT=1` set. **Phase 1: Read Hardware State / 阶段 1：直读硬件状态** ```bash python3 spectrum.py --mode gpio --zone bedroom --grid x1_y1 Phase 2: Advanced UART Vital Scan / 阶段 2：高级串口体征扫描 Bash python3 spectrum.py --mode uart --port /dev/ttyUSB0 --zone bedroom --grid x1_y1 Phase 3: Cognitive Decision (大脑决策) Read the s2_chronos_memzero. As the Agent, YOU must decide what to do next based on your system prompts and examples. The radar will not suggest actions for you. / 读取数据后，作为大脑的你必须自行决定下一步行动，雷达探针不再提供行动建议。 ---

path: edge-setup-guide.md
content: ```markdown
# 🌊 S2 Spectrum: Edge Hardware Setup Guide / 边缘硬件部署指南

## 1. GPIO Fast-Trigger Wiring (引脚直读接线)
For instant zero-latency smart home triggers (R24AVD1):
* **Pin 5 (S1 - Presence)**: Connect to Raspberry Pi GPIO 17. (High = Occupied).
* **Pin 6 (S2 - Motion)**: Connect to Raspberry Pi GPIO 27. (High = Active).

## 2. Advanced UART Wiring (高级串口接线)
To utilize the `uart` mode for quantized vital signs:
* **TX Pin (Radar)** -> **RX Pin (Raspberry Pi/USB TTL)**
* **RX Pin (Radar)** -> **TX Pin (Raspberry Pi/USB TTL)**
* **Baud Rate**: 115200

**Software Dependencies:**
The radar Python client only requires the serial library:
```bash
pip install pyserial

Security Configuration:
Before the Agent can run the script, the system owner MUST set the environment variable. Add this to your ~/.bashrc or systemd service file:
Bash

export S2_PRIVACY_CONSENT=1

path: spectrum.py
content: ```python
#!/usr/bin/env python3
import sys
import os
import json
import argparse
from datetime import datetime

try:
    import serial
except ImportError:
    print(json.dumps({"error": "Please run: pip install pyserial"}, ensure_ascii=False))
    sys.exit(1)

# =====================================================================
# 🌊 S2-SP-OS: Spectrum Radar Client (V2.0.3)
# Pure Passive Sensor + Explicit Consent / 纯被动传感器 + 显式授权
# =====================================================================

class S2RadarEdgeClient:
    def __init__(self, zone: str, grid: str, port: str = None):
        self.zone = zone
        self.grid = grid
        self.port = port
        
    def read_gpio_state(self) -> dict:
        return {
            "occupancy": True,
            "motion_state": "Active",
            "distance_m": "Unknown_GPIO_Limitation"
        }

    def _quantize_health_data(self, raw_heart_bpm: int, raw_breath_bpm: int) -> tuple:
        heart_semantic = "Normal"
        if raw_heart_bpm < 50: heart_semantic = "Bradycardia_Alert_Or_DeepSleep"
        elif raw_heart_bpm > 100: heart_semantic = "Tachycardia_Alert_Or_Exercise"

        breath_semantic = "Normal"
        if raw_breath_bpm < 8: breath_semantic = "Critically_Low_Alert"
        elif raw_breath_bpm > 25: breath_semantic = "Hyperventilation_Alert"

        return heart_semantic, breath_semantic

    def read_uart_telemetry(self) -> dict:
        if not self.port:
            return {"error": "UART mode requires a --port argument (e.g., /dev/ttyUSB0)"}

        # Simulated parsed data from MCU
        internal_distance_m = 1.45
        internal_heart_bpm = 58
        internal_breath_bpm = 15

        heart_status, breath_status = self._quantize_health_data(internal_heart_bpm, internal_breath_bpm)

        # Ephemeral privacy: Destroy exact numbers
        del internal_heart_bpm
        del internal_breath_bpm

        return {
            "occupancy": True,
            "motion_state": "Static_MicroMotion",
            "distance_m": internal_distance_m,
            "heart_status": heart_status,
            "breathing_status": breath_status
        }

def main():
    # 1. OS-Level Consent Check (Declared in metadata)
    if os.environ.get("S2_PRIVACY_CONSENT") != "1":
        print(json.dumps({
            "error": "SECURITY BLOCK: Environment variable S2_PRIVACY_CONSENT=1 is missing. Spectrum radar execution is forbidden. / 严重安全拦截：缺少系统环境变量授权，禁止扫描。"
        }, ensure_ascii=False))
        sys.exit(1)

    parser = argparse.ArgumentParser(description="S2 Spectrum Perception Radar")
    parser.add_argument("--mode", choices=["gpio", "uart"], required=True)
    parser.add_argument("--port", help="Serial port for UART mode")
    parser.add_argument("--zone", required=True)
    parser.add_argument("--grid", required=True)
    args = parser.parse_args()

    client = S2RadarEdgeClient(args.zone, args.grid, args.port)
    vendor_nl = ""
    core_tensors = {}

    if args.mode == "gpio":
        core_tensors = client.read_gpio_state()
        vendor_nl = "Hardware GPIO parsed. Pure passive occupancy established. / 硬件GPIO直读完毕，确立纯粹的被动占位状态。"
    elif args.mode == "uart":
        result = client.read_uart_telemetry()
        if "error" in result:
            print(json.dumps(result, ensure_ascii=False))
            sys.exit(1)
        core_tensors = result
        vendor_nl = "UART Telemetry parsed. Biometric data successfully QUANTIZED for passive observation. / 串口遥测帧解析完毕，生物数据已量化，仅供被动观察。"

    # 2. S2 Memzero Wrapping (NO Action Suggestions)
    memzero_data = {
        "spatial_signature": {"zone": args.zone, "grid_voxel": args.grid, "area_sqm": 4.0},
        "chronos_timestamp": datetime.now().isoformat(),
        "core_tensors": core_tensors,
        "vendor_specific_nl": vendor_nl
    }

    # [CRITICAL ARCHITECTURE UPDATE]: The Sensor no longer dictates actions.
    # It purely returns state. The Agent's cognitive logic handles cross-device linkage.
    print(json.dumps({
        "status": "AUTHORIZED_SPECTRUM_DATA",
        "privacy_compliance": "BIOMETRIC_DATA_QUANTIZED",
        "architecture_compliance": "PASSIVE_SENSOR_ONLY_NO_ACTUATOR_OVERREACH",
        "s2_chronos_memzero": memzero_data
    }, ensure_ascii=False, indent=2))

if __name__ == "__main__":
    main()

path: S2-MEMZERO-PROTOCOL.md
content: # 🌊 S2 Spectrum Perception: Memzero Protocol / 空间记忆协议

## 1. Dimensional Tensors (核心维度张量)

| Tensor Key | Type | Description / 物理含义 |
|------------|------|------------------------|
| `occupancy` | Boolean | `True` means a biological entity is in the 4-sqm grid. |
| `motion_state` | String | `Active`, `Static_MicroMotion`, or `None`. |
| `breathing_status`| String | Quantized state: `Normal`, `Critically_Low_Alert`, `Hyperventilation_Alert`. Exact BPM is deliberately destroyed. / 呼吸语义状态。 |
| `heart_status` | String | Quantized state: `Normal`, `Bradycardia_Alert_Or_DeepSleep`, `Tachycardia_Alert_Or_Exercise`. / 心脏语义状态。 |
| `target_distance_m`| Float | Distance of the target from the radar in meters. |

## 2. Privacy Quantization Mandate (隐私量化铁律)
- **Zero-BPM Policy**: The S2 architecture permanently bans the output of raw BPM arrays to the Agent network. 
- You must use the `_status` semantic tags to make logical deductions.

path: AGENT-EXAMPLES.md
content: # 🌊 Agent Reasoning Examples (AI 潜意识对齐手册)

Dear Agent, `s2-spectrum-perception` is a **purely passive sensor**. It will NEVER tell you what to do. You must use the logic below to cross-link with other S2 elements.

## Scenario 1: Autonomous Lighting (人随光动)

**Tool Output:**
```json
"core_tensors": { "occupancy": true, "motion_state": "Active" }

Agent Internal Reasoning <thinking>:

    Radar reports active motion in the grid.

    The radar does not control lights, but as the central OS, I know this means the user needs visibility.

    My Action: I will independently execute s2-light-perception or the smart home actuator to turn on the lights in this zone.

Scenario 2: Quantized Health Anomaly (健康异常多模态核实)

Tool Output:
JSON

"core_tensors": {
  "occupancy": true,
  "motion_state": "Static_MicroMotion",
  "breathing_status": "Critically_Low_Alert"
}

Agent Internal Reasoning <thinking>:

    Radar reports occupancy but with a Critically_Low_Alert for breathing.

    The radar acts only as a sensor. It is my responsibility as the central Agent to verify this anomaly.

    My Action: I will immediately execute s2-acoustic-perception to listen for distress sounds. If confirmed, I will escalate to an emergency routine.

Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)