-
Notifications
You must be signed in to change notification settings - Fork 301
feat(cli): add gist create to publish session transcripts to GitHub
#898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f23eb0d
feat(cli): add `gist create` command to publish session transcripts
chr1syy 8aa9a14
fix(cli): address gist review feedback + fix web-server-factory tests
chr1syy 6eea066
fix(cli): wire createGist through MessageHandler callbacks
chr1syy 2565444
merge: resolve conflicts with upstream/rc + address review feedback
chr1syy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| // Gist create - publish an agent's session transcript to a GitHub gist. | ||
| // Routes through the running Maestro desktop app (which holds live tab | ||
| // transcripts) and reuses the existing `gh gist create` IPC handler. | ||
|
|
||
| import { resolveAgentId } from '../services/storage'; | ||
| import { withMaestroClient } from '../services/maestro-client'; | ||
|
|
||
| interface GistCreateOptions { | ||
| description?: string; | ||
| public?: boolean; | ||
| } | ||
|
|
||
| interface GistCreateResponse { | ||
| success: boolean; | ||
| agentId?: string; | ||
| gistUrl?: string; | ||
| error?: string; | ||
| code?: string; | ||
| } | ||
|
|
||
| function emitErrorJson(error: string, code: string): void { | ||
| const payload: GistCreateResponse = { success: false, error, code }; | ||
| console.log(JSON.stringify(payload, null, 2)); | ||
| } | ||
|
|
||
| export async function gistCreate(agentIdArg: string, options: GistCreateOptions): Promise<void> { | ||
| let agentId: string; | ||
| try { | ||
| agentId = resolveAgentId(agentIdArg); | ||
| } catch (error) { | ||
| const msg = error instanceof Error ? error.message : 'Unknown error'; | ||
| emitErrorJson(msg, 'AGENT_NOT_FOUND'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const description = options.description ?? ''; | ||
| const isPublic = Boolean(options.public); | ||
|
|
||
| try { | ||
| const result = await withMaestroClient((client) => | ||
| client.sendCommand<{ | ||
| success: boolean; | ||
| gistUrl?: string; | ||
| error?: string; | ||
| }>( | ||
| { | ||
| type: 'create_gist', | ||
| sessionId: agentId, | ||
| description, | ||
| isPublic, | ||
| }, | ||
| 'create_gist_result', | ||
| 60000 | ||
| ) | ||
| ); | ||
|
|
||
| if (!result.success || !result.gistUrl) { | ||
| emitErrorJson(result.error ?? 'Failed to create gist', 'GIST_CREATE_FAILED'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const response: GistCreateResponse = { | ||
| success: true, | ||
| agentId, | ||
| gistUrl: result.gistUrl, | ||
| }; | ||
| console.log(JSON.stringify(response, null, 2)); | ||
| } catch (error) { | ||
| const msg = error instanceof Error ? error.message : String(error); | ||
| const lower = msg.toLowerCase(); | ||
| if ( | ||
| lower.includes('econnrefused') || | ||
| lower.includes('connection refused') || | ||
| lower.includes('websocket') || | ||
| lower.includes('enotfound') || | ||
| lower.includes('etimedout') || | ||
| lower.includes('not running') | ||
| ) { | ||
| emitErrorJson('Maestro desktop is not running or not reachable', 'MAESTRO_NOT_RUNNING'); | ||
| } else { | ||
| emitErrorJson(`Gist creation failed: ${msg}`, 'GIST_CREATE_FAILED'); | ||
| } | ||
| process.exit(1); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error.messageaccess withoutinstanceofguardIf the
createGistcallback rejects with a non-Error(a string, a plain object, etc.),error.messageevaluates toundefinedand the client receives"Failed to create gist: undefined". Guarding witherror instanceof Error ? error.message : String(error)is the convention used throughout this codebase (seegist.tsline 675 andweb-server-factory.tserror paths) and avoids the unhelpful message.