writing-p2-plugins
БесплатноЗапускает вложенные скриптыНе проверенWrite, apply and show a p2 plugin (shared or persistent views, multiplayer games, boards, editors several people use, server-side objects, tools for the…
от k3dom★ 17 звёзд на GitHubОб этом скилле
Writing p2 plugins
A p2 plugin is a directory of TypeScript files that p2 builds and loads into its server, every session's worker and
the page. Plugins you write live in the user plugin root, <data>/plugins/ on the p2 server (the local:
directory this skill's subagent works in). They survive p2 updates; a built-in plugin wins a name clash.
Use a plugin for anything multiplayer, persistent or with rules: games, shared boards, editors several people use.
An html artifact (artifact_write with kind html, a page you write) is for single-player pages.
Where to work
Work on the server's own files: as a subagent located at local:<data>/plugins (subagent env: null, cwd the
root), or in a session there. Write files with the ordinary write/edit/read/bash tools. Saving applies
nothing; reload_plugins does.
Layout
<name>/ lowercase letters, digits, dashes; not a built-in plugin's name
package.json { "name": "<name>", "private": true, "type": "module" } (name = directory)
contract.ts the types the other files share (no facet: imported by them)
server.ts runs on the server (shared state, rules)
worker.ts optional: runs in each session's worker (tools for the agent)
web.tsx optional: runs in the page (React panes)
skills/<skill>/SKILL.md optional: skills for agents on the server's machine (see below)
Imports: only @p2/app/v1 (any facet), @p2/app/v1/server (server), @p2/app/v1/worker (worker),
@p2/app/v1/web (web), @earendil-works/pi-schema, @earendil-works/pi-durable (worker, for
defineExtension), react (web), and the plugin's own files by relative path. No other packages, no top-level
await, no import.meta. pluginFile(path) from @earendil-works/chord/plugins gives a facet the absolute path of
a file of its own plugin.
The pieces
- Contract (
contract.ts):remote(name, { version, params, hostAddress: serverHost, state, methods, events }):state(JSON schemas from@earendil-works/pi-schema),methods(method(args, result)) andevents(fire-and-forget values for motion: pointers, drags, game inputs; never kept or replayed). One shape for every caller: a member only some callers get is markedgrantable(...)(grantable(method(...))), and the server grants it per caller (below). Every change of a contract's shape bumps itsversion. - Server object (
server.ts):export default defineFacet((host) => { host.serve(Contract, (params, principal, self) => members) }). A contract with grantable members is served with{ admit: grantBy((principal, params) => [names]) }(from@p2/app/v1), and its factory takes(params, principal, admitted, self); a grantable state member is returned as a builder,() => watchable, built only when granted. Check the principal:canView/canSend(principal, session)for people,isWorker(principal) && principal.session === sessionfor the session's agent. Persistent data lives in a local store served once (local(name, { version, params: {}, members })withself.state(defineState(name, { schema, version, initial, keyed?, persist: true, checkpointWhen })), changed withhandle.change(key, draft => ..., ctx)); each person's object reaches it withself.get(Store, {})and shows derives (self.derive([sources], fn)). Data that belongs to one session is keyed by the session's address (keyed: Sessionfrom@p2/app/v1, keysSession({ id })): a session's export, import and delete carry it. Events:self.events<T>(),.emit(value); listening to a reference's event member:await ref.member.on(listener, ctx). Presence:host.references(Contract)lists who holds which object now. - Pane (
web.tsx):contribute(host, "<name>.web", (self) => self.contribute(ViewKinds, { <kind>: { Pane } })). The pane getsPaneProps(session,item(the view's item: what it shows, e.g. a board's ID),inline(true in the transcript, false beside it),view(beside the transcript),editable,select,annotations) and holds objects withuseObject(Contract, params),live(ref)(orliveWith(ref, "member")for a grantable member),useReadable(member). - One script per plugin: each plugin's web facet is built into a script of its own, and a file it imports from
another plugin is copied into it. Never share module state (a
Map, alet, a store, a React context) through such a file: the other plugin's copy is another instance. Use a registry the owning plugin serves, orsharedContext(name, initial)from@p2/app/v1/webfor a React context. A plugin's web change applies in open pages in place (no reload). - Listable items (
web.tsx, optional): a plugin keeping several items per session (boards, games) contributes an artifact kind,self.contribute(ArtifactKinds, { <kind>: { title, icon, useItems, useCount, view, useRemove? } })(`
Установить writing-p2-plugins в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл writing-p2-plugins?
Write, apply and show a p2 plugin (shared or persistent views, multiplayer games, boards, editors several people use, server-side objects, tools for the agent). Use when the user wants something multiplayer, persistent or with rules inside p2; html artifacts are for single-player pages.
Как установить скилл writing-p2-plugins?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл writing-p2-plugins запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic