Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问许可证需确认审计通过

wps-eventsWPS 事件

Agent Skill

wps-events 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

499

周安装

21

GitHub Stars

19,406

下载量

175
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/wavetermdev/waveterm --skill wps-events

简介

该技能用于处理 WPS 事件相关的 GitHub 协作信息。

  • 适用于 Codex、Claude、Cursor、Gemini CLI 中围绕代码变更与 Issue 管理。
  • 支持 Pull Request 状态跟踪与团队协作事项整理。
  • 通过 GitHub 仓库安装,注意权限与文件操作风险。
  • 建议结合原始文档确认具体功能与使用限制。

SKILL.md

WPS Events Guide

Overview

WPS (Wave PubSub) is Wave Terminal's publish-subscribe event system that enables different parts of the application to communicate asynchronously. The system uses a broker pattern to route events from publishers to subscribers based on event types and scopes.

Key Files

  • pkg/wps/wpstypes.go - Event type constants and data structures
  • pkg/wps/wps.go - Broker implementation and core logic
  • pkg/wcore/wcore.go - Example usage patterns

Event Structure

Events in WPS have the following structure:

type WaveEvent struct {
    Event   string   `json:"event"`      // Event type constant
    Scopes  []string `json:"scopes,omitempty"` // Optional scopes for targeted delivery
    Sender  string   `json:"sender,omitempty"` // Optional sender identifier
    Persist int      `json:"persist,omitempty"` // Number of events to persist in history
    Data    any      `json:"data,omitempty"`    // Event payload
}

Adding a New Event Type

Step 1: Define the Event Constant

Add your event type constant to pkg/wps/wpstypes.go:

const (
    Event_BlockClose       = "blockclose"
    Event_ConnChange       = "connchange"
    // ... other events ...
    Event_YourNewEvent     = "your:newevent"  // type: YourEventData (or "none" if no data)
)

Naming Convention:

  • Use descriptive PascalCase for the constant name with Event_ prefix
  • Use lowercase with colons for the string value (e.g., "namespace:eventname")
  • Group related events with the same namespace prefix
  • Always add a // type: <TypeName> comment; use // type: none if no data is sent

Step 2: Add to AllEvents

Add your new constant to the AllEvents slice in pkg/wps/wpstypes.go:

var AllEvents []string = []string{
    // ... existing events ...
    Event_YourNewEvent,
}

Step 3: Register in WaveEventDataTypes (REQUIRED)

You must add an entry to WaveEventDataTypes in pkg/tsgen/tsgenevent.go. This drives TypeScript type generation for the event's data field:

var WaveEventDataTypes = map[string]reflect.Type{
    // ... existing entries ...
    wps.Event_YourNewEvent: reflect.TypeOf(YourEventData{}),        // value type
    // wps.Event_YourNewEvent: reflect.TypeOf((*YourEventData)(nil)), // pointer type
    // wps.Event_YourNewEvent: nil,                                   // no data (type: none)
}
  • Use reflect.TypeOf(YourType{}) for value types
  • Use reflect.TypeOf((*YourType)(nil)) for pointer types
  • Use nil if no data is sent for the event

Step 4: Define Event Data Structure (Optional)

If your event carries structured data, define a type for it:

type YourEventData struct {
    Field1 string `json:"field1"`
    Field2 int    `json:"field2"`
}

Step 5: Expose Type to Frontend (If Needed)

If your event data type isn't already exposed via an RPC call, you need to add it to pkg/tsgen/tsgen.go so TypeScript types are generated:

// add extra types to generate here
var ExtraTypes = []any{
    waveobj.ORef{},
    // ... other types ...
    uctypes.RateLimitInfo{},  // Example: already added
    YourEventData{},          // Add your new type here
}

Then run code generation:

task generate

This will update frontend/types/gotypes.d.ts with TypeScript definitions for your type, ensuring type safety in the frontend when handling these events.

Publishing Events

Basic Publishing

To publish an event, use the global broker:

import "github.com/wavetermdev/waveterm/pkg/wps"

wps.Broker.Publish(wps.WaveEvent{
    Event: wps.Event_YourNewEvent,
    Data:  yourData,
})

Publishing with Scopes

Scopes allow targeted event delivery. Subscribers can filter events by scope:

wps.Broker.Publish(wps.WaveEvent{
    Event:  wps.Event_WaveObjUpdate,
    Scopes: []string{oref.String()},  // Target specific object
    Data:   updateData,
})

Publishing in a Goroutine

To avoid blocking the caller, publish events asynchronously:

go func() {
    wps.Broker.Publish(wps.WaveEvent{
        Event: wps.Event_YourNewEvent,
        Data:  data,
    })
}()

When to use goroutines:

  • When publishing from performance-critical code paths
  • When the event is informational and doesn't need immediate delivery
  • When publishing from code that holds locks (to prevent deadlocks)

Event Persistence

Events can be persisted in memory for late subscribers:

wps.Broker.Publish(wps.WaveEvent{
    Event:   wps.Event_YourNewEvent,
    Persist: 100,  // Keep last 100 events
    Data:    data,
})

Complete Example: Rate Limit Updates

This example shows how rate limit information is published when AI chat responses include rate limit headers.

1. Define the Event Type

In pkg/wps/wpstypes.go:

const (
    // ... other events ...
    Event_WaveAIRateLimit  = "waveai:ratelimit"
)

2. Publish the Event

In pkg/aiusechat/usechat.go:

import "github.com/wavetermdev/waveterm/pkg/wps"

func updateRateLimit(info *uctypes.RateLimitInfo) {
    if info == nil {
        return
    }
    rateLimitLock.Lock()
    defer rateLimitLock.Unlock()
    globalRateLimitInfo = info

    // Publish event in goroutine to avoid blocking
    go func() {
        wps.Broker.Publish(wps.WaveEvent{
            Event: wps.Event_WaveAIRateLimit,
            Data:  info,  // RateLimitInfo struct
        })
    }()
}

3. Subscribe to the Event (Frontend)

In the frontend, subscribe to events via WebSocket:

// Subscribe to rate limit updates
const subscription = {
  event: "waveai:ratelimit",
  allscopes: true, // Receive all rate limit events
};

Subscribing to Events

From Go Code

// Subscribe to all events of a type
wps.Broker.Subscribe(routeId, wps.SubscriptionRequest{
    Event:     wps.Event_YourNewEvent,
    AllScopes: true,
})

// Subscribe to specific scopes
wps.Broker.Subscribe(routeId, wps.SubscriptionRequest{
    Event:  wps.Event_WaveObjUpdate,
    Scopes: []string{"workspace:123"},
})

// Unsubscribe
wps.Broker.Unsubscribe(routeId, wps.Event_YourNewEvent)

Scope Matching

Scopes support wildcard matching:

  • * matches a single scope segment
  • ** matches multiple scope segments
// Subscribe to all workspace events
wps.Broker.Subscribe(routeId, wps.SubscriptionRequest{
    Event:  wps.Event_WaveObjUpdate,
    Scopes: []string{"workspace:*"},
})

Best Practices

  1. Use Namespaces: Prefix event names with a namespace (e.g., waveai:, workspace:, block:)
  2. Don't Block: Use goroutines when publishing from performance-critical code or while holding locks
  3. Type-Safe Data: Define struct types for event data rather than using maps
  4. Scope Wisely: Use scopes to limit event delivery and reduce unnecessary processing
  5. Document Events: Add comments explaining when events are fired and what data they carry
  6. Consider Persistence: Use Persist for events that late subscribers might need (like status updates). This is normally not used. We normally do a live RPC call to get the current value and then subscribe for updates.

Common Event Patterns

Status Updates

wps.Broker.Publish(wps.WaveEvent{
    Event:   wps.Event_ControllerStatus,
    Scopes:  []string{blockId},
    Persist: 1,  // Keep only latest status
    Data:    statusData,
})

Object Updates

wps.Broker.Publish(wps.WaveEvent{
    Event:  wps.Event_WaveObjUpdate,
    Scopes: []string{oref.String()},
    Data: waveobj.WaveObjUpdate{
        UpdateType: waveobj.UpdateType_Update,
        OType:      obj.GetOType(),
        OID:        waveobj.GetOID(obj),
        Obj:        obj,
    },
})

Batch Updates

// Helper function for multiple updates
func (b *BrokerType) SendUpdateEvents(updates waveobj.UpdatesRtnType) {
    for _, update := range updates {
        b.Publish(WaveEvent{
            Event:  Event_WaveObjUpdate,
            Scopes: []string{waveobj.MakeORef(update.OType, update.OID).String()},
            Data:   update,
        })
    }
}

Debugging

To debug event flow:

  1. Check broker subscription map: wps.Broker.SubMap
  2. View persisted events: wps.Broker.ReadEventHistory(eventType, scope, maxItems)
  3. Add logging in publish/subscribe methods
  4. Monitor WebSocket traffic in browser dev tools

Quick Reference

When adding a new event:

  • Add event constant to pkg/wps/wpstypes.go with a // type: <TypeName> comment (use none if no data)
  • Add the constant to AllEvents in pkg/wps/wpstypes.go
  • REQUIRED: Add an entry to WaveEventDataTypes in pkg/tsgen/tsgenevent.go — use nil for events with no data
  • Define event data structure (if needed)
  • Add data type to pkg/tsgen/tsgen.go for frontend use (if not already exposed via RPC)
  • Run task generate to update TypeScript types
  • Publish events using wps.Broker.Publish()
  • Use goroutines for non-blocking publish when appropriate
  • Subscribe to events in relevant components

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.3%
按下载量换算60

Claude

32.86%
按下载量换算58

Cursor

20.2%
按下载量换算35

Gemini CLI

9.45%
按下载量换算17

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

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

来源信息

继续浏览同类 Skills