Skip to content

Commit b2b28ea

Browse files
committed
even more help with context
1 parent 95e8936 commit b2b28ea

6 files changed

Lines changed: 243 additions & 17 deletions

File tree

commands/coldbox/ai/install.cfc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,7 @@ component extends="coldbox-cli.models.BaseAICommand" {
8888
print.line()
8989
}
9090

91-
printInfo( "Agents configured:" );
92-
93-
if ( arguments.verbose ) {
94-
result.agents.each( ( agent ) => {
95-
print.indentedLine( " • #agent#" )
96-
} )
97-
print.line()
98-
}
91+
printInfo( "Agents configured: #result.agents.toList()#" )
9992

10093
// Show MCP servers
10194
var totalMcpServers = result.mcpServers.core.len() + result.mcpServers.module.len()

commands/coldbox/ai/refresh.cfc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ component extends="coldbox-cli.models.BaseAICommand" {
8282
if ( !totalAdded && !totalUpdated && !totalRemoved ) {
8383
printInfo( "No changes detected. Everything is up to date!" )
8484
}
85+
86+
// Show regenerated agent files
87+
if ( structKeyExists( result, "agents" ) && result.agents.len() ) {
88+
print.cyanLine( "Agent files regenerated (#result.agents.len()#):" )
89+
result.agents.each( ( agent ) => {
90+
print.indentedCyanLine( " ↻ #agent#" )
91+
} )
92+
print.line()
93+
}
8594
}
8695

8796
}

models/AIService.cfc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ component singleton {
155155
"updated" : [],
156156
"removed" : []
157157
},
158-
"mcpServers" : { "added" : [], "removed" : [] }
158+
"mcpServers" : { "added" : [], "removed" : [] },
159+
"agents" : []
159160
};
160161

161162
// Load existing manifest
@@ -228,6 +229,7 @@ component singleton {
228229
var language = manifest.language ?: "boxlang";
229230
manifest.agents.each( ( agent ) => {
230231
variables.agentRegistry.configureAgent( directory, agent, language );
232+
result.agents.append( agent );
231233
} );
232234
}
233235

models/AgentRegistry.cfc

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,28 @@ component singleton {
384384
"all"
385385
)
386386

387+
// Add guidelines inventory (module and additional guidelines only)
388+
// Language-specific guideline file and description
389+
var languageGuidelineFile = "`.ai/guidelines/core/boxlang.md`"
390+
var languageGuidelineDesc = "BoxLang syntax and patterns"
391+
if ( arguments.language == "cfml" ) {
392+
languageGuidelineFile = "`.ai/guidelines/core/cfml.md`"
393+
languageGuidelineDesc = "CFML syntax and patterns"
394+
} else if ( arguments.language == "hybrid" ) {
395+
languageGuidelineFile = "`.ai/guidelines/core/boxlang.md`"
396+
languageGuidelineDesc = "BoxLang/CFML syntax and patterns (or `cfml.md` for CFML-only)"
397+
}
398+
content = replaceNoCase( content, "|LANGUAGE_GUIDELINE_FILE|", languageGuidelineFile, "all" )
399+
content = replaceNoCase( content, "|LANGUAGE_GUIDELINE_DESC|", languageGuidelineDesc, "all" )
400+
401+
// Generate installed modules content
402+
var installedModulesContent = generateInstalledModulesContent( arguments.directory, boxJson )
403+
content = replaceNoCase( content, "|INSTALLED_MODULES|", installedModulesContent, "all" )
404+
405+
// Generate handlers snapshot
406+
var handlersSnapshotContent = generateHandlersSnapshot( arguments.directory, arguments.templateType )
407+
content = replaceNoCase( content, "|HANDLERS_SNAPSHOT|", handlersSnapshotContent, "all" )
408+
387409
// Add guidelines inventory (module and additional guidelines only)
388410
var guidelinesContent = generateGuidelinesContent(
389411
arguments.directory,
@@ -757,4 +779,116 @@ component singleton {
757779
return content.toList( chr( 10 ) )
758780
}
759781

782+
/**
783+
* Generate a list of installed project modules (excluding framework packages)
784+
*
785+
* @directory The project directory
786+
* @boxJson The parsed box.json struct
787+
*
788+
* @return Formatted markdown bullet list of installed modules
789+
*/
790+
private function generateInstalledModulesContent(
791+
required string directory,
792+
required struct boxJson
793+
){
794+
// Packages to skip — framework internals that aren't actionable for the AI
795+
var frameworkPackages = [
796+
"coldbox",
797+
"testbox",
798+
"wirebox",
799+
"cachebox",
800+
"logbox"
801+
]
802+
803+
var dependencies = arguments.boxJson.dependencies ?: {}
804+
var lines = []
805+
806+
for ( var pkg in dependencies ) {
807+
// Skip framework packages and commandbox-* infrastructure packages
808+
if ( frameworkPackages.findNoCase( pkg ) || pkg.startsWith( "commandbox-" ) ) {
809+
continue;
810+
}
811+
var version = dependencies[ pkg ]
812+
lines.append( "- **#pkg#** (#version#)" )
813+
}
814+
815+
if ( !lines.len() ) {
816+
return "No additional modules installed yet."
817+
}
818+
819+
lines.sort( "textnocase" )
820+
return lines.toList( chr( 10 ) )
821+
}
822+
823+
/**
824+
* Generate a snapshot of existing handlers and their public actions
825+
*
826+
* @directory The project directory
827+
* @templateType "modern" or "flat"
828+
*
829+
* @return Formatted markdown bullet list of handlers and their actions
830+
*/
831+
private function generateHandlersSnapshot(
832+
required string directory,
833+
required string templateType
834+
){
835+
var handlersRoot = arguments.templateType == "modern"
836+
? "#arguments.directory#/app/handlers"
837+
: "#arguments.directory#/handlers"
838+
839+
if ( !directoryExists( handlersRoot ) ) {
840+
return "No handlers found."
841+
}
842+
843+
// Lifecycle / framework methods to exclude from the action list
844+
var lifecycleMethods = [
845+
"init",
846+
"onmissingaction",
847+
"onerror",
848+
"onrequeststart",
849+
"onrequestend",
850+
"onapplicationstart",
851+
"onsessionstart",
852+
"onsessionend",
853+
"onapplicationend"
854+
]
855+
856+
// Use a Java regex to extract public function names
857+
var pattern = createObject( "java", "java.util.regex.Pattern" ).compile(
858+
"(?i)(?:^|\s)(?:public\s+)?(?:\w+\s+)?function\s+(\w+)\s*\("
859+
)
860+
861+
var handlerFiles = directoryList( handlersRoot, false, "path", "*.cfc|*.bx" )
862+
var lines = []
863+
864+
for ( var handlerFile in handlerFiles ) {
865+
var handlerName = listFirst( getFileFromPath( handlerFile ), "." )
866+
var source = fileRead( handlerFile )
867+
var matcher = pattern.matcher( source )
868+
var actions = []
869+
870+
while ( matcher.find() ) {
871+
var fnName = matcher.group( 1 )
872+
if ( !lifecycleMethods.findNoCase( fnName ) ) {
873+
if ( !actions.findNoCase( fnName ) ) {
874+
actions.append( fnName )
875+
}
876+
}
877+
}
878+
879+
if ( actions.len() ) {
880+
lines.append( "- **#handlerName#**: #actions.toList( ', ' )#" )
881+
} else {
882+
lines.append( "- **#handlerName#**: _(no public actions)_" )
883+
}
884+
}
885+
886+
if ( !lines.len() ) {
887+
return "No handlers found."
888+
}
889+
890+
lines.sort( "textnocase" )
891+
return lines.toList( chr( 10 ) )
892+
}
893+
760894
}

templates/ai/agents/agent-flat-instructions.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,24 @@ This is a ColdBox HMVC application using the **flat template structure** where a
3737

3838
## Framework Knowledge
3939

40-
Core ColdBox and |LANGUAGE_MODE| guidelines are installed in `.ai/guidelines/core/`. Supported tools
40+
Core ColdBox and language guidelines are installed in `.ai/guidelines/core/`. Supported tools
4141
(e.g., VS Code Copilot) load them automatically via file attachments. For other agents, load them
4242
explicitly when you need framework fundamentals:
4343

4444
- `read_file` on `.ai/guidelines/core/coldbox.md` — ColdBox conventions, handlers, routing, DI reference
45-
- `read_file` on `.ai/guidelines/core/boxlang.md` — BoxLang syntax and patterns (or `cfml.md` for CFML projects)
45+
- `read_file` on |LANGUAGE_GUIDELINE_FILE| — |LANGUAGE_GUIDELINE_DESC|
46+
47+
## Installed Modules
48+
49+
The following ColdBox modules are installed in this project. Use these when generating code, checking available services, and suggesting relevant skills or guidelines:
50+
51+
|INSTALLED_MODULES|
52+
53+
## Handlers Snapshot
54+
55+
Current event handlers and their public actions (auto-updated on `coldbox ai refresh`):
56+
57+
|HANDLERS_SNAPSHOT|
4658

4759
## AI Integration & Resources
4860

@@ -177,5 +189,37 @@ This project has access to the following Model Context Protocol (MCP) documentat
177189
<!-- COLDBOX-CLI:END -->
178190

179191
<!-- ℹ️ YOUR PROJECT DOCUMENTATION — Add your custom details below. ColdBox CLI will NOT overwrite this section. -->
180-
<!-- 📝 TODO: Describe your business domain, key services, auth approach, and project-specific conventions. -->
181-
<!-- Suggested sections: Business Domain, Key Services/Models, Authentication/Security, API Endpoints, Database, Deployment -->
192+
193+
## About This Application
194+
195+
> ⚠️ Fill in this section to give your AI assistant context about your specific application.
196+
197+
### Business Domain
198+
199+
<!-- Describe what this application does and its primary purpose -->
200+
201+
### Key Services & Models
202+
203+
<!-- List important services and their responsibilities, e.g.:
204+
- UserService — authentication, registration, profile management
205+
- OrderService — cart, checkout, order lifecycle
206+
-->
207+
208+
### Authentication & Security
209+
210+
<!-- Describe authentication approach, e.g., cbSecurity + JWT, session-based, etc. -->
211+
212+
### API Endpoints
213+
214+
<!-- Document REST API routes if applicable, e.g.:
215+
- GET /api/v1/users — list users
216+
- POST /api/v1/users — create user
217+
-->
218+
219+
### Database
220+
221+
<!-- Document database setup, ORM entities, migrations if applicable -->
222+
223+
### Deployment
224+
225+
<!-- Document deployment process, environments, CI/CD pipeline -->

templates/ai/agents/agent-modern-instructions.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,24 @@ This is a ColdBox HMVC application using the **modern template structure** with
6464

6565
## Framework Knowledge
6666

67-
Core ColdBox and |LANGUAGE_MODE| guidelines are installed in `.ai/guidelines/core/`. Supported tools
67+
Core ColdBox and language guidelines are installed in `.ai/guidelines/core/`. Supported tools
6868
(e.g., VS Code Copilot) load them automatically via file attachments. For other agents, load them
6969
explicitly when you need framework fundamentals:
7070

7171
- `read_file` on `.ai/guidelines/core/coldbox.md` — ColdBox conventions, handlers, routing, DI reference
72-
- `read_file` on `.ai/guidelines/core/boxlang.md` — BoxLang syntax and patterns (or `cfml.md` for CFML projects)
72+
- `read_file` on |LANGUAGE_GUIDELINE_FILE| — |LANGUAGE_GUIDELINE_DESC|
73+
74+
## Installed Modules
75+
76+
The following ColdBox modules are installed in this project. Use these when generating code, checking available services, and suggesting relevant skills or guidelines:
77+
78+
|INSTALLED_MODULES|
79+
80+
## Handlers Snapshot
81+
82+
Current event handlers and their public actions (auto-updated on `coldbox ai refresh`):
83+
84+
|HANDLERS_SNAPSHOT|
7385

7486
## AI Integration & Resources
7587

@@ -216,5 +228,37 @@ This project has access to the following Model Context Protocol (MCP) documentat
216228
<!-- COLDBOX-CLI:END -->
217229

218230
<!-- ℹ️ YOUR PROJECT DOCUMENTATION — Add your custom details below. ColdBox CLI will NOT overwrite this section. -->
219-
<!-- 📝 TODO: Describe your business domain, key services, auth approach, and project-specific conventions. -->
220-
<!-- Suggested sections: Business Domain, Key Services/Models, Authentication/Security, API Endpoints, Database, Deployment -->
231+
232+
## About This Application
233+
234+
> ⚠️ Fill in this section to give your AI assistant context about your specific application.
235+
236+
### Business Domain
237+
238+
<!-- Describe what this application does and its primary purpose -->
239+
240+
### Key Services & Models
241+
242+
<!-- List important services and their responsibilities, e.g.:
243+
- UserService — authentication, registration, profile management
244+
- OrderService — cart, checkout, order lifecycle
245+
-->
246+
247+
### Authentication & Security
248+
249+
<!-- Describe authentication approach, e.g., cbSecurity + JWT, session-based, etc. -->
250+
251+
### API Endpoints
252+
253+
<!-- Document REST API routes if applicable, e.g.:
254+
- GET /api/v1/users — list users
255+
- POST /api/v1/users — create user
256+
-->
257+
258+
### Database
259+
260+
<!-- Document database setup, ORM entities, migrations if applicable -->
261+
262+
### Deployment
263+
264+
<!-- Document deployment process, environments, CI/CD pipeline -->

0 commit comments

Comments
 (0)