@swarmclawai/swarmclaw 1.2.1 → 1.2.3
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/README.md +16 -85
- package/bin/server-cmd.js +64 -1
- package/package.json +2 -2
- package/skills/coding-agent/SKILL.md +111 -0
- package/skills/github/SKILL.md +140 -0
- package/skills/nano-banana-pro/SKILL.md +62 -0
- package/skills/nano-banana-pro/scripts/generate_image.py +235 -0
- package/skills/nano-pdf/SKILL.md +53 -0
- package/skills/openai-image-gen/SKILL.md +78 -0
- package/skills/openai-image-gen/scripts/gen.py +328 -0
- package/skills/resourceful-problem-solving/SKILL.md +49 -0
- package/skills/skill-creator/SKILL.md +147 -0
- package/skills/skill-creator/scripts/init_skill.py +378 -0
- package/skills/skill-creator/scripts/quick_validate.py +159 -0
- package/skills/summarize/SKILL.md +77 -0
- package/src/app/api/auth/route.ts +20 -5
- package/src/app/api/chats/[id]/devserver/route.ts +13 -19
- package/src/app/api/chats/[id]/messages/route.ts +13 -15
- package/src/app/api/chats/[id]/route.ts +9 -10
- package/src/app/api/chats/[id]/stop/route.ts +5 -7
- package/src/app/api/chats/messages-route.test.ts +8 -6
- package/src/app/api/chats/route.ts +9 -10
- package/src/app/api/ip/route.ts +2 -2
- package/src/app/api/preview-server/route.ts +1 -1
- package/src/app/api/projects/[id]/route.ts +7 -46
- package/src/cli/server-cmd.test.js +74 -0
- package/src/components/chat/chat-area.tsx +45 -23
- package/src/components/chat/message-bubble.test.ts +35 -0
- package/src/components/chat/message-bubble.tsx +19 -9
- package/src/components/chat/message-list.tsx +37 -3
- package/src/components/input/chat-input.tsx +34 -14
- package/src/components/openclaw/openclaw-deploy-panel.tsx +4 -0
- package/src/instrumentation.ts +1 -1
- package/src/lib/chat/assistant-render-id.ts +3 -0
- package/src/lib/chat/chat-streaming-state.test.ts +42 -3
- package/src/lib/chat/chat-streaming-state.ts +20 -8
- package/src/lib/chat/queued-message-queue.test.ts +23 -1
- package/src/lib/chat/queued-message-queue.ts +11 -2
- package/src/lib/providers/cli-utils.test.ts +124 -0
- package/src/lib/server/activity/activity-log.ts +21 -0
- package/src/lib/server/agents/agent-availability.test.ts +10 -5
- package/src/lib/server/agents/agent-cascade.ts +79 -59
- package/src/lib/server/agents/agent-registry.ts +3 -1
- package/src/lib/server/agents/agent-repository.ts +90 -0
- package/src/lib/server/agents/delegation-job-repository.ts +53 -0
- package/src/lib/server/agents/delegation-jobs.ts +11 -4
- package/src/lib/server/agents/guardian-checkpoint-repository.ts +35 -0
- package/src/lib/server/agents/guardian.ts +2 -2
- package/src/lib/server/agents/main-agent-loop.ts +10 -3
- package/src/lib/server/agents/main-loop-state-repository.ts +38 -0
- package/src/lib/server/agents/subagent-runtime.ts +9 -6
- package/src/lib/server/agents/subagent-swarm.ts +3 -2
- package/src/lib/server/agents/task-session.ts +3 -4
- package/src/lib/server/approvals/approval-repository.ts +30 -0
- package/src/lib/server/autonomy/supervisor-incident-repository.ts +42 -0
- package/src/lib/server/chat-execution/chat-execution-types.ts +38 -0
- package/src/lib/server/chat-execution/chat-execution-utils.ts +1 -1
- package/src/lib/server/chat-execution/chat-execution.ts +84 -1926
- package/src/lib/server/chat-execution/chat-turn-finalization.ts +620 -0
- package/src/lib/server/chat-execution/chat-turn-partial-persistence.ts +221 -0
- package/src/lib/server/chat-execution/chat-turn-preflight.ts +133 -0
- package/src/lib/server/chat-execution/chat-turn-preparation.ts +817 -0
- package/src/lib/server/chat-execution/chat-turn-stream-execution.ts +296 -0
- package/src/lib/server/chat-execution/chat-turn-tool-routing.ts +5 -5
- package/src/lib/server/chat-execution/message-classifier.test.ts +329 -0
- package/src/lib/server/chat-execution/post-stream-finalization.ts +1 -1
- package/src/lib/server/chat-execution/prompt-builder.ts +11 -0
- package/src/lib/server/chat-execution/prompt-sections.ts +5 -6
- package/src/lib/server/chat-execution/situational-awareness.ts +12 -7
- package/src/lib/server/chat-execution/stream-agent-chat.ts +16 -13
- package/src/lib/server/chatrooms/chatroom-repository.ts +32 -0
- package/src/lib/server/connectors/connector-repository.ts +58 -0
- package/src/lib/server/connectors/runtime-state.test.ts +117 -0
- package/src/lib/server/credentials/credential-repository.ts +7 -0
- package/src/lib/server/gateways/gateway-profile-repository.ts +4 -0
- package/src/lib/server/memory/memory-abstract.test.ts +59 -0
- package/src/lib/server/missions/mission-repository.ts +74 -0
- package/src/lib/server/missions/mission-service/actions.ts +6 -0
- package/src/lib/server/missions/mission-service/bindings.ts +9 -0
- package/src/lib/server/missions/mission-service/context.ts +4 -0
- package/src/lib/server/missions/mission-service/core.ts +2269 -0
- package/src/lib/server/missions/mission-service/queries.ts +12 -0
- package/src/lib/server/missions/mission-service/recovery.ts +5 -0
- package/src/lib/server/missions/mission-service/ticks.ts +9 -0
- package/src/lib/server/missions/mission-service.test.ts +9 -2
- package/src/lib/server/missions/mission-service.ts +6 -2266
- package/src/lib/server/openclaw/deploy.test.ts +42 -3
- package/src/lib/server/openclaw/deploy.ts +26 -12
- package/src/lib/server/persistence/repository-utils.ts +154 -0
- package/src/lib/server/persistence/storage-context.ts +51 -0
- package/src/lib/server/persistence/transaction.ts +1 -0
- package/src/lib/server/projects/project-repository.ts +36 -0
- package/src/lib/server/projects/project-service.ts +79 -0
- package/src/lib/server/protocols/protocol-normalization.test.ts +6 -4
- package/src/lib/server/runtime/alert-dispatch.ts +1 -1
- package/src/lib/server/runtime/daemon-policy.ts +1 -1
- package/src/lib/server/runtime/daemon-state/core.ts +1570 -0
- package/src/lib/server/runtime/daemon-state/health.ts +6 -0
- package/src/lib/server/runtime/daemon-state/policy.ts +7 -0
- package/src/lib/server/runtime/daemon-state/supervisor.ts +6 -0
- package/src/lib/server/runtime/daemon-state.test.ts +48 -0
- package/src/lib/server/runtime/daemon-state.ts +3 -1470
- package/src/lib/server/runtime/estop-repository.ts +4 -0
- package/src/lib/server/runtime/estop.ts +3 -1
- package/src/lib/server/runtime/heartbeat-service.test.ts +2 -2
- package/src/lib/server/runtime/heartbeat-service.ts +55 -34
- package/src/lib/server/runtime/heartbeat-wake.ts +6 -4
- package/src/lib/server/runtime/idle-window.ts +2 -2
- package/src/lib/server/runtime/network.ts +11 -0
- package/src/lib/server/runtime/orchestrator-events.ts +2 -2
- package/src/lib/server/runtime/queue/claims.ts +4 -0
- package/src/lib/server/runtime/queue/core.ts +2079 -0
- package/src/lib/server/runtime/queue/execution.ts +7 -0
- package/src/lib/server/runtime/queue/followups.ts +4 -0
- package/src/lib/server/runtime/queue/queries.ts +12 -0
- package/src/lib/server/runtime/queue/recovery.ts +7 -0
- package/src/lib/server/runtime/queue-recovery.test.ts +48 -13
- package/src/lib/server/runtime/queue-repository.ts +17 -0
- package/src/lib/server/runtime/queue.ts +5 -2061
- package/src/lib/server/runtime/run-ledger.ts +6 -5
- package/src/lib/server/runtime/run-repository.ts +73 -0
- package/src/lib/server/runtime/runtime-lock-repository.ts +8 -0
- package/src/lib/server/runtime/runtime-settings.ts +1 -1
- package/src/lib/server/runtime/runtime-state.ts +99 -0
- package/src/lib/server/runtime/scheduler.ts +4 -2
- package/src/lib/server/runtime/session-run-manager/cancellation.ts +157 -0
- package/src/lib/server/runtime/session-run-manager/drain.ts +246 -0
- package/src/lib/server/runtime/session-run-manager/enqueue.ts +287 -0
- package/src/lib/server/runtime/session-run-manager/queries.ts +117 -0
- package/src/lib/server/runtime/session-run-manager/recovery.ts +238 -0
- package/src/lib/server/runtime/session-run-manager/state.ts +441 -0
- package/src/lib/server/runtime/session-run-manager/types.ts +74 -0
- package/src/lib/server/runtime/session-run-manager.ts +72 -1377
- package/src/lib/server/runtime/watch-job-repository.ts +35 -0
- package/src/lib/server/runtime/watch-jobs.ts +3 -1
- package/src/lib/server/schedules/schedule-repository.ts +42 -0
- package/src/lib/server/sessions/session-repository.ts +85 -0
- package/src/lib/server/settings/settings-repository.ts +25 -0
- package/src/lib/server/skills/skill-discovery.test.ts +2 -2
- package/src/lib/server/skills/skill-discovery.ts +2 -2
- package/src/lib/server/skills/skill-repository.ts +14 -0
- package/src/lib/server/storage.ts +13 -24
- package/src/lib/server/tasks/task-repository.ts +54 -0
- package/src/lib/server/usage/usage-repository.ts +30 -0
- package/src/lib/server/webhooks/webhook-repository.ts +10 -0
- package/src/lib/strip-internal-metadata.test.ts +42 -41
- package/src/stores/use-chat-store.test.ts +54 -0
- package/src/stores/use-chat-store.ts +21 -5
- /package/{bundled-skills → skills}/google-workspace/SKILL.md +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: resourceful-problem-solving
|
|
3
|
+
description: Always-on guidance for solving tasks resourcefully. Teaches agents to escalate through skills, CLI tools, and custom scripts instead of refusing. Applies to any request where the agent lacks a dedicated tool.
|
|
4
|
+
always: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Resourceful Problem Solving
|
|
8
|
+
|
|
9
|
+
When asked to do something and no dedicated tool exists, follow this escalation pattern:
|
|
10
|
+
|
|
11
|
+
## 1. Check Skills
|
|
12
|
+
|
|
13
|
+
Use `use_skill` to search for a matching skill. Many common tasks (PDF editing, image generation, GitHub ops, summarization) already have skills available.
|
|
14
|
+
|
|
15
|
+
## 2. Search for a CLI Tool
|
|
16
|
+
|
|
17
|
+
If no skill matches, check whether a CLI tool exists:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
which <tool> # already installed?
|
|
21
|
+
brew search <tool> # macOS
|
|
22
|
+
pip search <tool> # Python ecosystem
|
|
23
|
+
npm search <tool> # Node ecosystem
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If a suitable tool exists, install it and use it.
|
|
27
|
+
|
|
28
|
+
## 3. Write a Script
|
|
29
|
+
|
|
30
|
+
If no CLI tool fits, write a short script (Python, Node, or bash) to accomplish the task. Common patterns:
|
|
31
|
+
|
|
32
|
+
- **PDF creation**: Use Python `reportlab` or `fpdf2`
|
|
33
|
+
- **Image manipulation**: Use Python `Pillow`
|
|
34
|
+
- **Spreadsheets**: Use Python `openpyxl` or `csv`
|
|
35
|
+
- **Data conversion**: Use `jq`, `csvkit`, or a short Python script
|
|
36
|
+
- **Web scraping**: Use `curl` + parsing or Python `requests` + `beautifulsoup4`
|
|
37
|
+
|
|
38
|
+
Install dependencies as needed: `pip install <package>` or `npm install <package>`.
|
|
39
|
+
|
|
40
|
+
## 4. Save for Reuse
|
|
41
|
+
|
|
42
|
+
If the script solves a task that's likely to come up again, offer to save it as a reusable extension via the `extension_creator` tool.
|
|
43
|
+
|
|
44
|
+
## Rules
|
|
45
|
+
|
|
46
|
+
- Never refuse a task when shell tools are available. Attempt a code-based solution first.
|
|
47
|
+
- Only report inability after genuinely trying and failing.
|
|
48
|
+
- Prefer lightweight, well-known packages over complex bespoke solutions.
|
|
49
|
+
- Always verify the output before reporting success.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: skill-creator
|
|
3
|
+
description: Create, edit, improve, or audit skills for SwarmClaw agents. Use when creating a new skill from scratch or when asked to improve, review, audit, tidy up, or clean up an existing skill or SKILL.md file. Also use when editing or restructuring a skill directory. Triggers on phrases like "create a skill", "author a skill", "tidy up a skill", "improve this skill", "review the skill", "clean up the skill", "audit the skill".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill Creator
|
|
7
|
+
|
|
8
|
+
Guidance for creating effective skills that extend SwarmClaw agent capabilities.
|
|
9
|
+
|
|
10
|
+
## About Skills
|
|
11
|
+
|
|
12
|
+
Skills are modular, self-contained packages that provide specialized knowledge, workflows, and tools. They transform a general-purpose agent into a specialized one equipped with procedural knowledge that no model can fully possess.
|
|
13
|
+
|
|
14
|
+
### What Skills Provide
|
|
15
|
+
|
|
16
|
+
1. Specialized workflows — multi-step procedures for specific domains
|
|
17
|
+
2. Tool integrations — instructions for working with specific file formats or APIs
|
|
18
|
+
3. Domain expertise — company-specific knowledge, schemas, business logic
|
|
19
|
+
4. Bundled resources — scripts, references, and assets for complex and repetitive tasks
|
|
20
|
+
|
|
21
|
+
## Core Principles
|
|
22
|
+
|
|
23
|
+
### Concise is Key
|
|
24
|
+
|
|
25
|
+
The context window is a shared resource. Only add context the agent doesn't already have. Challenge each piece of information: "Does the agent really need this explanation?" Prefer concise examples over verbose explanations.
|
|
26
|
+
|
|
27
|
+
### Set Appropriate Degrees of Freedom
|
|
28
|
+
|
|
29
|
+
- **High freedom** (text instructions): Multiple valid approaches, context-dependent decisions
|
|
30
|
+
- **Medium freedom** (pseudocode/parameterized scripts): Preferred pattern exists, some variation OK
|
|
31
|
+
- **Low freedom** (specific scripts): Fragile operations, consistency critical, exact sequence required
|
|
32
|
+
|
|
33
|
+
### Anatomy of a Skill
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
skill-name/
|
|
37
|
+
├── SKILL.md (required)
|
|
38
|
+
│ ├── YAML frontmatter (name + description, required)
|
|
39
|
+
│ └── Markdown instructions (required)
|
|
40
|
+
└── Bundled Resources (optional)
|
|
41
|
+
├── scripts/ — Executable code (Python/Bash/etc.)
|
|
42
|
+
├── references/ — Documentation loaded into context as needed
|
|
43
|
+
└── assets/ — Files used in output (templates, icons, fonts)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Frontmatter
|
|
47
|
+
|
|
48
|
+
- `name`: Skill name (hyphen-case, lowercase)
|
|
49
|
+
- `description`: Primary triggering mechanism. Include what the skill does AND when to use it. All "when to use" info goes here — not in the body.
|
|
50
|
+
|
|
51
|
+
#### Scripts (`scripts/`)
|
|
52
|
+
|
|
53
|
+
Executable code for tasks that require deterministic reliability or are repeatedly rewritten. Token efficient and may be executed without loading into context.
|
|
54
|
+
|
|
55
|
+
#### References (`references/`)
|
|
56
|
+
|
|
57
|
+
Documentation loaded as needed to inform the agent's process. Keep only essential instructions in SKILL.md; move detailed reference material here.
|
|
58
|
+
|
|
59
|
+
#### Assets (`assets/`)
|
|
60
|
+
|
|
61
|
+
Files not loaded into context but used in output (templates, images, fonts). Separates output resources from documentation.
|
|
62
|
+
|
|
63
|
+
### What NOT to Include
|
|
64
|
+
|
|
65
|
+
- README.md, CHANGELOG.md, INSTALLATION_GUIDE.md, or other auxiliary docs
|
|
66
|
+
- Setup/testing procedures or user-facing documentation
|
|
67
|
+
- Information the agent already knows from general training
|
|
68
|
+
|
|
69
|
+
## Skill Creation Process
|
|
70
|
+
|
|
71
|
+
1. Understand the skill with concrete examples
|
|
72
|
+
2. Plan reusable contents (scripts, references, assets)
|
|
73
|
+
3. Initialize the skill
|
|
74
|
+
4. Edit the skill (implement resources, write SKILL.md)
|
|
75
|
+
5. Validate the skill
|
|
76
|
+
6. Iterate based on real usage
|
|
77
|
+
|
|
78
|
+
### Skill Naming
|
|
79
|
+
|
|
80
|
+
- Lowercase letters, digits, and hyphens only (hyphen-case)
|
|
81
|
+
- Under 64 characters
|
|
82
|
+
- Prefer short, verb-led phrases describing the action
|
|
83
|
+
- Name the skill folder exactly after the skill name
|
|
84
|
+
|
|
85
|
+
### Step 1: Understanding with Concrete Examples
|
|
86
|
+
|
|
87
|
+
Ask the user clarifying questions:
|
|
88
|
+
|
|
89
|
+
- What functionality should the skill support?
|
|
90
|
+
- Can you give examples of how it would be used?
|
|
91
|
+
- What would a user say that should trigger this skill?
|
|
92
|
+
|
|
93
|
+
### Step 2: Planning Reusable Contents
|
|
94
|
+
|
|
95
|
+
Analyze each example to identify what scripts, references, and assets would be helpful:
|
|
96
|
+
|
|
97
|
+
- **Repeated code** → `scripts/` (e.g., `scripts/rotate_pdf.py`)
|
|
98
|
+
- **Boilerplate** → `assets/` (e.g., `assets/hello-world/` template)
|
|
99
|
+
- **Domain knowledge** → `references/` (e.g., `references/schema.md`)
|
|
100
|
+
|
|
101
|
+
### Step 3: Initializing the Skill
|
|
102
|
+
|
|
103
|
+
Use the bundled init script to create the directory structure:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
python3 {baseDir}/scripts/init_skill.py <skill-name> --path <output-directory> [--resources scripts,references,assets] [--examples]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Examples:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
python3 {baseDir}/scripts/init_skill.py my-skill --path skills
|
|
113
|
+
python3 {baseDir}/scripts/init_skill.py my-skill --path skills --resources scripts,references
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Step 4: Edit the Skill
|
|
117
|
+
|
|
118
|
+
Write instructions that would help another agent instance execute tasks effectively. Include information that is beneficial and non-obvious.
|
|
119
|
+
|
|
120
|
+
**Writing guidelines:** Use imperative/infinitive form. Keep SKILL.md body under 500 lines.
|
|
121
|
+
|
|
122
|
+
**Frontmatter description:** Include both what the skill does and specific triggers for when to use it. This is the primary mechanism for skill selection.
|
|
123
|
+
|
|
124
|
+
### Step 5: Validate the Skill
|
|
125
|
+
|
|
126
|
+
Run the validator to check structure and frontmatter:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
python3 {baseDir}/scripts/quick_validate.py <path/to/skill-folder>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Step 6: Iterate
|
|
133
|
+
|
|
134
|
+
1. Use the skill on real tasks
|
|
135
|
+
2. Notice struggles or inefficiencies
|
|
136
|
+
3. Update SKILL.md or bundled resources
|
|
137
|
+
4. Test again
|
|
138
|
+
|
|
139
|
+
## Progressive Disclosure
|
|
140
|
+
|
|
141
|
+
Skills use a three-level loading system:
|
|
142
|
+
|
|
143
|
+
1. **Metadata** (name + description) — always in context (~100 words)
|
|
144
|
+
2. **SKILL.md body** — when skill triggers (<5k words)
|
|
145
|
+
3. **Bundled resources** — as needed (unlimited, since scripts can be executed without reading)
|
|
146
|
+
|
|
147
|
+
Keep SKILL.md lean. Move detailed information to reference files and describe clearly when to read them.
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Skill Initializer - Creates a new skill from template
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
init_skill.py <skill-name> --path <path> [--resources scripts,references,assets] [--examples]
|
|
7
|
+
|
|
8
|
+
Examples:
|
|
9
|
+
init_skill.py my-new-skill --path skills/public
|
|
10
|
+
init_skill.py my-new-skill --path skills/public --resources scripts,references
|
|
11
|
+
init_skill.py my-api-helper --path skills/private --resources scripts --examples
|
|
12
|
+
init_skill.py custom-skill --path /custom/location
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import re
|
|
17
|
+
import sys
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
MAX_SKILL_NAME_LENGTH = 64
|
|
21
|
+
ALLOWED_RESOURCES = {"scripts", "references", "assets"}
|
|
22
|
+
|
|
23
|
+
SKILL_TEMPLATE = """---
|
|
24
|
+
name: {skill_name}
|
|
25
|
+
description: [TODO: Complete and informative explanation of what the skill does and when to use it. Include WHEN to use this skill - specific scenarios, file types, or tasks that trigger it.]
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# {skill_title}
|
|
29
|
+
|
|
30
|
+
## Overview
|
|
31
|
+
|
|
32
|
+
[TODO: 1-2 sentences explaining what this skill enables]
|
|
33
|
+
|
|
34
|
+
## Structuring This Skill
|
|
35
|
+
|
|
36
|
+
[TODO: Choose the structure that best fits this skill's purpose. Common patterns:
|
|
37
|
+
|
|
38
|
+
**1. Workflow-Based** (best for sequential processes)
|
|
39
|
+
- Works well when there are clear step-by-step procedures
|
|
40
|
+
- Example: DOCX skill with "Workflow Decision Tree" -> "Reading" -> "Creating" -> "Editing"
|
|
41
|
+
- Structure: ## Overview -> ## Workflow Decision Tree -> ## Step 1 -> ## Step 2...
|
|
42
|
+
|
|
43
|
+
**2. Task-Based** (best for tool collections)
|
|
44
|
+
- Works well when the skill offers different operations/capabilities
|
|
45
|
+
- Example: PDF skill with "Quick Start" -> "Merge PDFs" -> "Split PDFs" -> "Extract Text"
|
|
46
|
+
- Structure: ## Overview -> ## Quick Start -> ## Task Category 1 -> ## Task Category 2...
|
|
47
|
+
|
|
48
|
+
**3. Reference/Guidelines** (best for standards or specifications)
|
|
49
|
+
- Works well for brand guidelines, coding standards, or requirements
|
|
50
|
+
- Example: Brand styling with "Brand Guidelines" -> "Colors" -> "Typography" -> "Features"
|
|
51
|
+
- Structure: ## Overview -> ## Guidelines -> ## Specifications -> ## Usage...
|
|
52
|
+
|
|
53
|
+
**4. Capabilities-Based** (best for integrated systems)
|
|
54
|
+
- Works well when the skill provides multiple interrelated features
|
|
55
|
+
- Example: Product Management with "Core Capabilities" -> numbered capability list
|
|
56
|
+
- Structure: ## Overview -> ## Core Capabilities -> ### 1. Feature -> ### 2. Feature...
|
|
57
|
+
|
|
58
|
+
Patterns can be mixed and matched as needed. Most skills combine patterns (e.g., start with task-based, add workflow for complex operations).
|
|
59
|
+
|
|
60
|
+
Delete this entire "Structuring This Skill" section when done - it's just guidance.]
|
|
61
|
+
|
|
62
|
+
## [TODO: Replace with the first main section based on chosen structure]
|
|
63
|
+
|
|
64
|
+
[TODO: Add content here. See examples in existing skills:
|
|
65
|
+
- Code samples for technical skills
|
|
66
|
+
- Decision trees for complex workflows
|
|
67
|
+
- Concrete examples with realistic user requests
|
|
68
|
+
- References to scripts/templates/references as needed]
|
|
69
|
+
|
|
70
|
+
## Resources (optional)
|
|
71
|
+
|
|
72
|
+
Create only the resource directories this skill actually needs. Delete this section if no resources are required.
|
|
73
|
+
|
|
74
|
+
### scripts/
|
|
75
|
+
Executable code (Python/Bash/etc.) that can be run directly to perform specific operations.
|
|
76
|
+
|
|
77
|
+
**Examples from other skills:**
|
|
78
|
+
- PDF skill: `fill_fillable_fields.py`, `extract_form_field_info.py` - utilities for PDF manipulation
|
|
79
|
+
- DOCX skill: `document.py`, `utilities.py` - Python modules for document processing
|
|
80
|
+
|
|
81
|
+
**Appropriate for:** Python scripts, shell scripts, or any executable code that performs automation, data processing, or specific operations.
|
|
82
|
+
|
|
83
|
+
**Note:** Scripts may be executed without loading into context, but can still be read by Codex for patching or environment adjustments.
|
|
84
|
+
|
|
85
|
+
### references/
|
|
86
|
+
Documentation and reference material intended to be loaded into context to inform Codex's process and thinking.
|
|
87
|
+
|
|
88
|
+
**Examples from other skills:**
|
|
89
|
+
- Product management: `communication.md`, `context_building.md` - detailed workflow guides
|
|
90
|
+
- BigQuery: API reference documentation and query examples
|
|
91
|
+
- Finance: Schema documentation, company policies
|
|
92
|
+
|
|
93
|
+
**Appropriate for:** In-depth documentation, API references, database schemas, comprehensive guides, or any detailed information that Codex should reference while working.
|
|
94
|
+
|
|
95
|
+
### assets/
|
|
96
|
+
Files not intended to be loaded into context, but rather used within the output Codex produces.
|
|
97
|
+
|
|
98
|
+
**Examples from other skills:**
|
|
99
|
+
- Brand styling: PowerPoint template files (.pptx), logo files
|
|
100
|
+
- Frontend builder: HTML/React boilerplate project directories
|
|
101
|
+
- Typography: Font files (.ttf, .woff2)
|
|
102
|
+
|
|
103
|
+
**Appropriate for:** Templates, boilerplate code, document templates, images, icons, fonts, or any files meant to be copied or used in the final output.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
**Not every skill requires all three types of resources.**
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
EXAMPLE_SCRIPT = '''#!/usr/bin/env python3
|
|
111
|
+
"""
|
|
112
|
+
Example helper script for {skill_name}
|
|
113
|
+
|
|
114
|
+
This is a placeholder script that can be executed directly.
|
|
115
|
+
Replace with actual implementation or delete if not needed.
|
|
116
|
+
|
|
117
|
+
Example real scripts from other skills:
|
|
118
|
+
- pdf/scripts/fill_fillable_fields.py - Fills PDF form fields
|
|
119
|
+
- pdf/scripts/convert_pdf_to_images.py - Converts PDF pages to images
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
def main():
|
|
123
|
+
print("This is an example script for {skill_name}")
|
|
124
|
+
# TODO: Add actual script logic here
|
|
125
|
+
# This could be data processing, file conversion, API calls, etc.
|
|
126
|
+
|
|
127
|
+
if __name__ == "__main__":
|
|
128
|
+
main()
|
|
129
|
+
'''
|
|
130
|
+
|
|
131
|
+
EXAMPLE_REFERENCE = """# Reference Documentation for {skill_title}
|
|
132
|
+
|
|
133
|
+
This is a placeholder for detailed reference documentation.
|
|
134
|
+
Replace with actual reference content or delete if not needed.
|
|
135
|
+
|
|
136
|
+
Example real reference docs from other skills:
|
|
137
|
+
- product-management/references/communication.md - Comprehensive guide for status updates
|
|
138
|
+
- product-management/references/context_building.md - Deep-dive on gathering context
|
|
139
|
+
- bigquery/references/ - API references and query examples
|
|
140
|
+
|
|
141
|
+
## When Reference Docs Are Useful
|
|
142
|
+
|
|
143
|
+
Reference docs are ideal for:
|
|
144
|
+
- Comprehensive API documentation
|
|
145
|
+
- Detailed workflow guides
|
|
146
|
+
- Complex multi-step processes
|
|
147
|
+
- Information too lengthy for main SKILL.md
|
|
148
|
+
- Content that's only needed for specific use cases
|
|
149
|
+
|
|
150
|
+
## Structure Suggestions
|
|
151
|
+
|
|
152
|
+
### API Reference Example
|
|
153
|
+
- Overview
|
|
154
|
+
- Authentication
|
|
155
|
+
- Endpoints with examples
|
|
156
|
+
- Error codes
|
|
157
|
+
- Rate limits
|
|
158
|
+
|
|
159
|
+
### Workflow Guide Example
|
|
160
|
+
- Prerequisites
|
|
161
|
+
- Step-by-step instructions
|
|
162
|
+
- Common patterns
|
|
163
|
+
- Troubleshooting
|
|
164
|
+
- Best practices
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
EXAMPLE_ASSET = """# Example Asset File
|
|
168
|
+
|
|
169
|
+
This placeholder represents where asset files would be stored.
|
|
170
|
+
Replace with actual asset files (templates, images, fonts, etc.) or delete if not needed.
|
|
171
|
+
|
|
172
|
+
Asset files are NOT intended to be loaded into context, but rather used within
|
|
173
|
+
the output Codex produces.
|
|
174
|
+
|
|
175
|
+
Example asset files from other skills:
|
|
176
|
+
- Brand guidelines: logo.png, slides_template.pptx
|
|
177
|
+
- Frontend builder: hello-world/ directory with HTML/React boilerplate
|
|
178
|
+
- Typography: custom-font.ttf, font-family.woff2
|
|
179
|
+
- Data: sample_data.csv, test_dataset.json
|
|
180
|
+
|
|
181
|
+
## Common Asset Types
|
|
182
|
+
|
|
183
|
+
- Templates: .pptx, .docx, boilerplate directories
|
|
184
|
+
- Images: .png, .jpg, .svg, .gif
|
|
185
|
+
- Fonts: .ttf, .otf, .woff, .woff2
|
|
186
|
+
- Boilerplate code: Project directories, starter files
|
|
187
|
+
- Icons: .ico, .svg
|
|
188
|
+
- Data files: .csv, .json, .xml, .yaml
|
|
189
|
+
|
|
190
|
+
Note: This is a text placeholder. Actual assets can be any file type.
|
|
191
|
+
"""
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def normalize_skill_name(skill_name):
|
|
195
|
+
"""Normalize a skill name to lowercase hyphen-case."""
|
|
196
|
+
normalized = skill_name.strip().lower()
|
|
197
|
+
normalized = re.sub(r"[^a-z0-9]+", "-", normalized)
|
|
198
|
+
normalized = normalized.strip("-")
|
|
199
|
+
normalized = re.sub(r"-{2,}", "-", normalized)
|
|
200
|
+
return normalized
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def title_case_skill_name(skill_name):
|
|
204
|
+
"""Convert hyphenated skill name to Title Case for display."""
|
|
205
|
+
return " ".join(word.capitalize() for word in skill_name.split("-"))
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def parse_resources(raw_resources):
|
|
209
|
+
if not raw_resources:
|
|
210
|
+
return []
|
|
211
|
+
resources = [item.strip() for item in raw_resources.split(",") if item.strip()]
|
|
212
|
+
invalid = sorted({item for item in resources if item not in ALLOWED_RESOURCES})
|
|
213
|
+
if invalid:
|
|
214
|
+
allowed = ", ".join(sorted(ALLOWED_RESOURCES))
|
|
215
|
+
print(f"[ERROR] Unknown resource type(s): {', '.join(invalid)}")
|
|
216
|
+
print(f" Allowed: {allowed}")
|
|
217
|
+
sys.exit(1)
|
|
218
|
+
deduped = []
|
|
219
|
+
seen = set()
|
|
220
|
+
for resource in resources:
|
|
221
|
+
if resource not in seen:
|
|
222
|
+
deduped.append(resource)
|
|
223
|
+
seen.add(resource)
|
|
224
|
+
return deduped
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def create_resource_dirs(skill_dir, skill_name, skill_title, resources, include_examples):
|
|
228
|
+
for resource in resources:
|
|
229
|
+
resource_dir = skill_dir / resource
|
|
230
|
+
resource_dir.mkdir(exist_ok=True)
|
|
231
|
+
if resource == "scripts":
|
|
232
|
+
if include_examples:
|
|
233
|
+
example_script = resource_dir / "example.py"
|
|
234
|
+
example_script.write_text(EXAMPLE_SCRIPT.format(skill_name=skill_name))
|
|
235
|
+
example_script.chmod(0o755)
|
|
236
|
+
print("[OK] Created scripts/example.py")
|
|
237
|
+
else:
|
|
238
|
+
print("[OK] Created scripts/")
|
|
239
|
+
elif resource == "references":
|
|
240
|
+
if include_examples:
|
|
241
|
+
example_reference = resource_dir / "api_reference.md"
|
|
242
|
+
example_reference.write_text(EXAMPLE_REFERENCE.format(skill_title=skill_title))
|
|
243
|
+
print("[OK] Created references/api_reference.md")
|
|
244
|
+
else:
|
|
245
|
+
print("[OK] Created references/")
|
|
246
|
+
elif resource == "assets":
|
|
247
|
+
if include_examples:
|
|
248
|
+
example_asset = resource_dir / "example_asset.txt"
|
|
249
|
+
example_asset.write_text(EXAMPLE_ASSET)
|
|
250
|
+
print("[OK] Created assets/example_asset.txt")
|
|
251
|
+
else:
|
|
252
|
+
print("[OK] Created assets/")
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def init_skill(skill_name, path, resources, include_examples):
|
|
256
|
+
"""
|
|
257
|
+
Initialize a new skill directory with template SKILL.md.
|
|
258
|
+
|
|
259
|
+
Args:
|
|
260
|
+
skill_name: Name of the skill
|
|
261
|
+
path: Path where the skill directory should be created
|
|
262
|
+
resources: Resource directories to create
|
|
263
|
+
include_examples: Whether to create example files in resource directories
|
|
264
|
+
|
|
265
|
+
Returns:
|
|
266
|
+
Path to created skill directory, or None if error
|
|
267
|
+
"""
|
|
268
|
+
# Determine skill directory path
|
|
269
|
+
skill_dir = Path(path).resolve() / skill_name
|
|
270
|
+
|
|
271
|
+
# Check if directory already exists
|
|
272
|
+
if skill_dir.exists():
|
|
273
|
+
print(f"[ERROR] Skill directory already exists: {skill_dir}")
|
|
274
|
+
return None
|
|
275
|
+
|
|
276
|
+
# Create skill directory
|
|
277
|
+
try:
|
|
278
|
+
skill_dir.mkdir(parents=True, exist_ok=False)
|
|
279
|
+
print(f"[OK] Created skill directory: {skill_dir}")
|
|
280
|
+
except Exception as e:
|
|
281
|
+
print(f"[ERROR] Error creating directory: {e}")
|
|
282
|
+
return None
|
|
283
|
+
|
|
284
|
+
# Create SKILL.md from template
|
|
285
|
+
skill_title = title_case_skill_name(skill_name)
|
|
286
|
+
skill_content = SKILL_TEMPLATE.format(skill_name=skill_name, skill_title=skill_title)
|
|
287
|
+
|
|
288
|
+
skill_md_path = skill_dir / "SKILL.md"
|
|
289
|
+
try:
|
|
290
|
+
skill_md_path.write_text(skill_content)
|
|
291
|
+
print("[OK] Created SKILL.md")
|
|
292
|
+
except Exception as e:
|
|
293
|
+
print(f"[ERROR] Error creating SKILL.md: {e}")
|
|
294
|
+
return None
|
|
295
|
+
|
|
296
|
+
# Create resource directories if requested
|
|
297
|
+
if resources:
|
|
298
|
+
try:
|
|
299
|
+
create_resource_dirs(skill_dir, skill_name, skill_title, resources, include_examples)
|
|
300
|
+
except Exception as e:
|
|
301
|
+
print(f"[ERROR] Error creating resource directories: {e}")
|
|
302
|
+
return None
|
|
303
|
+
|
|
304
|
+
# Print next steps
|
|
305
|
+
print(f"\n[OK] Skill '{skill_name}' initialized successfully at {skill_dir}")
|
|
306
|
+
print("\nNext steps:")
|
|
307
|
+
print("1. Edit SKILL.md to complete the TODO items and update the description")
|
|
308
|
+
if resources:
|
|
309
|
+
if include_examples:
|
|
310
|
+
print("2. Customize or delete the example files in scripts/, references/, and assets/")
|
|
311
|
+
else:
|
|
312
|
+
print("2. Add resources to scripts/, references/, and assets/ as needed")
|
|
313
|
+
else:
|
|
314
|
+
print("2. Create resource directories only if needed (scripts/, references/, assets/)")
|
|
315
|
+
print("3. Run the validator when ready to check the skill structure")
|
|
316
|
+
|
|
317
|
+
return skill_dir
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def main():
|
|
321
|
+
parser = argparse.ArgumentParser(
|
|
322
|
+
description="Create a new skill directory with a SKILL.md template.",
|
|
323
|
+
)
|
|
324
|
+
parser.add_argument("skill_name", help="Skill name (normalized to hyphen-case)")
|
|
325
|
+
parser.add_argument("--path", required=True, help="Output directory for the skill")
|
|
326
|
+
parser.add_argument(
|
|
327
|
+
"--resources",
|
|
328
|
+
default="",
|
|
329
|
+
help="Comma-separated list: scripts,references,assets",
|
|
330
|
+
)
|
|
331
|
+
parser.add_argument(
|
|
332
|
+
"--examples",
|
|
333
|
+
action="store_true",
|
|
334
|
+
help="Create example files inside the selected resource directories",
|
|
335
|
+
)
|
|
336
|
+
args = parser.parse_args()
|
|
337
|
+
|
|
338
|
+
raw_skill_name = args.skill_name
|
|
339
|
+
skill_name = normalize_skill_name(raw_skill_name)
|
|
340
|
+
if not skill_name:
|
|
341
|
+
print("[ERROR] Skill name must include at least one letter or digit.")
|
|
342
|
+
sys.exit(1)
|
|
343
|
+
if len(skill_name) > MAX_SKILL_NAME_LENGTH:
|
|
344
|
+
print(
|
|
345
|
+
f"[ERROR] Skill name '{skill_name}' is too long ({len(skill_name)} characters). "
|
|
346
|
+
f"Maximum is {MAX_SKILL_NAME_LENGTH} characters."
|
|
347
|
+
)
|
|
348
|
+
sys.exit(1)
|
|
349
|
+
if skill_name != raw_skill_name:
|
|
350
|
+
print(f"Note: Normalized skill name from '{raw_skill_name}' to '{skill_name}'.")
|
|
351
|
+
|
|
352
|
+
resources = parse_resources(args.resources)
|
|
353
|
+
if args.examples and not resources:
|
|
354
|
+
print("[ERROR] --examples requires --resources to be set.")
|
|
355
|
+
sys.exit(1)
|
|
356
|
+
|
|
357
|
+
path = args.path
|
|
358
|
+
|
|
359
|
+
print(f"Initializing skill: {skill_name}")
|
|
360
|
+
print(f" Location: {path}")
|
|
361
|
+
if resources:
|
|
362
|
+
print(f" Resources: {', '.join(resources)}")
|
|
363
|
+
if args.examples:
|
|
364
|
+
print(" Examples: enabled")
|
|
365
|
+
else:
|
|
366
|
+
print(" Resources: none (create as needed)")
|
|
367
|
+
print()
|
|
368
|
+
|
|
369
|
+
result = init_skill(skill_name, path, resources, args.examples)
|
|
370
|
+
|
|
371
|
+
if result:
|
|
372
|
+
sys.exit(0)
|
|
373
|
+
else:
|
|
374
|
+
sys.exit(1)
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
if __name__ == "__main__":
|
|
378
|
+
main()
|