Files
larksuite__cli/shortcuts/base/workflow_create.go
bytedance-zhangbinkai ac0f243e5b feat(base): support AI classification and AI Analysis Action (#2590)
* docs(base): sync workflow guide to current branch

* docs(base): sync workflow schema to current branch

* feat(base): support AI classification workflow validation

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* docs(base): document AI classification workflow schema

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* feat(base): validate AI classification agent data

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* fix(base): relax ai classification optional fields

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* fix(base): validate workflow ai analysis json

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* fix(base): validate workflow ai analysis json

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* fix(base): default ai classification no match action

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* fix(base): keep ai analysis validation scoped

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* fix(base): normalize workflow empty steps

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* fix(base): reject ai classification mode input

Co-authored-by: TRAE CLI <traecli@bytedance.com>

* fix: polish skill

* fix: 还原 step 判断逻辑

* fix: 调整校验逻辑组织形式

* fix: polish skill

* fix: CR Comment

* feat: support development environment overrides

* fix: CR Comment

* Revert "feat: support development environment overrides"

This reverts commit cef8f78dc6.

* fix: polish skill

* fix: compress skill

* feat: support development environment overrides

* Revert "feat: support development environment overrides"

This reverts commit cef8f78dc6.

* fix: polish skill

* feat: support development environment overrides

* fix(base): preserve omitted AI classification strategy

* Revert "feat: support development environment overrides"

This reverts commit cef8f78dc6.

* fix: polish skill

* fix: ut

* feat: support development environment overrides

* fix: 沿用全量更新逻辑

* Revert "feat: support development environment overrides"

This reverts commit f805081e89.

---------

Co-authored-by: TRAE CLI <traecli@bytedance.com>
2026-09-03 19:34:14 +08:00

68 lines
2.3 KiB
Go

// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT
package base
import (
"context"
"strings"
"github.com/larksuite/cli/shortcuts/common"
)
var BaseWorkflowCreate = common.Shortcut{
Service: "base",
Command: "+workflow-create",
Description: "Create a new workflow in a base",
Risk: "write",
Scopes: []string{"base:workflow:create"},
AuthTypes: []string{"user", "bot"},
Flags: []common.Flag{
{Name: "base-token", Desc: "base token", Required: true},
{Name: "json", Desc: "workflow body JSON; read lark-base-workflow.md and lark-base-workflow-schema.md before constructing steps", Required: true},
},
Tips: []string{
"lark-cli base +workflow-create --base-token <base_token> --json @workflow.json",
"client_token is required and should be unique per create request.",
"New workflows are created disabled; call +workflow-enable after creation when the user wants it active.",
"Before constructing steps, use +table-list and +field-list to confirm real table and field names.",
"Step ids must be unique, and every next/children link must reference an existing step id.",
"Use lark-base-workflow.md as the module entry and lark-base-workflow-schema.md as the steps JSON SSOT; do not invent steps[].type/data/next/children from natural language.",
},
Validate: func(ctx context.Context, runtime *common.RuntimeContext) error {
if strings.TrimSpace(runtime.Str("base-token")) == "" {
return baseFlagErrorf("--base-token must not be blank")
}
if _, err := parseWorkflowBodyJSON(runtime); err != nil {
return err
}
return nil
},
DryRun: func(ctx context.Context, runtime *common.RuntimeContext) *common.DryRunAPI {
var body map[string]interface{}
if parsed, err := parseWorkflowBodyJSON(runtime); err == nil {
body = parsed
}
return common.NewDryRunAPI().
POST("/open-apis/base/v3/bases/:base_token/workflows").
Body(body).
Set("base_token", runtime.Str("base-token"))
},
Execute: func(ctx context.Context, runtime *common.RuntimeContext) error {
body, err := parseWorkflowBodyJSON(runtime)
if err != nil {
return err
}
data, err := baseV3Call(runtime, "POST",
baseV3Path("bases", runtime.Str("base-token"), "workflows"),
nil,
body,
)
if err != nil {
return err
}
runtime.Out(data, nil)
return nil
},
}