/ commands / thinkback-play / thinkback-play.ts
thinkback-play.ts
 1  import { join } from 'path'
 2  import type { LocalCommandResult } from '../../commands.js'
 3  import { loadInstalledPluginsV2 } from '../../utils/plugins/installedPluginsManager.js'
 4  import { OFFICIAL_MARKETPLACE_NAME } from '../../utils/plugins/officialMarketplace.js'
 5  import { playAnimation } from '../thinkback/thinkback.js'
 6  
 7  const INTERNAL_MARKETPLACE_NAME = 'claude-code-marketplace'
 8  const SKILL_NAME = 'thinkback'
 9  
10  function getPluginId(): string {
11    const marketplaceName =
12      process.env.USER_TYPE === 'ant'
13        ? INTERNAL_MARKETPLACE_NAME
14        : OFFICIAL_MARKETPLACE_NAME
15    return `thinkback@${marketplaceName}`
16  }
17  
18  export async function call(): Promise<LocalCommandResult> {
19    // Get skill directory from installed plugins config
20    const v2Data = loadInstalledPluginsV2()
21    const pluginId = getPluginId()
22    const installations = v2Data.plugins[pluginId]
23  
24    if (!installations || installations.length === 0) {
25      return {
26        type: 'text' as const,
27        value:
28          'Thinkback plugin not installed. Run /think-back first to install it.',
29      }
30    }
31  
32    const firstInstall = installations[0]
33    if (!firstInstall?.installPath) {
34      return {
35        type: 'text' as const,
36        value: 'Thinkback plugin installation path not found.',
37      }
38    }
39  
40    const skillDir = join(firstInstall.installPath, 'skills', SKILL_NAME)
41    const result = await playAnimation(skillDir)
42    return { type: 'text' as const, value: result.message }
43  }