ucu-mcp 0.3.2 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,68 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.5] - 2026-06-06 *(Yanked — see 0.3.6)*
9
+
10
+ ### Tests
11
+
12
+ - `macos-platform`: new regression test for the value-field regex pre-validation (`findElement({value:"[", textMode:"regex"})` throws `PlatformError` with an `Invalid regex pattern` message). Pins the 0.3.2 commit `0710eca` behavior change.
13
+ - `macos-platform`: new regression test for the near-sort bounds fallback (elements without `bounds` are pushed to the end of the sorted result, instead of implicitly being centered at (0,0)). Pins the 0.3.2 commit `0710eca` second behavior change.
14
+ - `tools-layer`: new regression test that `find_element({value:""})` returns `isError: true`. Pins the 0.3.2 commit `46d4ddd` schema tightening (`z.string().min(1).optional()`).
15
+
16
+ ### Changed
17
+
18
+ - JXA `textMatches` regex branch now compiles the `RegExp` once per element instead of once per source (name / value / description) — three fewer compilations per matched element when `textMode="regex"`. The TS-side pre-validation in `findElement` guarantees the pattern is valid, so the `RegExp` constructor cannot throw here. (Herschel review perf Minor)
19
+
20
+ ### Fixed
21
+
22
+ - Comment on the JXA `matchesValue` helper no longer claims "JXA function declarations are order-sensitive" (they aren't — JXA hoists them like any ES engine). The comment now correctly notes that the leading placement is for readability. (Herschel review comment Minor)
23
+
24
+ ## [0.3.6] - 2026-06-06
25
+
26
+ ### Re-publish of 0.3.5
27
+
28
+ 0.3.5 was published with a test that didn't account for the McpServer
29
+ schema-validation wrapper. The test called `handler({value:""})`
30
+ directly, which bypasses the schema validation, so the assertion
31
+ `r.isError === true` saw `undefined` instead. The actual fix
32
+ (asserting the zod schema constraint directly) was a one-test rewrite;
33
+ 0.3.6 carries the same code as 0.3.5 plus the test fix.
34
+
35
+ ### Yanked
36
+
37
+ `ucu-mcp@0.3.5` was unpublished (yanked) within minutes of release
38
+ due to the broken test. Users on `@latest` are now on 0.3.6.
39
+
40
+ ## [0.3.4] - 2026-06-06
41
+
42
+ ### Re-publish of 0.3.3
43
+
44
+ 0.3.3 was published with a syntax error in the source test file
45
+ (`tests/unit/tools-layer.test.ts:355` was a continuation of a `//`
46
+ comment block that lost its `//` prefix on a hard line break, so
47
+ tsc parsed the second line as a bare identifier). The published
48
+ npm tarball was functionally correct (`dist/` was unaffected), but
49
+ the broken test file would fail to compile for any consumer
50
+ running `npm test` against the source. The fix (a single-character
51
+ comment prefix) was applied, but npm disallows re-publishing the
52
+ same version, so the fixed source ships as 0.3.4 with the same
53
+ contents and CHANGELOG entry as 0.3.3 plus this note.
54
+
55
+ ### Yanked
56
+
57
+ `ucu-mcp@0.3.3` was unpublished (yanked) shortly after release due to
58
+ the test file compile error. Users on `@latest` are now on 0.3.4.
59
+
60
+ ## [0.3.3] - 2026-06-06 *(Yanked — see 0.3.4)*
61
+
62
+ ### Tests
63
+
64
+ - `tools-layer`: three new test cases cover `wait_for_element` value+textMode combinations (contains, exact, regex). They confirm the response surfaces the matched value unchanged so the model can branch on it. (Completes Singer Item 4)
65
+
66
+ ### Refactor
67
+
68
+ - JXA `textMatches` and `valueMatches` consolidated through a shared `matchesValue(filter, value, mode)` helper. No behavior change; the three branches (contains / exact / regex) now live in one place. (Completes Singer Item 8)
69
+
8
70
  ## [0.3.2] - 2026-06-06
9
71
 
10
72
  ### Bug fixes
@@ -863,45 +863,47 @@ export class MacOSPlatform {
863
863
  }
864
864
  }
865
865
 
866
- function textMatches(elemName, elemValue, elemDesc) {
867
- if (textFilter === null) return true;
868
- var sources = [elemName, elemValue, elemDesc];
869
- if (textMode === "exact") {
870
- var t = textFilter.toLowerCase();
871
- for (var i = 0; i < sources.length; i++) {
872
- if (sources[i].toLowerCase() === t) return true;
873
- }
874
- return false;
875
- } else if (textMode === "regex") {
866
+ // Shared filter helper. textMatches and valueMatches used to be near
867
+ // copies of the same three-branch dispatch (contains / exact / regex);
868
+ // this consolidates the logic so the two callers only differ in which
869
+ // sources they iterate. Declared before textMatches/valueMatches for
870
+ // readability JXA's function declarations are hoisted, so order
871
+ // doesn't affect callability. (Singer Nit + Herschel comment fix)
872
+ function matchesValue(filter, value, mode) {
873
+ if (filter === null) return true;
874
+ if (mode === "exact") {
875
+ return value.toLowerCase() === filter.toLowerCase();
876
+ } else if (mode === "regex") {
876
877
  try {
877
- var re = new RegExp(textFilter, "i");
878
- for (var i = 0; i < sources.length; i++) {
879
- if (re.test(sources[i])) return true;
880
- }
881
- } catch(e) {}
882
- return false;
878
+ return new RegExp(filter, "i").test(value);
879
+ } catch(e) { return false; }
883
880
  } else {
884
881
  // contains (default)
885
- var t = textFilter.toLowerCase();
882
+ return value.toLowerCase().indexOf(filter.toLowerCase()) !== -1;
883
+ }
884
+ }
885
+
886
+ function textMatches(elemName, elemValue, elemDesc) {
887
+ if (textFilter === null) return true;
888
+ var sources = [elemName, elemValue, elemDesc];
889
+ // Hoist regex compilation out of the loop. The TS-side pre-validation
890
+ // in findElement guarantees the pattern is valid, so the RegExp
891
+ // constructor cannot throw here. (Herschel perf Minor)
892
+ if (textMode === "regex") {
893
+ var reText = new RegExp(textFilter, "i");
886
894
  for (var i = 0; i < sources.length; i++) {
887
- if (sources[i].toLowerCase().indexOf(t) !== -1) return true;
895
+ if (reText.test(sources[i])) return true;
888
896
  }
889
897
  return false;
890
898
  }
899
+ for (var j = 0; j < sources.length; j++) {
900
+ if (matchesValue(textFilter, sources[j], textMode)) return true;
901
+ }
902
+ return false;
891
903
  }
892
904
 
893
905
  function valueMatches(elemValue) {
894
- if (valueFilter === null) return true;
895
- if (textMode === "exact") {
896
- return elemValue.toLowerCase() === valueFilter.toLowerCase();
897
- } else if (textMode === "regex") {
898
- try {
899
- return new RegExp(valueFilter, "i").test(elemValue);
900
- } catch(e) { return false; }
901
- } else {
902
- // contains (default)
903
- return elemValue.toLowerCase().indexOf(valueFilter.toLowerCase()) !== -1;
904
- }
906
+ return matchesValue(valueFilter, elemValue, textMode);
905
907
  }
906
908
 
907
909
  function matches(elem) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ucu-mcp",
3
- "version": "0.3.2",
3
+ "version": "0.3.6",
4
4
  "description": "MCP server for Universal Computer Use — desktop automation for AI agents via Model Context Protocol",
5
5
  "type": "module",
6
6
  "bin": {