@@ -8,6 +8,7 @@ import { performGitHubOAuthFlow } from '../auth/github-oauth';
88import { generateExportData } from './config' ;
99import { CliError , handleError } from '../utils/errors' ;
1010import { enforceWriteAccess } from '../utils/read-only' ;
11+ import { addExamples } from '../utils/command-tree' ;
1112import type { GitHubCredentials } from '../types/github' ;
1213
1314const getGitHubClient = createClientGetter < GitHubCredentials , GitHubClient > ( {
@@ -32,70 +33,88 @@ export function registerGitHubCommands(program: Command): void {
3233 . command ( 'github' )
3334 . description ( 'GitHub operations' ) ;
3435
35- github
36- . command ( 'install' )
37- . description ( 'Install AGENTIO_KEY and AGENTIO_CONFIG as GitHub Actions secrets' )
38- . argument ( '<repo>' , 'Repository in owner/repo format' )
39- . option ( '--profile <name>' , 'Profile name (optional if only one profile exists)' )
40- . action ( async ( repo : string , options ) => {
41- try {
42- // Validate repo format
43- parseRepo ( repo ) ;
44-
45- const { client, profile } = await getGitHubClient ( options . profile ) ;
46- await enforceWriteAccess ( 'github' , profile , 'install secrets' ) ;
47-
48- console . error ( `Using GitHub profile: ${ profile } ` ) ;
49- console . error ( `Installing secrets to: ${ repo } ` ) ;
50-
51- // Generate the export data
52- const exportData = await generateExportData ( ) ;
53-
54- // Set secrets on the repo
55- console . error ( '\nSetting AGENTIO_KEY...' ) ;
56- await client . setRepoSecret ( repo , 'AGENTIO_KEY' , exportData . key ) ;
57-
58- console . error ( 'Setting AGENTIO_CONFIG...' ) ;
59- await client . setRepoSecret ( repo , 'AGENTIO_CONFIG' , exportData . config ) ;
60-
61- console . log ( `\nInstalled AGENTIO_KEY and AGENTIO_CONFIG to ${ repo } ` ) ;
62- console . log ( '\nIn your GitHub Actions workflow, use:' ) ;
63- console . log ( ' env:' ) ;
64- console . log ( ' AGENTIO_KEY: ${{ secrets.AGENTIO_KEY }}' ) ;
65- console . log ( ' AGENTIO_CONFIG: ${{ secrets.AGENTIO_CONFIG }}' ) ;
66- } catch ( error ) {
67- handleError ( error ) ;
68- }
69- } ) ;
70-
71- github
72- . command ( 'uninstall' )
73- . description ( 'Remove AGENTIO_KEY and AGENTIO_CONFIG secrets from a repository' )
74- . argument ( '<repo>' , 'Repository in owner/repo format' )
75- . option ( '--profile <name>' , 'Profile name (optional if only one profile exists)' )
76- . action ( async ( repo : string , options ) => {
77- try {
78- // Validate repo format
79- parseRepo ( repo ) ;
80-
81- const { client, profile } = await getGitHubClient ( options . profile ) ;
82- await enforceWriteAccess ( 'github' , profile , 'uninstall secrets' ) ;
83-
84- console . error ( `Using GitHub profile: ${ profile } ` ) ;
85- console . error ( `Removing secrets from: ${ repo } ` ) ;
86-
87- // Delete secrets from the repo
88- console . error ( '\nDeleting AGENTIO_KEY...' ) ;
89- await client . deleteRepoSecret ( repo , 'AGENTIO_KEY' ) ;
90-
91- console . error ( 'Deleting AGENTIO_CONFIG...' ) ;
92- await client . deleteRepoSecret ( repo , 'AGENTIO_CONFIG' ) ;
93-
94- console . log ( `\nRemoved AGENTIO_KEY and AGENTIO_CONFIG from ${ repo } ` ) ;
95- } catch ( error ) {
96- handleError ( error ) ;
97- }
98- } ) ;
36+ addExamples (
37+ github
38+ . command ( 'install' )
39+ . description ( 'Install AGENTIO_KEY and AGENTIO_CONFIG as GitHub Actions secrets' )
40+ . argument ( '<repo>' , 'Repository in owner/repo format' )
41+ . option ( '--profile <name>' , 'Profile name (optional if only one profile exists)' )
42+ . action ( async ( repo : string , options ) => {
43+ try {
44+ // Validate repo format
45+ parseRepo ( repo ) ;
46+
47+ const { client, profile } = await getGitHubClient ( options . profile ) ;
48+ await enforceWriteAccess ( 'github' , profile , 'install secrets' ) ;
49+
50+ console . error ( `Using GitHub profile: ${ profile } ` ) ;
51+ console . error ( `Installing secrets to: ${ repo } ` ) ;
52+
53+ // Generate the export data
54+ const exportData = await generateExportData ( ) ;
55+
56+ // Set secrets on the repo
57+ console . error ( '\nSetting AGENTIO_KEY...' ) ;
58+ await client . setRepoSecret ( repo , 'AGENTIO_KEY' , exportData . key ) ;
59+
60+ console . error ( 'Setting AGENTIO_CONFIG...' ) ;
61+ await client . setRepoSecret ( repo , 'AGENTIO_CONFIG' , exportData . config ) ;
62+
63+ console . log ( `\nInstalled AGENTIO_KEY and AGENTIO_CONFIG to ${ repo } ` ) ;
64+ console . log ( '\nIn your GitHub Actions workflow, use:' ) ;
65+ console . log ( ' env:' ) ;
66+ console . log ( ' AGENTIO_KEY: ${{ secrets.AGENTIO_KEY }}' ) ;
67+ console . log ( ' AGENTIO_CONFIG: ${{ secrets.AGENTIO_CONFIG }}' ) ;
68+ } catch ( error ) {
69+ handleError ( error ) ;
70+ }
71+ } ) ,
72+ `Examples:
73+
74+ # install secrets into a repo using the default github profile
75+ agentio github install octocat/hello-world
76+
77+ # install secrets using a named profile
78+ agentio github install octocat/hello-world --profile work` ,
79+ ) ;
80+
81+ addExamples (
82+ github
83+ . command ( 'uninstall' )
84+ . description ( 'Remove AGENTIO_KEY and AGENTIO_CONFIG secrets from a repository' )
85+ . argument ( '<repo>' , 'Repository in owner/repo format' )
86+ . option ( '--profile <name>' , 'Profile name (optional if only one profile exists)' )
87+ . action ( async ( repo : string , options ) => {
88+ try {
89+ // Validate repo format
90+ parseRepo ( repo ) ;
91+
92+ const { client, profile } = await getGitHubClient ( options . profile ) ;
93+ await enforceWriteAccess ( 'github' , profile , 'uninstall secrets' ) ;
94+
95+ console . error ( `Using GitHub profile: ${ profile } ` ) ;
96+ console . error ( `Removing secrets from: ${ repo } ` ) ;
97+
98+ // Delete secrets from the repo
99+ console . error ( '\nDeleting AGENTIO_KEY...' ) ;
100+ await client . deleteRepoSecret ( repo , 'AGENTIO_KEY' ) ;
101+
102+ console . error ( 'Deleting AGENTIO_CONFIG...' ) ;
103+ await client . deleteRepoSecret ( repo , 'AGENTIO_CONFIG' ) ;
104+
105+ console . log ( `\nRemoved AGENTIO_KEY and AGENTIO_CONFIG from ${ repo } ` ) ;
106+ } catch ( error ) {
107+ handleError ( error ) ;
108+ }
109+ } ) ,
110+ `Examples:
111+
112+ # remove the agentio secrets from a repo
113+ agentio github uninstall octocat/hello-world
114+
115+ # uninstall using a named profile
116+ agentio github uninstall octocat/hello-world --profile work` ,
117+ ) ;
99118
100119 // Profile management
101120 const profile = createProfileCommands < GitHubCredentials > ( github , {
0 commit comments