惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
J
Java Code Geeks
有赞技术团队
有赞技术团队
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
Apple Machine Learning Research
Apple Machine Learning Research
量子位
D
Docker
V
Visual Studio Blog
博客园 - 司徒正美
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
WordPress大学
WordPress大学
U
Unit 42
M
MIT News - Artificial intelligence
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
V
V2EX
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
Vercel News
Vercel News
C
Check Point Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor(cli): lazy-load models runtime · openclaw/opencl...
vincentkoc · 2026-05-14 · via Recent Commits to openclaw:main

@@ -0,0 +1,77 @@

1+

import { Command } from "commander";

2+

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

3+4+

describe("models cli lazy runtime boundary", () => {

5+

beforeEach(() => {

6+

vi.resetModules();

7+

});

8+9+

afterEach(() => {

10+

vi.doUnmock("./models-cli.runtime.js");

11+

vi.doUnmock("../commands/models/list.status-command.js");

12+

vi.resetModules();

13+

});

14+15+

it("renders help without importing the models runtime", async () => {

16+

const runtimeLoaded = vi.fn();

17+

vi.doMock("./models-cli.runtime.js", () => {

18+

runtimeLoaded();

19+

return {

20+

defaultRuntime: {},

21+

rejectAgentScopedModelWrite: vi.fn(),

22+

resolveModelAgentOption: vi.fn(),

23+

runModelsCommand: vi.fn(),

24+

};

25+

});

26+27+

const { registerModelsCli } = await import("./models-cli.js");

28+

const program = new Command();

29+

program.exitOverride();

30+

program.configureOutput({

31+

writeErr: () => {},

32+

writeOut: () => {},

33+

});

34+

registerModelsCli(program);

35+36+

await expect(program.parseAsync(["models", "--help"], { from: "user" })).rejects.toMatchObject({

37+

exitCode: 0,

38+

});

39+

expect(runtimeLoaded).not.toHaveBeenCalled();

40+

});

41+42+

it("loads the models runtime for command actions", async () => {

43+

const defaultRuntime = {};

44+

const modelsStatusCommand = vi.fn().mockResolvedValue(undefined);

45+

const runModelsCommand = vi.fn(async (action: () => Promise<void>) => {

46+

await action();

47+

});

48+

const resolveModelAgentOption = vi.fn(() => "poe");

49+

const runtimeLoaded = vi.fn();

50+51+

vi.doMock("./models-cli.runtime.js", () => {

52+

runtimeLoaded();

53+

return {

54+

defaultRuntime,

55+

rejectAgentScopedModelWrite: vi.fn(),

56+

resolveModelAgentOption,

57+

runModelsCommand,

58+

};

59+

});

60+

vi.doMock("../commands/models/list.status-command.js", () => ({

61+

modelsStatusCommand,

62+

}));

63+64+

const { registerModelsCli } = await import("./models-cli.js");

65+

const program = new Command();

66+

registerModelsCli(program);

67+68+

await program.parseAsync(["models", "status", "--json"], { from: "user" });

69+70+

expect(runtimeLoaded).toHaveBeenCalledTimes(1);

71+

expect(runModelsCommand).toHaveBeenCalledTimes(1);

72+

expect(modelsStatusCommand).toHaveBeenCalledWith(

73+

expect.objectContaining({ agent: "poe", json: true }),

74+

defaultRuntime,

75+

);

76+

});

77+

});