360 Secure SkillHub
360 安全技能中心

ST Develop

该 Skill 为 State Threads(C 协程库)提供开发支持:先加载协程知识库,按需加载 ST 源码,调试调度、上下文切换与平台汇编问题,并通过 utest 与 scripts/verify.sh 验证改动。当前包内仅含 SKILL.md 和验证脚本,引用的知识库、ST 源码及测试文件未随包提供。

分类:开发
winlinvip
winlinvip
热度 4.63
最近更新 2026-03-30 13:23:08

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add winlinvip/st-develop
兼容性
通用兼容
联网要求
不联网
数据出网
数据不出本机
Metadata
name
st-develop
description
Anything related to coroutines, State Threads (ST), or SRS's concurrency model. Use when discussing coroutine concepts, updating coroutine knowledge (srs-coroutines.md), developing/debugging/porting ST source code, porting ST to new CPU architectures or OSes, debugging coroutine context switching, analyzing ST scheduler behavior, adding new platform assembly, fixing ASAN/Valgrind/SEH issues, or understanding ST internals (sched, stk, sync, key, io, event, context switch ASM).

ST Development

State Threads (ST) is a C coroutine library.

Setup

All files are in the current working directory. Find everything from here — no discovery logic needed.

Available directories: trunk/, cmd/, internal/, cmake/, docs/, memory/

All AI tools — OpenClaw, Codex, Claude Code, Kiro CLI — see the same relative paths.

Load Knowledge Base (MANDATORY)

Before any ST work, use the read tool to load the knowledge base. Do NOT use memory_search — read the full file directly.

  • memory/srs-coroutines.md

Loading ST Source Code (ON REQUEST)

When the user asks to load the ST codebase (or needs you to work directly with the source), load ALL ST source files — no partial loads.

All under trunk/3rdparty/st-srs/:

Headers: public.h, common.h, md.h

Core C: sched.c, stk.c, sync.c, key.c, io.c, event.c, common.c

Platform ASM: md_darwin.S, md_linux.S, md_linux2.S, md_cygwin64.S

Build: Makefile

Load every single file listed above — no shortcuts, no skipping.

Unit Tests (utest)

ST has a Google Test-based unit test suite in trunk/3rdparty/st-srs/utest/:

  • st_utest.cpp / st_utest.hpp — Test main and shared helpers
  • st_utest_coroutines.cpp — Coroutine tests (start, params, multiple coroutines, addition across yields)
  • st_utest_tcp.cpp — TCP connection test
  • gtest-fit/ — Embedded Google Test framework

Build targets (in the ST Makefile):

  • darwin-debug-utest — macOS debug build + utest
  • linux-debug-utest — Linux debug build + utest
  • cygwin64-debug-utest — Cygwin64 debug build + utest

Coverage variants: darwin-debug-gcov, linux-debug-gcov (adds -fprofile-arcs -ftest-coverage).

The build compiles ST as a static library first, then builds and links the utest binary at obj/st_utest.

Verifying Changes

After any ST change (including utest-only changes), run the verifier script in this skill folder (not in the ST codebase):

  • scripts/verify.sh

This script runs unit tests in trunk/3rdparty/st-srs. Always run verification before considering a change complete.