Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {getSelfReviewRequirementsMarkdown} from '../../../services/agent/self-review-requirements.js'
import Command from '@shopify/cli-kit/node/base-command'
import {globalFlags} from '@shopify/cli-kit/node/cli'
import {outputResult} from '@shopify/cli-kit/node/output'
import {CLI_KIT_VERSION} from '@shopify/cli-kit/common/version'

export default class AgentGetSelfReviewRequirements extends Command {
static hidden = true

static description = 'Agent-only. Not for human use.'

static flags = {
...globalFlags,
}

public async run(): Promise<void> {
const markdown = await getSelfReviewRequirementsMarkdown({cliVersion: CLI_KIT_VERSION})
outputResult(markdown)
}
}
2 changes: 2 additions & 0 deletions packages/app/src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AgentGetSelfReviewRequirements from './commands/app/agent/get-self-review-requirements.js'
import Build from './commands/app/build.js'
import BulkCancel from './commands/app/bulk/cancel.js'
import BulkStatus from './commands/app/bulk/status.js'
Expand Down Expand Up @@ -44,6 +45,7 @@ import BaseCommand from '@shopify/cli-kit/node/base-command'
* Organization commands extend BaseCommand directly.
*/
export const commands: {[key: string]: typeof AppLinkedCommand | typeof AppUnlinkedCommand | typeof BaseCommand} = {
'app:agent:get-self-review-requirements': AgentGetSelfReviewRequirements,
'app:build': Build,
'app:bulk:cancel': BulkCancel,
'app:bulk:status': BulkStatus,
Expand Down
36 changes: 36 additions & 0 deletions packages/app/src/cli/services/agent/self-review-requirements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {shopifyFetch} from '@shopify/cli-kit/node/http'
import {addPublicMetadata} from '@shopify/cli-kit/node/metadata'
import {AbortError} from '@shopify/cli-kit/node/error'

const REQUIREMENTS_URL = 'https://shopify.dev/docs/apps/launch/app-store-review/app-store-ai-self-review-requirements'

// Sentinel comment prepended to the response so an agent can confirm it parsed the expected command's output.
const SENTINEL = '<!-- shopify-agent: get-self-review-requirements -->'

interface GetSelfReviewRequirementsInput {
cliVersion: string
}

export async function getSelfReviewRequirementsMarkdown({cliVersion}: GetSelfReviewRequirementsInput): Promise<string> {
const response = await shopifyFetch(REQUIREMENTS_URL, {
method: 'GET',
headers: {
Accept: 'text/markdown',
'User-Agent': `shopify-cli/${cliVersion}`,
},
})

if (!response.ok) {
await addPublicMetadata(() => ({cmd_app_agent_upstream_status: response.status}))
throw new AbortError(`Failed to fetch self-review requirements: HTTP ${response.status}`)
}

const body = await response.text()

await addPublicMetadata(() => ({
cmd_app_agent_upstream_status: response.status,
cmd_app_agent_response_bytes: body.length,
}))

return `${SENTINEL}\n\n${body}`
}
5 changes: 4 additions & 1 deletion packages/cli-kit/src/public/node/hooks/postrun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ export const hook: Hook.Postrun = async ({config, Command}) => {
deprecationsHook(Command)

const {outputDebug} = await import('../output.js')
const isAgentCommand = Command.id.startsWith('app:agent:')
const command = Command.id.replace(/:/g, ' ')
outputDebug(`Completed command ${command}`)
postRunHookCompleted = true

if (!command.includes('notifications') && !command.includes('upgrade')) await autoUpgradeIfNeeded()
if (!isAgentCommand && !command.includes('notifications') && !command.includes('upgrade')) {
await autoUpgradeIfNeeded()
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions packages/cli-kit/src/public/node/monorail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export interface Schemas {
cmd_app_validate_issue_count?: Optional<number>
cmd_app_validate_file_count?: Optional<number>

// Agent (`app:agent:*`) related commands
cmd_app_agent_upstream_status?: Optional<number>
cmd_app_agent_response_bytes?: Optional<number>

// Dev related commands
cmd_dev_tunnel_type?: Optional<string>
cmd_dev_tunnel_custom_hash?: Optional<string>
Expand Down
Loading
Loading