MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getPromptForCommand

Function getPromptForCommand

src/commands/insights.ts:3046–3181  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

3044 progressMessage: 'analyzing your sessions',
3045 source: 'builtin',
3046 async getPromptForCommand(args) {
3047 let collectRemote = false
3048 let remoteHosts: string[] = []
3049 let hasRemoteHosts = false
3050
3051 if (process.env.USER_TYPE === 'ant') {
3052 // Parse --homespaces flag
3053 collectRemote = args?.includes('--homespaces') ?? false
3054
3055 // Check for available remote hosts
3056 remoteHosts = await getRunningRemoteHosts()
3057 hasRemoteHosts = remoteHosts.length > 0
3058
3059 // Show collection message if collecting
3060 if (collectRemote && hasRemoteHosts) {
3061 // biome-ignore lint/suspicious/noConsole: intentional
3062 console.error(
3063 `Collecting sessions from ${remoteHosts.length} homespace(s): ${remoteHosts.join(', ')}...`,
3064 )
3065 }
3066 }
3067
3068 const { insights, htmlPath, data, remoteStats } = await generateUsageReport(
3069 { collectRemote },
3070 )
3071
3072 let reportUrl = `file://${htmlPath}`
3073 let uploadHint = ''
3074
3075 if (process.env.USER_TYPE === 'ant') {
3076 // Try to upload to S3
3077 const timestamp = new Date()
3078 .toISOString()
3079 .replace(/[-:]/g, '')
3080 .replace('T', '_')
3081 .slice(0, 15)
3082 const username = process.env.SAFEUSER || process.env.USER || 'unknown'
3083 const filename = `${username}_insights_${timestamp}.html`
3084 const s3Path = `s3://anthropic-serve/atamkin/cc-user-reports/${filename}`
3085 const s3Url = `https://s3-frontend.infra.ant.dev/anthropic-serve/atamkin/cc-user-reports/${filename}`
3086
3087 reportUrl = s3Url
3088 try {
3089 execFileSync('ff', ['cp', htmlPath, s3Path], {
3090 timeout: 60000,
3091 stdio: 'pipe', // Suppress output
3092 })
3093 } catch {
3094 // Upload failed - fall back to local file and show upload command
3095 reportUrl = `file://${htmlPath}`
3096 uploadHint = `\nAutomatic upload failed. Are you on the boron namespace? Try \`use-bo\` and ensure you've run \`sso\`.
3097To share, run: ff cp ${htmlPath} ${s3Path}
3098Then access at: ${s3Url}`
3099 }
3100 }
3101
3102 // Build header with stats
3103 const sessionLabel =

Callers

nothing calls this directly

Calls 4

generateUsageReportFunction · 0.85
jsonStringifyFunction · 0.85
getFacetsDirFunction · 0.85
errorMethod · 0.45

Tested by

no test coverage detected