WIP: A simple cli for daily tangled use cases and AI integration. This is for my personal use right now, but happy if others get mileage from it! :)
at main 38 lines 1.4 kB view raw
1import { Command } from 'commander'; 2import { getCurrentRepoContext } from '../lib/context.js'; 3 4/** 5 * Create the context command for debugging repository context resolution 6 */ 7export function createContextCommand(): Command { 8 const context = new Command('context'); 9 context.description('Show current repository context (debug)'); 10 11 context.action(async () => { 12 try { 13 const repoContext = await getCurrentRepoContext(); 14 15 if (!repoContext) { 16 console.log('✗ Not in a Tangled repository'); 17 console.log('\nTo use this repository with Tangled, add a tangled.org remote:'); 18 console.log(' git remote add origin git@tangled.org:<did>/<repo>.git'); 19 console.log('\nOr clone from tangled.org:'); 20 console.log(' git clone git@tangled.org:<did>/<repo>.git'); 21 process.exit(1); 22 } 23 24 console.log('✓ Repository context resolved:\n'); 25 console.log(` Owner: ${repoContext.owner} (${repoContext.ownerType})`); 26 console.log(` Repository: ${repoContext.name}`); 27 console.log(` Protocol: ${repoContext.protocol}`); 28 console.log(` Remote: ${repoContext.remoteName} (${repoContext.remoteUrl})`); 29 } catch (error) { 30 console.error( 31 `Failed to resolve context: ${error instanceof Error ? error.message : 'Unknown error'}` 32 ); 33 process.exit(1); 34 } 35 }); 36 37 return context; 38}