Commit Graph

358 Commits

Author SHA1 Message Date
若麒 c18844120a fix: preserve offline dry-run validation before auth 2026-07-08 15:19:31 +08:00
若麒 b0c48bab6b Merge branch 'main' into feat/self-built-framework 2026-07-08 14:05:48 +08:00
若麒 d20e037dec fix(verbose): restore request-side log lines dropped in credential refactor 2026-07-07 23:16:28 +08:00
若麒 476dd3b841 refactor(output): centralize ANSI styling and remove no-color flag
- remove --no-color from GLOBAL_FLAGS and drop Settings.noColor
- move ANSI styling decisions into runtime color helpers with NO_COLOR support
- update command text renderers to use shared color helpers instead of local ANSI codes
- refresh e2e invocations, generated reference, and agent skill guidance
2026-07-07 00:07:21 +08:00
若麒 c35f2856e5 refactor(flags): align media command async and concurrent handling
- scope image/video task execution to --async and --concurrent
- add concurrent task fan-out for video edit and video ref
- extend image edit to the async image task path
- refresh e2e coverage and generated command references
2026-07-06 22:11:52 +08:00
若麒 468b4d710e refactor(flags): scope yes/async/concurrent to command-owned flags
- remove nonInteractive plus yes/async/concurrent from GLOBAL_FLAGS and Settings;
  command dispatch no longer resolves command-only switches into global settings
- add shared ASYNC_FLAG / CONCURRENT_FLAG definitions for commands that actually
  support task-only return or parallel requests
- keep quota downgrade protection by moving --yes onto quota request and reading
  flags.yes for confirmed downgrade submission
- update existing async/concurrent consumers to read own flags; no new capability
  matrix entries are added
- refresh generated command reference and remove stale --non-interactive usage
  from e2e/stress invocations
2026-07-06 20:43:29 +08:00
若麒 deab3b3841 refactor(flags): scope credential flags by command auth domain
- flags split into GLOBAL_FLAGS (all commands) plus MODEL_AUTH_FLAGS /
  CONSOLE_AUTH_FLAGS, parsed only for commands of the matching auth
  domain; cross-domain flags now fail with "Unknown flag" instead of
  being silently ignored
- all shadow redeclarations removed; the registry guard now rejects any
  own flag named after a reserved (global or visible-domain) flag
- --workspace-id joins the console domain (chain: flag > env > file);
  usage stats drops its private declaration and in-command priority
- auth login declares its credential args as own command parameters
  (--api-key / --base-url / --console-site, original behavior intact);
  auth status no longer accepts credential-domain overrides (use env or
  config set instead)
- command help and the generated reference both show Flags (own + auth
  domain) plus a full Global Flags section, replacing the footer hint
- breaking: pipeline run --timeout renamed to --step-timeout (collided
  with the global request timeout)
2026-07-06 17:42:11 +08:00
若麒 d31b7f83ca refactor(core): split god Config into Identity/Settings/Credential resolved at the dispatch boundary
- commands consume a narrowed context (identity/settings/own flags/client);
  config/auth commands additionally use configStore()/authStore() accessors
- resolution happens once at dispatch: buildSources/buildSettings plus
  per-domain credential resolvers; dry-run tolerates missing credentials
- transport takes structured deps; credentials are injected only by Client;
  console gateway takes a resolved target with optional token (anonymous
  catalog calls); pipeline steps and advisor run against client/settings
- telemetry receives authMethod as a value; global/command flags are split
  at dispatch with a same-type shadowing guard at registry build
- behavior change: base URL resolution now prefers DASHSCOPE_BASE_URL env
  over config file base_url (unified flag > env > file > default chain)
- priority chains, store semantics and command capability boundaries are
  locked by unit tests
2026-07-06 15:59:33 +08:00
若麒 ae88f7a4ad refactor(runtime): group process-lifecycle setup into installProcessHandlers 2026-06-29 16:08:14 +08:00
若麒 bd431d769f feat(update-checker): surface update notice to non-TTY/agent runs
- drop the CI / non-TTY early-return so agents see "Update available" too
- widen check interval 4h→24h; stay silent inside the window (no per-command repeat)
- remove orphan isCI() helper (zero callers)
- versioning.md: drop the now-false "banner suppressed under agent" rationale
2026-06-29 15:45:34 +08:00
若麒 df89ededc2 test(e2e): align with UsageError validation contract
Missing required flags now throw UsageError (exit code 2, error on
stderr, JSON under --output json) instead of printing help and exiting
0. Update assertions and titles accordingly:

- missing-flag cases: exitCode 0/1 -> 2, retitle to "errors as usage error (2)"
- auth / video-task-get under --output json: assert the error JSON on stderr
- proxy probe: import setupProxyFromEnv from runtime/src/proxy.ts
- drop tests for the removed config export-schema command
- fix t2v dry-run: cliTimeoutPrefix misplaced between --model and its value
2026-06-29 14:53:24 +08:00
若麒 1f56feab24 refactor(commands): route all exits through the central error handler
Commands no longer call process.exit() directly. Every failure now throws
UsageError (bad input → exit 2) or BailianError (runtime failure, with
AUTH/TIMEOUT codes), so the runtime's handleError stays the single exit
point and telemetry always flushes.

- convert 27 process.exit() sites across 15 commands to throws
- move cross-flag/value checks into validate(); use flag `choices` for
  --events / --sort; drop dead --model required check
- keep pipeline's process.exitCode for lint-style soft failures
- enforce with unicorn/no-process-exit, allowed only in runtime/tools/tests
- fix incidental lint: void floating run(), narrow console errorCode,
  align generate-reference type imports to source
2026-06-29 09:07:12 +08:00
若麒 2f9558c161 refactor(auth): remove deprecated AK/SK auth for knowledge retrieve
AK/SK signing was used only by `knowledge retrieve`'s deprecated fallback,
which the api-key auth gate now makes unreachable. Drop it; the command is
pure api-key.

- knowledge/retrieve: remove the AK/SK path + --access-key-id/secret/workspace-id
  flags; api-key only
- delete client/ak-sign.ts and its signRequest/AkSignConfig exports
- drop access_key_id/access_key_secret from config schema, loader, and
  `config show` / `config set`
- remove the now-unused PascalCase KnowledgeRetrieve request/response types
2026-06-28 22:24:59 +08:00
若麒 95eb07d04a refactor(auth): centralize credential resolution into authStage + Client
Move all credential handling out of commands into one place. authStage
resolves the credential for the command's declared `auth` and bakes it into
`ctx.client`, gating (throw) when missing; commands reach the network only
through `ctx.client` and never touch tokens or baseUrl.

- add Client (request/requestJson/uploadFile/mcp/console/url) wrapping the
  token + baseUrl; commands call it instead of self-resolving
- run(config, flags) → run(ctx) + CommandContext; migrate all 45 commands
- split domains: model = pure api-key (drop access-token fallback), console =
  config.json only (drop DASHSCOPE_ACCESS_TOKEN env)
- consolidate env reads in loadConfig; CredentialSource = flag | env | config;
  priority flag > env > config
- endpoints return paths (xxxPath) instead of full URLs; baseUrl owned by Client
- auth status now uses describeAuth
- video/download: auth "none" → "apiKey" (it needs the model API)
- dedupe fetchModelList behind an injected console-call function
- remove ensureApiKey/ensure-key.ts, prompt.ts + isInteractive, and the old
  resolveCredential/resolveConsoleGatewayCredential resolvers
- tests: adapt auth.e2e to the new auth status shape; drop the
  DASHSCOPE_ACCESS_TOKEN branch from console-readiness gates
2026-06-28 20:42:33 +08:00
若麒 f9bf36c242 refactor(flags): keyed type-inferred flag schema; option→flag rename
Replace the positional `OptionDef[]` array (key/type regex-parsed from
"--x <v>" strings) with a keyed `FlagsDef` record whose `type` drives both
runtime parsing and compile-time flag-type inference (`Flags<typeof DEF>`).
GLOBAL_FLAGS becomes the single source; the hand-kept GlobalFlags interface
(types/flags.ts) is deleted.

- core: SwitchFlag|ValueFlag union, ParsedFlags/Flags inference, defineCommand
  infers F from spec.flags
- runtime: parseFlags dispatches on def.type (switch/string/number/boolean/
  array/choices) with declarative required-flag enforcement
- commands: migrate every flag declaration to the keyed form
- naming: option→flag throughout (OptionDef→FlagDef, OptionsDef→FlagsDef,
  GLOBAL_OPTIONS→GLOBAL_FLAGS, command field options→flags), plus user-facing
  "Options:"→"Flags:" in help and the regenerated skill reference docs

Behavior-preserving aside from the intentional Options→Flags wording:
vp check clean across all packages, 29 parser tests pass, reference regen
byte-identical before the terminology swap.
2026-06-28 11:19:21 +08:00
若麒 cbd3c1232c refactor(runtime): unify validation into UsageError; bare command shows help
- drop IncompleteCommandError: missing-required, failed validate, and bad/unknown
  flags are all UsageError now
- error boundary keys on bareness — bare command that fails → help (exit 0);
  non-bare invalid → error + message (exit 2)
- login: drop config.apiKey fallback, --api-key required-unless-console via validate
- speech: drop empty --text-file guard (empty content is the API's concern)
2026-06-27 10:56:28 +08:00
若麒 91e6c6f553 refactor(runtime): resolve/middleware kernel + declarative arg validation
把 main 从一堆 if + process.exit 重构为「argv 解析成数据 → 交给统一管线执行」。

内核
- resolve(argv) → Resolution(version/help/run/usageError):路由即数据,dispatch 只 switch
- compose 洋葱中间件 (versionCheck/telemetry/auth/runCommand),命令仍收 (config, flags)
- registry.locate() 统一 leaf/group/unknown,取代 isGroupPath + 抛异常的 resolve
- 删除 command-help.ts 全局可变单例:help 渲染收口到错误边界

错误模型
- 新增 UsageError(写错了 → exit 2) 与 IncompleteCommandError(没写完 → 打 help、exit 0)
- version / help / onboarding / 组帮助统一由 resolve 产出、dispatch 分派

参数与校验
- parseFlags 重写:无 positional、新增 switch 类型、值/类型/重复校验
- 无条件必填 → 解析器声明式强制 (OptionDef.required)
- 跨 flag / 条件约束 → 新增 command.validate(flags) 钩子
  (text-chat / search-web / speech / vision / video-ref)
- 移除全部交互式输入 (promptText/Select/Confirm),缺输入直接打 help

输出
- detectOutputFormat 默认 text,不再按 TTY 切 json

测试
- 删除 3 个 stale cli 测试,runtime 单测重写 (29 passed),e2e 适配新行为
2026-06-26 16:50:12 +08:00
若麒 7a0a083b2e refactor(core): replace skipDefaultApiKeySetup with required auth field
Commands now declare their credential requirement explicitly via a
required `auth: "apiKey" | "console" | "none"` field instead of the
boolean `skipDefaultApiKeySetup`. The runtime prepares credentials
based on this declaration and skips API-key setup under --dry-run.

- core: add AuthRequirement type and required `auth` field to
  Command/CommandSpec; drop skipDefaultApiKeySetup
- runtime: gate API-key setup on `auth === "apiKey" && !dryRun`
- commands: annotate all 45 commands (apiKey 25 / console 11 / none 9)
2026-06-24 16:41:09 +08:00
若麒 61689ec0da build: jump to source across packages via @bailian-cli/source export condition 2026-06-24 16:14:20 +08:00
若麒 24abdbf450 refactor(commands): decouple command paths from binary name; drop path presets
Commands no longer hardcode "bl" or their path — the runtime renders the
`<bin> <path>` prefix from each product's registry key, so shared commands
show `bl knowledge retrieve` / `rag retrieve` from one codebase. commands
package now exports only individual commands (no groups/catalog); bl and rag
each spell out their own path map. Also removes the unused export-schema command.
2026-06-24 14:40:08 +08:00
若麒 ad236e9b11 test(runtime): move unit tests from cli to runtime package 2026-06-23 19:32:21 +08:00
若麒 d971a04fb8 refactor(cli): split into runtime / commands packages for composable CLIs
Decompose the monolithic `cli` package into three layers so multiple
products can be assembled from a shared base:

- bailian-cli-runtime: framework infra (createCli, registry, args,
  output, pipeline, utils) — product-agnostic
- bailian-cli-commands: command library, grouped (base/knowledge/text/
  media/memory/misc) so each product picks the sets it needs
- packages/cli (bl): full command set; packages/rag (rag): base +
  knowledge only

Product identity (binName / clientName / npmPackage) is injected at the
createCli boundary and required there, with no per-consumer defaults.
2026-06-23 17:51:14 +08:00
Gong Shiqi 1ffcbdd80c Merge pull request #65 from modelstudioai/feat/optimize-skill
Feat/optimize skill
2026-06-18 18:05:07 +08:00
qcq01083097 07dafc0fd4 feat: The method to modify and update skills 2026-06-18 14:07:06 +08:00
若麒 c3df659ef0 Merge remote-tracking branch 'origin/main' into release/1.4.0 2026-06-17 21:07:39 +08:00
若麒 0ceb15b0be fix(video): correct resolution/ratio flag descriptions 2026-06-17 20:26:55 +08:00
故璃 dc3c02f68c fix: e2e test update logic 2026-06-17 19:51:21 +08:00
若麒 8906af8ad1 docs(readme): sync China-site-only notice to zh and cli-package READMEs 2026-06-17 17:21:25 +08:00
若麒 8c893a59ef Merge remote-tracking branch 'origin/main' into release/1.4.0 2026-06-17 16:06:14 +08:00
若麒 611ecc1e68 chore(release): 1.4.0 2026-06-17 15:58:08 +08:00
故璃 edb34658a1 feat: temp save 2026-06-17 15:16:54 +08:00
ls 1fd08fe1c8 Merge pull request #56 from modelstudioai/feat/console-gateway-region-site
feat(console): resolve gateway URL from region + site, add switchAgent
2026-06-17 14:49:28 +08:00
故璃 8cb24b719b feat: merge main 2026-06-17 14:43:13 +08:00
qcq01083097 d4c0809951 feat: resolve conflict 2026-06-17 14:43:01 +08:00
故璃 b01d35c246 Merge branch 'main' into feat/update-intent-model 2026-06-17 14:35:14 +08:00
Gong Shiqi 67ff4d2811 Merge pull request #63 from modelstudioai/feat/i18n-english-only
feat(cli): standardize user-facing CLI text to English
2026-06-17 14:27:27 +08:00
clh02467605 a830965feb feat(omni): add new voice option to omni chat command 2026-06-17 14:19:47 +08:00
故璃 14583cf6d1 feat: update access token logic 2026-06-17 11:58:09 +08:00
lishengzxc e9feb380f5 Merge branch 'main' of github.com:modelstudioai/cli into feat/console-gateway-region-site 2026-06-17 11:45:49 +08:00
clh02467605 62ad8768e3 merge: merge main into feat/i18n-english-only 2026-06-17 11:28:24 +08:00
clh02467605 e8a40cdad0 Merge remote-tracking branch 'refs/remotes/origin/main' into feat/i18n-english-only
# Conflicts:
#	packages/cli/src/commands/knowledge/retrieve.ts
#	skills/bailian-cli/reference/knowledge.md
2026-06-17 11:26:04 +08:00
qcq01083097 9bcb66b1ff feat: Resolve conflicts 2026-06-17 10:02:00 +08:00
lishengzxc 60cad1001c chore: remove redundant "(global flag)" from option descriptions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-16 19:44:08 +08:00
qcq01083097 a5d078b8a0 Merge branch 'feat/console-gateway-region-site' of github.com:modelstudioai/cli into feat/console-gateway-region-site 2026-06-16 18:23:09 +08:00
qcq01083097 685c0176ff feat: clean up region remnants 2026-06-16 18:22:18 +08:00
qcq01083097 d24b41d452 feat: Remove the logic related to region 2026-06-16 18:16:10 +08:00
lishengzxc d320d36ba7 docs: add console gateway flags convention to AGENTS.md and command help
Add console global flags (--console-region, --console-site, --console-switch-agent)
to the options of all 12 commands that depend on callConsoleGateway, so they appear
in --help output. Document this as convention #4 in AGENTS.md for future commands.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-06-16 17:50:58 +08:00
故璃 f816d5cb1f Merge branch 'main' into feat/update-intent-model 2026-06-16 17:38:10 +08:00
故璃 93cecc35de feat: model recommend use english output 2026-06-16 17:37:40 +08:00
qcq01083097 a5d055f45a feat: Adjust the priority of base_url in config to be higher than that of the environment variable DASHSCOPE_BASE_URL 2026-06-16 17:16:25 +08:00