pk-agent 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +403 -0
- package/bin/cli.js +2 -0
- package/dist/index.js +20549 -0
- package/dist/index.js.map +120 -0
- package/package.json +98 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2025 Leon Ho.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
<picture>
|
|
2
|
+
<source media="(prefers-color-scheme: dark)" srcset="./static/pk-agent-logo-dark.png">
|
|
3
|
+
<source media="(prefers-color-scheme: light)" srcset="./static/pk-agent-logo.png">
|
|
4
|
+
<img alt="PK Agent Logo" src="./static/pk-agent-logo.png" width="full">
|
|
5
|
+
</picture>
|
|
6
|
+
|
|
7
|
+
<br/>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/pk-agent"><img alt="Version" src="https://img.shields.io/npm/v/pk-agent?style=flat-square&color=00DC82&label=version"></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/pk-agent"><img alt="Downloads" src="https://img.shields.io/npm/dm/pk-agent?style=flat-square&color=00DC82"></a>
|
|
12
|
+
<a href="https://github.com/pk-agent/pk-agent/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/pk-agent?style=flat-square&color=00DC82"></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<h3 align="center">
|
|
16
|
+
Build AI agents as simple text files.<br/>
|
|
17
|
+
No coding required.
|
|
18
|
+
</h3>
|
|
19
|
+
|
|
20
|
+
<br/>
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
<br/>
|
|
25
|
+
|
|
26
|
+
## Quickstart
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git clone git@github.com:kingkillery/pk-agent.git && cd pk-agent && bun install && bun run build && npm pack && npm install -g ./pk-agent-*.tgz
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## What is PK-Agent?
|
|
33
|
+
|
|
34
|
+
PK-Agent lets you create **AI-powered assistants** by writing a short text file - no programming needed. Each file is a set of instructions that tells an AI model what to do, like giving directions to a very capable coworker.
|
|
35
|
+
|
|
36
|
+
Think of it like a recipe card. The top section lists the ingredients (which AI model to use, what tools it needs). The bottom section is the actual instructions - written in plain English.
|
|
37
|
+
|
|
38
|
+
Here's a complete agent that generates a daily motivation quote:
|
|
39
|
+
|
|
40
|
+
```markdown
|
|
41
|
+
---
|
|
42
|
+
model: anthropic:claude-sonnet-4-5
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
Generate a daily motivation quote with a tech fact.
|
|
46
|
+
Format as JSON with 'quote' and 'fact' fields.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
That's it. That file *is* the agent.
|
|
50
|
+
|
|
51
|
+
<br/>
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
<br/>
|
|
56
|
+
|
|
57
|
+
## Getting Started
|
|
58
|
+
|
|
59
|
+
### 1. Install
|
|
60
|
+
|
|
61
|
+
Open a terminal (Command Prompt, PowerShell, or Terminal) and run:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
npm install -g pk-agent
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 2. Connect your AI provider
|
|
68
|
+
|
|
69
|
+
PK-Agent needs an API key from an AI provider. Think of this like a password that lets PK-Agent talk to the AI on your behalf.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
pk-agent auth login
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
This walks you through connecting to **Anthropic** (Claude), **OpenAI** (GPT), or other providers.
|
|
76
|
+
|
|
77
|
+
### 3. Create your first agent
|
|
78
|
+
|
|
79
|
+
Recommended: generate a starter agent file with:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
pk-agent create
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Or create one manually:
|
|
86
|
+
|
|
87
|
+
Create a new text file called `my-agent.pk-agent` and paste this in:
|
|
88
|
+
|
|
89
|
+
```markdown
|
|
90
|
+
---
|
|
91
|
+
model: anthropic:claude-sonnet-4-5
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
You are a friendly assistant. Greet the user, tell them one
|
|
95
|
+
interesting fact about space, and wish them a great day.
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 4. Run it
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
pk-agent run my-agent.pk-agent
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
You'll see the AI respond right in your terminal.
|
|
105
|
+
|
|
106
|
+
> **Tip:** You can also try agents without installing anything:
|
|
107
|
+
> ```
|
|
108
|
+
> npx pk-agent@latest run my-agent.pk-agent
|
|
109
|
+
> ```
|
|
110
|
+
|
|
111
|
+
<br/>
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
<br/>
|
|
116
|
+
|
|
117
|
+
## How Agent Files Work
|
|
118
|
+
|
|
119
|
+
Every `.pk-agent` file has two parts:
|
|
120
|
+
|
|
121
|
+
```markdown
|
|
122
|
+
---
|
|
123
|
+
model: anthropic:claude-sonnet-4-5 # Settings (YAML)
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
You are a helpful research assistant. # Instructions (Markdown)
|
|
127
|
+
Summarize the latest news about AI
|
|
128
|
+
and format it as bullet points.
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| Part | What it does | Required? |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| **Settings** (between `---` lines) | Tells PK-Agent which AI model to use and what tools to provide | Yes |
|
|
134
|
+
| **Instructions** (below the settings) | Tells the AI what to do, in plain English | Yes |
|
|
135
|
+
|
|
136
|
+
### Choosing a model
|
|
137
|
+
|
|
138
|
+
The `model` line tells PK-Agent which AI to use. Some popular options:
|
|
139
|
+
|
|
140
|
+
| Model | Best for |
|
|
141
|
+
|---|---|
|
|
142
|
+
| `anthropic:claude-sonnet-4-5` | General tasks, writing, analysis |
|
|
143
|
+
| `openai:gpt-5.2` | Broad knowledge, conversation |
|
|
144
|
+
| `openai:gpt-5.2-mini` | Fast, lightweight tasks |
|
|
145
|
+
|
|
146
|
+
You can switch models by changing one line - your instructions stay the same.
|
|
147
|
+
|
|
148
|
+
<br/>
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
<br/>
|
|
153
|
+
|
|
154
|
+
## Real-World Examples
|
|
155
|
+
|
|
156
|
+
### Summarize a webpage
|
|
157
|
+
|
|
158
|
+
```markdown
|
|
159
|
+
---
|
|
160
|
+
model: anthropic:claude-sonnet-4-5
|
|
161
|
+
mcpServers:
|
|
162
|
+
fetch:
|
|
163
|
+
command: uvx
|
|
164
|
+
args: [mcp-server-fetch]
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
Fetch https://news.ycombinator.com and summarize the top 5 stories
|
|
168
|
+
in plain language. Keep each summary to 2 sentences.
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Monitor a website for changes
|
|
172
|
+
|
|
173
|
+
```markdown
|
|
174
|
+
---
|
|
175
|
+
model: anthropic:claude-sonnet-4-5
|
|
176
|
+
schedule: "0 9 * * *"
|
|
177
|
+
mcpServers:
|
|
178
|
+
fetch:
|
|
179
|
+
command: uvx
|
|
180
|
+
args: [mcp-server-fetch]
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
Fetch https://example.com/changelog and compare it to yesterday.
|
|
184
|
+
If anything changed, write a summary of what's new.
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
> The `schedule` line tells PK-Agent to run this automatically. `"0 9 * * *"` means "every day at 9:00 AM."
|
|
188
|
+
|
|
189
|
+
### Query a database and write a report
|
|
190
|
+
|
|
191
|
+
```markdown
|
|
192
|
+
---
|
|
193
|
+
model: anthropic:claude-sonnet-4-5
|
|
194
|
+
mcpServers:
|
|
195
|
+
postgres:
|
|
196
|
+
command: npx
|
|
197
|
+
args: ["-y", "@modelcontextprotocol/server-postgres"]
|
|
198
|
+
requiredEnvVars: [DATABASE_URL]
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
Query the sales table for yesterday's metrics.
|
|
202
|
+
Generate an executive summary with trends and anomalies.
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
<br/>
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
<br/>
|
|
210
|
+
|
|
211
|
+
## Adding Capabilities with Tools
|
|
212
|
+
|
|
213
|
+
Out of the box, an agent can only read and write text. To give it access to the outside world - websites, databases, files, APIs - you connect **tools**.
|
|
214
|
+
|
|
215
|
+
PK-Agent uses the [Model Context Protocol](https://modelcontextprotocol.io) (MCP) standard, which means hundreds of pre-built tools already exist. You list them in your agent's settings:
|
|
216
|
+
|
|
217
|
+
```yaml
|
|
218
|
+
mcpServers:
|
|
219
|
+
fetch:
|
|
220
|
+
command: uvx
|
|
221
|
+
args: [mcp-server-fetch]
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
That single block gives your agent the ability to read any webpage. No code to write, no setup beyond adding those lines.
|
|
225
|
+
|
|
226
|
+
### Built-in tools
|
|
227
|
+
|
|
228
|
+
PK-Agent also comes with built-in tools you can enable directly.
|
|
229
|
+
|
|
230
|
+
#### File access
|
|
231
|
+
|
|
232
|
+
```yaml
|
|
233
|
+
tools:
|
|
234
|
+
filesystem:
|
|
235
|
+
- path: .
|
|
236
|
+
permissions: [read, write, edit]
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
#### Shell commands
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
tools:
|
|
243
|
+
bash:
|
|
244
|
+
commands:
|
|
245
|
+
- "rg -n \"TODO\" ."
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### Window capture
|
|
249
|
+
|
|
250
|
+
```yaml
|
|
251
|
+
tools:
|
|
252
|
+
captureWindow: true
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
<br/>
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
<br/>
|
|
260
|
+
|
|
261
|
+
## Running Agents
|
|
262
|
+
|
|
263
|
+
### From a file
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
pk-agent run my-agent.pk-agent
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### With an extra prompt
|
|
270
|
+
|
|
271
|
+
Append a question or instruction at run time:
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
pk-agent run my-agent.pk-agent "Focus on stories about robotics"
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### On a schedule
|
|
278
|
+
|
|
279
|
+
Add a `schedule` line to your agent file and it runs automatically:
|
|
280
|
+
|
|
281
|
+
```yaml
|
|
282
|
+
schedule: "0 9 * * *" # Every day at 9 AM
|
|
283
|
+
schedule: "*/30 * * * *" # Every 30 minutes
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### As an HTTP server
|
|
287
|
+
|
|
288
|
+
Start a server and trigger agents over the network:
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
pk-agent serve
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Then from any app, script, or automation tool:
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
curl -X POST http://localhost:12233/run -d '{"agent": "my-agent"}'
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
<br/>
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
<br/>
|
|
305
|
+
|
|
306
|
+
## Composing Agents Together
|
|
307
|
+
|
|
308
|
+
Agents can call other agents. A "manager" agent can delegate tasks to specialized "worker" agents, each with their own instructions and tools.
|
|
309
|
+
|
|
310
|
+
```markdown
|
|
311
|
+
---
|
|
312
|
+
model: anthropic:claude-sonnet-4-5
|
|
313
|
+
subagents:
|
|
314
|
+
researcher:
|
|
315
|
+
path: ./researcher.pk-agent
|
|
316
|
+
writer:
|
|
317
|
+
path: ./writer.pk-agent
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
Use the researcher to gather information about today's AI news,
|
|
321
|
+
then hand the results to the writer to create a blog post draft.
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
You can also reference agents with a shorthand - just wrap the name in double brackets:
|
|
325
|
+
|
|
326
|
+
```markdown
|
|
327
|
+
Use [[researcher]] to find sources, then [[writer]] to draft.
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
PK-Agent will find the agent files automatically and wire everything up.
|
|
331
|
+
|
|
332
|
+
<br/>
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
<br/>
|
|
337
|
+
|
|
338
|
+
## Reusable Skills
|
|
339
|
+
|
|
340
|
+
If you find yourself writing the same instructions across multiple agents, save them as a **skill** - a reusable block of instructions stored in a `SKILL.md` file.
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
.pk-agent/
|
|
344
|
+
skills/
|
|
345
|
+
summarizer/
|
|
346
|
+
SKILL.md <-- reusable instructions
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Reference a skill in any agent with triple brackets:
|
|
350
|
+
|
|
351
|
+
```markdown
|
|
352
|
+
Apply [[[summarizer]]] to the fetched content.
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
List all available skills:
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
pk-agent skills
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
<br/>
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
<br/>
|
|
366
|
+
|
|
367
|
+
## All Commands
|
|
368
|
+
|
|
369
|
+
| Command | What it does |
|
|
370
|
+
|---|---|
|
|
371
|
+
| `pk-agent run <file>` | Run an agent |
|
|
372
|
+
| `pk-agent test <target>` | Validate an agent file or URL (no execution) |
|
|
373
|
+
| `pk-agent config <subcommand>` | Manage non-secret defaults (user and project scope) |
|
|
374
|
+
| `pk-agent serve` | Start the HTTP server |
|
|
375
|
+
| `pk-agent auth login` | Connect an AI provider |
|
|
376
|
+
| `pk-agent sessions` | View past agent runs |
|
|
377
|
+
| `pk-agent agents` | List agents in your project |
|
|
378
|
+
| `pk-agent skills` | List available skills |
|
|
379
|
+
| `pk-agent models` | Show supported AI models |
|
|
380
|
+
| `pk-agent add <source>` | Import agents or skills from a URL or repo |
|
|
381
|
+
|
|
382
|
+
<br/>
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
<br/>
|
|
387
|
+
|
|
388
|
+
## Platform Support
|
|
389
|
+
|
|
390
|
+
PK-Agent runs on **Windows**, **macOS**, and **Linux**.
|
|
391
|
+
|
|
392
|
+
It also works in Docker containers, GitHub Actions, and any CI/CD pipeline - anywhere Node.js runs.
|
|
393
|
+
|
|
394
|
+
<br/>
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
<br/>
|
|
399
|
+
|
|
400
|
+
<p align="center">
|
|
401
|
+
<strong>Apache 2.0 License</strong>
|
|
402
|
+
</p>
|
|
403
|
+
|
package/bin/cli.js
ADDED