@agent-native/core 0.2.8 → 0.3.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/README.md +59 -26
- package/dist/a2a/agent-card.d.ts +3 -0
- package/dist/a2a/agent-card.d.ts.map +1 -0
- package/dist/a2a/agent-card.js +26 -0
- package/dist/a2a/agent-card.js.map +1 -0
- package/dist/a2a/client.d.ts +25 -0
- package/dist/a2a/client.d.ts.map +1 -0
- package/dist/a2a/client.js +119 -0
- package/dist/a2a/client.js.map +1 -0
- package/dist/a2a/handlers.d.ts +4 -0
- package/dist/a2a/handlers.d.ts.map +1 -0
- package/dist/a2a/handlers.js +252 -0
- package/dist/a2a/handlers.js.map +1 -0
- package/dist/a2a/index.d.ts +4 -0
- package/dist/a2a/index.d.ts.map +1 -0
- package/dist/a2a/index.js +5 -0
- package/dist/a2a/index.js.map +1 -0
- package/dist/a2a/middleware.d.ts +3 -0
- package/dist/a2a/middleware.d.ts.map +1 -0
- package/dist/a2a/middleware.js +36 -0
- package/dist/a2a/middleware.js.map +1 -0
- package/dist/a2a/server.d.ts +4 -0
- package/dist/a2a/server.d.ts.map +1 -0
- package/dist/a2a/server.js +18 -0
- package/dist/a2a/server.js.map +1 -0
- package/dist/a2a/task-store.d.ts +10 -0
- package/dist/a2a/task-store.d.ts.map +1 -0
- package/dist/a2a/task-store.js +73 -0
- package/dist/a2a/task-store.js.map +1 -0
- package/dist/a2a/types.d.ts +109 -0
- package/dist/a2a/types.d.ts.map +1 -0
- package/dist/a2a/types.js +3 -0
- package/dist/a2a/types.js.map +1 -0
- package/dist/adapters/cli/index.d.ts +4 -0
- package/dist/adapters/cli/index.d.ts.map +1 -0
- package/dist/adapters/cli/index.js +3 -0
- package/dist/adapters/cli/index.js.map +1 -0
- package/dist/adapters/cli/registry.d.ts +33 -0
- package/dist/adapters/cli/registry.d.ts.map +1 -0
- package/dist/adapters/cli/registry.js +62 -0
- package/dist/adapters/cli/registry.js.map +1 -0
- package/dist/adapters/cli/shell-adapter.d.ts +42 -0
- package/dist/adapters/cli/shell-adapter.d.ts.map +1 -0
- package/dist/adapters/cli/shell-adapter.js +57 -0
- package/dist/adapters/cli/shell-adapter.js.map +1 -0
- package/dist/adapters/cli/types.d.ts +24 -0
- package/dist/adapters/cli/types.d.ts.map +1 -0
- package/dist/adapters/cli/types.js +2 -0
- package/dist/adapters/cli/types.js.map +1 -0
- package/dist/adapters/firestore/adapter.d.ts.map +1 -1
- package/dist/adapters/firestore/adapter.js.map +1 -1
- package/dist/adapters/neon/adapter.d.ts.map +1 -1
- package/dist/adapters/neon/adapter.js +37 -21
- package/dist/adapters/neon/adapter.js.map +1 -1
- package/dist/adapters/supabase/adapter.d.ts.map +1 -1
- package/dist/adapters/supabase/adapter.js +10 -2
- package/dist/adapters/supabase/adapter.js.map +1 -1
- package/dist/adapters/sync/file-sync.d.ts.map +1 -1
- package/dist/adapters/sync/file-sync.js.map +1 -1
- package/dist/adapters/sync/index.d.ts +2 -2
- package/dist/adapters/sync/index.d.ts.map +1 -1
- package/dist/adapters/sync/index.js +1 -1
- package/dist/adapters/sync/index.js.map +1 -1
- package/dist/adapters/sync/merge.js +1 -2
- package/dist/adapters/sync/merge.js.map +1 -1
- package/dist/adapters/sync/types.d.ts.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +15 -13
- package/dist/cli/index.js.map +1 -1
- package/dist/client/components/ApiKeySettings.d.ts +1 -1
- package/dist/client/components/ApiKeySettings.d.ts.map +1 -1
- package/dist/client/components/ApiKeySettings.js +9 -4
- package/dist/client/components/ApiKeySettings.js.map +1 -1
- package/dist/client/components/MissingKeyCard.d.ts +1 -1
- package/dist/client/components/MissingKeyCard.d.ts.map +1 -1
- package/dist/client/components/MissingKeyCard.js +1 -1
- package/dist/client/components/MissingKeyCard.js.map +1 -1
- package/dist/client/harness.d.ts +10 -0
- package/dist/client/harness.d.ts.map +1 -1
- package/dist/client/harness.js +27 -0
- package/dist/client/harness.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/use-file-watcher.d.ts.map +1 -1
- package/dist/client/use-file-watcher.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/scripts/utils.d.ts.map +1 -1
- package/dist/scripts/utils.js +3 -1
- package/dist/scripts/utils.js.map +1 -1
- package/dist/server/create-server.d.ts.map +1 -1
- package/dist/server/create-server.js +2 -1
- package/dist/server/create-server.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/missing-key.d.ts.map +1 -1
- package/dist/server/missing-key.js.map +1 -1
- package/dist/server/production.d.ts.map +1 -1
- package/dist/server/production.js.map +1 -1
- package/dist/server/sse.d.ts +1 -1
- package/dist/server/sse.d.ts.map +1 -1
- package/dist/server/sse.js.map +1 -1
- package/dist/shared/agent-chat.d.ts +18 -0
- package/dist/shared/agent-chat.d.ts.map +1 -1
- package/dist/shared/agent-chat.js +35 -0
- package/dist/shared/agent-chat.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/index.js.map +1 -1
- package/package.json +127 -125
- package/src/templates/default/.agents/skills/capture-learnings/SKILL.md +50 -0
- package/src/templates/default/.agents/skills/create-skill/SKILL.md +167 -0
- package/src/templates/default/.agents/skills/delegate-to-agent/SKILL.md +90 -0
- package/src/templates/default/.agents/skills/files-as-database/SKILL.md +91 -0
- package/src/templates/default/.agents/skills/frontend-design/SKILL.md +69 -0
- package/src/templates/default/.agents/skills/scripts/SKILL.md +118 -0
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +79 -0
- package/src/templates/default/.agents/skills/sse-file-watcher/SKILL.md +95 -0
- package/src/templates/default/.claude/settings.json +86 -68
- package/src/templates/default/.prettierrc +5 -5
- package/src/templates/default/AGENTS.md +86 -69
- package/src/templates/default/client/App.tsx +56 -54
- package/src/templates/default/client/global.css +75 -72
- package/src/templates/default/client/lib/utils.ts +1 -1
- package/src/templates/default/client/vite-env.d.ts +1 -1
- package/src/templates/default/components.json +20 -20
- package/src/templates/default/index.html +14 -14
- package/src/templates/default/package.json +43 -43
- package/src/templates/default/postcss.config.js +6 -6
- package/src/templates/default/scripts/hello.ts +20 -20
- package/src/templates/default/scripts/run.ts +9 -9
- package/src/templates/default/server/index.ts +22 -18
- package/src/templates/default/server/node-build.ts +4 -4
- package/src/templates/default/shared/api.ts +6 -6
- package/src/templates/default/tailwind.config.ts +7 -7
- package/src/templates/default/tsconfig.json +3 -3
- package/src/templates/default/vite.config.server.ts +3 -3
- package/src/templates/default/vite.config.ts +3 -3
- package/tsconfig.base.json +41 -41
package/package.json
CHANGED
|
@@ -1,125 +1,127 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.2
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Framework for agent-native application development — where AI agents and UI share state via files",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/BuilderIO/agent-native",
|
|
10
|
-
"directory": "packages/core"
|
|
11
|
-
},
|
|
12
|
-
"bin": {
|
|
13
|
-
"agent-native": "dist/cli/index.js"
|
|
14
|
-
},
|
|
15
|
-
"exports": {
|
|
16
|
-
".": {
|
|
17
|
-
"browser": "./dist/index.browser.js",
|
|
18
|
-
"default": "./dist/index.js"
|
|
19
|
-
},
|
|
20
|
-
"./vite": "./dist/vite/index.js",
|
|
21
|
-
"./server": "./dist/server/index.js",
|
|
22
|
-
"./client": "./dist/client/index.js",
|
|
23
|
-
"./shared": "./dist/shared/index.js",
|
|
24
|
-
"./scripts": "./dist/scripts/index.js",
|
|
25
|
-
"./adapters/sync": "./dist/adapters/sync/index.js",
|
|
26
|
-
"./adapters/firestore": "./dist/adapters/firestore/index.js",
|
|
27
|
-
"./adapters/supabase": "./dist/adapters/supabase/index.js",
|
|
28
|
-
"./adapters/neon": "./dist/adapters/neon/index.js",
|
|
29
|
-
"./
|
|
30
|
-
"./
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"@
|
|
108
|
-
"@types/
|
|
109
|
-
"@types/
|
|
110
|
-
"@
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@agent-native/core",
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Framework for agent-native application development — where AI agents and UI share state via files",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/BuilderIO/agent-native",
|
|
10
|
+
"directory": "packages/core"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"agent-native": "dist/cli/index.js"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"browser": "./dist/index.browser.js",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./vite": "./dist/vite/index.js",
|
|
21
|
+
"./server": "./dist/server/index.js",
|
|
22
|
+
"./client": "./dist/client/index.js",
|
|
23
|
+
"./shared": "./dist/shared/index.js",
|
|
24
|
+
"./scripts": "./dist/scripts/index.js",
|
|
25
|
+
"./adapters/sync": "./dist/adapters/sync/index.js",
|
|
26
|
+
"./adapters/firestore": "./dist/adapters/firestore/index.js",
|
|
27
|
+
"./adapters/supabase": "./dist/adapters/supabase/index.js",
|
|
28
|
+
"./adapters/neon": "./dist/adapters/neon/index.js",
|
|
29
|
+
"./adapters/cli": "./dist/adapters/cli/index.js",
|
|
30
|
+
"./a2a": "./dist/a2a/index.js",
|
|
31
|
+
"./tailwind": "./dist/tailwind.preset.js",
|
|
32
|
+
"./tsconfig.base.json": "./tsconfig.base.json"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"tsconfig.base.json",
|
|
37
|
+
"src/templates"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"dev": "tsc --watch",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"test": "vitest --run",
|
|
44
|
+
"prepack": "cp ../../README.md ./README.md",
|
|
45
|
+
"prepublishOnly": "npm run build",
|
|
46
|
+
"release": "npm version patch && npm publish --access public"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"chokidar": "^4.0.0",
|
|
50
|
+
"clsx": "^2.1.1",
|
|
51
|
+
"dotenv": "^17.2.1",
|
|
52
|
+
"minimatch": "^10.0.0",
|
|
53
|
+
"tailwind-merge": "^2.6.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@supabase/supabase-js": ">=2",
|
|
57
|
+
"@neondatabase/serverless": ">=0.9",
|
|
58
|
+
"@tanstack/react-query": ">=5",
|
|
59
|
+
"@vitejs/plugin-react-swc": ">=4",
|
|
60
|
+
"autoprefixer": ">=10",
|
|
61
|
+
"cors": ">=2",
|
|
62
|
+
"express": ">=5",
|
|
63
|
+
"postcss": ">=8",
|
|
64
|
+
"react": ">=18",
|
|
65
|
+
"react-dom": ">=18",
|
|
66
|
+
"tailwindcss": ">=3",
|
|
67
|
+
"tailwindcss-animate": ">=1",
|
|
68
|
+
"typescript": ">=5",
|
|
69
|
+
"vite": ">=7"
|
|
70
|
+
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"@tanstack/react-query": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"tailwindcss": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"tailwindcss-animate": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"autoprefixer": {
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"postcss": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
87
|
+
"cors": {
|
|
88
|
+
"optional": true
|
|
89
|
+
},
|
|
90
|
+
"express": {
|
|
91
|
+
"optional": true
|
|
92
|
+
},
|
|
93
|
+
"@vitejs/plugin-react-swc": {
|
|
94
|
+
"optional": true
|
|
95
|
+
},
|
|
96
|
+
"vite": {
|
|
97
|
+
"optional": true
|
|
98
|
+
},
|
|
99
|
+
"@supabase/supabase-js": {
|
|
100
|
+
"optional": true
|
|
101
|
+
},
|
|
102
|
+
"@neondatabase/serverless": {
|
|
103
|
+
"optional": true
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"devDependencies": {
|
|
107
|
+
"@tanstack/react-query": "^5.84.2",
|
|
108
|
+
"@types/cors": "^2.8.19",
|
|
109
|
+
"@types/express": "^5.0.3",
|
|
110
|
+
"@types/node": "^24.2.1",
|
|
111
|
+
"@types/react": "^18.3.23",
|
|
112
|
+
"@vitejs/plugin-react-swc": "^4.0.0",
|
|
113
|
+
"autoprefixer": "^10.4.21",
|
|
114
|
+
"cors": "^2.8.5",
|
|
115
|
+
"express": "^5.1.0",
|
|
116
|
+
"@neondatabase/serverless": "^1.0.0",
|
|
117
|
+
"@supabase/supabase-js": "^2.49.0",
|
|
118
|
+
"firebase-admin": "^13.0.0",
|
|
119
|
+
"postcss": "^8.5.6",
|
|
120
|
+
"react": "^18.3.1",
|
|
121
|
+
"tailwindcss": "^3.4.17",
|
|
122
|
+
"tailwindcss-animate": "^1.0.7",
|
|
123
|
+
"typescript": "^5.9.2",
|
|
124
|
+
"vite": "^8.0.0",
|
|
125
|
+
"vitest": "^3.2.4"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: capture-learnings
|
|
3
|
+
description: >-
|
|
4
|
+
Capture and apply accumulated knowledge in learnings.md. Use when the user
|
|
5
|
+
corrects a mistake, when debugging reveals unexpected behavior, or when an
|
|
6
|
+
architectural decision should be recorded for future reference.
|
|
7
|
+
user-invocable: false
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Capture Learnings
|
|
11
|
+
|
|
12
|
+
This is background knowledge, not a slash command. Read `learnings.md` before starting significant work. Update it when you discover something worth remembering.
|
|
13
|
+
|
|
14
|
+
## When to Capture
|
|
15
|
+
|
|
16
|
+
Use judgment, not rules. Capture when:
|
|
17
|
+
|
|
18
|
+
- **Surprising behavior** — Something didn't work as expected and you figured out why
|
|
19
|
+
- **Repeated friction** — You hit the same issue twice; write it down so there's no third time
|
|
20
|
+
- **Architectural decisions** — Why something is done a certain way (the "why" isn't in the code)
|
|
21
|
+
- **API/library quirks** — Undocumented behavior, version-specific gotchas
|
|
22
|
+
- **Performance insights** — What's slow and what fixed it
|
|
23
|
+
|
|
24
|
+
Don't capture:
|
|
25
|
+
|
|
26
|
+
- Things that are obvious from reading the code
|
|
27
|
+
- Standard language/framework behavior
|
|
28
|
+
- Temporary debugging notes
|
|
29
|
+
|
|
30
|
+
## Format
|
|
31
|
+
|
|
32
|
+
Add entries to `learnings.md` at the project root. Match the existing format — typically a heading per topic with a brief explanation:
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
## [Topic]
|
|
36
|
+
|
|
37
|
+
[What you learned and why it matters. Keep it to 2-3 sentences.]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Graduation
|
|
41
|
+
|
|
42
|
+
When a learning is referenced repeatedly, it's outgrowing `learnings.md`. Propose adding it to the relevant skill or creating a new skill via `create-skill`.
|
|
43
|
+
|
|
44
|
+
- Updating `learnings.md` is a Tier 1 modification (data — auto-apply)
|
|
45
|
+
- Updating a SKILL.md based on learnings is Tier 2 (source — verify after)
|
|
46
|
+
|
|
47
|
+
## Related Skills
|
|
48
|
+
|
|
49
|
+
- **self-modifying-code** — Learnings.md updates are Tier 1; skill updates are Tier 2
|
|
50
|
+
- **create-skill** — When a learning graduates, create a skill from it
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: create-skill
|
|
3
|
+
description: >-
|
|
4
|
+
How to create new skills for an agent-native app. Use when adding a new
|
|
5
|
+
skill, documenting a pattern the agent should follow, or creating reusable
|
|
6
|
+
guidance for the agent.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Create a Skill
|
|
10
|
+
|
|
11
|
+
## When to Use
|
|
12
|
+
|
|
13
|
+
Create a new skill when:
|
|
14
|
+
|
|
15
|
+
- There's a pattern the agent should follow repeatedly
|
|
16
|
+
- A workflow needs step-by-step guidance
|
|
17
|
+
- You want to scaffold files from a template
|
|
18
|
+
|
|
19
|
+
Don't create a skill when:
|
|
20
|
+
|
|
21
|
+
- The guidance already exists in another skill (extend it instead)
|
|
22
|
+
- You're documenting something the agent already knows (e.g., how to write TypeScript)
|
|
23
|
+
- The guidance is a one-off — put it in `AGENTS.md` or `learnings.md` instead
|
|
24
|
+
|
|
25
|
+
## 5-Question Interview
|
|
26
|
+
|
|
27
|
+
Before writing the skill, answer these:
|
|
28
|
+
|
|
29
|
+
1. **What should this skill enable?** — The core purpose in one sentence.
|
|
30
|
+
2. **Which agent-native rule does it serve?** — Rule 1 (files), Rule 2 (delegate), Rule 3 (scripts), Rule 4 (SSE), Rule 5 (self-modify), or "utility."
|
|
31
|
+
3. **When should it trigger?** — Describe the situations in natural language. Be slightly pushy — over-triggering is better than under-triggering.
|
|
32
|
+
4. **What type of skill?** — Pattern, Workflow, or Generator (see templates below).
|
|
33
|
+
5. **Does it need supporting files?** — References (read-only context) or none. Keep it minimal.
|
|
34
|
+
|
|
35
|
+
## Skill Types and Templates
|
|
36
|
+
|
|
37
|
+
### Pattern (architectural rule)
|
|
38
|
+
|
|
39
|
+
For documenting how things should be done:
|
|
40
|
+
|
|
41
|
+
```markdown
|
|
42
|
+
---
|
|
43
|
+
name: my-pattern
|
|
44
|
+
description: >-
|
|
45
|
+
[Under 40 words. When should this trigger?]
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
# [Pattern Name]
|
|
49
|
+
|
|
50
|
+
## Rule
|
|
51
|
+
|
|
52
|
+
[One sentence: what must be true]
|
|
53
|
+
|
|
54
|
+
## Why
|
|
55
|
+
|
|
56
|
+
[Why this rule exists]
|
|
57
|
+
|
|
58
|
+
## How
|
|
59
|
+
|
|
60
|
+
[How to follow it, with code examples]
|
|
61
|
+
|
|
62
|
+
## Don't
|
|
63
|
+
|
|
64
|
+
[Common violations]
|
|
65
|
+
|
|
66
|
+
## Related Skills
|
|
67
|
+
|
|
68
|
+
[Which skills compose with this one]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Workflow (step-by-step)
|
|
72
|
+
|
|
73
|
+
For multi-step implementation tasks:
|
|
74
|
+
|
|
75
|
+
```markdown
|
|
76
|
+
---
|
|
77
|
+
name: my-workflow
|
|
78
|
+
description: >-
|
|
79
|
+
[Under 40 words. When should this trigger?]
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
# [Workflow Name]
|
|
83
|
+
|
|
84
|
+
## Prerequisites
|
|
85
|
+
|
|
86
|
+
[What must be in place first]
|
|
87
|
+
|
|
88
|
+
## Steps
|
|
89
|
+
|
|
90
|
+
[Numbered steps with code examples]
|
|
91
|
+
|
|
92
|
+
## Verification
|
|
93
|
+
|
|
94
|
+
[How to confirm it worked]
|
|
95
|
+
|
|
96
|
+
## Troubleshooting
|
|
97
|
+
|
|
98
|
+
[Common issues and fixes]
|
|
99
|
+
|
|
100
|
+
## Related Skills
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Generator (scaffolding)
|
|
104
|
+
|
|
105
|
+
For creating files from templates:
|
|
106
|
+
|
|
107
|
+
```markdown
|
|
108
|
+
---
|
|
109
|
+
name: my-generator
|
|
110
|
+
description: >-
|
|
111
|
+
[Under 40 words. When should this trigger?]
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
# [Generator Name]
|
|
115
|
+
|
|
116
|
+
## Usage
|
|
117
|
+
|
|
118
|
+
[How to invoke — what args/inputs are needed]
|
|
119
|
+
|
|
120
|
+
## What Gets Created
|
|
121
|
+
|
|
122
|
+
[List of files and their purpose]
|
|
123
|
+
|
|
124
|
+
## Template
|
|
125
|
+
|
|
126
|
+
[The template content with placeholders]
|
|
127
|
+
|
|
128
|
+
## After Generation
|
|
129
|
+
|
|
130
|
+
[What to do next — wire up SSE, add routes, etc.]
|
|
131
|
+
|
|
132
|
+
## Related Skills
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Naming Conventions
|
|
136
|
+
|
|
137
|
+
- Hyphen-case only: `[a-z0-9-]`, max 64 characters
|
|
138
|
+
- Pattern skills: descriptive names (`files-as-database`, `delegate-to-agent`)
|
|
139
|
+
- Workflow/generator skills: verb-noun (`create-script`, `capture-learnings`)
|
|
140
|
+
|
|
141
|
+
## Tips
|
|
142
|
+
|
|
143
|
+
- **Keep descriptions under 40 words** — They're loaded into context on every conversation.
|
|
144
|
+
- **Keep SKILL.md under 500 lines** — Move detailed content to `references/` files.
|
|
145
|
+
- **Use standard markdown headings** — No XML tags or custom formats.
|
|
146
|
+
|
|
147
|
+
## Anti-Patterns
|
|
148
|
+
|
|
149
|
+
- **Inline LLM calls** — Skills must not call LLMs directly (violates Rule 2)
|
|
150
|
+
- **Database patterns** — Skills must not introduce databases (violates Rule 1)
|
|
151
|
+
- **Ignoring SSE** — If a skill creates data files, mention wiring up `useFileWatcher`
|
|
152
|
+
- **Vague descriptions** — "Helps with development" won't trigger. Be specific about _when_.
|
|
153
|
+
- **Pure documentation** — Skills should guide action, not just explain concepts
|
|
154
|
+
|
|
155
|
+
## File Structure
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
.agents/skills/my-skill/
|
|
159
|
+
├── SKILL.md # Main skill (required)
|
|
160
|
+
└── references/ # Optional supporting context
|
|
161
|
+
└── detailed-guide.md
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Related Skills
|
|
165
|
+
|
|
166
|
+
- **capture-learnings** — When a learning graduates to reusable guidance, create a skill
|
|
167
|
+
- **self-modifying-code** — The agent can create new skills (Tier 2 modification)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: delegate-to-agent
|
|
3
|
+
description: >-
|
|
4
|
+
How to delegate all AI work to the agent chat. Use when delegating AI work
|
|
5
|
+
from UI or scripts to the agent, when tempted to add inline LLM calls, or
|
|
6
|
+
when sending messages to the agent from application code.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Delegate All AI to the Agent
|
|
10
|
+
|
|
11
|
+
## Rule
|
|
12
|
+
|
|
13
|
+
The UI and server never call an LLM directly. All AI work is delegated to the agent through the chat bridge.
|
|
14
|
+
|
|
15
|
+
## Why
|
|
16
|
+
|
|
17
|
+
The agent is the single AI interface. It has context about the full project, can read/write any file, and can run scripts. Inline LLM calls bypass this — they create a shadow AI that doesn't know what the agent knows and can't coordinate with it.
|
|
18
|
+
|
|
19
|
+
## How
|
|
20
|
+
|
|
21
|
+
**From the UI (client):**
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { sendToAgentChat } from "@agent-native/core";
|
|
25
|
+
|
|
26
|
+
sendToAgentChat({
|
|
27
|
+
message: "Generate a summary of this document",
|
|
28
|
+
context: documentContent, // optional hidden context (not shown in chat UI)
|
|
29
|
+
submit: true, // auto-submit to the agent
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**From scripts (Node):**
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { agentChat } from "@agent-native/core";
|
|
37
|
+
|
|
38
|
+
agentChat.submit("Process the uploaded images and create thumbnails");
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**From the UI, detecting when agent is done:**
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { useAgentChatGenerating } from "@agent-native/core";
|
|
45
|
+
|
|
46
|
+
function MyComponent() {
|
|
47
|
+
const isGenerating = useAgentChatGenerating();
|
|
48
|
+
// Show loading state while agent is working
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## `submit` vs Prefill
|
|
53
|
+
|
|
54
|
+
The `submit` option controls whether the message is sent automatically or placed in the chat input for user review:
|
|
55
|
+
|
|
56
|
+
| `submit` value | Behavior | Use when |
|
|
57
|
+
| -------------- | --------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
58
|
+
| `true` | Auto-submits to the agent immediately | Routine operations the user has already approved |
|
|
59
|
+
| `false` | Prefills the chat input for user review | High-stakes operations (deleting data, modifying code, API calls with side effects) |
|
|
60
|
+
| omitted | Uses the project's default setting | General-purpose delegation |
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
// Auto-submit: routine operation
|
|
64
|
+
sendToAgentChat({ message: "Update the project summary", submit: true });
|
|
65
|
+
|
|
66
|
+
// Prefill: let user review before sending
|
|
67
|
+
sendToAgentChat({
|
|
68
|
+
message: "Delete all projects older than 30 days",
|
|
69
|
+
submit: false,
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Don't
|
|
74
|
+
|
|
75
|
+
- Don't `import Anthropic from "@anthropic-ai/sdk"` in client or server code
|
|
76
|
+
- Don't `import OpenAI from "openai"` in client or server code
|
|
77
|
+
- Don't make direct API calls to any LLM provider
|
|
78
|
+
- Don't use AI SDK functions like `generateText()`, `streamText()`, etc.
|
|
79
|
+
- Don't build "AI features" that bypass the agent chat
|
|
80
|
+
|
|
81
|
+
## Exception
|
|
82
|
+
|
|
83
|
+
Scripts may call external APIs (image generation, search, etc.) — but the AI reasoning and orchestration still goes through the agent. A script is a tool the agent uses, not a replacement for the agent.
|
|
84
|
+
|
|
85
|
+
## Related Skills
|
|
86
|
+
|
|
87
|
+
- **scripts** — The agent invokes scripts via `pnpm script <name>` to perform complex operations
|
|
88
|
+
- **self-modifying-code** — The agent operates through the chat bridge to make code changes
|
|
89
|
+
- **files-as-database** — The agent writes results to data files after processing requests
|
|
90
|
+
- **sse-file-watcher** — The UI updates automatically when the agent writes files
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: files-as-database
|
|
3
|
+
description: >-
|
|
4
|
+
How to store and manage application state as JSON/markdown files in data/.
|
|
5
|
+
Use when adding data models, creating file-based state, deciding where to
|
|
6
|
+
store data, or reading/writing application data files.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Files as Database
|
|
10
|
+
|
|
11
|
+
## Rule
|
|
12
|
+
|
|
13
|
+
All application state must be stored as files. There is no traditional database in an agent-native app.
|
|
14
|
+
|
|
15
|
+
## Why
|
|
16
|
+
|
|
17
|
+
Files are the shared interface between the AI agent and the UI. The agent reads and writes files directly on the filesystem. The UI reads files via API routes. SSE streams file changes back to the UI in real-time. This only works if files are the single source of truth.
|
|
18
|
+
|
|
19
|
+
## How
|
|
20
|
+
|
|
21
|
+
- Store data as JSON or markdown files in `data/` (or a project-specific subdirectory).
|
|
22
|
+
- API routes in `server/index.ts` read files with `fs.readFile` and return them.
|
|
23
|
+
- The agent modifies files directly — no API calls needed from the agent side.
|
|
24
|
+
- `createFileWatcher("./data")` watches for changes and streams them via SSE.
|
|
25
|
+
- `useFileWatcher()` on the client invalidates React Query caches when files change.
|
|
26
|
+
|
|
27
|
+
## Don't
|
|
28
|
+
|
|
29
|
+
- Don't add a database (SQLite, Postgres, MongoDB, etc.)
|
|
30
|
+
- Don't store app state in localStorage, sessionStorage, or cookies
|
|
31
|
+
- Don't keep state only in memory (server variables, global stores)
|
|
32
|
+
- Don't use Redis or any external state store
|
|
33
|
+
- Don't interpolate user input directly into file paths (see Security below)
|
|
34
|
+
|
|
35
|
+
## Example
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import fs from "fs";
|
|
39
|
+
|
|
40
|
+
// Writing state (agent or script)
|
|
41
|
+
fs.writeFileSync(
|
|
42
|
+
"data/projects/my-project.json",
|
|
43
|
+
JSON.stringify(project, null, 2),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Reading state (server route) — note the path sanitization
|
|
47
|
+
app.get("/api/projects/:id", (req, res) => {
|
|
48
|
+
const id = req.params.id.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
49
|
+
const data = fs.readFileSync(`data/projects/${id}.json`, "utf-8");
|
|
50
|
+
res.json(JSON.parse(data));
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Creating a New Data Model
|
|
55
|
+
|
|
56
|
+
When adding a new data entity (e.g., projects, tasks, settings):
|
|
57
|
+
|
|
58
|
+
1. **Define the type** in `shared/` so both client and server import it
|
|
59
|
+
2. **Create the data directory** — `data/<model>/<id>.json` (one file per item) or `data/<model>.json` (single collection)
|
|
60
|
+
3. **Add API routes** in `server/` that read/write the files (sanitize IDs from params)
|
|
61
|
+
4. **Wire SSE invalidation** — Add the query key to `useFileWatcher()` so the UI refreshes on changes
|
|
62
|
+
|
|
63
|
+
## Judgment Criteria
|
|
64
|
+
|
|
65
|
+
| Question | Single file | Directory of files |
|
|
66
|
+
| ------------------------------------ | ----------------- | ---------------------------- |
|
|
67
|
+
| Are items independently addressable? | No — use one file | Yes — one file per item |
|
|
68
|
+
| Will there be >50 items? | Probably fine | Definitely split |
|
|
69
|
+
| Do items need individual URLs? | No | Yes |
|
|
70
|
+
| Do items change independently? | No | Yes — avoids write conflicts |
|
|
71
|
+
|
|
72
|
+
## Scaling Guidance
|
|
73
|
+
|
|
74
|
+
| File Count | Recommendation |
|
|
75
|
+
| ---------- | --------------------------------------------------------------------- |
|
|
76
|
+
| Under 50 | Read-all with `readdirSync` + `readFileSync` is fine |
|
|
77
|
+
| 50–200 | Add an index file (`data/<model>/_index.json`) with IDs and summaries |
|
|
78
|
+
| 200+ | Partition into subdirectories |
|
|
79
|
+
|
|
80
|
+
For list endpoints serving many files, use `fs.promises.readFile` instead of `readFileSync` to avoid blocking the event loop.
|
|
81
|
+
|
|
82
|
+
## Security
|
|
83
|
+
|
|
84
|
+
- **Path sanitization** — Always sanitize IDs from request params before constructing file paths. Use `id.replace(/[^a-zA-Z0-9_-]/g, "")` or the core utility `isValidPath()`. Without this, `../../.env` as an ID reads your environment file.
|
|
85
|
+
- **Validate before writing** — Check data shape before writing files, especially for user-submitted data. A malformed write can break all subsequent reads.
|
|
86
|
+
|
|
87
|
+
## Related Skills
|
|
88
|
+
|
|
89
|
+
- **sse-file-watcher** — Set up real-time sync so the UI updates when data files change
|
|
90
|
+
- **scripts** — Create scripts that read/write data files for complex operations
|
|
91
|
+
- **self-modifying-code** — The agent writes data files as Tier 1 (auto-apply) modifications
|