mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 02:43:49 +08:00
fix(cli): declare write effect for import and context-switch commands (#41225)
Signed-off-by: samzong <samzong.lu@gmail.com>
This commit is contained in:
parent
f360a7bf94
commit
dd2e691ea8
@ -1,3 +1,4 @@
|
||||
import type { CommandEffect } from '@/framework/command'
|
||||
import { DifyCommand } from '@/commands/_shared/dify-command'
|
||||
import { httpRetryFlag } from '@/commands/_shared/global-flags'
|
||||
import { Flags } from '@/framework/flags'
|
||||
@ -7,6 +8,8 @@ import { pluginDependencyLabel, runImportApp } from './run'
|
||||
export default class ImportStudioApp extends DifyCommand {
|
||||
static override description = 'Import a studio app from a DSL YAML file or URL'
|
||||
|
||||
static override effect: CommandEffect = 'write'
|
||||
|
||||
static override examples = [
|
||||
'<%= config.bin %> import studio-app --from-file ./app.yaml',
|
||||
'<%= config.bin %> import studio-app --from-file /path/to/app.yaml --name "My App"',
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import type { CommandEffect } from '@/framework/command'
|
||||
import { DifyCommand } from '@/commands/_shared/dify-command'
|
||||
import { Flags } from '@/framework/flags'
|
||||
import { realStreams } from '@/sys/io/streams'
|
||||
@ -6,6 +7,8 @@ import { runUseAccount } from './use-account'
|
||||
export default class UseAccount extends DifyCommand {
|
||||
static override description = 'Switch the active account on the current host'
|
||||
|
||||
static override effect: CommandEffect = 'write'
|
||||
|
||||
static override examples = [
|
||||
'<%= config.bin %> use account',
|
||||
'<%= config.bin %> use account --email bob@corp.com',
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import type { CommandEffect } from '@/framework/command'
|
||||
import { DifyCommand } from '@/commands/_shared/dify-command'
|
||||
import { Flags } from '@/framework/flags'
|
||||
import { realStreams } from '@/sys/io/streams'
|
||||
@ -6,6 +7,8 @@ import { runUseHost } from './use-host'
|
||||
export default class UseHost extends DifyCommand {
|
||||
static override description = 'Switch the active Dify host'
|
||||
|
||||
static override effect: CommandEffect = 'write'
|
||||
|
||||
static override examples = [
|
||||
'<%= config.bin %> use host',
|
||||
'<%= config.bin %> use host --domain cloud.dify.ai',
|
||||
|
||||
@ -583,6 +583,18 @@ describe('E2E / agent skill — effect guard (no auth)', () => {
|
||||
expect(JSON.parse(r.stdout).effect).toBe('write')
|
||||
})
|
||||
|
||||
it('[P0] state-mutating import and context switches have effect=write', async () => {
|
||||
for (const args of [
|
||||
['help', 'import', 'studio-app', '-o', 'json'],
|
||||
['help', 'use', 'account', '-o', 'json'],
|
||||
['help', 'use', 'host', '-o', 'json'],
|
||||
]) {
|
||||
const r = await run(args)
|
||||
expect(r.exitCode).toBe(0)
|
||||
expect(JSON.parse(r.stdout).effect).toBe('write')
|
||||
}
|
||||
})
|
||||
|
||||
it('[P0] auth devices revoke effect=destructive — agent must confirm before calling', async () => {
|
||||
const r = await run(['help', 'auth', 'devices', 'revoke', '-o', 'json'])
|
||||
expect(r.exitCode).toBe(0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user