@musashishao/agent-kit 1.0.1 → 1.1.1
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/.agent/ARCHITECTURE.md +2 -2
- package/.agent/CONTEXT.md +3 -3
- package/.agent/FEATURE_ROADMAP.md +37 -37
- package/.agent/PROMPT_TEMPLATES.md +8 -8
- package/.agent/plans/codex-cli-integration.md +338 -0
- package/.agent/plans/rename-to-agent-kit.md +40 -0
- package/.agent/skills/context-engineering/SKILL.md +74 -0
- package/.agent/skills/context-engineering/examples/advanced_code_request.md +73 -0
- package/.agent/skills/context-engineering/scripts/repo_mapper.py +27 -0
- package/.agent/skills/context-engineering/scripts/token_counter.py +65 -0
- package/.agent/skills/context-engineering/strategies/context-caching.md +50 -0
- package/.agent/skills/context-engineering/strategies/few-shot-examples.md +56 -0
- package/.agent/skills/context-engineering/strategies/skeleton-code.md +59 -0
- package/.agent/skills/context-engineering/strategies/xml-framing.md +57 -0
- package/.agent/skills/doc.md +5 -5
- package/.agent/workflows/context.md +47 -0
- package/README.md +1 -1
- package/bin/cli.js +77 -6
- package/package.json +2 -2
package/.agent/ARCHITECTURE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agent Kit Architecture
|
|
2
2
|
|
|
3
3
|
> **Version 5.0** - Comprehensive AI Agent Capability Expansion Toolkit
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## 📋 Overview
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Agent Kit is a modular system consisting of:
|
|
10
10
|
- **16 Specialist Agents** - Role-based AI personas
|
|
11
11
|
- **40 Skills** - Domain-specific knowledge modules
|
|
12
12
|
- **11 Workflows** - Slash command procedures
|
package/.agent/CONTEXT.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agent Kit - AI Development Context
|
|
2
2
|
|
|
3
3
|
> **Version:** 2.0.0
|
|
4
4
|
> **Last Updated:** 2026-01-21
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
## 🎯 Project Overview
|
|
10
10
|
|
|
11
|
-
**
|
|
11
|
+
**Agent Kit** là một bộ AI Agent templates bao gồm Skills, Agents, và Workflows để tăng cường khả năng của AI coding assistants.
|
|
12
12
|
|
|
13
13
|
### Tech Stack
|
|
14
14
|
| Layer | Technology |
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
### Project Structure
|
|
24
24
|
```
|
|
25
|
-
|
|
25
|
+
agent-kit/
|
|
26
26
|
├── .agent/ # 🧠 AI Agent System (CORE)
|
|
27
27
|
│ ├── agents/ # 16 Specialist Agents
|
|
28
28
|
│ ├── skills/ # 40 Domain Skills
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# 🚀 Feature Roadmap -
|
|
1
|
+
# 🚀 Feature Roadmap - Agent Kit
|
|
2
2
|
|
|
3
3
|
> Nghiên cứu từ: ClaudeKit, Claude Code, Task Master, Cursor Rules, và các AI Agent frameworks 2025
|
|
4
4
|
> Ngày tạo: 2026-01-21
|
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
|
|
8
8
|
## 📊 So Sánh Với Đối Thủ
|
|
9
9
|
|
|
10
|
-
| Feature | ClaudeKit | Task Master | Claude Code | **
|
|
10
|
+
| Feature | ClaudeKit | Task Master | Claude Code | **Agent Kit** |
|
|
11
11
|
|---------|-----------|-------------|-------------|---------------------|
|
|
12
12
|
| Skills/Agents | 50+ skills, 45 agents | Task-focused | Plugins | 40 skills, 16 agents |
|
|
13
13
|
| Marketplace | ✅ Plugin marketplace | ✅ npm package | ✅ Plugins dir | ❌ Manual install |
|
|
14
|
-
| MCP Support | ✅ mcp-builder, mcp-management | ✅ MCP integration | ✅ Built-in |
|
|
15
|
-
| CLI Tool | ❌ | ✅ task-master CLI | ✅ claude CLI | ⚠️ Basic (
|
|
14
|
+
| MCP Support | ✅ mcp-builder, mcp-management | ✅ MCP integration | ✅ Built-in | ✅ mcp-builder skill |
|
|
15
|
+
| CLI Tool | ❌ | ✅ task-master CLI | ✅ claude CLI | ⚠️ Basic (agent-kit) |
|
|
16
16
|
| Task Management | ❌ | ✅ (Core feature) | ⚠️ Basic | ❌ Missing |
|
|
17
17
|
| Web UI/Dashboard | ❌ | ❌ | ❌ | ⚠️ Docs only |
|
|
18
18
|
| Multi-AI Support | ✅ Claude-focused | ✅ Any AI chat | ✅ Claude only | ✅ Gemini + others |
|
|
19
|
-
| Problem-Solving Skills | ✅ 6 frameworks | ❌ | ❌ |
|
|
19
|
+
| Problem-Solving Skills | ✅ 6 frameworks | ❌ | ❌ | ✅ 6 frameworks used |
|
|
20
20
|
| Marketing Skills | ✅ 28 agents | ❌ | ❌ | ❌ Missing |
|
|
21
21
|
|
|
22
22
|
---
|
|
@@ -52,24 +52,24 @@ Thêm:
|
|
|
52
52
|
### 1.2 📦 Plugin Marketplace System
|
|
53
53
|
**Thấy ở:** ClaudeKit, Claude Code plugins
|
|
54
54
|
|
|
55
|
-
**Hiện tại:** `npx @vudovn/
|
|
55
|
+
**Hiện tại:** `npx @vudovn/agent-kit init` chỉ install tất cả
|
|
56
56
|
|
|
57
57
|
**Đề xuất:**
|
|
58
58
|
```bash
|
|
59
59
|
# Selective install
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
agent-kit install skill:react-patterns
|
|
61
|
+
agent-kit install agent:frontend-specialist
|
|
62
|
+
agent-kit install workflow:debug
|
|
63
63
|
|
|
64
64
|
# Marketplace commands
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
agent-kit search "database"
|
|
66
|
+
agent-kit list --installed
|
|
67
|
+
agent-kit update
|
|
68
68
|
|
|
69
69
|
# Plugin bundles
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
agent-kit install bundle:web-dev # React + Next.js + Tailwind
|
|
71
|
+
agent-kit install bundle:backend # API + Database + DevOps
|
|
72
|
+
agent-kit install bundle:mobile # React Native + Flutter
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
**Lợi ích:**
|
|
@@ -264,36 +264,36 @@ agents/
|
|
|
264
264
|
|
|
265
265
|
### Hiện tại:
|
|
266
266
|
```bash
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
agent-kit init
|
|
268
|
+
agent-kit update
|
|
269
|
+
agent-kit status
|
|
270
270
|
```
|
|
271
271
|
|
|
272
272
|
### Đề xuất thêm:
|
|
273
273
|
```bash
|
|
274
274
|
# Skill management
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
275
|
+
agent-kit skills list # List all available skills
|
|
276
|
+
agent-kit skills search "api" # Search skills
|
|
277
|
+
agent-kit skills install <name> # Install specific skill
|
|
278
|
+
agent-kit skills remove <name> # Remove skill
|
|
279
|
+
agent-kit skills update # Update installed skills
|
|
280
280
|
|
|
281
281
|
# Agent management
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
agent-kit agents list
|
|
283
|
+
agent-kit agents info <name> # Show agent details
|
|
284
284
|
|
|
285
285
|
# Workflow management
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
agent-kit workflows list
|
|
287
|
+
agent-kit workflows run <name> # Run workflow programmatically
|
|
288
288
|
|
|
289
289
|
# Project analysis
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
agent-kit analyze # Analyze project, suggest skills
|
|
291
|
+
agent-kit doctor # Check configuration issues
|
|
292
|
+
agent-kit stats # Show usage statistics
|
|
293
293
|
|
|
294
294
|
# Export/Share
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
agent-kit export skill <name> # Export skill as standalone
|
|
296
|
+
agent-kit share # Share config to team
|
|
297
297
|
```
|
|
298
298
|
|
|
299
299
|
---
|
|
@@ -410,11 +410,11 @@ compatible_with:
|
|
|
410
410
|
|
|
411
411
|
## 🎯 Quick Wins (< 1 day each)
|
|
412
412
|
|
|
413
|
-
1. **Add `mcp-builder` skill** - Port từ ClaudeKit
|
|
414
|
-
2. **Add problem-solving skills** (6 frameworks)
|
|
413
|
+
1. **Add `mcp-builder` skill** - Port từ ClaudeKit ✅ Done
|
|
414
|
+
2. **Add problem-solving skills** (6 frameworks) ✅ Done
|
|
415
415
|
3. **Add `mermaidjs` skill** for diagrams
|
|
416
|
-
4. **Add `context-engineering` skill**
|
|
417
|
-
5. **Improve CLI với `
|
|
416
|
+
4. **Add `context-engineering` skill** ✅ Done
|
|
417
|
+
5. **Improve CLI với `agent-kit skills list`**
|
|
418
418
|
6. **Add `/task` workflow** cho task management
|
|
419
419
|
|
|
420
420
|
---
|
|
@@ -428,7 +428,7 @@ compatible_with:
|
|
|
428
428
|
|
|
429
429
|
---
|
|
430
430
|
|
|
431
|
-
> **Kết luận:**
|
|
431
|
+
> **Kết luận:** Agent Kit có foundation tốt với 40 skills và 16 agents. Để cạnh tranh với ClaudeKit và Task Master, cần tập trung vào:
|
|
432
432
|
> 1. **MCP Support** (must have 2025)
|
|
433
433
|
> 2. **Plugin Marketplace** (selective install)
|
|
434
434
|
> 3. **Task Management** (workflow productivity)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# 🎯 Prompt Templates cho
|
|
1
|
+
# 🎯 Prompt Templates cho agent Kit
|
|
2
2
|
|
|
3
3
|
> Copy-paste các prompt mẫu bên dưới để sử dụng với AI Agent
|
|
4
4
|
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
## 📌 PROMPT 1: Context Khởi Đầu (Dùng mỗi session mới)
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
Tôi đang phát triển dự án
|
|
10
|
+
Tôi đang phát triển dự án agent Kit - một bộ AI Agent templates.
|
|
11
11
|
|
|
12
12
|
## Project Info
|
|
13
|
-
- **Repo:**
|
|
13
|
+
- **Repo:** agent-kit
|
|
14
14
|
- **Tech:** Next.js 16.1.3, React 19, TypeScript, Tailwind CSS 4
|
|
15
15
|
- **Structure:**
|
|
16
16
|
- `.agent/` = AI Agent templates (16 agents, 40 skills, 11 workflows)
|
|
@@ -37,7 +37,7 @@ Hãy đọc file `.agent/CONTEXT.md` để hiểu đầy đủ context của d
|
|
|
37
37
|
## 📌 PROMPT 2: Thêm Feature Mới
|
|
38
38
|
|
|
39
39
|
```
|
|
40
|
-
Tôi muốn thêm feature mới vào
|
|
40
|
+
Tôi muốn thêm feature mới vào agent Kit.
|
|
41
41
|
|
|
42
42
|
## Feature: [TÊN FEATURE]
|
|
43
43
|
|
|
@@ -66,7 +66,7 @@ Hãy implement theo đúng code style của project (xem `.agent/CONTEXT.md`).
|
|
|
66
66
|
## 📌 PROMPT 3: Fix Bug / Debug
|
|
67
67
|
|
|
68
68
|
```
|
|
69
|
-
Tôi gặp bug trong
|
|
69
|
+
Tôi gặp bug trong agent Kit.
|
|
70
70
|
|
|
71
71
|
## Bug Description
|
|
72
72
|
[Mô tả bug]
|
|
@@ -179,7 +179,7 @@ Format xem: `.agent/ARCHITECTURE.md`
|
|
|
179
179
|
## 📌 PROMPT 7: Code Review
|
|
180
180
|
|
|
181
181
|
```
|
|
182
|
-
Hãy review code của tôi cho
|
|
182
|
+
Hãy review code của tôi cho agent Kit.
|
|
183
183
|
|
|
184
184
|
## Files to Review
|
|
185
185
|
- `[file1]`
|
|
@@ -201,7 +201,7 @@ Checklist xem: `.agent/skills/code-review-checklist/SKILL.md`
|
|
|
201
201
|
## 📌 PROMPT 8: Deploy/Release
|
|
202
202
|
|
|
203
203
|
```
|
|
204
|
-
Tôi muốn deploy/release
|
|
204
|
+
Tôi muốn deploy/release agent Kit.
|
|
205
205
|
|
|
206
206
|
## Release Type
|
|
207
207
|
- [ ] Patch (bug fixes)
|
|
@@ -229,7 +229,7 @@ Guidelines xem: `.agent/skills/deployment-procedures/SKILL.md`
|
|
|
229
229
|
|
|
230
230
|
```
|
|
231
231
|
# Homepage
|
|
232
|
-
Cải thiện homepage của
|
|
232
|
+
Cải thiện homepage của agent Kit, làm nó impressive hơn với animations.
|
|
233
233
|
|
|
234
234
|
# Performance
|
|
235
235
|
Tối ưu performance của documentation site, target Lighthouse 90+.
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# Implementation Plan: Codex CLI Integration
|
|
2
|
+
|
|
3
|
+
> **Created:** 2026-01-23
|
|
4
|
+
> **Status:** Draft
|
|
5
|
+
> **Priority:** High
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 📊 Research Summary
|
|
10
|
+
|
|
11
|
+
### What is Codex CLI?
|
|
12
|
+
|
|
13
|
+
OpenAI Codex CLI là một công cụ AI coding agent chạy terminal, sử dụng file `AGENTS.md` làm context để hiểu project và thực hiện các tác vụ coding.
|
|
14
|
+
|
|
15
|
+
### Key Findings
|
|
16
|
+
|
|
17
|
+
| Aspect | Detail |
|
|
18
|
+
|--------|--------|
|
|
19
|
+
| **Config File** | `AGENTS.md` (project root) |
|
|
20
|
+
| **Format** | Plain Markdown - flexible structure |
|
|
21
|
+
| **Discovery** | Auto-reads from project root |
|
|
22
|
+
| **Monorepo** | Supports nested `AGENTS.md` files |
|
|
23
|
+
| **Adoption** | 60k+ open-source projects |
|
|
24
|
+
| **Standard** | Open standard by Linux Foundation |
|
|
25
|
+
|
|
26
|
+
### AGENTS.md Recommended Sections
|
|
27
|
+
|
|
28
|
+
1. **Project Overview** - What the project does
|
|
29
|
+
2. **Setup Commands** - Install, dev, build, test
|
|
30
|
+
3. **Code Style** - Conventions, patterns
|
|
31
|
+
4. **Testing Instructions** - How to run tests
|
|
32
|
+
5. **Security Considerations** - Guidelines
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🎯 Problem Analysis
|
|
37
|
+
|
|
38
|
+
### Current State (Agent Kit)
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
.agent/
|
|
42
|
+
├── rules/GEMINI.md # → Gemini CLI (config: .gemini/settings.json)
|
|
43
|
+
├── agents/ # 16 agents
|
|
44
|
+
├── skills/ # 40 skills
|
|
45
|
+
└── workflows/ # 11 workflows
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Issues:**
|
|
49
|
+
1. ❌ Không có `AGENTS.md` ở root → Codex CLI không đọc được
|
|
50
|
+
2. ❌ `GEMINI.md` chỉ cho Gemini CLI, không tương thích Codex
|
|
51
|
+
3. ❌ Thiếu cấu trúc modular cho multi-platform support
|
|
52
|
+
|
|
53
|
+
### Target State
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
agent-kit/
|
|
57
|
+
├── AGENTS.md # ← NEW: Universal entry point
|
|
58
|
+
├── .codex/ # ← NEW: Codex-specific config (optional)
|
|
59
|
+
│ └── instructions.md
|
|
60
|
+
├── .agent/
|
|
61
|
+
│ ├── rules/
|
|
62
|
+
│ │ ├── GEMINI.md # Gemini-specific
|
|
63
|
+
│ │ ├── CODEX.md # ← NEW: Codex-specific rules
|
|
64
|
+
│ │ └── SHARED.md # ← NEW: Common rules
|
|
65
|
+
│ └── ...
|
|
66
|
+
└── bin/cli.js # Update to generate AGENTS.md
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 🛠️ Solution Options
|
|
72
|
+
|
|
73
|
+
### Option A: Single AGENTS.md (Recommended) ⭐
|
|
74
|
+
|
|
75
|
+
**Approach:** Tạo một `AGENTS.md` tổng hợp ở root, include/reference các rules từ `.agent/`
|
|
76
|
+
|
|
77
|
+
**Pros:**
|
|
78
|
+
- ✅ Tuân thủ chuẩn AGENTS.md
|
|
79
|
+
- ✅ Codex CLI auto-discover
|
|
80
|
+
- ✅ Dễ maintain single source of truth
|
|
81
|
+
- ✅ Compatible với 60k+ projects đang dùng
|
|
82
|
+
|
|
83
|
+
**Cons:**
|
|
84
|
+
- ⚠️ Cần sync với GEMINI.md nếu có thay đổi
|
|
85
|
+
|
|
86
|
+
**Implementation:**
|
|
87
|
+
```markdown
|
|
88
|
+
# AGENTS.md
|
|
89
|
+
|
|
90
|
+
## Project Overview
|
|
91
|
+
Agent Kit - AI Agent templates
|
|
92
|
+
|
|
93
|
+
## Setup Commands
|
|
94
|
+
...
|
|
95
|
+
|
|
96
|
+
## Rules
|
|
97
|
+
See `.agent/rules/GEMINI.md` for detailed rules.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### Option B: Adapter Pattern
|
|
103
|
+
|
|
104
|
+
**Approach:** Tạo script tự động generate `AGENTS.md` từ `GEMINI.md`
|
|
105
|
+
|
|
106
|
+
**Pros:**
|
|
107
|
+
- ✅ Single source of truth (GEMINI.md)
|
|
108
|
+
- ✅ Auto-sync
|
|
109
|
+
- ✅ Custom transformations
|
|
110
|
+
|
|
111
|
+
**Cons:**
|
|
112
|
+
- ⚠️ Thêm complexity
|
|
113
|
+
- ⚠️ Phải chạy script mỗi khi update
|
|
114
|
+
|
|
115
|
+
**Implementation:**
|
|
116
|
+
```javascript
|
|
117
|
+
// bin/generate-agents-md.js
|
|
118
|
+
const geminiRules = fs.readFileSync('.agent/rules/GEMINI.md');
|
|
119
|
+
const agentsMd = transformToAgentsFormat(geminiRules);
|
|
120
|
+
fs.writeFileSync('AGENTS.md', agentsMd);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### Option C: Symlink
|
|
126
|
+
|
|
127
|
+
**Approach:** Symlink `AGENTS.md → .agent/rules/GEMINI.md`
|
|
128
|
+
|
|
129
|
+
**Pros:**
|
|
130
|
+
- ✅ Zero maintenance
|
|
131
|
+
- ✅ Always in sync
|
|
132
|
+
|
|
133
|
+
**Cons:**
|
|
134
|
+
- ❌ GEMINI.md format không tối ưu cho Codex
|
|
135
|
+
- ❌ Windows compatibility issues
|
|
136
|
+
- ❌ Git tracking phức tạp
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 📋 Recommended Plan: Option A + CLI Enhancement
|
|
141
|
+
|
|
142
|
+
### Phase 1: Create AGENTS.md (Day 1)
|
|
143
|
+
|
|
144
|
+
**Task 1.1:** Create `/AGENTS.md` at project root
|
|
145
|
+
|
|
146
|
+
```markdown
|
|
147
|
+
# AGENTS.md
|
|
148
|
+
|
|
149
|
+
> Agent Kit - AI Agent Templates for Enhanced Coding Assistants
|
|
150
|
+
|
|
151
|
+
## Project Overview
|
|
152
|
+
|
|
153
|
+
A modular system of AI agent templates:
|
|
154
|
+
- **16 Specialist Agents** - Role-based AI personas
|
|
155
|
+
- **40 Skills** - Domain-specific knowledge
|
|
156
|
+
- **11 Workflows** - Slash command procedures
|
|
157
|
+
|
|
158
|
+
## Setup Commands
|
|
159
|
+
|
|
160
|
+
# Install dependencies
|
|
161
|
+
cd web && npm install
|
|
162
|
+
|
|
163
|
+
# Start dev server
|
|
164
|
+
cd web && npm run dev
|
|
165
|
+
|
|
166
|
+
# Run linting
|
|
167
|
+
cd web && npm run lint
|
|
168
|
+
|
|
169
|
+
# Install agent kit to your project
|
|
170
|
+
npx @musashishao/agent-kit init
|
|
171
|
+
|
|
172
|
+
## Code Style
|
|
173
|
+
|
|
174
|
+
- TypeScript strict mode
|
|
175
|
+
- React functional components with hooks
|
|
176
|
+
- Tailwind CSS for styling
|
|
177
|
+
- Absolute imports with @/ alias
|
|
178
|
+
- CSS variables for theming (dark/light mode)
|
|
179
|
+
|
|
180
|
+
## Project Structure
|
|
181
|
+
|
|
182
|
+
See `.agent/ARCHITECTURE.md` for full documentation.
|
|
183
|
+
|
|
184
|
+
## Testing
|
|
185
|
+
|
|
186
|
+
# Run tests (when available)
|
|
187
|
+
npm test
|
|
188
|
+
|
|
189
|
+
## Security Considerations
|
|
190
|
+
|
|
191
|
+
- All external links: rel="noopener noreferrer"
|
|
192
|
+
- No hardcoded secrets
|
|
193
|
+
- Environment variables for configs
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Task 1.2:** Update `.gitignore` if needed
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### Phase 2: Refactor Rules Structure (Day 2)
|
|
201
|
+
|
|
202
|
+
**Task 2.1:** Create shared rules file
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
.agent/rules/
|
|
206
|
+
├── GEMINI.md # Gemini CLI specific
|
|
207
|
+
├── CODEX.md # Codex CLI specific (optional)
|
|
208
|
+
├── SHARED.md # Common rules (can be included in both)
|
|
209
|
+
└── README.md # How rules work
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Task 2.2:** Extract common rules from GEMINI.md to SHARED.md
|
|
213
|
+
|
|
214
|
+
Common rules to extract:
|
|
215
|
+
- Clean Code standards
|
|
216
|
+
- Socratic Gate protocol
|
|
217
|
+
- Request Classifier
|
|
218
|
+
- Tier 0/1/2 rules
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### Phase 3: CLI Enhancement (Day 3)
|
|
223
|
+
|
|
224
|
+
**Task 3.1:** Add `codex` command to CLI
|
|
225
|
+
|
|
226
|
+
Update `bin/cli.js`:
|
|
227
|
+
```javascript
|
|
228
|
+
// New command: npx @musashishao/agent-kit codex
|
|
229
|
+
function codexCommand(options) {
|
|
230
|
+
// Generate AGENTS.md from templates
|
|
231
|
+
// Option to include/exclude rules
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Task 3.2:** Add `agents-md` template generation
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
function generateAgentsMd(targetDir) {
|
|
239
|
+
const template = fs.readFileSync(
|
|
240
|
+
path.join(__dirname, '../templates/AGENTS.md')
|
|
241
|
+
);
|
|
242
|
+
// Customize based on project detection
|
|
243
|
+
fs.writeFileSync(path.join(targetDir, 'AGENTS.md'), template);
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
### Phase 4: Documentation (Day 4)
|
|
250
|
+
|
|
251
|
+
**Task 4.1:** Update README.md
|
|
252
|
+
|
|
253
|
+
Add section:
|
|
254
|
+
```markdown
|
|
255
|
+
## Multi-Platform Support
|
|
256
|
+
|
|
257
|
+
Agent Kit works with:
|
|
258
|
+
|
|
259
|
+
| Platform | Config File | Setup |
|
|
260
|
+
|----------|-------------|-------|
|
|
261
|
+
| Gemini CLI | `.gemini/settings.json` | `{ "contextFileName": ".agent/rules/GEMINI.md" }` |
|
|
262
|
+
| Codex CLI | `AGENTS.md` | Auto-discovered at root |
|
|
263
|
+
| Cursor | `.cursor/rules` | Copy from `.agent/rules/` |
|
|
264
|
+
| Aider | `.aider.conf.yml` | `read: AGENTS.md` |
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Task 4.2:** Add docs page
|
|
268
|
+
|
|
269
|
+
Create `web/src/app/docs/platforms/page.tsx`:
|
|
270
|
+
- Gemini CLI setup
|
|
271
|
+
- Codex CLI setup
|
|
272
|
+
- Cursor setup
|
|
273
|
+
- Aider setup
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
### Phase 5: Templates (Day 5)
|
|
278
|
+
|
|
279
|
+
**Task 5.1:** Create AGENTS.md templates
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
.agent/templates/
|
|
283
|
+
├── AGENTS.md.web # For web projects
|
|
284
|
+
├── AGENTS.md.mobile # For mobile projects
|
|
285
|
+
├── AGENTS.md.backend # For backend projects
|
|
286
|
+
└── AGENTS.md.fullstack # For fullstack projects
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**Task 5.2:** CLI template selection
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
npx @musashishao/agent-kit codex --template web
|
|
293
|
+
npx @musashishao/agent-kit codex --template mobile
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## 📊 File Changes Summary
|
|
299
|
+
|
|
300
|
+
| File | Action | Priority |
|
|
301
|
+
|------|--------|----------|
|
|
302
|
+
| `/AGENTS.md` | **CREATE** | P0 |
|
|
303
|
+
| `/bin/cli.js` | UPDATE | P1 |
|
|
304
|
+
| `/.agent/rules/SHARED.md` | CREATE | P2 |
|
|
305
|
+
| `/.agent/rules/CODEX.md` | CREATE | P2 |
|
|
306
|
+
| `/web/src/app/docs/platforms/page.tsx` | CREATE | P3 |
|
|
307
|
+
| `/README.md` | UPDATE | P3 |
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## ✅ Success Criteria
|
|
312
|
+
|
|
313
|
+
1. [ ] `AGENTS.md` exists at project root
|
|
314
|
+
2. [ ] Codex CLI can read and use the config
|
|
315
|
+
3. [ ] CLI can generate `AGENTS.md` for user projects
|
|
316
|
+
4. [ ] Documentation covers multi-platform setup
|
|
317
|
+
5. [ ] Templates available for different project types
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## 🚀 Quick Start (Minimal)
|
|
322
|
+
|
|
323
|
+
Nếu chỉ muốn làm nhanh, chỉ cần:
|
|
324
|
+
|
|
325
|
+
1. Tạo `/AGENTS.md` ở root (Phase 1)
|
|
326
|
+
2. Done! Codex CLI sẽ tự động đọc
|
|
327
|
+
|
|
328
|
+
**Effort:** ~30 minutes
|
|
329
|
+
**Impact:** Codex CLI compatibility ✅
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
## 📝 Notes
|
|
334
|
+
|
|
335
|
+
- AGENTS.md là open standard của Linux Foundation
|
|
336
|
+
- 60k+ GitHub repos đang sử dụng
|
|
337
|
+
- Một lần setup, hoạt động với multiple AI tools
|
|
338
|
+
- Không conflict với GEMINI.md (khác file path)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Plan: Rename Antigravity Kit to Agent Kit
|
|
2
|
+
|
|
3
|
+
Rename all instances of "Antigravity Kit" to "Agent Kit" across the repository to unify the branding.
|
|
4
|
+
|
|
5
|
+
## 1. Analysis
|
|
6
|
+
- **Core Branding:** "Antigravity Kit" -> "Agent Kit"
|
|
7
|
+
- **Internal IDs/Slugs:** Check if "antigravity" is used in folder names or hidden files (e.g., `.antigravityignore`).
|
|
8
|
+
- **Web UI:** Hero section, titles, navigation, and documentation pages need updating.
|
|
9
|
+
- **CLI:** Ensure the CLI messages match the new branding.
|
|
10
|
+
|
|
11
|
+
## 2. Planning (Task Breakdown)
|
|
12
|
+
- [x] **Task 1: Project Metadata & Documentation**
|
|
13
|
+
- Update `README.md` (root and `web/`)
|
|
14
|
+
- Update `.agent/ARCHITECTURE.md`
|
|
15
|
+
- Update `.agent/CONTEXT.md`
|
|
16
|
+
- Update `.agent/FEATURE_ROADMAP.md`
|
|
17
|
+
- [x] **Task 2: Web Application**
|
|
18
|
+
- Update `web/src/app/page.tsx`
|
|
19
|
+
- Update `web/src/app/layout.tsx`
|
|
20
|
+
- Update `web/src/components/donate-dialog.tsx`
|
|
21
|
+
- Update `web/src/app/docs/` (all pages)
|
|
22
|
+
- Update footer and header components
|
|
23
|
+
- [x] **Task 3: CLI & Scripts**
|
|
24
|
+
- Update `bin/cli.js`
|
|
25
|
+
- Update `package.json` if needed
|
|
26
|
+
- [x] **Task 4: File System Cleanup**
|
|
27
|
+
- Rename any files containing "antigravity" in their filename.
|
|
28
|
+
|
|
29
|
+
## 3. Solutioning (Implementation Detail)
|
|
30
|
+
- Use `sed` or similar multi-replace tool for text across many files.
|
|
31
|
+
- Manual check for UI components like `AntigravityGoogle` svg/component.
|
|
32
|
+
- Case sensitivity: Standardize on "Agent Kit" (Title Case) and "agent-kit" (slug).
|
|
33
|
+
|
|
34
|
+
## 4. Implementation
|
|
35
|
+
- (To be executed via multi_replace_file_content and write_to_file)
|
|
36
|
+
|
|
37
|
+
## 5. Verification
|
|
38
|
+
- Search for "Antigravity" again to ensure 0 results.
|
|
39
|
+
- Run `npm run dev` in `web/` to check UI.
|
|
40
|
+
- Run `agent-kit status` to check CLI.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: context-engineering
|
|
3
|
+
description: Advanced strategies to optimize LLM context window, reduce lost-in-the-middle phenomena, and improve reasoning through structured inputs.
|
|
4
|
+
requirements:
|
|
5
|
+
- python >= 3.8
|
|
6
|
+
- tiktoken (for counting tokens)
|
|
7
|
+
types:
|
|
8
|
+
- strategy
|
|
9
|
+
- optimization
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Context Engineering
|
|
13
|
+
|
|
14
|
+
> **"Context is King."** - In the era of LLMs, managing the context window is the single most important factor for performance, accuracy, and cost efficiency.
|
|
15
|
+
|
|
16
|
+
This skill provides a systematic approach to curating, structuring, and optimizing the information sent to AI models. It moves beyond simple "prompt engineering" into the architectural design of information flow.
|
|
17
|
+
|
|
18
|
+
## 🧠 Core Philosophy: The 4 Pillars
|
|
19
|
+
|
|
20
|
+
1. **Context Curation (Signal-to-Noise Ratio):**
|
|
21
|
+
- NEVER dump the entire codebase.
|
|
22
|
+
- Use **Dependency Graphs** and **Symbol Jumping** to select only highly relevant files.
|
|
23
|
+
- *Technique:* `RepoMap` (Tree structure) for high-level understanding + `Skeleton` (Signatures) for interface understanding.
|
|
24
|
+
|
|
25
|
+
2. **Context Structuring (XML & Framing):**
|
|
26
|
+
- Use explicit XML tags (`<documents>`, `<instructions>`, `<history>`) to separate semantic zones.
|
|
27
|
+
- **Prime Positioning:** Place critical instructions at the very end of the prompt (Recency Bias).
|
|
28
|
+
- **Context Caching:** Structure static content (docs, rules) at the top to leverage API caching (Anthropic/Gemini).
|
|
29
|
+
|
|
30
|
+
3. **Context Compression (Information Density):**
|
|
31
|
+
- **Skeletonization:** Replace function bodies with `...` or `pass` when only the interface is needed.
|
|
32
|
+
- **Summarization:** Compress chat history into key architectural decisions, discarding "chit-chat".
|
|
33
|
+
- **Token Budgeting:** Allocate tokens strictly: 40% Active Code, 30% Reference, 20% Reasoning buffer, 10% History.
|
|
34
|
+
|
|
35
|
+
4. **In-Context Guidance (Few-Shot & CoT):**
|
|
36
|
+
- **Few-Shot Learning:** Include 2-3 examples of "Golden Code" (perfect code style for this project) to align style instantly.
|
|
37
|
+
- **Chain-of-Thought (CoT):** Force the model to `<think>` before answering.
|
|
38
|
+
|
|
39
|
+
## 📂 Skill Structure
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
skills/context-engineering/
|
|
43
|
+
├── SKILL.md # You are here
|
|
44
|
+
├── strategies/
|
|
45
|
+
│ ├── xml-framing.md # How to organize the prompt payload
|
|
46
|
+
│ ├── context-caching.md # Optimizing for Anthropic/Gemini Cache
|
|
47
|
+
│ ├── skeleton-code.md # Technique to compress code reading
|
|
48
|
+
│ └── few-shot-examples.md # Constructing powerful examples
|
|
49
|
+
└── scripts/
|
|
50
|
+
├── token_counter.py # Utility to estimate token usage
|
|
51
|
+
└── repo_mapper.py # Generates a tree-view map of the project
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 🚀 How to Apply
|
|
55
|
+
|
|
56
|
+
### 1. Before asking a complex question:
|
|
57
|
+
- Run `repo_mapper.py` to give the AI a high-level map.
|
|
58
|
+
- Decide which files are "Active" (need editing) vs "Reference" (need reading).
|
|
59
|
+
- Use **Skeleton** mode for Reference files to save tokens.
|
|
60
|
+
|
|
61
|
+
### 2. When writing instructions:
|
|
62
|
+
- Wrap your request in standard XML structures.
|
|
63
|
+
- Use the **Golden Rule of Positioning**:
|
|
64
|
+
- Top: Static Context (Docs, Project Rules) -> *Cached*
|
|
65
|
+
- Middle: Dynamic Context (Current Files, Chat History)
|
|
66
|
+
- Bottom: The Request (Instruction + Output Format)
|
|
67
|
+
|
|
68
|
+
### 3. For Debugging & Architecture:
|
|
69
|
+
- Enable **Chain-of-Thought**: Ask the AI to "Think step-by-step inside <thinking> tags".
|
|
70
|
+
|
|
71
|
+
## 📚 References
|
|
72
|
+
- **MemGPT:** Paging and eviction strategies (Working vs Reference memory).
|
|
73
|
+
- **Anthropic Research:** Long-context prompting, finding the needle in a haystack.
|
|
74
|
+
- **LlamaIndex:** Node parsing and index retrieval strategies.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# 🤖 Advanced Context-Engineered Prompt Template
|
|
2
|
+
|
|
3
|
+
Copy this entire block and fill in the placeholders to experience "SOTA" (State-of-the-Art) AI coding.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```xml
|
|
8
|
+
<system_context>
|
|
9
|
+
<role>
|
|
10
|
+
You are a Principal Software Architect at Google Deepmind, specialized in Next.js, TypeScript, and Shadcn UI.
|
|
11
|
+
Your goal is to write "Golden Code": secure, performant, readable, and perfectly typed.
|
|
12
|
+
</role>
|
|
13
|
+
<constraints>
|
|
14
|
+
1. NO "any" types. Use proper interfaces or generics.
|
|
15
|
+
2. Use functional components with hooks.
|
|
16
|
+
3. Prioritize "Composition over Inheritance".
|
|
17
|
+
4. Measure twice, cut once: Think before coding.
|
|
18
|
+
</constraints>
|
|
19
|
+
</system_context>
|
|
20
|
+
|
|
21
|
+
<project_structure>
|
|
22
|
+
./
|
|
23
|
+
web/
|
|
24
|
+
src/
|
|
25
|
+
components/
|
|
26
|
+
ui/ # Base Shadcn components
|
|
27
|
+
layout/ # Structure components
|
|
28
|
+
app/
|
|
29
|
+
docs/ # Documentation pages
|
|
30
|
+
lib/
|
|
31
|
+
utils.ts # Helper functions
|
|
32
|
+
</project_structure>
|
|
33
|
+
|
|
34
|
+
<reference_documents>
|
|
35
|
+
<!-- We inject the "Skeleton" of a relevant utility to save tokens -->
|
|
36
|
+
<document path="web/src/lib/utils.ts" type="skeleton">
|
|
37
|
+
export function cn(...inputs: ClassValue[]): string;
|
|
38
|
+
export function formatDate(date: Date): string;
|
|
39
|
+
</document>
|
|
40
|
+
|
|
41
|
+
<!-- We inject the design system rules -->
|
|
42
|
+
<document path="web/tailwind.config.ts" type="summary">
|
|
43
|
+
Primary Color: HSL(222.2, 47.4%, 11.2%)
|
|
44
|
+
Border Radius: 0.5rem
|
|
45
|
+
Font: Inter
|
|
46
|
+
</document>
|
|
47
|
+
</reference_documents>
|
|
48
|
+
|
|
49
|
+
<user_instruction>
|
|
50
|
+
<task>
|
|
51
|
+
Create a new "FeatureCard" component in `web/src/components/ui/feature-card.tsx`.
|
|
52
|
+
</task>
|
|
53
|
+
|
|
54
|
+
<requirements>
|
|
55
|
+
1. It must look premium (glassmorphism effect).
|
|
56
|
+
2. It should accept an Icon, Title, Description, and an optional "Learn More" link.
|
|
57
|
+
3. It must be responsive (stack on mobile, grid on desktop).
|
|
58
|
+
4. Use the `cn()` utility for class merging.
|
|
59
|
+
</requirements>
|
|
60
|
+
|
|
61
|
+
<example_output>
|
|
62
|
+
Provide the full code for `feature-card.tsx` and a usage example.
|
|
63
|
+
</example_output>
|
|
64
|
+
</user_instruction>
|
|
65
|
+
|
|
66
|
+
<thinking_process_guidance>
|
|
67
|
+
Before generating the code, you must perform a "Chain of Thought" analysis inside <thinking> tags:
|
|
68
|
+
1. Analyze the requirements.
|
|
69
|
+
2. Check the <reference_documents> for available tools (cn).
|
|
70
|
+
3. Plan the component API (Props interface).
|
|
71
|
+
4. Plan the Tailwind classes for "glassmorphism".
|
|
72
|
+
</thinking_process_guidance>
|
|
73
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
def generate_repo_map(root_dir, ignore_dirs=None):
|
|
5
|
+
if ignore_dirs is None:
|
|
6
|
+
ignore_dirs = {'.git', 'node_modules', 'dist', 'build', '.next', '__pycache__', '.agent'}
|
|
7
|
+
|
|
8
|
+
repo_map = []
|
|
9
|
+
|
|
10
|
+
for root, dirs, files in os.walk(root_dir):
|
|
11
|
+
# Modify dirs in-place to skip ignored directories
|
|
12
|
+
dirs[:] = [d for d in dirs if d not in ignore_dirs]
|
|
13
|
+
|
|
14
|
+
level = root.replace(root_dir, '').count(os.sep)
|
|
15
|
+
indent = ' ' * 4 * (level)
|
|
16
|
+
repo_map.append(f'{indent}{os.path.basename(root)}/')
|
|
17
|
+
|
|
18
|
+
subindent = ' ' * 4 * (level + 1)
|
|
19
|
+
for f in files:
|
|
20
|
+
if f.startswith('.'): continue
|
|
21
|
+
repo_map.append(f'{subindent}{f}')
|
|
22
|
+
|
|
23
|
+
return '\n'.join(repo_map)
|
|
24
|
+
|
|
25
|
+
if __name__ == "__main__":
|
|
26
|
+
path = sys.argv[1] if len(sys.argv) > 1 else "."
|
|
27
|
+
print(generate_repo_map(path))
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import tiktoken
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
def count_tokens(text):
|
|
6
|
+
"""
|
|
7
|
+
Count tokens using cl100k_base encoding (used by GPT-4, Claude 3, Gemini).
|
|
8
|
+
This is an approximation for non-OpenAI models but generally accurate enough for budgeting.
|
|
9
|
+
"""
|
|
10
|
+
try:
|
|
11
|
+
encoding = tiktoken.get_encoding("cl100k_base")
|
|
12
|
+
num_tokens = len(encoding.encode(text))
|
|
13
|
+
return num_tokens
|
|
14
|
+
except Exception as e:
|
|
15
|
+
print(f"Error initializing tokenizer: {e}")
|
|
16
|
+
return 0
|
|
17
|
+
|
|
18
|
+
def estimate_cost(tokens, model="gpt-4o"):
|
|
19
|
+
# Approx prices per 1M tokens (as of late 2024/2025)
|
|
20
|
+
pricing = {
|
|
21
|
+
"gpt-4o": 5.00, # Input
|
|
22
|
+
"claude-3-5-sonnet": 3.00,
|
|
23
|
+
"gemini-1.5-pro": 3.50
|
|
24
|
+
}
|
|
25
|
+
price_per_1m = pricing.get(model, 5.00)
|
|
26
|
+
cost = (tokens / 1_000_000) * price_per_1m
|
|
27
|
+
return cost
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
if len(sys.argv) < 2:
|
|
31
|
+
print("Usage: python token_counter.py <file_or_directory>")
|
|
32
|
+
sys.exit(1)
|
|
33
|
+
|
|
34
|
+
path = sys.argv[1]
|
|
35
|
+
total_tokens = 0
|
|
36
|
+
|
|
37
|
+
if os.path.isfile(path):
|
|
38
|
+
with open(path, 'r', encoding='utf-8', errors='ignore') as f:
|
|
39
|
+
content = f.read()
|
|
40
|
+
total_tokens = count_tokens(content)
|
|
41
|
+
print(f"File: {path}")
|
|
42
|
+
print(f"Tokens: {total_tokens}")
|
|
43
|
+
elif os.path.isdir(path):
|
|
44
|
+
print(f"Scanning directory: {path} (ignoring hidden & node_modules)...")
|
|
45
|
+
for root, dirs, files in os.walk(path):
|
|
46
|
+
dirs[:] = [d for d in dirs if not d.startswith('.') and d != 'node_modules']
|
|
47
|
+
for file in files:
|
|
48
|
+
if file.startswith('.'): continue
|
|
49
|
+
if file.endswith(('.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.woff', '.ttf')): continue
|
|
50
|
+
|
|
51
|
+
file_path = os.path.join(root, file)
|
|
52
|
+
try:
|
|
53
|
+
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
|
|
54
|
+
content = f.read()
|
|
55
|
+
tokens = count_tokens(content)
|
|
56
|
+
total_tokens += tokens
|
|
57
|
+
# Optional: Print large files
|
|
58
|
+
if tokens > 5000:
|
|
59
|
+
print(f" - Large file: {file_path} ({tokens} tokens)")
|
|
60
|
+
except Exception as e:
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
print("-" * 30)
|
|
64
|
+
print(f"TOTAL TOKENS: {total_tokens:,}")
|
|
65
|
+
print(f"Est. Input Cost (GPT-4o/Claude-3.5): ~${estimate_cost(total_tokens):.4f}")
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Context Caching Strategy
|
|
2
|
+
|
|
3
|
+
Context Caching is a game-changer for reducing latency and cost when dealing with large contexts (e.g., full documentation, design systems, or large codebases).
|
|
4
|
+
|
|
5
|
+
## How it Works
|
|
6
|
+
|
|
7
|
+
Most LLM providers (Anthropic, Google Gemini) process the prompt sequentially. If the first part of the prompt (the "prefix") is identical across multiple requests, the server can cache the computed attention states of that prefix.
|
|
8
|
+
|
|
9
|
+
- **Hit:** Instant processing, drastically reduced cost (usually ~10% of input price).
|
|
10
|
+
- **Miss:** Normal processing time and cost.
|
|
11
|
+
|
|
12
|
+
## The "Static-First" Rule
|
|
13
|
+
|
|
14
|
+
To maximize cache hits, you must structure your prompt so that **static content is always at the top**.
|
|
15
|
+
|
|
16
|
+
### ✅ Optimized Structure (Cache-Friendly)
|
|
17
|
+
|
|
18
|
+
```xml
|
|
19
|
+
<!-- BLOCK 1: STATIC (Cached) -->
|
|
20
|
+
<system_instructions>...</system_instructions>
|
|
21
|
+
<project_rules>...</project_rules>
|
|
22
|
+
<library_documentation>...</library_documentation>
|
|
23
|
+
<design_system>...</design_system>
|
|
24
|
+
|
|
25
|
+
<!-- BLOCK 2: DYNAMIC (Not Cached) -->
|
|
26
|
+
<chat_history>
|
|
27
|
+
User: Hi
|
|
28
|
+
AI: Hello
|
|
29
|
+
</chat_history>
|
|
30
|
+
<current_file_content>...</current_file_content>
|
|
31
|
+
<new_user_request>...</new_user_request>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### ❌ Bad Structure (Cache-Killer)
|
|
35
|
+
|
|
36
|
+
```xml
|
|
37
|
+
<chat_history>...</chat_history> <!-- Changes every turn! -->
|
|
38
|
+
<system_instructions>...</system_instructions> <!-- Reformatted every time, cache miss! -->
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Implementation Guidelines
|
|
42
|
+
|
|
43
|
+
1. **Breakpoint Management:** Providers usually require a minimum token count to activate caching (e.g., 1024 tokens for Anthropic). Ensure your static block is large enough.
|
|
44
|
+
2. **Immutable Docs:** Treat your documentation and rules as "Immutable". Do not change them dynamically per request unless necessary.
|
|
45
|
+
3. **Cache Control:** Explicitly mark the boundary where caching should stop (if the API supports explicit cache control headers or breakpoints).
|
|
46
|
+
|
|
47
|
+
## Provider Specifics
|
|
48
|
+
|
|
49
|
+
- **Anthropic:** Supports `cache_control: {"type": "ephemeral"}` on specific blocks.
|
|
50
|
+
- **Gemini:** Automatic prefix caching for high-volume endpoints (check current API docs).
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Few-Shot Learning & In-Context Guidance
|
|
2
|
+
|
|
3
|
+
"Show, Don't Tell". LLMs are excellent pattern matchers. Instead of writing 10 paragraphs of rules explaining your coding style, provide **2-3 examples** of code that follows those rules.
|
|
4
|
+
|
|
5
|
+
## The Power of Few-Shot
|
|
6
|
+
|
|
7
|
+
- **Zero-Shot:** "Write a Python function to add numbers." -> *Generic output.*
|
|
8
|
+
- **Few-Shot:** "Here are 3 examples of our project's Python style. Now write a function to add numbers." -> *Output perfectly matches your project's error handling, typing, and docstring standards.*
|
|
9
|
+
|
|
10
|
+
## Constructing "Golden Examples"
|
|
11
|
+
|
|
12
|
+
A Golden Example should demonstrate the **Key Pillars** of your architecture.
|
|
13
|
+
|
|
14
|
+
### Example: "The Robust Handler Pattern"
|
|
15
|
+
|
|
16
|
+
If your project requires all API handlers to have Try-Catch, Logging, and Zod Validation, create an example like this:
|
|
17
|
+
|
|
18
|
+
```xml
|
|
19
|
+
<examples>
|
|
20
|
+
<example>
|
|
21
|
+
<input>Create a handler to update user profile.</input>
|
|
22
|
+
<output>
|
|
23
|
+
<thinking>
|
|
24
|
+
1. Validate input with Zod.
|
|
25
|
+
2. Use UserService for logic.
|
|
26
|
+
3. Wrap in try/catch for global error handler.
|
|
27
|
+
</thinking>
|
|
28
|
+
<code>
|
|
29
|
+
export const updateProfile = async (req: Request, res: Response) => {
|
|
30
|
+
try {
|
|
31
|
+
const schema = z.object({ name: z.string() });
|
|
32
|
+
const data = schema.parse(req.body);
|
|
33
|
+
const user = await UserService.update(req.user.id, data);
|
|
34
|
+
return res.json({ success: true, data: user });
|
|
35
|
+
} catch (error) {
|
|
36
|
+
logger.error("Update profile failed", error);
|
|
37
|
+
next(error);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
</code>
|
|
41
|
+
</output>
|
|
42
|
+
</example>
|
|
43
|
+
</examples>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## When to use?
|
|
47
|
+
|
|
48
|
+
1. **New File Creation:** Essential. The AI needs to know the "boilerplate" feel.
|
|
49
|
+
2. **Complex Refactoring:** Useful to show "Before vs After" examples.
|
|
50
|
+
3. **Specific Libraries:** If using a niche library, provide examples of its usage.
|
|
51
|
+
|
|
52
|
+
## Strategy: Dynamic Retrieval
|
|
53
|
+
|
|
54
|
+
Don't stuff 50 examples into the context. Use **RAG (Retrieval Augmented Generation)** (or a simple grep-based selector) to find the *most relevant* example for the current task.
|
|
55
|
+
- Task: "Create React Component" -> Inject "React Component Example".
|
|
56
|
+
- Task: "Create SQL Query" -> Inject "SQL Query Example".
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Skeleton Code Strategy
|
|
2
|
+
|
|
3
|
+
**Context Compression** is vital. You rarely need the full implementation of imported modules to understand how to use them. You only need the **Interface** (signatures).
|
|
4
|
+
|
|
5
|
+
## What is Skeleton Code?
|
|
6
|
+
|
|
7
|
+
Skeleton code retains the structure but removes the logic implementation.
|
|
8
|
+
|
|
9
|
+
### Original `auth.service.ts`:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export class AuthService {
|
|
13
|
+
private apiUrl: string;
|
|
14
|
+
|
|
15
|
+
constructor(config: Config) {
|
|
16
|
+
this.apiUrl = config.apiUrl;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async login(credentials: Credentials): Promise<AuthResponse> {
|
|
20
|
+
if (!credentials.email || !credentials.password) {
|
|
21
|
+
throw new Error("Invalid input");
|
|
22
|
+
}
|
|
23
|
+
// ... 50 lines of logic ...
|
|
24
|
+
return response.data;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async logout(): Promise<void> {
|
|
28
|
+
// ... logic ...
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Skeleton Version (Token Cost: ~10%):
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
export class AuthService {
|
|
37
|
+
private apiUrl: string;
|
|
38
|
+
constructor(config: Config);
|
|
39
|
+
async login(credentials: Credentials): Promise<AuthResponse>;
|
|
40
|
+
async logout(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## When to use?
|
|
45
|
+
|
|
46
|
+
| File Type | Usage | Strategy |
|
|
47
|
+
| :--- | :--- | :--- |
|
|
48
|
+
| **Active File** | The file being edited | **Full Content** |
|
|
49
|
+
| **Direct Import** | Used by Active File | **Skeleton** (usually) |
|
|
50
|
+
| **Reference** | For understanding patterns | **Skeleton** or **Summary** |
|
|
51
|
+
| **Config/Types** | TypeScript interfaces, Zod schemas | **Full Content** (Critical for correctness) |
|
|
52
|
+
|
|
53
|
+
## Implementation Logic
|
|
54
|
+
|
|
55
|
+
1. Parse the AST (Abstract Syntax Tree) of the code.
|
|
56
|
+
2. Keep `class`, `function` definitions, `interface`, `type`.
|
|
57
|
+
3. Keep Docstrings/JSDoc (optional, usually helpful for semantics).
|
|
58
|
+
4. Remove function bodies `{ ... }`.
|
|
59
|
+
5. Remove private members (unless relevant for inheritance).
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# XML Framing Strategy
|
|
2
|
+
|
|
3
|
+
Use structured XML tags to clearly separate different types of information in the context. This helps the LLM distinguish between instructions, reference data, and user input.
|
|
4
|
+
|
|
5
|
+
## Standard Prompt Structure
|
|
6
|
+
|
|
7
|
+
```xml
|
|
8
|
+
<system_context>
|
|
9
|
+
<role>You are a Senior Software Engineer specialized in [Domain].</role>
|
|
10
|
+
<rules>
|
|
11
|
+
<!-- Project-specific rules (GEMINI.md) -->
|
|
12
|
+
</rules>
|
|
13
|
+
</system_context>
|
|
14
|
+
|
|
15
|
+
<reference_documents>
|
|
16
|
+
<document path="docs/api_spec.md">
|
|
17
|
+
... content ...
|
|
18
|
+
</document>
|
|
19
|
+
<document path="src/types.ts" mode="skeleton">
|
|
20
|
+
... content ...
|
|
21
|
+
</document>
|
|
22
|
+
</reference_documents>
|
|
23
|
+
|
|
24
|
+
<project_structure>
|
|
25
|
+
<!-- Output of repo_mapper.py -->
|
|
26
|
+
</project_structure>
|
|
27
|
+
|
|
28
|
+
<chat_history>
|
|
29
|
+
<!-- Compressed history -->
|
|
30
|
+
</chat_history>
|
|
31
|
+
|
|
32
|
+
<user_request>
|
|
33
|
+
<instruction>
|
|
34
|
+
Refactor the login function to use the new AuthService.
|
|
35
|
+
</instruction>
|
|
36
|
+
<constraints>
|
|
37
|
+
- Do not change the function signature.
|
|
38
|
+
- Add comprehensive error handling.
|
|
39
|
+
</constraints>
|
|
40
|
+
<active_file path="src/auth.ts">
|
|
41
|
+
... full content of the file to edit ...
|
|
42
|
+
</active_file>
|
|
43
|
+
</user_request>
|
|
44
|
+
|
|
45
|
+
<output_format>
|
|
46
|
+
Please provide the solution in the following format:
|
|
47
|
+
1. <thinking>: Analysis of the problem.
|
|
48
|
+
2. <plan>: Step-by-step implementation plan.
|
|
49
|
+
3. <code>: The modified code blocks.
|
|
50
|
+
</output_format>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Key Principles
|
|
54
|
+
|
|
55
|
+
1. **Wrappers matter:** `<code_block>` is better than just backticks for parsing.
|
|
56
|
+
2. **Attributes:** Use attributes like `<file path="...">` so the LLM knows the source.
|
|
57
|
+
3. **Nesting:** Don't go too deep (max 3 levels of nesting) to avoid confusing the attention mechanism.
|
package/.agent/skills/doc.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agent Kit Skills
|
|
2
2
|
|
|
3
|
-
> **Hướng dẫn tạo và sử dụng Skills trong
|
|
3
|
+
> **Hướng dẫn tạo và sử dụng Skills trong Agent Kit**
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## 📋 Giới thiệu
|
|
8
8
|
|
|
9
|
-
Mặc dù các mô hình cơ bản của
|
|
9
|
+
Mặc dù các mô hình cơ bản của Agent Kit (như Gemini) là những mô hình đa năng mạnh mẽ, nhưng chúng không biết ngữ cảnh dự án cụ thể hoặc các tiêu chuẩn của nhóm bạn. Việc tải từng quy tắc hoặc công cụ vào cửa sổ ngữ cảnh của tác nhân sẽ dẫn đến tình trạng "phình to công cụ", chi phí cao hơn, độ trễ và sự nhầm lẫn.
|
|
10
10
|
|
|
11
|
-
**
|
|
11
|
+
**Agent Kit Skills** giải quyết vấn đề này thông qua tính năng **Progressive Disclosure**. Kỹ năng là một gói kiến thức chuyên biệt, ở trạng thái không hoạt động cho đến khi cần. Thông tin này chỉ được tải vào ngữ cảnh của tác nhân khi yêu cầu cụ thể của bạn khớp với nội dung mô tả của kỹ năng.
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -39,7 +39,7 @@ my-skill/
|
|
|
39
39
|
### Bước 1: Tạo thư mục
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
mkdir -p ~/.
|
|
42
|
+
mkdir -p ~/.agent/agent-kit/skills/code-review
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
### Bước 2: Tạo SKILL.md
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Auto-generate optimized context for complex tasks using Context Engineering strategies.
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Context Optimization Workflow
|
|
6
|
+
|
|
7
|
+
This workflow automates the "Context Engineering" process. It analyzes your request, maps the project structure, summarizes relevant files, and wraps everything in a high-performance XML prompt structure for the AI.
|
|
8
|
+
|
|
9
|
+
**Trigger:** `/context [your task description]`
|
|
10
|
+
|
|
11
|
+
## Steps
|
|
12
|
+
|
|
13
|
+
1. **Analyze Intent:**
|
|
14
|
+
Take the user's task description ("{{task_description}}") and identify key domains (e.g., frontend, auth, database).
|
|
15
|
+
|
|
16
|
+
2. **Generate Repo Map:**
|
|
17
|
+
// turbo
|
|
18
|
+
Run the repo mapper to see the current structure.
|
|
19
|
+
`python3 .agent/skills/context-engineering/scripts/repo_mapper.py .`
|
|
20
|
+
|
|
21
|
+
3. **Construct Optimized Prompt:**
|
|
22
|
+
Based on the repo map and task, construct the following `Advanced Context` block.
|
|
23
|
+
|
|
24
|
+
**(Internal Instruction to AI):**
|
|
25
|
+
> You must now act as a Context Engineer. Do NOT just answer the user yet.
|
|
26
|
+
> Instead, OUTPUT a structured plan and code analysis using the gathered context.
|
|
27
|
+
> Use the `<thinking>` tag to analyze the Repo Map below.
|
|
28
|
+
> If the user's task matches specific files in the map, read them using `view_file`.
|
|
29
|
+
|
|
30
|
+
**Structure to enforce:**
|
|
31
|
+
```xml
|
|
32
|
+
<system_role>Senior Architect</system_role>
|
|
33
|
+
<project_context>
|
|
34
|
+
[Insert Output from Step 2 here]
|
|
35
|
+
</project_context>
|
|
36
|
+
<user_task>
|
|
37
|
+
{{task_description}}
|
|
38
|
+
</user_task>
|
|
39
|
+
<instruction>
|
|
40
|
+
1. Analyze the project structure above.
|
|
41
|
+
2. Identify ensuring files that need to be read or modified.
|
|
42
|
+
3. Proceed with solving the user's task using Chain-of-Thought (<thinking> tags).
|
|
43
|
+
</instruction>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
4. **Execute:**
|
|
47
|
+
Proceed to solve the user's request using the heightened context awareness.
|
package/README.md
CHANGED
package/bin/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
5
6
|
const { execSync } = require('child_process');
|
|
6
7
|
|
|
7
8
|
const VERSION = '1.0.0';
|
|
@@ -36,24 +37,28 @@ ${colors.bright}Usage:${colors.reset}
|
|
|
36
37
|
|
|
37
38
|
${colors.bright}Commands:${colors.reset}
|
|
38
39
|
init Install .agent folder into current project
|
|
39
|
-
|
|
40
|
+
setup-codex Sync workflows with Codex CLI slash commands
|
|
41
|
+
update Update .agent folder to match current package version
|
|
40
42
|
status Check installation status
|
|
41
43
|
|
|
42
44
|
${colors.bright}Options:${colors.reset}
|
|
43
|
-
--force Overwrite existing .agent folder
|
|
45
|
+
--force Overwrite existing .agent folder (REQUIRED for update)
|
|
44
46
|
--path <dir> Install in specific directory
|
|
47
|
+
--prefix <str> Custom prefix for slash commands (default: kit-)
|
|
45
48
|
--quiet Suppress output
|
|
46
49
|
--help Show this help message
|
|
47
50
|
--version Show version
|
|
48
51
|
|
|
49
52
|
${colors.bright}Examples:${colors.reset}
|
|
50
53
|
npx ${PACKAGE_NAME} init
|
|
51
|
-
npx ${PACKAGE_NAME}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
npx ${PACKAGE_NAME} setup-codex
|
|
55
|
+
|
|
56
|
+
${colors.yellow}# To ensure you have the latest version from NPM:${colors.reset}
|
|
57
|
+
npx ${PACKAGE_NAME}@latest update
|
|
54
58
|
`);
|
|
55
59
|
}
|
|
56
60
|
|
|
61
|
+
|
|
57
62
|
function showVersion() {
|
|
58
63
|
console.log(`${PACKAGE_NAME} v${VERSION}`);
|
|
59
64
|
}
|
|
@@ -151,6 +156,61 @@ ${colors.bright}📚 Documentation:${colors.reset}
|
|
|
151
156
|
}
|
|
152
157
|
}
|
|
153
158
|
|
|
159
|
+
function setupCodexCommand(options) {
|
|
160
|
+
const codexPromptDir = path.join(os.homedir(), '.codex', 'prompts');
|
|
161
|
+
const agentDir = path.join(process.cwd(), '.agent');
|
|
162
|
+
const workflowDir = path.join(agentDir, 'workflows');
|
|
163
|
+
const prefix = options.prefix || 'kit-';
|
|
164
|
+
|
|
165
|
+
log.title('🔗 Musa Agent Kit - Syncing with Codex CLI');
|
|
166
|
+
|
|
167
|
+
if (!fs.existsSync(agentDir)) {
|
|
168
|
+
log.error('.agent folder not found. Please run "init" first.');
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!fs.existsSync(codexPromptDir)) {
|
|
173
|
+
log.info('Creating Codex prompt directory...');
|
|
174
|
+
fs.mkdirSync(codexPromptDir, { recursive: true });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const workflows = fs.readdirSync(workflowDir).filter(f => f.endsWith('.md'));
|
|
178
|
+
|
|
179
|
+
log.info(`Found ${workflows.length} workflows. Linking to ${codexPromptDir}...`);
|
|
180
|
+
|
|
181
|
+
let successCount = 0;
|
|
182
|
+
for (const wf of workflows) {
|
|
183
|
+
const src = path.join(workflowDir, wf);
|
|
184
|
+
const destName = `${prefix}${wf}`;
|
|
185
|
+
const dest = path.join(codexPromptDir, destName);
|
|
186
|
+
|
|
187
|
+
try {
|
|
188
|
+
if (fs.existsSync(dest)) {
|
|
189
|
+
if (options.force) {
|
|
190
|
+
fs.unlinkSync(dest);
|
|
191
|
+
} else {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Use absolute path for symlink
|
|
197
|
+
fs.symlinkSync(src, dest, 'file');
|
|
198
|
+
successCount++;
|
|
199
|
+
} catch (err) {
|
|
200
|
+
// If symlink fails (e.g. on Windows without admin), copy instead
|
|
201
|
+
try {
|
|
202
|
+
fs.copyFileSync(src, dest);
|
|
203
|
+
successCount++;
|
|
204
|
+
} catch (copyErr) {
|
|
205
|
+
log.error(`Failed to sync ${wf}: ${copyErr.message}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
log.success(`Successfully synced ${successCount} slash commands to Codex CLI!`);
|
|
211
|
+
log.info(`You can now use: /${prefix}${workflows[0].replace('.md', '')} in Codex CLI.`);
|
|
212
|
+
}
|
|
213
|
+
|
|
154
214
|
function statusCommand() {
|
|
155
215
|
const agentDir = path.join(process.cwd(), '.agent');
|
|
156
216
|
|
|
@@ -199,7 +259,8 @@ const command = args[0];
|
|
|
199
259
|
const options = {
|
|
200
260
|
force: args.includes('--force'),
|
|
201
261
|
quiet: args.includes('--quiet'),
|
|
202
|
-
path: null
|
|
262
|
+
path: null,
|
|
263
|
+
prefix: null
|
|
203
264
|
};
|
|
204
265
|
|
|
205
266
|
// Parse --path
|
|
@@ -208,11 +269,20 @@ if (pathIndex !== -1 && args[pathIndex + 1]) {
|
|
|
208
269
|
options.path = path.resolve(args[pathIndex + 1]);
|
|
209
270
|
}
|
|
210
271
|
|
|
272
|
+
// Parse --prefix
|
|
273
|
+
const prefixIndex = args.indexOf('--prefix');
|
|
274
|
+
if (prefixIndex !== -1 && args[prefixIndex + 1]) {
|
|
275
|
+
options.prefix = args[prefixIndex + 1];
|
|
276
|
+
}
|
|
277
|
+
|
|
211
278
|
// Execute command
|
|
212
279
|
switch (command) {
|
|
213
280
|
case 'init':
|
|
214
281
|
initCommand(options);
|
|
215
282
|
break;
|
|
283
|
+
case 'setup-codex':
|
|
284
|
+
setupCodexCommand(options);
|
|
285
|
+
break;
|
|
216
286
|
case 'update':
|
|
217
287
|
updateCommand(options);
|
|
218
288
|
break;
|
|
@@ -233,3 +303,4 @@ switch (command) {
|
|
|
233
303
|
showHelp();
|
|
234
304
|
process.exit(1);
|
|
235
305
|
}
|
|
306
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@musashishao/agent-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "AI Agent templates - Skills, Agents, and Workflows for enhanced coding assistance",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -40,4 +40,4 @@
|
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=16.0.0"
|
|
42
42
|
}
|
|
43
|
-
}
|
|
43
|
+
}
|