Skip to content

Commit 92a67ab

Browse files
committed
more skills work
1 parent 07d1529 commit 92a67ab

File tree

6 files changed

+349
-101
lines changed

6 files changed

+349
-101
lines changed

commands/coldbox/ai/skills/create.cfc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Examples:
66
* coldbox ai skills create api-development
77
* coldbox ai skills create testing-patterns --open
8+
* coldbox ai skills create payment-processing --cfml
89
*/
910
component extends="coldbox-cli.models.BaseAICommand" {
1011

@@ -15,20 +16,27 @@ component extends="coldbox-cli.models.BaseAICommand" {
1516
* Run the command
1617
*
1718
* @name The custom skill name
19+
* @boxlang Use BoxLang syntax (default)
20+
* @cfml Use CFML syntax
1821
* @open Open the created file in the default editor
1922
* @directory The target directory (defaults to current directory)
2023
*/
2124
function run(
2225
required string name,
26+
boolean boxlang = true,
27+
boolean cfml = false,
2328
boolean open = false,
2429
string directory = getCwd()
2530
){
2631
showColdBoxBanner( "Create Custom Skill" )
2732

2833
ensureInstalled( arguments.directory )
2934

35+
// Determine language (cfml flag overrides boxlang)
36+
var language = arguments.cfml ? "cfml" : "boxlang"
37+
3038
print.line()
31-
printInfo( "Creating custom skill: #arguments.name#" )
39+
printInfo( "Creating custom skill: #arguments.name# (#uCase(language)#)" )
3240
print.line()
3341

3442
// Check if already exists
@@ -47,7 +55,8 @@ component extends="coldbox-cli.models.BaseAICommand" {
4755
// Create skill from template
4856
variables.skillManager.createCustomSkill(
4957
arguments.directory,
50-
arguments.name
58+
arguments.name,
59+
language
5160
)
5261

5362
// Regenerate agent files

commands/coldbox/ai/skills/help.cfc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ component excludeFromHelp=true extends="coldbox-cli.models.BaseCommand" {
2626
.dim( " ## List all skills" )
2727
.line( " coldbox ai skills list" )
2828
.line()
29-
.dim( " ## Create a custom deployment workflow skill" )
30-
.line( " coldbox ai skills create deployment-workflow" )
29+
.dim( " ## Create a custom deployment workflow skill (BoxLang syntax)" )
30+
.line( " coldbox ai skills create deployment-workflow" )
31+
.line()
32+
.dim( " ## Create a custom skill with CFML syntax" )
33+
.line( " coldbox ai skills create payment-processing --cfml" )
3134
.line()
3235
.dim( " ## Refresh skills after installing new modules" )
3336
.line( " coldbox ai skills refresh" )

models/SkillManager.cfc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@ component singleton {
104104
*
105105
* @directory The project directory
106106
* @name The custom skill name
107+
* @language The language variant (boxlang or cfml)
107108
*/
108-
function createCustomSkill( required string directory, required string name ){
109+
function createCustomSkill(
110+
required string directory,
111+
required string name,
112+
string language = "boxlang"
113+
){
109114
var targetDir = "#arguments.directory#/.ai/skills/custom/#arguments.name#"
110115
var skillFile = "#targetDir#/SKILL.md"
111116

@@ -115,7 +120,8 @@ component singleton {
115120
}
116121

117122
// Create skill from template
118-
var templatePath = variables.utility.getTemplatesPath() & "/ai/skills/custom-skill-template.md"
123+
var languageSuffix = arguments.language == "cfml" ? ".cfml" : ".bx"
124+
var templatePath = variables.utility.getTemplatesPath() & "/ai/skills/custom-skill-template#languageSuffix#.md"
119125
var template = fileRead( templatePath )
120126

121127
// Replace tokens
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
---
2+
name: |skillName|
3+
category: custom
4+
triggers:
5+
- "Add trigger keywords here"
6+
- "When implementing [feature]"
7+
- "For [specific use case]"
8+
confidence: high
9+
---
10+
11+
# |skillName| Skill
12+
13+
## When to Use
14+
15+
Describe when this skill should be activated. Be specific about:
16+
17+
- User requests that should trigger this skill
18+
- Project contexts where this applies
19+
- Specific keywords or phrases that indicate this skill is needed
20+
21+
## Implementation Pattern
22+
23+
### Overview
24+
25+
Provide a high-level description of the implementation approach.
26+
27+
### Step-by-Step Guide
28+
29+
1. **Step One**: Describe the first step
30+
31+
```boxlang
32+
/**
33+
* Example implementation
34+
*/
35+
class MyClass {
36+
37+
function init() {
38+
// Implementation
39+
return this
40+
}
41+
42+
function myMethod() {
43+
// Method implementation
44+
}
45+
}
46+
```
47+
48+
2. **Step Two**: Describe the second step
49+
50+
```boxlang
51+
// More example code with BoxLang syntax
52+
var result = someService.getData()
53+
.filter( ( item ) => item.active )
54+
.map( ( item ) => item.name )
55+
```
56+
57+
3. **Step Three**: Continue with additional steps
58+
59+
## Code Examples
60+
61+
### Example 1: Basic Usage
62+
63+
```boxlang
64+
/**
65+
* Provide a complete, working example
66+
*/
67+
class MyHandler {
68+
69+
property name="userService" inject="UserService";
70+
71+
/**
72+
* Example action
73+
*/
74+
function index( event, rc, prc ) {
75+
prc.users = userService.getAll()
76+
77+
event.setView( "users/index" )
78+
}
79+
}
80+
```
81+
82+
### Example 2: Advanced Pattern
83+
84+
```boxlang
85+
/**
86+
* Show more complex usage with BoxLang features
87+
*/
88+
class MyService {
89+
90+
property name="wirebox" inject="wirebox";
91+
92+
function processData( required array data ) {
93+
return arguments.data
94+
.filter( ( item ) => item.status == "active" )
95+
.map( ( item ) => {
96+
return {
97+
"id": item.id,
98+
"name": item.name,
99+
"processed": true
100+
}
101+
} )
102+
}
103+
104+
function getRepository() {
105+
return wirebox.getInstance( "MyRepository" )
106+
}
107+
}
108+
```
109+
110+
## Best Practices
111+
112+
- Use BoxLang class syntax for modern components
113+
- Leverage lambda expressions for cleaner code
114+
- Follow BoxLang naming conventions
115+
- Document all public methods with JavaDoc-style comments
116+
- Use type hints where beneficial
117+
- Implement proper dependency injection
118+
119+
## Testing Approach
120+
121+
```boxlang
122+
/**
123+
* Example test case using TestBox BDD
124+
*/
125+
class MyHandlerTest extends BaseTestCase {
126+
127+
function beforeAll() {
128+
super.beforeAll()
129+
}
130+
131+
function run() {
132+
describe( "|skillName| Tests", () => {
133+
it( "should implement feature", () => {
134+
var result = getInstance( "MyHandler" ).index(
135+
event = getRequestContext(),
136+
rc = {},
137+
prc = {}
138+
)
139+
140+
expect( result ).notToBeNull()
141+
} )
142+
} )
143+
}
144+
}
145+
```
146+
147+
## Common Mistakes
148+
149+
- **Using component syntax instead of class**: BoxLang prefers `class` over `component`
150+
- **Not using lambda expressions**: Take advantage of modern functional programming
151+
- **Missing type hints**: While optional, type hints improve code clarity
152+
- **Inconsistent formatting**: Follow BoxLang style guidelines
153+
154+
## References
155+
156+
- Link to relevant documentation
157+
- Related skills
158+
- External resources
159+
- BoxLang documentation: <https://boxlang.io/docs>

0 commit comments

Comments
 (0)