본문으로 건너뛰기
cccskills
무료GitHub에 공개

waveenv

Guide for creating WaveEnv narrowings in Wave Terminal. Use when writing a named subset type of WaveEnv for a component tree, documenting environmental dependencies, or enabling mock environments for preview/test server usage.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md6.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

WaveEnv Narrowing Skill

Purpose

A WaveEnv narrowing creates a named subset type of WaveEnv that:

  1. Documents exactly which parts of the environment a component tree actually uses.
  2. Forms a type contract so callers and tests know what to provide.
  3. Enables mocking in the preview/test server — you only need to implement what's listed.

When To Create One

Create a narrowing whenever you are writing a component (or group of components) that you want to test in the preview server, or when you want to make the environmental dependencies of a component tree explicit.

Core Principle: Only Include What You Use

Only list the fields, methods, atoms, and keys that the component tree actually accesses. If you don't call wos, don't include wos. If you only call one RPC command, only list that one command. The narrowing is a precise dependency declaration — not a copy of WaveEnv.

File Location

  • Separate file (preferred for shared/complex envs): name it <feature>env.ts next to the component, e.g. frontend/app/block/blockenv.ts.
  • Inline (acceptable for small, single-file components): export the type directly from the component file, e.g. WidgetsEnv in frontend/app/workspace/widgets.tsx.

Imports Required

import {
  BlockMetaKeyAtomFnType, // only if you use getBlockMetaKeyAtom
  ConnConfigKeyAtomFnType, // only if you use getConnConfigKeyAtom
  SettingsKeyAtomFnType, // only if you use getSettingsKeyAtom
  WaveEnv,
  WaveEnvSubset,
} from "@/app/waveenv/waveenv";

The Shape

export type MyEnv = WaveEnvSubset<{
  // --- Simple WaveEnv properties ---
  // Copy the type verbatim from WaveEnv with WaveEnv["key"] syntax.
  isDev: WaveEnv["isDev"];
  createBlock: WaveEnv["createBlock"];
  showContextMenu: WaveEnv["showContextMenu"];
  platform: WaveEnv["platform"];

  // --- electron: list only the methods you call ---
  electron: {
    openExternal: WaveEnv["electron"]["openExternal"];
  };

  // --- rpc: list only the commands you call ---
  rpc: {
    ActivityCommand: WaveEnv["rpc"]["ActivityCommand"];
    ConnEnsureCommand: WaveEnv["rpc"]["ConnEnsureCommand"];
  };

  // --- atoms: list only the atoms you read ---
  atoms: {
    modalOpen: WaveEnv["atoms"]["modalOpen"];
    fullConfigAtom: WaveEnv["atoms"]["fullConfigAtom"];
  };

  // --- wos: always take the whole thing, no sub-typing needed ---
  wos: WaveEnv["wos"];

  // --- services: list only the services you call; no method-level narrowing ---
  services: {
    block: WaveEnv["services"]["block"];
    workspace: WaveEnv["services"]["workspace"];
  };

  // --- key-parameterized atom factories: enumerate the keys you use ---
  getSettingsKeyAtom: SettingsKeyAtomFnType<"app:focusfollowscursor" | "window:magnifiedblockopacity">;
  getBlockMetaKeyAtom: BlockMetaKeyAtomFnType<"view" | "frame:title" | "connection">;
  getConnConfigKeyAtom: ConnConfigKeyAtomFnType<"conn:wshenabled">;

  // --- other atom helpers: copy verbatim ---
  getConnStatusAtom: WaveEnv["getConnStatusAtom"];
  getLocalHostDisplayNameAtom: WaveEnv["getLocalHostDisplayNameAtom"];
}>;

Automatically Included Fields

Every WaveEnvSubset<T> automatically includes the mock fields — you never need to declare them:

  • isMock: boolean
  • mockSetWaveObj: <T extends WaveObj>(oref: string, obj: T) => void
  • mockModels?: Map<any, any>

Rules for Each Section

SectionPatternNotes
electronelectron: { method: WaveEnv["electron"]["method"]; }List every method called; omit the rest.
rpcrpc: { Cmd: WaveEnv["rpc"]["Cmd"]; }List every RPC command called; omit the rest.
atomsatoms: { atom: WaveEnv["atoms"]["atom"]; }List every atom read; omit the rest.
woswos: WaveEnv["wos"]Take the whole wos object (no sub-typing needed), but only add it if wos is actually used.
servicesservices: { svc: WaveEnv["services"]["svc"]; }List each service used; take the whole service object (no method-level narrowing).
getSettingsKeyAtomSettingsKeyAtomFnType<"key1" | "key2">Union all settings keys accessed.
getBlockMetaKeyAtomBlockMetaKeyAtomFnType<"key1" | "key2">Union all block meta keys accessed.
getConnConfigKeyAtomConnConfigKeyAtomFnType<"key1">Union all conn config keys accessed.
All other WaveEnv fieldsWaveEnv["fieldName"]Copy type verbatim.

Using the Narrowed Type in Components

import { useWaveEnv } from "@/app/waveenv/waveenv";
import { MyEnv } from "./myenv";

const MyComponent = memo(() => {
    const env = useWaveEnv<MyEnv>();
    // TypeScript now enforces you only access what's in MyEnv.
    const val = useAtomValue(env.getSettingsKeyAtom("app:focusfollowscursor"));
    ...
});

The generic parameter on useWaveEnv<MyEnv>() casts the context to your narrowed type. The real production WaveEnv satisfies every narrowing; mock envs only need to implement the listed subset.

Real Examples

  • BlockEnv in frontend/app/block/blockenv.ts — complex narrowing with all section types, in a separate file.
  • WidgetsEnv in frontend/app/workspace/widgets.tsx — smaller narrowing defined inline in the component file.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guide for adding new configuration settings to Wave Terminal. Use when adding a new setting to the configuration system, implementing a new config key, or adding user-customizable settings.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

add-rpc

무료

Guide for adding new RPC calls to Wave Terminal. Use when implementing new RPC commands, adding server-client communication methods, or extending the RPC interface with new functionality.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

Guide for adding new wsh commands to Wave Terminal. Use when implementing new CLI commands, adding command-line functionality, or extending the wsh command interface.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

Guide for creating and displaying context menus in Wave Terminal. Use when implementing right-click menus, adding context menu items, creating submenus, or handling menu interactions with checkboxes and separators.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

Guide for implementing a new view type in Wave Terminal. Use when creating a new view component, implementing the ViewModel interface, registering a new view type in BlockRegistry, or adding a new content type to display within blocks.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

Guide for adding new Electron APIs to Wave Terminal. Use when implementing new frontend-to-electron communications via preload/IPC.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

mits-pl의 스킬 모두 보기

이 스킬의 문제 신고