Skip to content

Commit 2c703f2

Browse files
raistlin042linchao5102wangjiangwen-gifchenxingyang1019aihao-git
authored
feat: apps support multi dev modes (#1175)
* feat: add fullstack app-type and --message to apps +create (#1) * feat: accept fullstack app-type and require --message for it * feat: inject message into fullstack create request body * refactor: align fullstack message injection with existing body-build style * docs: document fullstack app-type and --message for apps +create * docs: keep scene numbering consistent in lark-apps-create reference * docs: add HTML/fullstack intent routing to lark-apps SKILL.md * docs: cover fullstack in lark-apps skill description and clarify HTML flow step * test: assert fullstack in allow-list error and reject wrong-cased fullstack * feat: drop --message from apps +create (#4) * feat: drop --message from apps +create * docs: drop --message and document agent-generated name/description for apps +create * feat: add apps local key-value file storage (#5) * feat: add Miaoda app git credential support (#9) * fix: remove APIError detail field dependency * docs(apps): expand lark-apps skill for local-dev & cloud-chat workflows (#3) Reframe lark-apps from an HTML-publish skill into a full Miaoda app dev tool covering three paths: local fullstack dev, HTML hosting, and cloud session dev. Builds on the fullstack create change already on this branch. - SKILL.md: 3-path routing table; mental models (code via native git, develop/main branch model, DB via +db-* through Miaoda, env auto-pulled by `npm dev run`, auto-managed credentials); command index for the new verbs; ambiguous-input fallback (infer app type from need, ask local vs cloud instead of assuming; default HTML when no signal) - add local-dev and cloud-dev playbooks - create: keep HTML/fullstack + required --message; add local/cloud scene routing and --enable-multi-env-db - list: usable by agents with --filter; app_id resolution order (user-provided / .spark/meta.json / +list --filter) Co-authored-by: wangjiangwen-gif <286006750+wangjiangwen-gif@users.noreply.github.com> Co-authored-by: raistlin042 <lvxinsheng@bytedance.com> * feat(apps): add 4 db CLI commands (table-list / table-schema / sql / dev-init) 妙搭 data CLI 4 条命令,复用存量 OpenAPI URL + 1 个新增 dev-init: - +db-table-list → GET /apps/{id}/tables(游标分页,AppTable 含预估行数/占用空间) - +db-table-schema → GET /apps/{id}/tables/{name}(默认结构化 schema;--format pretty 出建表 DDL) - +db-sql → POST /apps/{id}/sql_commands(?transactional=false DBA 模式) - +db-dev-init → POST /apps/{id}/db_dev_init(单库→online/dev,不可逆,high-risk-write) 要点: - sql result 兼容两种 wire 形态(结构化 [{sql_type,data,record_count}] 与 legacy ["rows-json"]) - 多语句失败:server 返 code:0 + ERROR 哨兵,CLI 升级成 typed api_error(exit 非 0), detail 带 statement_index/completed/rolled_back,防止 agent 误判 ok:true 假成功 - pretty 渲染对齐 miaoda:列间两空格、CJK 双宽、size 友好格式(KB/MB/GB) - 单测 + e2e dry-run 全覆盖;BOE 真机 e2e 验证通过(25 PASS) - SKILL.md 注册 4 条命令 + 4 篇 reference 注:内含的 BOE 联调专用 env 覆盖(LARK_CLI_OPEN_API_BASE / LARK_CLI_X_TT_ENV, internal/cmdutil + internal/envvars)未包含在本次提交,仅本地联调用。 Change-Id: I0fe4458086708a93941e2dee852fa6a10b53bd4a * docs(lark-apps): db 能力补进 SKILL.md description 的 WHEN 段 按 skill 质量规范(description 三段式 WHAT+WHEN+NOT,加载前唯一可见信息), 原 WHEN 仅"连数据库调试"含糊覆盖 db。补成「查看或操作应用数据库(看表结构 / 跑 SQL / 初始化 dev 环境)」,让 +db-table-schema / +db-sql / +db-dev-init 类查询能精确触发,净增 ~12 字无膨胀。 Change-Id: Id52819fa7d6b8ed0c1f174bf5946d55da7b893d7 * Feat/apps env pull (#11) * feat: add apps env-pull shortcut * fix: support array env_vars response in apps env-pull * fix(apps): improve env-pull merge and expiry output * feat: add keyword/scope/app-type query to apps +list and unhide it (#8) * feat: switch apps +create --app-type enum to lowercase html/full_stack * feat: add keyword/scope/app-type query to apps +list and unhide it * docs: document apps +list query params and lowercase app_type enum * test: update apps cli_e2e dry-run tests for lowercase app_type and +list filters * docs: trim redundant app_type case-sensitivity note in create skill * docs: single-source apps +list usage contract to SKILL.md * feat: add apps publish shortcuts (publish/status/history/error-log) (#12) * feat: add apps publish shared guard and NodeStatus mapping * test: cover json.Number path in injectStatusName * feat: add apps +publish shortcut Implements the `apps +publish` command with dry-run preview (upstream PSM path shown) and an Execute gated by ensurePublishWired() per the not-yet-deployed OpenAPI gateway constraint (publishAPIWired=false). * refactor: make apps publish path placeholders var to satisfy go vet Declare the four publishXxxPath constants as var instead of const so go vet's printf analyzer skips them while they are empty placeholders. Revert the Execute path-build in apps_publish.go from strings.Replace back to fmt.Sprintf (now safe because the format string is a var). * feat: add apps +publish-history shortcut * feat: add apps +publish-status shortcut * feat: add apps +publish-error-log shortcut * feat: register apps publish shortcuts Add AppsPublish, AppsPublishHistory, AppsPublishStatus, AppsPublishErrorLog to Shortcuts() and update count test from 6 → 10. * docs: add skill references for apps publish shortcuts * docs: surface apps publish shortcuts in lark-apps SKILL.md * docs: clarify publish instance id is not an approval instance * docs: nudge agent to run apps +publish --dry-run for release requests * feat: update apps publish shortcuts to v1.0.381 release protocol Rename concept instance→release across all 4 publish shortcuts and their tests: NodeStatus→ReleaseStatus enum, --instance-id→--release-id flag, pipelineTaskID→releaseID response field, errorJobs→errorLogs, and upstream HTTP path consts→RPC method name consts (PSM lark.apaas.devops v1.0.381). Dry-run now shows psm+rpc_method instead of an HTTP path. * docs: update apps publish skill docs to v1.0.381 release protocol * fix: soften apps publish unavailable hint to user-facing language * feat: update apps publish to v1.0.385 string status + --status filter - Remove obsolete int-enum machinery (releaseStatusName/toInt/injectStatusName) and their encoding/json + fmt imports from apps_publish_common.go - +publish Execute now returns status string alongside release_id - +publish-history gains --status Enum flag (publishing/finished/failed); buildHistoryBody gains status param, table column status_name→status - +publish-status Execute drops injectStatusName, pretty prints out["status"] - +publish-error-log shapeErrorLog is string passthrough (no status_name) - Unit tests updated: delete 3 obsolete common tests, update history/error-log * docs: update apps publish docs to v1.0.385 string status + --status filter * feat: wire apps publish shortcuts to final gateway paths (guard stays until deploy) Replace RPC-name placeholders with real OpenAPI paths (publishCreate/Get/ErrorLog/ListPath consts). Switch DryRun to idiomatic HTTP form (POST/GET + real URL + body/params). Fix body/query placement: publish body has no app_id (path-only); history switches from POST body to GET query with snake page_token. Fix Execute response reads to snake_case fields (release_id, created_at, updated_at, error_logs). publishAPIWired stays false; 1-line flip activates live calls. * docs: update apps publish docs to final gateway paths Replace RPC/PSM dry-run example with real HTTP form (POST/GET /open-apis/spark/v1/apps/:app_id/releases[/:release_id[/error_logs]]). Fix all response field names to snake_case (release_id, created_at, updated_at, error_log). Note --status/--limit/--page-token as HTTP query params in publish-history. * feat: enable apps publish gateway calls (remove not-deployed guard) * docs: remove not-deployed transition notes from apps publish docs * feat: use spark:app:publish scope for apps +publish * feat(apps): add +init shortcut to initialize Miaoda app repo (#6) * feat(apps): add command runner and credential redaction for +init * fix(apps): make credential redaction scheme matching case-insensitive * feat(apps): add +init shortcut declaration, validation, and dry-run * feat(apps): implement +init orchestration (credential-init, clone, checkout, conditional push) * fix(apps): redact full userinfo when repo URL contains literal @ * docs(apps): add +init skill reference * fix(apps): declare explicit empty Scopes on +init shortcut * fix(apps): consume repository_url from +git-credential-init in +init * feat(apps): add +init template flag and absolute-path dir resolution * refactor(apps): use shared charcheck for +init --dir validation * feat(apps): add meta.json, steering, and empty-repo helpers for +init * feat(apps): add +init npx scaffold orchestration (init/upgrade branches) * feat(apps): wire +init scaffold, already-initialized short-circuit, npx dep check * docs(apps): document +init npx scaffold, --template, --dir, already-initialized * docs(apps): correct stale +git-credential-init unreleased note in +init ref * fix(apps): reject all control chars in +init --dir * feat(apps): add +init progress logging and optional --template resolver * refactor(apps): inline constant in +init scaffold progress log * docs(apps): document +init optional --template and stderr progress contract * feat(apps): treat README-only repo as empty and commit with --no-verify in +init * docs(apps): explain README-seed match and --no-verify rationale in +init * docs(apps): document README-seed empty detection and commit --no-verify * feat(apps): add session conversation lifecycle shortcuts (#13) * feat(apps): add +session-create shortcut * fix(apps): remove unused sessionPath helper, assert empty +session-create body * feat(apps): add +session-list shortcut * feat(apps): add +session-read shortcut * feat(apps): add +session-stop shortcut * feat(apps): add +chat shortcut * feat(apps): register session lifecycle shortcuts * docs(apps): add session conversation skill reference * docs(apps): clarify fullstack session_id source and fallback * style(apps): gofmt apps_session_create.go * docs(apps): add conversation/session triggers to skill routing description * docs(apps): add conversation flow guidance (when to reuse vs new session, per-step user prompts) * docs(apps): slim session reference per skill quality standard (4047->1726 tok) * docs(apps): tighten session additions in SKILL.md (4394->4145 tok) * fix(apps): align +chat with v7.8 contract (async, no turn_id in response) * fix(apps): update +chat path to .../sessions/{id}/chat (backend endpoint change) * docs(apps): align SKILL.md session command shape with v7.8 contract * style(apps): gofmt apps_db_table_schema_dryrun_test.go Go 1.19+ gofmt 文档注释列表缩进新规则(普通缩进 → tab 对齐), 修复 fast-gate CI 的 gofmt 卡点。 Change-Id: Ic246a659e016d9d6216182199ef300ae6f00ef9d * feat(apps): split +init commit, plainer wording, align skill branches (#14) * refactor(apps): plainer +init progress/help wording, keep scaffold key * refactor(apps): add porcelain change classifier for +init commit split * feat(apps): split +init empty-repo commit into code + config, reword subjects * refactor(apps): scaffold-kind constants and pathspec assertions for +init split * docs(apps): use +init in Path A; align app-repo branch to sprint/default * docs(apps): align local-dev playbook to sprint/default + origin remote * docs(apps): document +init two-commit split and plainer init wording * docs(apps): require asking clone dir before +init, no assumed path * fix(apps): stage +init commits by exact paths to avoid gitignore error * refactor(apps): lowercase miaoda in +init commit subjects * test(apps): cover +init upgrade path with real git * fix: harden app git credential handling (#16) * fix: harden git credential refresh fallback (#18) * fix(apps): validate env-pull key names before writing to .env.local (#17) * fix(apps): validate env-pull key names before writing to .env.local S2 (medium-low) from security review: env-pull wrote server-returned env KEYs to .env.local without validation. A compromised or MITM'd backend could inject arbitrary lines via keys containing newlines. - Add envKeyPattern regex to validate keys match [A-Za-z_][A-Za-z0-9_]* - extractEnvPullVars now returns skippedKeys for invalid key names - Invalid keys are skipped (not hard-fail) so remaining valid keys are still pulled - writeEnvPullPretty prints a warning listing skipped keys * fix(skills): correct npm script syntax from 'npm dev run' to 'npm run dev' * fix(skills): align env-pull guidance with implementation 🤖 Generated with [Aiden x Claude Code] * test(apps): cover storage/git-credential error paths and fix tz-flaky env-pull tests (#19) The coverage and unit-test CI jobs failed on two timezone-dependent assertions in apps_env_pull_test.go: the code renders the database expiry via time.Local() while the tests hard-coded a CST literal, so they failed under CI's UTC. Compute the expected string from the same timestamp with Local() instead, making the assertions timezone-agnostic. Also add unit tests for the error branches codecov flagged as uncovered, taking storage.go and git_credential.go to 100%: - storage Read/Write/Delete/List filesystem-error paths - +git-credential-remove ConfigWarning output (pretty and JSON) - gitCredentialLocalError nil passthrough * fix(apps): silence +init forbidigo, npx app sync -y --prefer-online (#20) * fix(apps): add Subtype to env-pull error literals (#21) typed_error_completeness lint requires all errs.XxxError literals to set Problem.Subtype. Add the missing field to 11 error constructions: - ValidationError (user input checks): SubtypeInvalidArgument - ValidationError (API response parsing): SubtypeInvalidResponse - InternalError (filesystem ops): SubtypeUnknown * feat(apps): inject FORCE_DB_BRANCH=dev in env-pull output (#23) * feat(apps): inject FORCE_DB_BRANCH=dev in env-pull output Always write FORCE_DB_BRANCH="dev" into the resolved .env.local after extracting upstream env_vars, so downstream tooling pinning the dev database branch does not need a separate manual edit. Existing local values are overwritten in place via the canonical merge path. * docs(skills): document apps +env-pull in lark-apps skill Add the env-pull entry to the lark-apps SKILL index and ship the matching reference doc covering args, merge semantics, return shape, error envelope subtypes, and dry-run behavior so AI agents can route to it without reading the Go source. * feat(apps): surface is_published and online_url in +list pretty view (#22) * docs: refactor lark-apps skill per quality spec (#24) Slim SKILL.md and references against the lark-cli skill quality spec while preserving domain knowledge and safety guardrails. - Compress SKILL.md (drop the MUST-read prelude, full command-index tables, and content already owned by lark-shared: auth, scope, exit-10, risk policy, _notice); add version field; zero CRITICAL markers. - Defer flag enumeration in references to `--help`; convert narration-inducing prohibitions into positive defaults; de-duplicate the per-file error.hint relay into a single resident SKILL.md rule. - Fix stale facts found against shortcuts/apps source: drop the non-existent +create --message and --enable-multi-env-db flags, +list --filter (now --keyword), +db-multi-env-init (now +db-dev-init), and the removed html-publish cwd hard-reject. - Keep all safety guardrails: db-dev-init irreversibility/exit-10, db-sql non-transactional multi-statement, git-credential token handling, html-publish credential scan, access-scope confirmation. - Restore intent lost during slimming: release_id is not an approval instance (do not route to lark-approval); resolve access-scope targets via contact/im; ask the user before publishing as a side-effect; distinguish developing an existing app locally (+init) from creating a new one (+create). * test(apps): supplement shortcuts/apps unit-test coverage to 88% (#25) * test(apps): cover db-table-list numeric/byte formatting helpers * test(apps): cover db-sql cell/code/dml/error render helpers * test(apps): cover env-pull newline/expiry/extract-vars helpers * test(apps): cover db-sql render branches and env-pull expiry edge case * test(apps): cover init empty-dir/meta/ls-files error branches * test(apps): cover env-pull target/read/parent-dir error branches * test(apps): cover stage-and-commit and commit-push error branches * test(apps): cover access-scope target split and JSON validation * test(apps): cover html-publish decode error and scaffold sync failure * test(apps): cover apps-update body field combinations * test(apps): cover access-scope body build branches * feat(apps): pass --local to npx skills sync in +init (#26) * feat(apps): pass --local to all npx miaoda-cli calls in +init * feat(apps): pass --local only to npx skills sync in +init * docs(apps): surface +publish and +init dir-choice in local-dev flow (#27) * docs(apps): surface +publish as deploy action in skill routing * docs(apps): add explicit deploy-after-local-edit section to local-dev * docs(apps): promote +init dir-choice instruction to a domain rule * docs(apps): make dev-method a signal-driven entry gate before routing (#28) * docs(apps): restore three-path overview line in apps skill intro (#29) * feat(apps): add executable Examples to shortcut --help and error hints (#30) * test(apps): guard every shortcut has a help Example and no PII * feat(apps): add help Examples to all 24 apps shortcuts * feat(apps): add actionable hints to high-impact error paths * test(apps): cover withAppsHint set-if-empty hint behavior * feat(apps): use concrete enum value in access-scope-set Example * docs(apps): clarify db-sql/db-table-list json default output behavior 两处仅补充注释,不改逻辑: - +db-sql: data.results 在 json 默认路径原样透出全部行,CLI 不二次截断; server 对单条 SELECT 有 1000 行硬上限、超出直接返报错,非无界 token 黑洞。 - +db-table-list: json 默认透出含每表完整 columns[] 系产品设计(list 接口本就 返回列定义,json 消费方一次拿全量、免逐表再调 +db-table-schema),pretty 仅摘计数。 Change-Id: I1a49de8defc4428bfe1e774e4fd7adb45e59e3af * feat(apps): command-layer AI-friendliness governance (P0+P1) (#32) * fix(apps): normalize --app-type case to align with server * refactor(apps): migrate CallAPI to CallAPITyped for typed errors and retryable * feat(apps): trim icon_url and created_at from +list default output * feat(apps): add actionable hints to high-impact error paths * feat(apps): add 2-3 help Examples to +chat and +access-scope-set * docs(apps): add --jq filter tips to list/db commands * docs(apps): sync +list reference with trimmed output fields * test(apps): assert error hints and messages carry no secrets or PII * fix(apps): prefix --jq tips with .data. so they run against the response envelope * test(apps): expect --app-type uppercase normalization in create dry-run E2E (#33) * fix(apps): scaffold via @latest miaoda-cli instead of @Alpha (#34) * feat(apps): rework lark-apps triggering, routing & confirm policy (#35) * feat(apps): results-oriented triggering, pre-auth floors, terminal URL Widen description WHEN to cover app-building openers (CRM/审批/HTML page) with no Miaoda signal word, WHAT still anchored to 妙搭应用开发与托管. Add a pre-authorization rule (auth words skip confirm) with two non-exempt floors: destructive DDL (DROP/TRUNCATE/ALTER drop|modify column) dry-run, and first public-URL publish (+publish/+html-publish) when no auth word. Exempt html app_type from the local-vs-cloud dev-method gate, and scope that gate to new-app creation only (existing-app ops route directly). Require an accessible URL as the end-to-end terminal step. * feat(apps): apply eval-fix behavior contracts across reference docs init/local-dev: end-to-end default-directory escape hatch; end-to-end new-build starts with +create. db-sql: additive DDL direct-exec when authorized, destructive DDL stays dry-run. local-dev/publish-status: return online_url via +list as the full_stack publish terminal step. cloud-dev: generation != shareable URL, +publish handoff, background until-poll snippet (sleep N && cmd intercepted; deprecate ScheduleWakeup), multi-turn publish precondition. publish/publish-error-log: transient failure (EAI_AGAIN/ETIMEDOUT/registry) discrimination, retry cap 2, honest receipt. env-pull: first-launch fallback. local-dev/db-dev-init: new full_stack ships dual DB, skip +db-dev-init. * refactor(apps): apply review feedback — semantic criteria, drop overfit/unverified content Per line-by-line review of the eval-fix changes: - Entry routing reframed to objective/semantic criteria (new-vs-existing = 'can an existing app be identified'; dev-method = who-writes-code preference), replacing keyword/example matching. - db-sql DDL gate restated by effect (data-loss / reversibility), not a keyword list. - Pre-authorization judged by expressed intent (not a word list); single non-exempt floor (destructive/irreversible DB dry-run); confirm policy in its own section, error.hint in 'failure handling'. - init.md slimmed to command facts (directory choice owned by local-dev, no init<->local-dev cycle); local-dev defers new-vs-existing to the entry. - Reverted unverified/redundant/runtime-coupled additions: cloud-dev session-read preview-URL claim + background-poll snippet + queued_count precondition; publish transient-retry/ScheduleWakeup; env-pull first-launch; db-dev-init positive restatement; SKILL terminal-URL mandate. - Fixed dangling section references after the rename. * fix(apps): scope pre-authorization to hands-off intent, not 'wants a result' (#36) Follow-up to #35. The merged pre-authorization rule treated 'wanting the final result' as authorization, so '先在本地跑起来让我看看' was read as pre-authorized and the agent silently picked a clone directory without asking. Re-state the criterion as the user's hands-off intent (explicit waiver, or an end-to-end directive), judged uniformly across the flow (directory/clone, publish) — not a per-decision carve-out. Merely wanting a result or asking to review is not authorization. * docs: clarify apps cloud dev publish state * fix(apps): require commit+push before publish, clarify deploy flow (#38) * fix(apps): require committing changes before publish in local-dev flow * fix(apps): make commit+push mandatory before publish in agent rules * fix(apps): scope selective-add caveat to incremental deploy, not new-app flow * fix(apps): make pre-publish commit conditional on local changes * fix(apps): tighten pre-publish commit wording in agent rules * fix(apps): cloud-dev does not auto-deploy, add explicit publish step * docs(apps): document +chat init vs incremental turn cost (#39) First +chat on a not-initialized app runs full design+gen server-side (~20-50 min); chat on an already-initialized app is incremental and finishes in minutes. Surface this in the +chat Go comment as a pointer and put the init-state check + matching polling cadence (5-10s vs 60-120s) in the lark-apps cloud-dev skill reference as the canonical source. Cloud-side init check uses +session-read committed-version info or +list is_published:true. * docs(apps): document +chat init vs incremental turn cost (#40) First +chat on a not-initialized app runs full design+gen server-side (~20-50 min); chat on an already-initialized app is incremental and finishes in minutes. Surface this in the +chat Go comment as a pointer and put the init-state check + matching polling cadence (5-10s vs 60-120s) in the lark-apps cloud-dev skill reference as the canonical source. Cloud-side init check uses +session-read committed-version info or +list is_published:true. * feat(apps): surface online_url/error_logs in +publish-status output (#41) * refactor(apps): extract shared release error-log table helper * fix(apps): keep error-log table byte-identical for null error_logs * feat(apps): surface online_url/error_logs in +publish-status output * docs(apps): read online_url/error_logs from +publish-status in publish flow * docs(apps): align local/cloud dev publish flow with +publish-status fields * refactor(apps): rename +db-dev-init→+db-env-create, trim db-table-list columns - +db-env-create(原 +db-dev-init):新增 --env 参数(调用方传入,目前只支持 dev), --sync-data 改为 true/false 取值;服务端 URL 仍走 db_dev_init。 - +db-table-list:json 默认用白名单投影(dbTableListItem)只输出产品要求字段, 每表 columns[] 折算成 column_count、不再透出完整列定义(与 +db-table-schema 重复且放大 token);要完整列定义/索引/约束用 +db-table-schema。 - 同步对齐 db 相关 skill 文档(命令名、column_count、env-create 参数)。 - 单测 + cli_e2e dry-run 全绿。 Change-Id: I116ab11807679f8f06ed18221f705bab426d015c * refactor(apps): rename +db-table-schema → +db-table-get 动词对齐 +db-table-list(list/get)。仅命令名 + 标识符 + 文档改名,行为/输出/URL 不变: - AppsDBTableSchema→AppsDBTableGet,文件/测试/cli_e2e test 重命名 - buildDBTableSchemaParams→buildDBTableGetParams - +db-sql / +db-table-list 里的交叉引用 hint、skill 文档同步 Change-Id: I36dfb8fd0d2613492a57dc7815bc58414c145480 * feat: auto-pull env vars after apps +init (#42) * test: route apps +env-pull to its own fake-runner key * feat(apps): add +env-pull envelope parsers for +init * feat(apps): add pullEnv helper invoking sibling +env-pull * feat(apps): +init auto-runs +env-pull after push (non-fatal) * docs(apps): clarify db-sql --query @path is relative-only, use stdin for absolute paths @path 受 lark-cli 全局文件安全策略约束,只接受 cwd 内相对路径;绝对路径 / cwd 不固定 场景改用 stdin(--query - < /abs/file.sql),无需先 cd。 Change-Id: Ib3453810cfc9303d72b4facf3493ad9688eeffd3 * docs(apps): refine db-sql --query path guidance wording 以 agent 视角重写:@ 仅接受工作目录内相对路径,绝对路径/越界路径被拒(CLI 文件访问统一约束); 工作目录外的文件经 stdin 传入。 Change-Id: Ic7db00934b3571368eb704451f4ce1776463806d * feat(apps): make +db-sql high-risk-write (require --yes) +db-sql 可含 DML/DDL,统一升级为 high-risk-write:框架对所有执行强制 --yes 确认关卡 (--dry-run 预览豁免),无 --yes 返 confirmation_required / exit 10。 - Risk: write → high-risk-write(去掉自定义门禁,直接用框架机制) - skill 文档:命令骨架标注 --yes 要求;Agent 规则改为「执行需 --yes,只读可直接带、 破坏性先 dry-run 确认再带」 - 单测所有执行调用补 --yes Change-Id: I57e78832b35fa170a485774e6fb7289109d678c3 * docs(apps): clarify app_ (Miaoda) vs cli_ (Feishu) app id (#46) * 优化云端开发skill,明确执行模型,参数解释 (#44) Co-authored-by: fushengdong.1 <fushengdong.1@bytedance.com> * refactor: rename apps publish commands to release and session-get (#45) * refactor(apps): drop +publish-error-log, rename release path constants * refactor(apps): rename +publish to +release-create * refactor(apps): rename +publish-history to +release-list, unify pagination to --page-size * refactor(apps): rename +publish-status to +release-get Renames apps +publish-status → +release-get (AppsPublishStatus → AppsReleaseGet), updates --release-id desc to reference +release-create, and fixes the Execute error hint to point at +release-list instead of +publish-history. * refactor(apps): rename +session-read to +session-get * docs(apps): rename publish references to release, +session-read to +session-get * refactor(apps): clean up residual publish/session-read references Fix six leftover references missed in Tasks 1-6: +publish-history in jq-tip test wantCmds map and common_test hint fixture (×3), +session-read in apps_chat.go comment+output string (×2), apps_session_stop.go flag desc (×1), apps_chat_test.go comment (×1), and +publish-status in lark-apps-list.md agent rule prose (×1). * docs(apps): clarify release-get link contract and session-get vs session-list * docs(apps): generalize release-list page-size rule to N records * feat(apps): rename +list --scope flag to --ownership (#47) * feat(apps): rename +list --scope flag to --ownership * test(apps): update +list cli_e2e dry-run for --ownership rename * docs(apps): document +list --ownership flag * feat(apps): align +release commands with new release API format (#48) * feat(apps): align +release-create scope to spark:app:write * feat(apps): raise +release-list --page-size documented max to 500 * feat(apps): show commit_id in +release-get pretty output * docs(apps): update release reference docs for page-size 500 and commit_id * test(apps): cover empty commit_id in +release-get pretty output * docs: align lark apps cloud dev release flow * feat(apps): redesign +db-sql → +db-execute (--sql/--file, default env dev) 按 db 子域命令最终设计重做执行入口: - 命令 +db-sql → +db-execute(动词收尾,对齐 +db-table-list/-get) - --query 拆为 --sql(内联/stdin)与 --file(.sql 文件路径),二选一互斥; --file 在 Validate 阶段读出归一化到 --sql - 默认 --env online → dev(打生产库需显式 --env online) - 文件/标识符/注册/测试/cli_e2e/skill 文档全部对齐重命名 - 新增测试:--sql/--file 互斥、--file 读取、默认 env=dev 不在本次范围:--transaction/--no-transaction(服务端 transactional 实为路径切换、 非真事务,需 dataloom 侧先支持真事务开关)、--max-rows/--timeout 等后续项。 Change-Id: I50c06faf83527471446e2a6651ccb51f6eedd6ff * docs(apps): clearer --env online wording for +db-execute 把口语化的「打生产库需显式」改为「需要操作线上环境数据库时,显式指定 --env online」; flag desc 同步去掉 hit production 措辞。 Change-Id: Iee82fccf17e08bddb4b760c3970a416746b10c4c * docs(apps): drop 'ad-hoc' jargon from +db-execute description 中文文档/英文 description 去掉术语 ad-hoc;SELECT/DML/DDL 已表意,含义不丢。 Change-Id: Ie2cccc5fc3491fe5f57190a87b93ecd70405b156 * docs(apps): trim +db-execute when-to-use and --file path wording - 何时用去掉「(查询 / 临时数据修复 / 应急 DDL)」枚举 - --file 路径说明去掉 .. /符号链接/统一约束 的技术化描述,改为「相对路径, 否则用 --sql - < 文件路径」的产品化口吻 Change-Id: Ie70e57895c78650230b6942b03d90a2d95c937f2 * docs(apps): note --file rejects absolute/cwd-escaping paths 简短补回 --file 的路径约束(绝对路径 / 经 ..、符号链接越界会被拒),去掉冗余评注。 Change-Id: I549893c82cafbe97529e08dcbc3ee5496927da18 * fix(apps): replace t.Chdir with os.Chdir in db-execute test (Go 1.23 compat) t.Chdir 是 Go 1.24 API,但 go.mod 为 go 1.23.0,CI(Go 1.23)报 "t.Chdir undefined"。改用 os.Chdir + t.Cleanup 还原,1.23 兼容。 Change-Id: I550611773e5088275be1c4344d4f8269610ce74a * feat(apps): refine +init description and refresh env on re-init * fix(apps): treat accessible-link requests as publish intent (#53) * refactor(apps): +db-env-create --sync-data string-enum → Type:bool 原实现用 string + Enum["true","false"] + == "true" 模拟 bool,啰嗦且非惯用。 改为 Type:bool(rctx.Bool):传 --sync-data 即开启、省略为 false。 同步更新测试、cli_e2e dry-run、skill 文档。 Change-Id: I3068e0577fa20a7cbaf414ca9af3d197f6ae8049 * fix(apps): declare --app-type as strict lowercase enum (#55) * docs(apps): front-load routing, dedupe, and trim lark-apps skill (#56) * docs(apps): front-load intent-routing table and dedupe skill body * docs(apps): dedupe publish guardrail and polling rules in cloud-dev * docs(apps): trim env-pull implementation detail to behavior contract * docs(apps): add +env-pull routing entry in SKILL.md * docs(apps): fix create.md cross-ref to actual SKILL.md section name * feat(apps): add error.hint to command failures and a consistency gate (#57) * feat(apps): add appIDListHint const and wrap 4 pure app-id command failure paths Adds shared `appIDListHint` recovery hint to common.go and wraps the CallAPITyped failure branch of session-create, session-list, update, and release-list to surface an actionable next-step hint on 4xx errors. Includes httpmock unit tests in apps_hints_more_test.go (TDD: red→green). * feat(apps): add sessionStopHint and createHint for session-stop and create commands Adds per-command recovery hints with specific guidance: sessionStopHint points at +session-list and +session-get; createHint explains valid --app-type values and permission failure. Wraps the CallAPITyped failure branch in both commands. * feat(apps): add recovery hints for db-env-create, db-table-get, db-table-list Adds dbEnvCreateHint, dbTableGetHint, and dbTableListHint with actionable cross-command guidance (e.g. pointing at +db-table-list for env conflicts, +db-env-create for missing dev env). Wraps only the CallAPITyped failure branch; requireAppID validation errors are left untouched. * refactor(apps): make session-stop hint runnable and align hint test names * test(apps): guard withAppsHint upstream-wins contract and new hint leak safety * test(apps): add help-skill command consistency gate --------- Co-authored-by: linchao5102 <linchao.5102@bytedance.com> Co-authored-by: Wang <wangjiangwen@bytedance.com> Co-authored-by: wangjiangwen-gif <286006750+wangjiangwen-gif@users.noreply.github.com> Co-authored-by: 陈兴炀 <chenxingyang.1019@bytedance.com> Co-authored-by: aihao-git <aihao.0331@bytedance.com> Co-authored-by: bali <bali@bytedance.com> Co-authored-by: hunnnnngry <chenxi.xichen@bytedance.com> Co-authored-by: shengdongyc <1135978761fsd@gmail.com> Co-authored-by: fushengdong.1 <fushengdong.1@bytedance.com>
1 parent 501bf53 commit 2c703f2

101 files changed

Lines changed: 16166 additions & 777 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ The official [Lark/Feishu](https://www.larksuite.com/) CLI tool, maintained by t
4141
| ✍️ Approval | Query approval tasks, approve/reject/transfer tasks, cancel and CC instances |
4242
| 🎯 OKR | Query, create, update OKRs; manage objective & key results, alignments, indicators and progress. |
4343
| 📋 Project | Meegle — manage work items, schedules, and data via the standalone [meegle-cli](https://github.com/larksuite/meegle-cli) (install separately) |
44-
| 🔗 Apps | Develop, deploy HTML, web pages and applications |
44+
| 🔗 Apps | Create Spark/Miaoda apps, publish HTML/static sites, run cloud generation, and manage access scope |
4545

4646
## Installation & Quick Start
4747

README.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
| ✍️ 审批 | 查询审批任务、同意/拒绝/转交审批任务、撤回与抄送审批实例 |
4242
| 🎯 OKR | 查询、创建、更新 OKR,管理目标、关键结果、对齐、指标和进展记录 |
4343
| 📋 飞书项目 | 管理工作项、排期与数据 — 由独立的 [meegle-cli](https://github.com/larksuite/meegle-cli) 提供(需单独安装) |
44-
| 🔗 应用 | 开发、部署 HTML、Web 页面和应用 |
44+
| 🔗 应用 | 创建妙搭(Spark/Miaoda)应用、发布 HTML/静态站点、云端生成迭代、管理可用范围 |
4545

4646
## 安装与快速开始
4747

shortcuts/apps/apps_access_scope_get.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ var AppsAccessScopeGet = common.Shortcut{
2121
Command: "+access-scope-get",
2222
Description: "Get Miaoda app access scope configuration",
2323
Risk: "read",
24-
Scopes: []string{"spark:app:read"},
25-
AuthTypes: []string{"user"},
26-
HasFormat: true,
24+
Tips: []string{
25+
"Example: lark-cli apps +access-scope-get --app-id <app_id>",
26+
},
27+
Scopes: []string{"spark:app:read"},
28+
AuthTypes: []string{"user"},
29+
HasFormat: true,
2730
Flags: []common.Flag{
2831
{Name: "app-id", Desc: "app ID", Required: true},
2932
},
@@ -42,9 +45,9 @@ var AppsAccessScopeGet = common.Shortcut{
4245
Execute: func(ctx context.Context, rctx *common.RuntimeContext) error {
4346
appID := strings.TrimSpace(rctx.Str("app-id"))
4447
path := fmt.Sprintf("%s/apps/%s/access-scope", apiBasePath, validate.EncodePathSegment(appID))
45-
data, err := rctx.CallAPI("GET", path, nil, nil)
48+
data, err := rctx.CallAPITyped("GET", path, nil, nil)
4649
if err != nil {
47-
return err
50+
return withAppsHint(err, "verify --app-id is correct and you have access to the app; list your apps with `lark-cli apps +list`")
4851
}
4952
// 原样透传 — 保留服务端字符串枚举 (All/Tenant/Range),不合并 users/departments/chats。
5053
rctx.OutFormat(data, nil, func(w io.Writer) {

shortcuts/apps/apps_access_scope_set.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ var AppsAccessScopeSet = common.Shortcut{
2727
Command: "+access-scope-set",
2828
Description: "Set Miaoda app access scope (specific / public / tenant)",
2929
Risk: "write",
30-
Scopes: []string{"spark:app:write"},
31-
AuthTypes: []string{"user"},
32-
HasFormat: true,
30+
Tips: []string{
31+
`Example: lark-cli apps +access-scope-set --app-id <app_id> --scope tenant`,
32+
`Example: lark-cli apps +access-scope-set --app-id <app_id> --scope public --require-login`,
33+
`Example: lark-cli apps +access-scope-set --app-id <app_id> --scope specific --targets '[{"type":"user","id":"<open_id>"}]'`,
34+
},
35+
Scopes: []string{"spark:app:write"},
36+
AuthTypes: []string{"user"},
37+
HasFormat: true,
3338
Flags: []common.Flag{
3439
{Name: "app-id", Desc: "app ID", Required: true},
3540
{Name: "scope", Desc: "scope: specific | public | tenant", Required: true, Enum: []string{"specific", "public", "tenant"}},
@@ -64,9 +69,9 @@ var AppsAccessScopeSet = common.Shortcut{
6469
}
6570
appID := strings.TrimSpace(rctx.Str("app-id"))
6671
path := fmt.Sprintf("%s/apps/%s/access-scope", apiBasePath, validate.EncodePathSegment(appID))
67-
data, err := rctx.CallAPI("PUT", path, nil, body)
72+
data, err := rctx.CallAPITyped("PUT", path, nil, body)
6873
if err != nil {
69-
return err
74+
return withAppsHint(err, "verify --app-id is correct; for scope=specific, each --targets id must be a valid open_id/department_id/chat_id and --approver a valid open_id; review the current scope with `lark-cli apps +access-scope-get --app-id <app_id>`")
7075
}
7176
rctx.OutFormat(data, nil, func(w io.Writer) {
7277
fmt.Fprintf(w, "access-scope set: %s\n", rctx.Str("scope"))

shortcuts/apps/apps_access_scope_set_test.go

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,62 @@ import (
88
"strings"
99
"testing"
1010

11+
"github.com/spf13/cobra"
12+
1113
"github.com/larksuite/cli/internal/httpmock"
14+
"github.com/larksuite/cli/shortcuts/common"
1215
)
1316

17+
func testRuntimeAccessScope(t *testing.T, scope, targets, approver string, applyEnabled, requireLogin bool) *common.RuntimeContext {
18+
t.Helper()
19+
cmd := &cobra.Command{Use: "access-scope-set"}
20+
cmd.Flags().String("scope", scope, "")
21+
cmd.Flags().String("targets", targets, "")
22+
cmd.Flags().String("approver", approver, "")
23+
cmd.Flags().Bool("apply-enabled", applyEnabled, "")
24+
cmd.Flags().Bool("require-login", requireLogin, "")
25+
return common.TestNewRuntimeContext(cmd, nil)
26+
}
27+
28+
func TestBuildAccessScopeBody_Branches(t *testing.T) {
29+
t.Run("invalid scope", func(t *testing.T) {
30+
if _, err := buildAccessScopeBody(testRuntimeAccessScope(t, "bogus", "", "", false, false)); err == nil {
31+
t.Error("unknown scope must error")
32+
}
33+
})
34+
t.Run("specific with all target kinds and approver", func(t *testing.T) {
35+
body, err := buildAccessScopeBody(testRuntimeAccessScope(t,
36+
"specific",
37+
`[{"type":"user","id":"u1"},{"type":"department","id":"d1"},{"type":"chat","id":"c1"}]`,
38+
"ou_appr", true, false))
39+
if err != nil {
40+
t.Fatalf("err=%v", err)
41+
}
42+
if body["scope"] != "Range" {
43+
t.Errorf("scope=%v want Range", body["scope"])
44+
}
45+
for _, k := range []string{"users", "departments", "chats", "apply_config"} {
46+
if _, ok := body[k]; !ok {
47+
t.Errorf("missing %q in body=%v", k, body)
48+
}
49+
}
50+
})
51+
t.Run("specific with invalid targets JSON", func(t *testing.T) {
52+
if _, err := buildAccessScopeBody(testRuntimeAccessScope(t, "specific", "{bad", "", false, false)); err == nil {
53+
t.Error("invalid targets JSON must error")
54+
}
55+
})
56+
t.Run("public sets require_login", func(t *testing.T) {
57+
body, err := buildAccessScopeBody(testRuntimeAccessScope(t, "public", "", "", false, true))
58+
if err != nil {
59+
t.Fatalf("err=%v", err)
60+
}
61+
if body["scope"] != "All" || body["require_login"] != true {
62+
t.Errorf("public body=%v", body)
63+
}
64+
})
65+
}
66+
1467
func TestAppsAccessScopeSet_Specific(t *testing.T) {
1568
factory, stdout, reg := newAppsExecuteFactory(t)
1669
stub := &httpmock.Stub{
@@ -201,3 +254,44 @@ func TestAppsAccessScopeSet_TrimsAppIDInPath(t *testing.T) {
201254
t.Fatalf("execute err=%v", err)
202255
}
203256
}
257+
258+
func TestSplitAccessScopeTargets_Partitions(t *testing.T) {
259+
users, departments, chats := splitAccessScopeTargets([]map[string]interface{}{
260+
{"type": "user", "id": "u1"},
261+
{"type": "department", "id": "d1"},
262+
{"type": "chat", "id": "c1"},
263+
{"type": "user", "id": " "}, // empty id skipped
264+
{"type": "unknown", "id": "x"}, // unknown type skipped
265+
})
266+
if len(users) != 1 || users[0] != "u1" {
267+
t.Errorf("users=%v want [u1]", users)
268+
}
269+
if len(departments) != 1 || departments[0] != "d1" {
270+
t.Errorf("departments=%v want [d1]", departments)
271+
}
272+
if len(chats) != 1 || chats[0] != "c1" {
273+
t.Errorf("chats=%v want [c1]", chats)
274+
}
275+
}
276+
277+
func TestValidateTargetsJSON_Cases(t *testing.T) {
278+
cases := []struct {
279+
name string
280+
in string
281+
wantErr bool
282+
}{
283+
{"invalid json", "{not json", true},
284+
{"empty array", "[]", true},
285+
{"bad type", `[{"type":"role","id":"r1"}]`, true},
286+
{"empty id", `[{"type":"user","id":" "}]`, true},
287+
{"valid", `[{"type":"user","id":"u1"}]`, false},
288+
}
289+
for _, c := range cases {
290+
t.Run(c.name, func(t *testing.T) {
291+
err := validateTargetsJSON(c.in)
292+
if (err != nil) != c.wantErr {
293+
t.Errorf("validateTargetsJSON(%q) err=%v wantErr=%v", c.in, err, c.wantErr)
294+
}
295+
})
296+
}
297+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
2+
// SPDX-License-Identifier: MIT
3+
4+
package apps
5+
6+
import (
7+
"net/http"
8+
"strings"
9+
"testing"
10+
11+
"github.com/larksuite/cli/errs"
12+
"github.com/larksuite/cli/internal/httpmock"
13+
)
14+
15+
// TestAppsList_503IsRetryableTypedError pins the typed-error upgrade: a 5xx
16+
// response from the apps list endpoint must surface as a typed errs.Problem with
17+
// Retryable == true (via CallAPITyped → httpStatusError). The pre-migration
18+
// CallAPI path produced a legacy *output.ExitError with no Retryable field, so
19+
// this test fails until AppsList is migrated to CallAPITyped.
20+
func TestAppsList_503IsRetryableTypedError(t *testing.T) {
21+
factory, stdout, reg := newAppsExecuteFactory(t)
22+
reg.Register(&httpmock.Stub{
23+
Method: "GET",
24+
URL: "/open-apis/spark/v1/apps",
25+
Status: 503,
26+
// A gateway-style non-JSON body (text/html) forces the status-based
27+
// classifier (httpStatusError) rather than the API-envelope path.
28+
Headers: http.Header{"Content-Type": []string{"text/html"}},
29+
RawBody: []byte("<html><body>503 Service Unavailable</body></html>"),
30+
})
31+
32+
err := runAppsShortcut(t, AppsList,
33+
[]string{"+list", "--as", "user"}, factory, stdout)
34+
if err == nil {
35+
t.Fatalf("expected an error on 503, got nil; stdout:\n%s", stdout.String())
36+
}
37+
p, ok := errs.ProblemOf(err)
38+
if !ok {
39+
t.Fatalf("expected a typed errs.Problem on 503, got %T: %v", err, err)
40+
}
41+
if !p.Retryable {
42+
t.Fatalf("expected Retryable == true on 503, got Problem=%+v", p)
43+
}
44+
}
45+
46+
// TestAppsList_SuccessShapeUnchanged pins that the success path is
47+
// output-shape-neutral after migration: a 200 envelope still yields a success
48+
// stdout envelope carrying the app_id.
49+
func TestAppsList_SuccessShapeUnchanged(t *testing.T) {
50+
factory, stdout, reg := newAppsExecuteFactory(t)
51+
reg.Register(&httpmock.Stub{
52+
Method: "GET",
53+
URL: "/open-apis/spark/v1/apps",
54+
Body: map[string]interface{}{
55+
"code": 0,
56+
"data": map[string]interface{}{
57+
"items": []interface{}{
58+
map[string]interface{}{"app_id": "a", "name": "n"},
59+
},
60+
},
61+
},
62+
})
63+
64+
if err := runAppsShortcut(t, AppsList,
65+
[]string{"+list", "--as", "user"}, factory, stdout); err != nil {
66+
t.Fatalf("execute err=%v", err)
67+
}
68+
if got := stdout.String(); !strings.Contains(got, `"app_id": "a"`) {
69+
t.Fatalf("stdout missing app_id: %s", got)
70+
}
71+
}

shortcuts/apps/apps_chat.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
2+
// SPDX-License-Identifier: MIT
3+
4+
package apps
5+
6+
import (
7+
"context"
8+
"fmt"
9+
"io"
10+
"strings"
11+
12+
"github.com/larksuite/cli/internal/output"
13+
"github.com/larksuite/cli/shortcuts/common"
14+
)
15+
16+
// AppsChat sends a user message to a session, starting/continuing a conversation.
17+
// Async: the message is queued and the response carries no business payload (no
18+
// turn_id, no next_poll_after_ms — the turn is not generated yet). Poll
19+
// +session-get; it returns next_poll_after_ms, and once the turn runs its handle
20+
// is in latest_turn.turn_id.
21+
22+
// Turn cost varies sharply by init state: the first +chat on a not-initialized
23+
// app runs a one-time design + first-generation pass server-side (~20-50 min);
24+
// chat on an already-initialized app is incremental and finishes in minutes.
25+
// The init-state check and matching polling cadence live in the lark-apps
26+
// skill reference (references/lark-apps-cloud-dev.md) — the canonical source.
27+
var AppsChat = common.Shortcut{
28+
Service: appsService,
29+
Command: "+chat",
30+
Description: "Send a message to a session to start/continue a conversation",
31+
Risk: "write",
32+
Tips: []string{
33+
`Example: lark-cli apps +chat --app-id <app_id> --session-id <session_id> --message "做一个待办清单页面"`,
34+
`Example: lark-cli apps +chat --app-id <app_id> --session-id <session_id> --message "把首页标题改为 我的待办"`,
35+
},
36+
Scopes: []string{"spark:app:write"},
37+
AuthTypes: []string{"user"},
38+
HasFormat: true,
39+
Flags: []common.Flag{
40+
{Name: "app-id", Desc: "app ID", Required: true},
41+
{Name: "session-id", Desc: "session ID", Required: true},
42+
{Name: "message", Desc: "user message text", Required: true},
43+
},
44+
Validate: func(ctx context.Context, rctx *common.RuntimeContext) error {
45+
if strings.TrimSpace(rctx.Str("app-id")) == "" {
46+
return output.ErrValidation("--app-id is required")
47+
}
48+
if strings.TrimSpace(rctx.Str("session-id")) == "" {
49+
return output.ErrValidation("--session-id is required")
50+
}
51+
// Do not echo --message content in the error (spec §4 redaction).
52+
if strings.TrimSpace(rctx.Str("message")) == "" {
53+
return output.ErrValidation("--message is required")
54+
}
55+
return nil
56+
},
57+
DryRun: func(ctx context.Context, rctx *common.RuntimeContext) *common.DryRunAPI {
58+
return common.NewDryRunAPI().
59+
POST(chatPath(rctx.Str("app-id"), rctx.Str("session-id"))).
60+
Desc("Send a message to a session").
61+
Body(buildChatBody(rctx))
62+
},
63+
Execute: func(ctx context.Context, rctx *common.RuntimeContext) error {
64+
data, err := rctx.CallAPITyped("POST", chatPath(rctx.Str("app-id"), rctx.Str("session-id")), nil, buildChatBody(rctx))
65+
if err != nil {
66+
return withAppsHint(err, "if the session_id is unknown or invalid, list this app's sessions with `lark-cli apps +session-list --app-id "+strings.TrimSpace(rctx.Str("app-id"))+"`")
67+
}
68+
rctx.OutFormat(data, nil, func(w io.Writer) {
69+
fmt.Fprintf(w, "message sent; poll +session-get for turn status\n")
70+
})
71+
return nil
72+
},
73+
}
74+
75+
func chatPath(appID, sessionID string) string {
76+
return sessionPath(appID, sessionID) + "/chat"
77+
}
78+
79+
func buildChatBody(rctx *common.RuntimeContext) map[string]interface{} {
80+
return map[string]interface{}{
81+
"message": strings.TrimSpace(rctx.Str("message")),
82+
}
83+
}

0 commit comments

Comments
 (0)