@@ -61,28 +61,67 @@ export function registerConfig(program: Command): void {
6161
6262 config
6363 . command ( 'init [path]' )
64- . description ( `Scaffold a starter agent config YAML (default: ${ DEFAULT_CONFIG_PATH } )` )
64+ . description (
65+ `Scaffold a starter agent config YAML locally (default: ${ DEFAULT_CONFIG_PATH } ), ` +
66+ 'or with --template create the agent in a repo by opening a pull request' ,
67+ )
6568 . option ( '-f, --force' , 'overwrite the file if it already exists' )
66- . action ( ( path : string | undefined , opts : { force ?: boolean } ) => {
67- // Configs are sourced from YAML in GitHub, not created through the API
68- // (see documents/eng/ELLIPSIS_API_AND_CLI.md), so `init` is a local
69- // scaffold the user commits to a path Ellipsis syncs from.
70- const target = path ?? DEFAULT_CONFIG_PATH
71- if ( existsSync ( target ) && ! opts . force ) {
72- console . error ( `error: ${ target } already exists (use --force to overwrite)` )
73- process . exitCode = 1
74- return
75- }
76- const name = basename ( target , extname ( target ) )
77- mkdirSync ( dirname ( target ) , { recursive : true } )
78- writeFileSync ( target , starterConfig ( name ) )
79- console . log ( `✓ wrote ${ target } ` )
80- console . log (
81- 'Commit it to your default branch — Ellipsis syncs agent configs from GitHub.' ,
82- )
83- } )
69+ . option (
70+ '--template <slug>' ,
71+ 'create the agent from an Ellipsis template by opening a pull request (see `agent template list`)' ,
72+ )
73+ . option (
74+ '--repo <name>' ,
75+ 'repository name to open the pull request against (required with --template)' ,
76+ )
77+ . option (
78+ '--path <path>' ,
79+ 'file path within the repo for the config (default: agents/<slug>.yaml; must be a synced location)' ,
80+ )
81+ . action (
82+ async (
83+ path : string | undefined ,
84+ opts : { force ?: boolean ; template ?: string ; repo ?: string ; path ?: string } ,
85+ ) => {
86+ // With --template the agent is created in your repo: Ellipsis opens a
87+ // pull request that adds the config file and returns it. Without it,
88+ // this is a local scaffold you commit yourself.
89+ if ( opts . template ) {
90+ if ( ! opts . repo ) {
91+ console . error ( 'error: --repo <name> is required with --template' )
92+ process . exitCode = 1
93+ return
94+ }
95+ await runAction ( async ( ) => {
96+ const created = await new ApiClient ( ) . createAgentConfig ( {
97+ template_id : opts . template ,
98+ repository : opts . repo ! ,
99+ path : opts . path ,
100+ } )
101+ console . log ( `✓ opened a pull request adding the agent (${ created . path } )` )
102+ console . log ( created . pull_request_url )
103+ console . log ( 'Merge it to deploy the agent.' )
104+ } )
105+ return
106+ }
107+ const target = path ?? DEFAULT_CONFIG_PATH
108+ if ( existsSync ( target ) && ! opts . force ) {
109+ console . error ( `error: ${ target } already exists (use --force to overwrite)` )
110+ process . exitCode = 1
111+ return
112+ }
113+ const name = basename ( target , extname ( target ) )
114+ mkdirSync ( dirname ( target ) , { recursive : true } )
115+ writeFileSync ( target , starterConfig ( name ) )
116+ console . log ( `✓ wrote ${ target } ` )
117+ console . log ( COMMIT_HINT )
118+ } ,
119+ )
84120}
85121
122+ const COMMIT_HINT =
123+ 'Commit it to your default branch. Ellipsis syncs agent configs from GitHub.'
124+
86125// A minimal valid agent config. `claude.system` is the only required field;
87126// everything else has a server-side default. Roots Ellipsis syncs from:
88127// agents/, .agents/, ellipsis/, .ellipsis/ (any depth), as .yaml/.yml.
0 commit comments