Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

energykitenergykit 搜索

Agent Skill

energykit 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

25,608

周安装

1,133

GitHub Stars

489

下载量

8,976
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:energykit(energykit 搜索)
来源仓库:https://github.com/dpearson2699/swift-ios-skills
仓库路径:skills/energykit
安装命令:
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill energykit
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill energykit

简介

energykit 提供 iOS 26+ 的电网 electricity guidance 查询服务,助力应用优化用电时段选择。

  • 它识别清洁低价电力时段并提交负荷事件,实现碳足迹减少与电费节省双重目标。
  • 使用时需注意 API 仍处于 Beta 阶段,Apple 可能随时调整接口细节需持续关注更新公告。
  • 安装前应验证 Swift 6.3 编译环境和目标设备是否真正支持该框架的所有功能特性。
  • energykit 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

EnergyKit

Provide grid electricity forecasts to help users choose when to use electricity. EnergyKit identifies times when there is relatively cleaner or less expensive electricity on the grid, enabling apps to shift or reduce load accordingly. Targets Swift 6.3 / iOS 26+.

Beta-sensitive. EnergyKit is new in iOS 26 and may change before GM. Re-check current Apple documentation before relying on specific API details.

Contents

Setup

Entitlement

EnergyKit requires the com.apple.developer.energykit entitlement. Add it to your app's entitlements file.

Import

import EnergyKit

Platform availability: iOS 26+, iPadOS 26+.

Core Concepts

EnergyKit provides two main capabilities:

  1. Electricity Guidance -- time-weighted forecasts telling apps when electricity is cleaner or cheaper, so devices can shift or reduce consumption
  2. Load Events -- telemetry from devices (EV chargers, HVAC) submitted back to the system to track how well the app follows guidance

Key Types

TypeRole
ElectricityGuidanceForecast data with weighted time intervals
ElectricityGuidance.ServiceInterface for obtaining guidance data
ElectricityGuidance.QueryQuery specifying shift or reduce action
ElectricityGuidance.ValueA time interval with a rating (0.0-1.0)
EnergyVenueA physical location (home) registered for energy management
ElectricVehicleLoadEventLoad event for EV charger telemetry
ElectricHVACLoadEventLoad event for HVAC system telemetry
ElectricityInsightServiceService for querying energy/runtime insights
ElectricityInsightRecordHistorical energy data broken down by cleanliness/tariff
ElectricityInsightQueryQuery for historical insight data

Suggested Actions

ActionUse Case
.shiftDevices that can move consumption to a different time (EV charging)
.reduceDevices that can lower consumption without stopping (HVAC setback)

Querying Electricity Guidance

Use ElectricityGuidance.Service to get a forecast stream for a venue.

import EnergyKit

func observeGuidance(venueID: UUID) async throws {
    let query = ElectricityGuidance.Query(suggestedAction: .shift)
    let service = ElectricityGuidance.sharedService

    let guidanceStream = service.guidance(using: query, at: venueID)

    for try await guidance in guidanceStream {
        print("Guidance token: \(guidance.guidanceToken)")
        print("Interval: \(guidance.interval)")
        print("Venue: \(guidance.energyVenueID)")

        // Check if rate plan information is available
        if guidance.options.contains(.guidanceIncorporatesRatePlan) {
            print("Rate plan data incorporated")
        }
        if guidance.options.contains(.locationHasRatePlan) {
            print("Location has a rate plan")
        }

        processGuidanceValues(guidance.values)
    }
}

Working with Guidance Values

Each ElectricityGuidance.Value contains a time interval and a rating from 0.0 to 1.0. Lower ratings indicate better times to use electricity.

func processGuidanceValues(_ values: [ElectricityGuidance.Value]) {
    for value in values {
        let interval = value.interval
        let rating = value.rating  // 0.0 (best) to 1.0 (worst)

        print("From \(interval.start) to \(interval.end): rating \(rating)")
    }
}

// Find the best time to charge
func bestChargingWindow(
    in values: [ElectricityGuidance.Value]
) -> ElectricityGuidance.Value? {
    values.min(by: { $0.rating < $1.rating })
}

// Find all "good" windows below a threshold
func goodWindows(
    in values: [ElectricityGuidance.Value],
    threshold: Double = 0.3
) -> [ElectricityGuidance.Value] {
    values.filter { $0.rating <= threshold }
}

Displaying Guidance in SwiftUI

import SwiftUI
import EnergyKit

struct GuidanceTimelineView: View {
    let values: [ElectricityGuidance.Value]

    var body: some View {
        List(values, id: \.interval.start) { value in
            HStack {
                VStack(alignment: .leading) {
                    Text(value.interval.start, style: .time)
                    Text(value.interval.end, style: .time)
                        .foregroundStyle(.secondary)
                }
                Spacer()
                RatingIndicator(rating: value.rating)
            }
        }
    }
}

struct RatingIndicator: View {
    let rating: Double

    var color: Color {
        if rating <= 0.3 { return .green }
        if rating <= 0.6 { return .yellow }
        return .red
    }

    var label: String {
        if rating <= 0.3 { return "Good" }
        if rating <= 0.6 { return "Fair" }
        return "Avoid"
    }

    var body: some View {
        Text(label)
            .padding(.horizontal)
            .padding(.vertical)
            .background(color.opacity(0.2))
            .foregroundStyle(color)
            .clipShape(Capsule())
    }
}

Energy Venues

An EnergyVenue represents a physical location registered for energy management.

// List all venues
func listVenues() async throws -> [EnergyVenue] {
    try await EnergyVenue.venues()
}

// Get a specific venue by ID
func getVenue(id: UUID) async throws -> EnergyVenue {
    try await EnergyVenue.venue(for: id)
}

// Get a venue matching a HomeKit home
func getVenueForHome(homeID: UUID) async throws -> EnergyVenue {
    try await EnergyVenue.venue(matchingHomeUniqueIdentifier: homeID)
}

Venue Properties

let venue = try await EnergyVenue.venue(for: venueID)
print("Venue ID: \(venue.id)")
print("Venue name: \(venue.name)")

Submitting Load Events

Report device consumption data back to the system. This helps the system improve future guidance accuracy.

EV Charger Load Events

func submitEVChargingEvent(
    at venue: EnergyVenue,
    guidanceToken: UUID,
    deviceID: String
) async throws {
    let session = ElectricVehicleLoadEvent.Session(
        id: UUID(),
        state: .begin,
        guidanceState: ElectricVehicleLoadEvent.Session.GuidanceState(
            wasFollowingGuidance: true,
            guidanceToken: guidanceToken
        )
    )

    let measurement = ElectricVehicleLoadEvent.ElectricalMeasurement(
        stateOfCharge: 45,
        direction: .imported,
        power: Measurement(value: 7.2, unit: .kilowatts),
        energy: Measurement(value: 0, unit: .kilowattHours)
    )

    let event = ElectricVehicleLoadEvent(
        timestamp: Date(),
        measurement: measurement,
        session: session,
        deviceID: deviceID
    )

    try await venue.submitEvents([event])
}

HVAC Load Events

func submitHVACEvent(
    at venue: EnergyVenue,
    guidanceToken: UUID,
    stage: Int,
    deviceID: String
) async throws {
    let session = ElectricHVACLoadEvent.Session(
        id: UUID(),
        state: .active,
        guidanceState: ElectricHVACLoadEvent.Session.GuidanceState(
            wasFollowingGuidance: true,
            guidanceToken: guidanceToken
        )
    )

    let measurement = ElectricHVACLoadEvent.ElectricalMeasurement(stage: stage)

    let event = ElectricHVACLoadEvent(
        timestamp: Date(),
        measurement: measurement,
        session: session,
        deviceID: deviceID
    )

    try await venue.submitEvents([event])
}

Session States

StateWhen to Use
.beginDevice starts consuming electricity
.activeDevice is actively consuming (periodic updates)
.endDevice stops consuming electricity

Electricity Insights

Query historical energy and runtime data for devices using ElectricityInsightService.

func queryEnergyInsights(deviceID: String, venueID: UUID) async throws {
    let query = ElectricityInsightQuery(
        options: [.cleanliness, .tariff],
        range: DateInterval(
            start: Calendar.current.date(byAdding: .day, value: -7, to: Date())!,
            end: Date()
        ),
        granularity: .daily,
        flowDirection: .imported
    )

    let service = ElectricityInsightService.shared
    let stream = try await service.energyInsights(
        forDeviceID: deviceID, using: query, atVenue: venueID
    )

    for await record in stream {
        if let total = record.totalEnergy { print("Total: \(total)") }
        if let cleaner = record.dataByGridCleanliness?.cleaner {
            print("Cleaner: \(cleaner)")
        }
    }
}

Use runtimeInsights(forDeviceID:using:atVenue:) for runtime data instead of energy. Granularity options: .hourly, .daily, .weekly, .monthly, .yearly. See references/energykit-patterns.md for full insight examples.

Common Mistakes

DON'T: Forget the EnergyKit entitlement

Without the entitlement, all EnergyKit calls fail silently or throw errors.

// WRONG: No entitlement configured
let service = ElectricityGuidance.sharedService  // Will fail

// CORRECT: Add com.apple.developer.energykit to entitlements
// Then use the service
let service = ElectricityGuidance.sharedService

DON'T: Ignore unsupported regions

EnergyKit is not available in all regions. Handle the .unsupportedRegion and .guidanceUnavailable errors.

// WRONG: Assume guidance is always available
for try await guidance in service.guidance(using: query, at: venueID) {
    updateUI(guidance)
}

// CORRECT: Handle region-specific errors
do {
    for try await guidance in service.guidance(using: query, at: venueID) {
        updateUI(guidance)
    }
} catch let error as EnergyKitError {
    switch error {
    case .unsupportedRegion:
        showUnsupportedRegionMessage()
    case .guidanceUnavailable:
        showGuidanceUnavailableMessage()
    case .venueUnavailable:
        showNoVenueMessage()
    case .permissionDenied:
        showPermissionDeniedMessage()
    case .serviceUnavailable:
        retryLater()
    case .rateLimitExceeded:
        backOff()
    default:
        break
    }
}

DON'T: Discard the guidance token

The guidanceToken links load events to the guidance that influenced them. Always store and pass it through to load event submissions.

// WRONG: Ignore the guidance token
for try await guidance in guidanceStream {
    startCharging()
}

// CORRECT: Store the token for load events
for try await guidance in guidanceStream {
    let token = guidance.guidanceToken
    startCharging(followingGuidanceToken: token)
}

DON'T: Submit load events without a session lifecycle

Always submit .begin, then .active updates, then .end events.

// WRONG: Only submit one event
let event = ElectricVehicleLoadEvent(/* state: .active */)
try await venue.submitEvents([event])

// CORRECT: Full session lifecycle
try await venue.submitEvents([beginEvent])
// ... periodic active events ...
try await venue.submitEvents([activeEvent])
// ... when done ...
try await venue.submitEvents([endEvent])

DON'T: Query guidance without a venue

EnergyKit requires a venue ID. List venues first and select the appropriate one.

// WRONG: Use a hardcoded UUID
let fakeID = UUID()
service.guidance(using: query, at: fakeID)  // Will fail

// CORRECT: Discover venues first
let venues = try await EnergyVenue.venues()
guard let venue = venues.first else {
    showNoVenueSetup()
    return
}
let guidanceStream = service.guidance(using: query, at: venue.id)

Review Checklist

  • com.apple.developer.energykit entitlement added to the project
  • EnergyKitError.unsupportedRegion handled with user-facing message
  • EnergyKitError.permissionDenied handled gracefully
  • Guidance token stored and passed to load event submissions
  • Venues discovered via EnergyVenue.venues() before querying guidance
  • Load event sessions follow .begin -> .active -> .end lifecycle
  • ElectricityGuidance.Value.rating interpreted correctly (lower is better)
  • SuggestedAction matches the device type (.shift for EV, .reduce for HVAC)
  • Insight queries use appropriate granularity for the time range
  • Rate limiting handled via EnergyKitError.rateLimitExceeded
  • Service unavailability handled with retry logic

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.11%
按下载量换算3,241

Claude

28.62%
按下载量换算2,569

Cursor

18.29%
按下载量换算1,642

Gemini CLI

9.77%
按下载量换算877

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills