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

推荐订阅源

V
Visual Studio Blog
量子位
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
Google DeepMind News
Google DeepMind News
小众软件
小众软件
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
雷峰网
雷峰网
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell

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
chore(deadcode): share levenshtein distance helper · open...
vincentkoc · 2026-06-21 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,3 +1,4 @@

1+

import { levenshteinDistance } from "../../shared/levenshtein-distance.js";

12

import { formatCliCommand } from "../command-format.js";

23

import { getCoreCliCommandNames } from "./core-command-descriptors.js";

34

import { getSubCliEntries } from "./subcli-descriptors.js";

@@ -15,36 +16,6 @@ function uniqueSortedCommandNames(commands: Iterable<string>): string[] {

1516

);

1617

}

1718
18-

export function levenshteinDistance(left: string, right: string): number {

19-

if (left === right) {

20-

return 0;

21-

}

22-

if (left.length === 0) {

23-

return right.length;

24-

}

25-

if (right.length === 0) {

26-

return left.length;

27-

}

28-
29-

let previous = Array.from({ length: right.length + 1 }, (_, index) => index);

30-

let current = Array.from<number>({ length: right.length + 1 });

31-
32-

for (let leftIndex = 0; leftIndex < left.length; leftIndex += 1) {

33-

current[0] = leftIndex + 1;

34-

for (let rightIndex = 0; rightIndex < right.length; rightIndex += 1) {

35-

const substitutionCost = left[leftIndex] === right[rightIndex] ? 0 : 1;

36-

current[rightIndex + 1] = Math.min(

37-

current[rightIndex] + 1,

38-

previous[rightIndex + 1] + 1,

39-

previous[rightIndex] + substitutionCost,

40-

);

41-

}

42-

[previous, current] = [current, previous];

43-

}

44-
45-

return previous[right.length] ?? 0;

46-

}

47-
4819

export function formatCliCommandSuggestions(input: string): string | undefined {

4920

const normalizedInput = input.trim().toLowerCase();

5021

if (!normalizedInput) {

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,32 @@

1+

export function levenshteinDistance(left: string, right: string): number {

2+

if (left === right) {

3+

return 0;

4+

}

5+

if (!left) {

6+

return right.length;

7+

}

8+

if (!right) {

9+

return left.length;

10+

}

11+
12+

let previous = new Uint32Array(right.length + 1);

13+

let current = new Uint32Array(right.length + 1);

14+

for (let index = 0; index <= right.length; index += 1) {

15+

previous[index] = index;

16+

}

17+

for (let leftIndex = 0; leftIndex < left.length; leftIndex += 1) {

18+

current[0] = leftIndex + 1;

19+

for (let rightIndex = 0; rightIndex < right.length; rightIndex += 1) {

20+

const cost = left[leftIndex] === right[rightIndex] ? 0 : 1;

21+

current[rightIndex + 1] = Math.min(

22+

current[rightIndex] + 1,

23+

previous[rightIndex + 1] + 1,

24+

previous[rightIndex] + cost,

25+

);

26+

}

27+

const nextPrevious = current;

28+

current = previous;

29+

previous = nextPrevious;

30+

}

31+

return previous[right.length];

32+

}

Original file line numberDiff line numberDiff line change

@@ -5,6 +5,8 @@

55

* transcript, strips the name before agent routing, and keeps fuzzy matching

66

* conservative so ordinary dictation does not trigger Talk turns.

77

*/

8+

import { levenshteinDistance } from "../shared/levenshtein-distance.js";

9+
810

export const REALTIME_VOICE_ACTIVATION_NAME_MAX_WORDS = 2;

911
1012

/** Transcript edge where an activation name was heard. */

@@ -257,40 +259,6 @@ function trailingActivationNameCandidates(

257259

return candidates;

258260

}

259261
260-

function levenshteinDistance(left: string, right: string): number {

261-

if (left === right) {

262-

return 0;

263-

}

264-

if (!left) {

265-

return right.length;

266-

}

267-

if (!right) {

268-

return left.length;

269-

}

270-
271-

let previous = new Uint32Array(right.length + 1);

272-

let current = new Uint32Array(right.length + 1);

273-

// Keep only two rows so fuzzy matching stays allocation-light per transcript.

274-

for (let index = 0; index <= right.length; index += 1) {

275-

previous[index] = index;

276-

}

277-

for (let leftIndex = 0; leftIndex < left.length; leftIndex += 1) {

278-

current[0] = leftIndex + 1;

279-

for (let rightIndex = 0; rightIndex < right.length; rightIndex += 1) {

280-

const cost = left[leftIndex] === right[rightIndex] ? 0 : 1;

281-

current[rightIndex + 1] = Math.min(

282-

current[rightIndex] + 1,

283-

previous[rightIndex + 1] + 1,

284-

previous[rightIndex] + cost,

285-

);

286-

}

287-

const nextPrevious = current;

288-

current = previous;

289-

previous = nextPrevious;

290-

}

291-

return previous[right.length];

292-

}

293-
294262

function hasOnlyPhoneticSubstitutions(left: string, right: string): boolean {

295263

if (left.length !== right.length) {

296264

return false;