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

Function getPromptForCommand

src/skills/bundled/scheduleRemoteAgents.ts:336–445  ·  view source on GitHub ↗
(args: string, context: ToolUseContext)

Source from the content-addressed store, hash-verified

334 isPolicyAllowed('allow_remote_sessions'),
335 allowedTools: [REMOTE_TRIGGER_TOOL_NAME, ASK_USER_QUESTION_TOOL_NAME],
336 async getPromptForCommand(args: string, context: ToolUseContext) {
337 if (!getClaudeAIOAuthTokens()?.accessToken) {
338 return [
339 {
340 type: 'text',
341 text: 'You need to authenticate with a claude.ai account first. API accounts are not supported. Run /login, then try /schedule again.',
342 },
343 ]
344 }
345
346 let environments: EnvironmentResource[]
347 try {
348 environments = await fetchEnvironments()
349 } catch (err) {
350 logForDebugging(`[schedule] Failed to fetch environments: ${err}`, {
351 level: 'warn',
352 })
353 return [
354 {
355 type: 'text',
356 text: "We're having trouble connecting with your remote claude.ai account to set up a scheduled task. Please try /schedule again in a few minutes.",
357 },
358 ]
359 }
360
361 let createdEnvironment: EnvironmentResource | null = null
362 if (environments.length === 0) {
363 try {
364 createdEnvironment = await createDefaultCloudEnvironment(
365 'claude-code-default',
366 )
367 environments = [createdEnvironment]
368 } catch (err) {
369 logForDebugging(`[schedule] Failed to create environment: ${err}`, {
370 level: 'warn',
371 })
372 return [
373 {
374 type: 'text',
375 text: 'No remote environments found, and we could not create one automatically. Visit https://claude.ai/code to set one up, then run /schedule again.',
376 },
377 ]
378 }
379 }
380
381 // Soft setup checks — collected as upfront notes embedded in the initial
382 // AskUserQuestion dialog. Never block — triggers don't require a git
383 // source (e.g., Slack-only polls), and the trigger's sources may point
384 // at a different repo than cwd anyway.
385 const setupNotes: string[] = []
386 let needsGitHubAccessReminder = false
387
388 const repo = await detectCurrentRepositoryWithHost()
389 if (repo === null) {
390 setupNotes.push(
391 `Not in a git repo — you'll need to specify a repo URL manually (or skip repos entirely).`,
392 )
393 } else if (repo.host === 'github.com') {

Callers

nothing calls this directly

Calls 11

fetchEnvironmentsFunction · 0.85
logForDebuggingFunction · 0.85
checkRepoForRemoteAccessFunction · 0.85
formatConnectorsInfoFunction · 0.85
getCurrentRepoHttpsUrlFunction · 0.85
buildPromptFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected