dg-ai-notes is a tutorial and source-code study project about Pi-Agent, an SDK for building AI agents, with examples in TypeScript and Python. It helps developers understand agent loops, tools, messages, sessions, events, extensions, and the construction of deployable agents. Its catalogue skill provides an assistant for developing with the Pi-Agent SDK.
Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add buchidonggua/dg-ai-notes --skill dg-piagentgit clone --depth 1 https://github.com/buchidonggua/dg-ai-notesWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/buchidonggua/dg-ai-notes/dg-piagent)<a href="https://agentmods.dev/skills/buchidonggua/dg-ai-notes/dg-piagent"><img src="https://agentmods.dev/badge/skills/buchidonggua/dg-ai-notes/dg-piagent/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/buchidonggua/dg-ai-notes/dg-piagent"><img src="https://agentmods.dev/badge/skills/buchidonggua/dg-ai-notes/dg-piagent.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00205 | $0.04497 |
| Opus 5 | $0.00102 | $0.02249 |
| Sonnet 5 | $0.00041 | $0.00899 |
| Haiku 4.5 | $0.00020 | $0.00450 |
Grade A, and why
dg-piagent scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 278 lines — stays where its author put it; the contents beside it link to each section on GitHub.
pi-agent SDK 开发指南
⚠️ 版本基线: 本 skill 的 API 描述已对齐到 pi-coding-agent v0.83.0。
遇 pi-ai import 失败时,先查
node_modules/@earendil-works/pi-ai/dist/compat.d.ts的export *列表,确认符号归属哪个入口。
版本协议 ⭐
本 skill 核对到顶部基线版本(当前 v0.83.0)。涉及安装/升级 pi-agent 时遵循三步:
-
默认对齐:引导安装一律用基线版本
npm install @earendil-works/[email protected],不装latest——skill 的 API 描述精确核对到基线版本,装 latest 会立即漂移。场景文档里的安装命令同样以基线版本为准。 -
升级前评估:当任务涉及安装/升级(或用户问版本)时,先跑
npm view @earendil-works/pi-coding-agent version拿 latest 与基线对比。若不同,联网查该版本 CHANGELOG/release notes,从 SDK 二次开发角度评估(新功能 / 破坏性变更),给用户简短建议,由用户决定是否升级。日常开发(项目已装好)不触发。 -
升级即更新 skill:若用户同意升到 X.Y.Z,安装后按 skill-maintenance.md 流程,对照新版
dist/**/*.d.ts+ CHANGELOG 审查 skill 差异,产出更新清单,报用户确认后再改,并同步更新顶部基线版本号。
变更查阅渠道(第 2/3 步执行依据):
| 渠道 | 路径/命令 | 适用阶段 |
|---|---|---|
| ① node_modules CHANGELOG | <proj>/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md(标准 Keep-a-Changelog,按 ## [版本号] 分节,含 Breaking Changes) |
升级后(第3步) |
| ② GitHub | github.com/earendil-works/pi 的 packages/coding-agent/CHANGELOG.md 或 Releases |
升级前(第2步,需联网) |
时序关键:升级前 node_modules 仍是旧版,渠道①看不到新版内容,第 2 步必须用②(GitHub)。
Overview
pi-agent 是基于事件驱动的 Agent 开发框架(@earendil-works/pi-coding-agent)。核心心智模型:
createAgentSession() ← 组装入口(Provider + 工具 + 资源)
│
├── session.prompt(text) ← 驱动 Agent 主循环
│
├── session.subscribe(handler) ← 外部订阅层
│ 多数事件与扩展层共有(turn_*/message_*/tool_execution_*/agent_start/agent_end/agent_settled)
│ 外部层独有: queue_update / compaction_* / session_info_changed 等 session 状态事件
│
└── 扩展(pi.on) ← 内部扩展层
扩展独有(仅这 6 个 subscribe 收不到):
context / tool_call / tool_result / before_agent_start / input / model_select
关键区分(最大集成坑): 有 6 个扩展独有事件——context / tool_call / tool_result / before_agent_start / input / model_select。
在 server 层用 session.subscribe 监听这 6 个会静默失败(handler 被调用但 type 分支永不命中,无报错)。
对策: 需要抓这 6 个事件的逻辑(日志/trace/拦截/抓这 6 个事件的数据落库)必须写成扩展走 pi.on。⚠️ 但注意——pi.on handler 被派发方 await,落库这类慢 I/O 必须 fire-and-forget(推队列后台写),否则阻塞 agent loop。若只需存 message_*/turn_*/tool_execution_* 等 subscribe 收得到的事件,落库优先走 session.subscribe(不 await listener,可直接 await 写库,零阻塞)。详见 04-events.md 关键细节。
详见 Common Mistakes 与 sdk_doc/04-events.md。
What ships with it
60 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
- references/project-structure.md 5.3 KB
- references/scenarios/A01-minimal-startup.md 6.1 KB
- references/scenarios/A02-model-selection.md 16 KB
- references/scenarios/A03-system-prompt.md 11 KB
- references/scenarios/A04-tool-whitelist.md 3.2 KB
- references/scenarios/A05-custom-cwd.md 8.8 KB
- references/scenarios/A06-load-extensions.md 15 KB
- references/scenarios/B01-auth-config.md 20 KB
- references/scenarios/B02-settings.md 12 KB
- references/scenarios/B03-available-models.md 17 KB
- references/scenarios/B04-project-trust.md 8.6 KB
- references/scenarios/C01-custom-skill.md 16 KB
- references/scenarios/C02-prompt-templates.md 18 KB
- references/scenarios/C03-context-files.md 17 KB
- references/scenarios/D01-custom-tool.md 23 KB
- references/scenarios/D02-dynamic-tools.md 21 KB
- references/scenarios/D04-confirm-destructive.md 23 KB
- references/scenarios/D05-tool-result-render.md 33 KB
- references/scenarios/D06-protected-paths.md 21 KB
- references/scenarios/E01-tool-intercept.md 29 KB
- references/scenarios/E02-extension-basics.md 15 KB
- references/scenarios/E04-lifecycle-hooks.md 23 KB
- references/scenarios/E05-input-transform.md 24 KB
- references/scenarios/E06-streaming-transform.md 35 KB
- references/scenarios/E11-sse-progress-streaming.md 16 KB
- references/scenarios/F01-session-persistence.md 7.9 KB
- references/scenarios/F02-session-runtime.md 21 KB
- references/scenarios/F04-abort-session.md 16 KB
- references/scenarios/F05-steer-session.md 18 KB
- references/scenarios/G01-context-injection.md 19 KB
- references/scenarios/G02-custom-compaction.md 9.5 KB
- references/scenarios/G03-auto-summarize.md 21 KB
- references/scenarios/G04-preload-context.md 19 KB
- references/scenarios/H01-full-control.md 14 KB
- references/scenarios/H02-custom-provider.md 23 KB
- references/scenarios/H03-faux-provider.md 25 KB
- references/scenarios/H06-multi-agent.md 32 KB
- references/scenarios/H07-enterprise-interface.md 6.0 KB
- references/scenarios/I01-pi-package.md 18 KB
- references/scenarios/I02-distribute-extension.md 26 KB
- references/scenarios/I03-extension-deps.md 24 KB
- references/scenarios/I04-sandbox.md 20 KB
- references/scenarios/I05-subagent.md 32 KB
- references/sdk_doc/01-create-agent-session.md 13 KB
- references/sdk_doc/02-agent-session.md 14 KB
- references/sdk_doc/03-agent-session-runtime.md 13 KB
- references/sdk_doc/04-events.md 26 KB
- references/sdk_doc/05-auth-model-registry.md 15 KB
- references/sdk_doc/06-tools.md 17 KB
- references/sdk_doc/07-extensions-api.md 15 KB
- references/sdk_doc/08-resource-loader.md 11 KB
- references/sdk_doc/09-skills.md 17 KB
- references/sdk_doc/10-prompt-templates.md 12 KB
- references/sdk_doc/11-context-files.md 9.9 KB
- references/sdk_doc/12-session-manager.md 14 KB
- references/sdk_doc/13-settings-manager.md 20 KB
- references/sdk_doc/16-custom-provider.md 31 KB
- references/sdk_doc/18-compaction.md 29 KB
- references/sdk_doc/20-pi-package.md 13 KB
- references/sdk_doc/21-multi-agent.md 21 KB
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 10d ago First seen · 278 lines · 205 tokens per session scan A 1f489cea7120
dg-piagent is a skill published in the GitHub repository buchidonggua/dg-ai-notes (2,707 stars, last pushed 18d ago), licensed MIT. It adds 205 tokens to every session and 4,497 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
claude-md
Create or update CLAUDE.md files following best practices for optimal AI agent onboarding.
doc-generator
Generate comprehensive, accurate API documentation from source code. Use when creating or updating API documentation, generating OpenAPI specs, or when users mention API docs, endpoints, or documentation.
code-review-specialist
Comprehensive code review with security, performance, and quality analysis. Use when users ask to review code, analyze code quality, evaluate pull requests, or mention code review, security analysis, or performance optimization.
brand-voice
Ensure all communication matches brand voice and tone guidelines. Use when creating marketing copy, customer communications, public-facing content, or when users mention brand voice, tone, or writing style.
docs-page
A long-form technical documentation page with a left navigation panel, a main article, and a right table of contents. A table of contents lists the page sections and links to them.
modern-go
A Go code modernizer that updates source code to use language features and standard-library patterns supported by the project’s declared Go version.