lua-cli 2.2.8-alpha.2 → 2.3.0-alpha.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/API_REFERENCE.md +1408 -0
- package/CLI_REFERENCE.md +818 -0
- package/GETTING_STARTED.md +1040 -0
- package/README.md +738 -424
- package/TEMPLATE_GUIDE.md +1398 -0
- package/dist/api/agent.api.service.d.ts +33 -6
- package/dist/api/agent.api.service.js +27 -0
- package/dist/api/auth.api.service.d.ts +31 -2
- package/dist/api/auth.api.service.js +29 -0
- package/dist/api/basket.api.service.d.ts +53 -11
- package/dist/api/basket.api.service.js +63 -14
- package/dist/api/chat.api.service.d.ts +15 -3
- package/dist/api/chat.api.service.js +12 -0
- package/dist/api/credentials.d.ts +24 -0
- package/dist/api/credentials.js +46 -0
- package/dist/api/custom.data.api.service.d.ts +45 -9
- package/dist/api/custom.data.api.service.js +43 -9
- package/dist/api/lazy-instances.d.ts +49 -0
- package/dist/api/lazy-instances.js +95 -0
- package/dist/api/order.api.service.d.ts +34 -4
- package/dist/api/order.api.service.js +41 -3
- package/dist/api/products.api.service.d.ts +39 -9
- package/dist/api/products.api.service.js +43 -5
- package/dist/api/skills.api.service.d.ts +49 -2
- package/dist/api/skills.api.service.js +47 -1
- package/dist/api/tool.api.service.d.ts +39 -1
- package/dist/api/tool.api.service.js +38 -0
- package/dist/api/user.data.api.service.d.ts +23 -1
- package/dist/api/user.data.api.service.js +22 -0
- package/dist/api-exports.d.ts +236 -5
- package/dist/api-exports.js +264 -81
- package/dist/cli/command-definitions.d.ts +30 -0
- package/dist/cli/command-definitions.js +71 -0
- package/dist/commands/agents.d.ts +20 -0
- package/dist/commands/agents.js +24 -2
- package/dist/commands/apiKey.d.ts +23 -0
- package/dist/commands/apiKey.js +23 -0
- package/dist/commands/compile.d.ts +24 -0
- package/dist/commands/compile.js +67 -759
- package/dist/commands/configure.d.ts +24 -0
- package/dist/commands/configure.js +31 -96
- package/dist/commands/deploy.d.ts +31 -19
- package/dist/commands/deploy.js +45 -74
- package/dist/commands/destroy.d.ts +27 -0
- package/dist/commands/destroy.js +27 -1
- package/dist/commands/dev.d.ts +25 -62
- package/dist/commands/dev.js +58 -878
- package/dist/commands/init.d.ts +27 -0
- package/dist/commands/init.js +98 -260
- package/dist/commands/push.d.ts +24 -21
- package/dist/commands/push.js +39 -92
- package/dist/commands/test.d.ts +26 -0
- package/dist/commands/test.js +41 -188
- package/dist/common/basket.instance.d.ts +54 -3
- package/dist/common/basket.instance.js +56 -3
- package/dist/common/data.entry.instance.d.ts +25 -2
- package/dist/common/data.entry.instance.js +24 -0
- package/dist/common/http.client.d.ts +51 -1
- package/dist/common/http.client.js +50 -0
- package/dist/common/order.instance.d.ts +22 -0
- package/dist/common/order.instance.js +31 -4
- package/dist/common/product.instance.d.ts +22 -1
- package/dist/common/product.instance.js +24 -6
- package/dist/common/product.pagination.instance.d.ts +22 -2
- package/dist/common/product.pagination.instance.js +22 -1
- package/dist/common/product.search.instance.d.ts +13 -3
- package/dist/common/product.search.instance.js +12 -1
- package/dist/common/user.instance.d.ts +27 -3
- package/dist/common/user.instance.js +28 -7
- package/dist/config/auth.constants.d.ts +11 -0
- package/dist/config/auth.constants.js +11 -0
- package/dist/config/compile.constants.d.ts +67 -0
- package/dist/config/compile.constants.js +99 -0
- package/dist/config/constants.d.ts +5 -0
- package/dist/config/constants.js +5 -0
- package/dist/config/dev.constants.d.ts +65 -0
- package/dist/config/dev.constants.js +79 -0
- package/dist/config/init.constants.d.ts +23 -0
- package/dist/config/init.constants.js +41 -0
- package/dist/index.d.ts +19 -3
- package/dist/index.js +28 -44
- package/dist/interfaces/admin.d.ts +56 -50
- package/dist/interfaces/admin.js +4 -0
- package/dist/interfaces/agent.d.ts +21 -0
- package/dist/interfaces/agent.js +4 -0
- package/dist/interfaces/baskets.d.ts +60 -0
- package/dist/interfaces/baskets.js +12 -0
- package/dist/interfaces/chat.d.ts +48 -4
- package/dist/interfaces/chat.js +4 -0
- package/dist/interfaces/common.d.ts +62 -0
- package/dist/interfaces/common.js +8 -0
- package/dist/interfaces/compile.d.ts +11 -0
- package/dist/interfaces/compile.js +4 -0
- package/dist/interfaces/custom.data.d.ts +49 -19
- package/dist/interfaces/custom.data.js +4 -0
- package/dist/interfaces/deploy.d.ts +29 -0
- package/dist/interfaces/deploy.js +4 -0
- package/dist/interfaces/dev.d.ts +53 -0
- package/dist/interfaces/dev.js +5 -0
- package/dist/interfaces/init.d.ts +60 -0
- package/dist/interfaces/init.js +4 -0
- package/dist/interfaces/orders.d.ts +37 -0
- package/dist/interfaces/orders.js +12 -0
- package/dist/interfaces/product.d.ts +38 -10
- package/dist/interfaces/product.js +4 -0
- package/dist/interfaces/push.d.ts +26 -0
- package/dist/interfaces/push.js +4 -0
- package/dist/interfaces/test.d.ts +36 -0
- package/dist/interfaces/test.js +4 -0
- package/dist/services/auth.d.ts +54 -99
- package/dist/services/auth.js +76 -12
- package/dist/types/api-contracts.d.ts +211 -0
- package/dist/types/api-contracts.js +8 -0
- package/dist/types/compile.types.d.ts +76 -0
- package/dist/types/compile.types.js +4 -0
- package/dist/types/index.d.ts +23 -121
- package/dist/types/index.js +25 -14
- package/dist/types/skill.d.ts +142 -0
- package/dist/{skill.js → types/skill.js} +66 -17
- package/dist/types/tool-validation.d.ts +34 -0
- package/dist/types/tool-validation.js +42 -0
- package/dist/utils/auth-flows.d.ts +26 -0
- package/dist/utils/auth-flows.js +141 -0
- package/dist/utils/bundling.d.ts +36 -0
- package/dist/utils/bundling.js +137 -0
- package/dist/utils/compile.d.ts +37 -0
- package/dist/utils/compile.js +242 -0
- package/dist/utils/deploy-api.d.ts +26 -0
- package/dist/utils/deploy-api.js +53 -0
- package/dist/utils/deploy-helpers.d.ts +46 -0
- package/dist/utils/deploy-helpers.js +86 -0
- package/dist/utils/deployment.d.ts +25 -0
- package/dist/utils/deployment.js +161 -0
- package/dist/utils/dev-api.d.ts +61 -0
- package/dist/utils/dev-api.js +262 -0
- package/dist/utils/dev-helpers.d.ts +46 -0
- package/dist/utils/dev-helpers.js +83 -0
- package/dist/utils/dev-server.d.ts +24 -0
- package/dist/utils/dev-server.js +555 -0
- package/dist/utils/dev-watcher.d.ts +31 -0
- package/dist/utils/dev-watcher.js +110 -0
- package/dist/utils/files.js +0 -5
- package/dist/utils/init-agent.d.ts +34 -0
- package/dist/utils/init-agent.js +129 -0
- package/dist/utils/init-helpers.d.ts +41 -0
- package/dist/utils/init-helpers.js +73 -0
- package/dist/utils/init-prompts.d.ts +47 -0
- package/dist/utils/init-prompts.js +168 -0
- package/dist/utils/push-api.d.ts +15 -0
- package/dist/utils/push-api.js +48 -0
- package/dist/utils/push-helpers.d.ts +38 -0
- package/dist/utils/push-helpers.js +84 -0
- package/dist/utils/sandbox-storage.d.ts +27 -0
- package/dist/utils/sandbox-storage.js +71 -0
- package/dist/utils/sandbox.js +78 -114
- package/dist/utils/skill-management.d.ts +14 -0
- package/dist/utils/skill-management.js +148 -0
- package/dist/utils/test-helpers.d.ts +40 -0
- package/dist/utils/test-helpers.js +92 -0
- package/dist/utils/test-prompts.d.ts +23 -0
- package/dist/utils/test-prompts.js +186 -0
- package/dist/utils/tool-detection.d.ts +18 -0
- package/dist/utils/tool-detection.js +110 -0
- package/dist/web/app.css +941 -17
- package/dist/web/app.js +174 -22
- package/dist/web/index.html +7 -1
- package/package.json +13 -4
- package/template/QUICKSTART.md +299 -144
- package/template/README.md +928 -349
- package/template/TOOL_EXAMPLES.md +655 -0
- package/template/package-lock.json +5 -5
- package/template/package.json +1 -1
- package/template/src/index.ts +147 -207
- package/template/src/tools/BasketTool.ts +128 -0
- package/template/src/tools/CustomDataTool.ts +7 -13
- package/template/src/tools/OrderTool.ts +54 -0
- package/template/src/tools/PaymentTool.ts +1 -1
- package/template/src/tools/ProductsTool.ts +56 -118
- package/template/src/tools/UserDataTool.ts +4 -26
- package/dist/common/config.d.ts +0 -5
- package/dist/common/config.js +0 -5
- package/dist/custom-data-api.d.ts +0 -72
- package/dist/custom-data-api.js +0 -174
- package/dist/product-api.d.ts +0 -189
- package/dist/product-api.js +0 -141
- package/dist/services/api.d.ts +0 -549
- package/dist/services/api.js +0 -596
- package/dist/skill.d.ts +0 -50
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -2
- package/dist/user-data-api.d.ts +0 -39
- package/dist/user-data-api.js +0 -50
- package/template/API.md +0 -604
- package/template/DEVELOPER.md +0 -771
- package/template/lua.skill.yaml +0 -7
package/dist/web/index.html
CHANGED
|
@@ -5,11 +5,17 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<meta name="description" content="Lua Developer Console - Build, test, and deploy AI agents">
|
|
7
7
|
<title>Lua Developer Console</title>
|
|
8
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
|
|
11
|
+
<link href="https://fonts.googleapis.com/css2?family=Onest:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet">
|
|
8
12
|
<link rel="stylesheet" href="/app.css">
|
|
9
13
|
<link rel="stylesheet" href="/tools-page.css">
|
|
10
14
|
</head>
|
|
11
15
|
<body>
|
|
12
|
-
<div id="root"
|
|
16
|
+
<div id="lua-root">
|
|
17
|
+
<div id="root"></div>
|
|
18
|
+
</div>
|
|
13
19
|
|
|
14
20
|
<script>
|
|
15
21
|
// Configuration will be injected by the server
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lua-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-alpha.2",
|
|
4
4
|
"description": "Command-line interface for Lua AI platform - develop, test, and deploy LuaSkills with custom tools",
|
|
5
5
|
"readmeFilename": "README.md",
|
|
6
6
|
"main": "dist/api-exports.js",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"lua": "./dist/index.js"
|
|
9
9
|
},
|
|
10
10
|
"exports": {
|
|
11
|
-
".": "./dist/api-exports.js"
|
|
12
|
-
"./cli": "./dist/index.js"
|
|
11
|
+
".": "./dist/api-exports.js"
|
|
13
12
|
},
|
|
14
13
|
"scripts": {
|
|
15
14
|
"clean": "rm -rf dist",
|
|
@@ -54,19 +53,29 @@
|
|
|
54
53
|
"dist/**/*",
|
|
55
54
|
"template/**/*",
|
|
56
55
|
"README.md",
|
|
56
|
+
"GETTING_STARTED.md",
|
|
57
|
+
"CLI_REFERENCE.md",
|
|
58
|
+
"API_REFERENCE.md",
|
|
59
|
+
"TEMPLATE_GUIDE.md",
|
|
57
60
|
"CHANGELOG.md",
|
|
58
61
|
"LICENSE"
|
|
59
62
|
],
|
|
60
63
|
"dependencies": {
|
|
64
|
+
"@tailwindcss/postcss": "^4.1.14",
|
|
65
|
+
"autoprefixer": "^10.4.21",
|
|
61
66
|
"commander": "^14.0.1",
|
|
62
67
|
"dotenv": "^17.2.3",
|
|
63
68
|
"esbuild": "^0.25.10",
|
|
64
69
|
"inquirer": "^12.9.6",
|
|
65
70
|
"js-yaml": "^4.1.0",
|
|
66
71
|
"keytar": "^7.9.0",
|
|
67
|
-
"lua-
|
|
72
|
+
"lua-ai-chat": "^0.0.4",
|
|
73
|
+
"lua-cli": "^2.3.0-alpha.1",
|
|
74
|
+
"luaniverse": "^4.0.41",
|
|
68
75
|
"node-fetch": "^3.3.2",
|
|
69
76
|
"open": "^10.1.0",
|
|
77
|
+
"postcss": "^8.5.6",
|
|
78
|
+
"postcss-prefixwrap": "^1.57.0",
|
|
70
79
|
"react": "^18.2.0",
|
|
71
80
|
"react-dom": "^18.2.0",
|
|
72
81
|
"react-markdown": "^9.0.1",
|
package/template/QUICKSTART.md
CHANGED
|
@@ -1,170 +1,325 @@
|
|
|
1
|
-
# Quick Start
|
|
1
|
+
# Quick Start - 5 Minutes to Your First AI Skill
|
|
2
2
|
|
|
3
|
-
Get up and running
|
|
3
|
+
Get up and running in 5 minutes!
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ⚡ Super Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# 1. Test the examples
|
|
11
|
+
lua test
|
|
12
|
+
|
|
13
|
+
# 2. Start dev mode
|
|
14
|
+
lua dev
|
|
15
|
+
|
|
16
|
+
# 3. Chat at http://localhost:3000
|
|
17
|
+
# Try: "What's the weather in London?"
|
|
18
|
+
|
|
19
|
+
# 4. Customize src/index.ts
|
|
20
|
+
|
|
21
|
+
# 5. Deploy
|
|
22
|
+
lua push
|
|
23
|
+
lua deploy
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Done!** 🎉
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🧪 Step 1: Test Tools (1 minute)
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
lua test
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Try these:**
|
|
37
|
+
|
|
38
|
+
1. **Select:** `get_weather`
|
|
39
|
+
- **Input:** city: `London`
|
|
40
|
+
- **Output:** Temperature, wind speed, conditions
|
|
41
|
+
|
|
42
|
+
2. **Select:** `search_products`
|
|
43
|
+
- **Input:** query: `laptop`
|
|
44
|
+
- **Output:** Product list
|
|
45
|
+
|
|
46
|
+
3. **Select:** `search_movies`
|
|
47
|
+
- **Input:** query: `thriller`
|
|
48
|
+
- **Output:** Movies with similarity scores
|
|
49
|
+
|
|
50
|
+
**What you learned:** How tools work!
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 💬 Step 2: Chat Test (2 minutes)
|
|
6
55
|
|
|
7
56
|
```bash
|
|
8
|
-
|
|
57
|
+
lua dev
|
|
9
58
|
```
|
|
10
59
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
description = "Say hello to someone";
|
|
29
|
-
|
|
30
|
-
inputSchema = z.object({
|
|
31
|
-
name: z.string().describe("Name to greet")
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
outputSchema = z.object({
|
|
35
|
-
message: z.string(),
|
|
36
|
-
timestamp: z.string()
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
async execute(input) {
|
|
40
|
-
return {
|
|
41
|
-
message: `Hello, ${input.name}!`,
|
|
42
|
-
timestamp: new Date().toISOString()
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
3. **Register the tool:**
|
|
49
|
-
```typescript
|
|
50
|
-
// index.ts
|
|
51
|
-
import { LuaSkill } from "lua-cli/skill";
|
|
52
|
-
import HelloTool from "./tools/HelloTool";
|
|
53
|
-
|
|
54
|
-
const skill = new LuaSkill();
|
|
55
|
-
skill.addTool(new HelloTool());
|
|
56
|
-
|
|
57
|
-
// Test the tool
|
|
58
|
-
async function test() {
|
|
59
|
-
const result = await skill.run({
|
|
60
|
-
tool: "hello",
|
|
61
|
-
name: "World"
|
|
62
|
-
});
|
|
63
|
-
console.log(result);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
test().catch(console.error);
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
4. **Compile and test:**
|
|
70
|
-
```bash
|
|
71
|
-
lua compile
|
|
72
|
-
lua test
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## 🎯 Common Patterns
|
|
76
|
-
|
|
77
|
-
### API Call Tool
|
|
60
|
+
**Browser opens at http://localhost:3000**
|
|
61
|
+
|
|
62
|
+
**Try chatting:**
|
|
63
|
+
- "What's the weather in Tokyo?"
|
|
64
|
+
- "Show me your products"
|
|
65
|
+
- "Create a movie called Inception directed by Christopher Nolan in 2010"
|
|
66
|
+
- "Search for movies about dreams"
|
|
67
|
+
- "Create a shopping basket and add a laptop"
|
|
68
|
+
|
|
69
|
+
**What you learned:** How AI uses your tools!
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 🎨 Step 3: Customize (2 minutes)
|
|
74
|
+
|
|
75
|
+
Open **`src/index.ts`** and simplify:
|
|
76
|
+
|
|
78
77
|
```typescript
|
|
79
|
-
import
|
|
78
|
+
import { LuaSkill } from "lua-cli";
|
|
79
|
+
import GetWeatherTool from "./tools/GetWeatherTool";
|
|
80
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
|
-
|
|
81
|
+
// Keep only what you need
|
|
82
|
+
const mySkill = new LuaSkill({
|
|
83
|
+
name: "my-skill",
|
|
84
|
+
version: "1.0.0",
|
|
85
|
+
description: "My custom AI assistant",
|
|
86
|
+
context: "Use get_weather when users ask about weather.",
|
|
87
|
+
tools: [
|
|
88
|
+
new GetWeatherTool()
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Save the file** - dev mode auto-reloads!
|
|
94
|
+
|
|
95
|
+
Chat again: "What's the weather in Paris?"
|
|
96
|
+
|
|
97
|
+
**What you learned:** How to customize!
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 🚀 What's Next?
|
|
102
|
+
|
|
103
|
+
### Option A: Learn by Exploring
|
|
104
|
+
|
|
105
|
+
1. Read each tool in `src/tools/`
|
|
106
|
+
2. Try modifying them
|
|
107
|
+
3. Test your changes
|
|
108
|
+
4. Build confidence
|
|
109
|
+
|
|
110
|
+
**Time:** A few hours
|
|
111
|
+
**Best for:** Visual learners
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### Option B: Build Something Specific
|
|
116
|
+
|
|
117
|
+
Pick a use case:
|
|
118
|
+
- **Knowledge Base** → Use CustomDataTool.ts as template
|
|
119
|
+
- **E-commerce** → Use ProductsTool.ts + BasketTool.ts
|
|
120
|
+
- **Booking System** → Modify CustomDataTool.ts
|
|
121
|
+
- **CRM** → Create customer management tools
|
|
122
|
+
|
|
123
|
+
**Time:** 1-2 hours
|
|
124
|
+
**Best for:** Goal-oriented builders
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### Option C: Follow Complete Tutorial
|
|
129
|
+
|
|
130
|
+
Read **README.md** in this directory for:
|
|
131
|
+
- Detailed tool explanations
|
|
132
|
+
- Customization recipes
|
|
133
|
+
- Multi-skill projects
|
|
134
|
+
- Best practices
|
|
135
|
+
|
|
136
|
+
**Time:** 30 minutes reading, 1 hour building
|
|
137
|
+
**Best for:** Thorough learners
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 🎯 Common First Tasks
|
|
142
|
+
|
|
143
|
+
### Remove Unused Tools
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Delete what you don't need
|
|
147
|
+
rm src/tools/BasketTool.ts
|
|
148
|
+
rm src/tools/OrderTool.ts
|
|
149
|
+
|
|
150
|
+
# Update src/index.ts to remove imports
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### Add Your Own Tool
|
|
156
|
+
|
|
157
|
+
1. **Create** `src/tools/MyTool.ts`:
|
|
158
|
+
```typescript
|
|
159
|
+
import { LuaTool } from "lua-cli";
|
|
160
|
+
import { z } from "zod";
|
|
161
|
+
|
|
162
|
+
export default class MyTool implements LuaTool {
|
|
163
|
+
name = "my_tool";
|
|
164
|
+
description = "What it does";
|
|
165
|
+
inputSchema = z.object({ param: z.string() });
|
|
166
|
+
|
|
167
|
+
async execute(input: any) {
|
|
168
|
+
return { result: "Hello " + input.param };
|
|
105
169
|
}
|
|
106
170
|
}
|
|
107
171
|
```
|
|
108
172
|
|
|
109
|
-
|
|
173
|
+
2. **Add to** `src/index.ts`:
|
|
110
174
|
```typescript
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
175
|
+
import MyTool from "./tools/MyTool";
|
|
176
|
+
|
|
177
|
+
const skill = new LuaSkill({
|
|
178
|
+
tools: [new MyTool()]
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
3. **Test:**
|
|
183
|
+
```bash
|
|
184
|
+
lua test
|
|
185
|
+
# Select "my_tool" → Enter param → See result
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### Use External API
|
|
191
|
+
|
|
192
|
+
Example: Call a REST API
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
async execute(input: any) {
|
|
196
|
+
const response = await fetch('https://api.example.com/data', {
|
|
197
|
+
method: 'POST',
|
|
198
|
+
headers: { 'Content-Type': 'application/json' },
|
|
199
|
+
body: JSON.stringify(input)
|
|
118
200
|
});
|
|
119
201
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
202
|
+
const data = await response.json();
|
|
203
|
+
return data;
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### Store Data
|
|
210
|
+
|
|
211
|
+
Example: Save user preferences
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
import { Data } from "lua-cli";
|
|
215
|
+
|
|
216
|
+
async execute(input: any) {
|
|
217
|
+
// Create
|
|
218
|
+
await Data.create('preferences', {
|
|
219
|
+
theme: input.theme,
|
|
220
|
+
language: input.language
|
|
123
221
|
});
|
|
124
222
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
case "sort":
|
|
130
|
-
result = input.data.sort();
|
|
131
|
-
break;
|
|
132
|
-
case "filter":
|
|
133
|
-
result = input.data.filter(item => item > 0);
|
|
134
|
-
break;
|
|
135
|
-
case "map":
|
|
136
|
-
result = input.data.map(item => item * 2);
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
result,
|
|
142
|
-
count: result.length
|
|
143
|
-
};
|
|
144
|
-
}
|
|
223
|
+
// Later: Get
|
|
224
|
+
const prefs = await Data.get('preferences');
|
|
225
|
+
|
|
226
|
+
return prefs;
|
|
145
227
|
}
|
|
146
228
|
```
|
|
147
229
|
|
|
148
|
-
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 🎨 Template Features
|
|
233
|
+
|
|
234
|
+
### 30+ Working Examples
|
|
235
|
+
|
|
236
|
+
Every common pattern is demonstrated:
|
|
237
|
+
- ✅ External API calls
|
|
238
|
+
- ✅ Platform API usage
|
|
239
|
+
- ✅ Vector search
|
|
240
|
+
- ✅ CRUD operations
|
|
241
|
+
- ✅ Multi-step workflows
|
|
242
|
+
- ✅ Error handling
|
|
243
|
+
- ✅ Input validation
|
|
244
|
+
|
|
245
|
+
### All Platform APIs
|
|
246
|
+
|
|
247
|
+
- ✅ User - User data management
|
|
248
|
+
- ✅ Data - Custom data with search
|
|
249
|
+
- ✅ Products - Product catalog
|
|
250
|
+
- ✅ Baskets - Shopping carts
|
|
251
|
+
- ✅ Orders - Order processing
|
|
252
|
+
|
|
253
|
+
### Production Ready
|
|
254
|
+
|
|
255
|
+
- ✅ TypeScript configured
|
|
256
|
+
- ✅ Type-safe
|
|
257
|
+
- ✅ Error handling
|
|
258
|
+
- ✅ Validation
|
|
259
|
+
- ✅ Ready to deploy
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## 🚨 Need Help?
|
|
264
|
+
|
|
265
|
+
### Quick Answers
|
|
266
|
+
|
|
267
|
+
**"How do I test?"**
|
|
268
|
+
```bash
|
|
269
|
+
lua test # Interactive testing
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**"How do I see it work?"**
|
|
273
|
+
```bash
|
|
274
|
+
lua dev # Chat interface at http://localhost:3000
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**"How do I deploy?"**
|
|
278
|
+
```bash
|
|
279
|
+
lua push # Upload
|
|
280
|
+
lua deploy # Go live
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**"Which tool should I start with?"**
|
|
284
|
+
- Simple: `CreatePostTool.ts`
|
|
285
|
+
- External API: `GetWeatherTool.ts`
|
|
286
|
+
- Platform API: `UserDataTool.ts`
|
|
287
|
+
- Complex: `BasketTool.ts`
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### Documentation
|
|
292
|
+
|
|
293
|
+
- **README.md** (this directory) - Complete project guide
|
|
294
|
+
- **TOOL_EXAMPLES.md** - Detailed tool explanations
|
|
295
|
+
- **../API_REFERENCE.md** - Full API docs
|
|
296
|
+
- **../CLI_REFERENCE.md** - All commands
|
|
297
|
+
- **../GETTING_STARTED.md** - Complete tutorial
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## ✨ Pro Tips
|
|
302
|
+
|
|
303
|
+
1. **Start with `lua dev`** - See everything in action
|
|
304
|
+
2. **Copy, don't write from scratch** - Modify examples
|
|
305
|
+
3. **Test often** - `lua test` after every change
|
|
306
|
+
4. **Read the code** - Examples are well-commented
|
|
307
|
+
5. **Ask the AI** - Use dev mode to test edge cases
|
|
308
|
+
|
|
309
|
+
---
|
|
149
310
|
|
|
150
|
-
|
|
151
|
-
- [README.md](./README.md) - Complete guide
|
|
152
|
-
- [DEVELOPER.md](./DEVELOPER.md) - Technical details
|
|
153
|
-
- [API.md](./API.md) - API reference
|
|
311
|
+
## 🎯 5-Minute Challenge
|
|
154
312
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
313
|
+
**Can you:**
|
|
314
|
+
1. Run `lua dev`
|
|
315
|
+
2. Chat: "What's the weather in your city?"
|
|
316
|
+
3. Edit `GetWeatherTool.ts` to add a fun fact about the city
|
|
317
|
+
4. Save and see it auto-reload
|
|
318
|
+
5. Chat again and see your change
|
|
158
319
|
|
|
159
|
-
|
|
160
|
-
- Create tools for your specific use case
|
|
161
|
-
- Integrate with your favorite APIs
|
|
162
|
-
- Share your skills with the community
|
|
320
|
+
**If yes, you're ready to build!** 🚀
|
|
163
321
|
|
|
164
|
-
|
|
322
|
+
---
|
|
165
323
|
|
|
166
|
-
|
|
167
|
-
- Look at the [API reference](./API.md)
|
|
168
|
-
- Review the [developer documentation](./DEVELOPER.md)
|
|
324
|
+
**For more details, see README.md in this directory**
|
|
169
325
|
|
|
170
|
-
Happy coding! 🎉
|