Skip to content

Commit b59a82b

Browse files
committed
feat: add JSONL route formatter for AI agents and improve command descriptions
Add a new JSONL output format for list:routes that produces one flat JSON object per line, optimized for machine consumption. Auto-selects JSONL when running inside an AI agent with no explicit format flag. Update all command descriptions to include output locations, side effects, and key flags so AI agents can make better decisions about which command to use.
1 parent 60ae7d2 commit b59a82b

25 files changed

Lines changed: 401 additions & 23 deletions

commands/add.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ export default class Add extends BaseCommand {
3333
/**
3434
* The command description
3535
*/
36-
static description = 'Install and configure one or more packages'
36+
static description =
37+
'Install and configure one or more AdonisJS packages. Runs npm install followed by the package configure hook'
38+
39+
static help = [
40+
'Use this command instead of manually running npm install + configure separately.',
41+
'Accepts shorthand names: "vinejs" for @vinejs/vine, "edge" for edge.js.',
42+
'```',
43+
'{{ binaryName }} add @adonisjs/lucid',
44+
'{{ binaryName }} add @adonisjs/auth @adonisjs/session',
45+
'```',
46+
]
3747
/**
3848
* Command options configuration
3949
*/

commands/configure.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export default class Configure extends BaseCommand {
3636
/**
3737
* The command description
3838
*/
39-
static description = 'Configure a package after it has been installed'
39+
static description =
40+
'Run the configure hook of an already-installed package. Use "add" command instead to both install and configure in one step'
4041

4142
/**
4243
* Command options configuration.

commands/eject.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export default class Eject extends BaseCommand {
3131
/**
3232
* The command description
3333
*/
34-
static description = 'Eject scaffolding stubs to your application root'
34+
static description =
35+
'Copy scaffolding stubs from a package to your application for customization. Stubs are templates used by make:* commands'
3536

3637
/**
3738
* Path to the stubs directory or a single stub file to eject

commands/env/add.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export default class EnvAdd extends BaseCommand {
3838
/**
3939
* The command description
4040
*/
41-
static description = 'Add a new environment variable'
41+
static description =
42+
'Add a new environment variable to .env, .env.example, and its validation rule to start/env.ts'
4243

4344
/**
4445
* Command options configuration.

commands/generate_key.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export default class GenerateKey extends BaseCommand {
3030
/**
3131
* The command description
3232
*/
33-
static description = 'Generate a cryptographically secure random application key'
33+
static description =
34+
'Generate a cryptographically secure APP_KEY and write it to the .env file. Use --show to print without writing'
3435

3536
/**
3637
* Display the key on the terminal, instead of writing it to .env file

commands/inspect_rcfile.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export default class InspectRCFile extends BaseCommand {
2828
/**
2929
* The command description
3030
*/
31-
static description = 'Inspect the RC file with its default values'
31+
static description =
32+
'Display the resolved adonisrc.ts configuration as JSON, including providers, preloads, commands, and meta files'
3233

3334
/**
3435
* Execute the command to display RC file contents.

commands/list/routes.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class ListRoutes extends BaseCommand {
3636
* The command description
3737
*/
3838
static description =
39-
'List application routes. This command will boot the application in the console environment'
39+
'List all registered routes with their HTTP methods, URL patterns, handlers, and middleware'
4040

4141
/**
4242
* Command options configuration.
@@ -86,6 +86,15 @@ export default class ListRoutes extends BaseCommand {
8686
@flags.boolean({ description: 'View list of routes as a table' })
8787
declare table: boolean
8888

89+
/**
90+
* Output routes as JSONL (one JSON object per line), optimized for
91+
* machine consumption by AI agents and CLI tools
92+
*/
93+
@flags.boolean({
94+
description: 'Get routes as JSONL, one JSON object per line (optimized for AI agents)',
95+
})
96+
declare jsonl: boolean
97+
8998
/**
9099
* Execute the command to list application routes.
91100
* Creates a formatter with the specified filters and outputs routes
@@ -104,6 +113,19 @@ export default class ListRoutes extends BaseCommand {
104113
}
105114
)
106115

116+
/**
117+
* Display as JSONL (one JSON object per line).
118+
* Auto-selected when running inside an AI agent and no
119+
* explicit format flag is provided.
120+
*/
121+
if (this.jsonl || (!this.json && !this.table && this.app.runningInAIAgent)) {
122+
const lines = await formatter.formatAsJSONL()
123+
for (const line of lines) {
124+
this.logger.log(line)
125+
}
126+
return
127+
}
128+
107129
/**
108130
* Display as JSON
109131
*/

commands/make/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default class MakeCommand extends BaseCommand {
3333
/**
3434
* The command description
3535
*/
36-
static description = 'Create a new ace command class'
36+
static description = 'Create a new Ace CLI command class in commands/'
3737

3838
/**
3939
* Name of the command class to create

commands/make/controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export default class MakeController extends BaseCommand {
3232
/**
3333
* The command description
3434
*/
35-
static description = 'Create a new HTTP controller class'
35+
static description =
36+
'Create a new HTTP controller class in app/controllers. Use --resource for CRUD methods or --api for API-only CRUD (no create/edit)'
3637

3738
/**
3839
* Command options configuration

commands/make/event.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export default class MakeEvent extends BaseCommand {
3232
/**
3333
* The command description
3434
*/
35-
static description = 'Create a new event class'
35+
static description =
36+
'Create a new event class in app/events. Events are dispatched via emitter and handled by listeners'
3637

3738
/**
3839
* Command options configuration.

0 commit comments

Comments
 (0)