davinci-resolve-mcp 5.0.8 → 5.1.0
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 +17 -0
- package/README.md +1 -1
- package/README.zh-CN.md +2 -2
- package/docs/reference/typed-api-search.md +22 -10
- package/install.py +1 -1
- package/package.json +1 -1
- package/src/granular/common.py +1 -1
- package/src/granular/resolve_control.py +23 -9
- package/src/server.py +18 -11
- package/src/utils/typed_api_search.py +98 -21
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Release history for the DaVinci Resolve MCP Server. The latest release is summarized in the root README; older entries live here to keep the README focused.
|
|
4
4
|
|
|
5
|
+
## What's New in v5.1.0 — API search reads the installed Resolve's own stub
|
|
6
|
+
|
|
7
|
+
Completes #351, from #356 by @CaptRauti. v5.0.6 put the typed stub back in the npm package; this release stops it answering for builds newer than itself.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **`source` on `search_api`, `describe_api` and `api_surface`** (and the granular `search_resolve_api`, `describe_resolve_api`, `get_resolve_api_surface`). `auto`, the default, reads the `DaVinciResolveScript.pyi` that Resolve installs next to its scripting API and falls back to the copy shipped in `docs/reference`. `shipped` always reads the shipped copy. `installed` refuses rather than falling back. `RESOLVE_SCRIPT_API` still overrides the platform default location.
|
|
12
|
+
- **Every reply says which stub answered**: `stub` (the absolute path) and `stub_source` (`installed` or `shipped`). A "symbol not found" error now names the stub that answered and suggests `source='installed'`.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **Results can now differ between machines.** On a Resolve that installs a newer stub, the default answers from that build. The contributor measured Studio 21.2.0.6 on Windows: 530 methods against the shipped 410, including `ExportThumbnails`, the AutoColor calls and `GetCDL`/`SetCDL`, which the shipped copy reports as absent. Pass `source='shipped'` for the pinned 21.1 inventory.
|
|
17
|
+
|
|
18
|
+
### Not changed
|
|
19
|
+
|
|
20
|
+
- The shipped stub is still the 21.1 revision, and the 21.1 inventory tests now pin `source='shipped'`. On this machine (Resolve Studio 19.1.3.7, which installs no stub) `auto` falls back to the shipped copy; the installed path was measured by the contributor on 21.2.0.6 only. No Resolve API is called, so no live Resolve run.
|
|
21
|
+
|
|
5
22
|
## What's New in v5.0.8 — A bridge test no longer fails when the repository and the temp folder are on different drives
|
|
6
23
|
|
|
7
24
|
Fixes the second half of #352, from #357 by @0x-70da.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
English | [简体中文](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
[](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
|
|
6
6
|
[](https://www.npmjs.com/package/davinci-resolve-mcp)
|
|
7
7
|
[](docs/reference/api-coverage.md)
|
|
8
8
|
[-blue.svg)](#server-modes)
|
package/README.zh-CN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 简体中文
|
|
4
4
|
|
|
5
|
-
[](https://github.com/samuelgursky/davinci-resolve-mcp/releases)
|
|
6
6
|
[](https://www.npmjs.com/package/davinci-resolve-mcp)
|
|
7
7
|
[](docs/reference/api-coverage.md)
|
|
8
8
|
[-blue.svg)](#服务器模式)
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
[](https://www.python.org/downloads/)
|
|
13
13
|
[](https://opensource.org/licenses/MIT)
|
|
14
14
|
|
|
15
|
-
> 本翻译对应 v5.0
|
|
15
|
+
> 本翻译对应 v5.1.0 版 README。如与英文原版有出入,以 [英文原版](README.md) 为准。
|
|
16
16
|
|
|
17
17
|
一个 Model Context Protocol (MCP) 服务器,让 AI 助手通过官方脚本 API 控制 DaVinci Resolve Studio(达芬奇)。它提供完整的 API 覆盖,外加带护栏的工作流助手,涵盖剪辑、媒体池整理、渲染设置、审阅标记、调色、Fusion、Fairlight、项目生命周期任务、扩展开发,以及不碰源媒体的媒体分析。
|
|
18
18
|
|
|
@@ -35,22 +35,34 @@ Compound `resolve_control`, none of which need a Resolve connection:
|
|
|
35
35
|
guessing.
|
|
36
36
|
- `api_surface()` — counts and the object list.
|
|
37
37
|
|
|
38
|
+
All three take `source` (v5.1.0, #356): `auto` (the default) reads the stub the
|
|
39
|
+
installed Resolve writes next to its scripting API and falls back to the copy
|
|
40
|
+
shipped in `docs/reference`; `shipped` always reads the shipped copy;
|
|
41
|
+
`installed` refuses instead of falling back. Every reply carries `stub` (the
|
|
42
|
+
path that answered) and `stub_source` (`installed` or `shipped`).
|
|
43
|
+
|
|
38
44
|
Granular twins: `search_resolve_api`, `describe_resolve_api`,
|
|
39
45
|
`get_resolve_api_surface`. Tool count 384 → 387. The granular tools carry the read-only annotation, since
|
|
40
46
|
for the granular server the MCP annotation is the signal a client reads.
|
|
41
47
|
|
|
42
48
|
## Self-consistency
|
|
43
49
|
|
|
44
|
-
|
|
45
|
-
matching the inventory published in
|
|
46
|
-
disposition ledgers built during the 21.1
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
On the shipped stub the parser reports **410 methods, 46 TypedDicts, 513
|
|
51
|
+
fields**, independently matching the inventory published in
|
|
52
|
+
`resolve-211-typed-api.md` and the disposition ledgers built during the 21.1
|
|
53
|
+
audit. That agreement is asserted in `tests/test_typed_api_search.py` with
|
|
54
|
+
`source='shipped'`, so a stub refresh that changes the surface will fail the
|
|
55
|
+
suite rather than drift quietly, and the assertion does not depend on which
|
|
56
|
+
Resolve is installed on the test machine.
|
|
49
57
|
|
|
50
58
|
## Scope
|
|
51
59
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
None of this queries a running Resolve; it parses a stub file, and it reports a
|
|
61
|
+
missing stub rather than guessing. With the default `auto`, a machine whose
|
|
62
|
+
Resolve installs a stub answers from that build. The contributor of #356
|
|
63
|
+
measured Studio 21.2.0.6 on Windows at 530 methods against the shipped 410. A
|
|
64
|
+
Resolve that installs no stub, such as 19.x, falls back to the shipped copy,
|
|
65
|
+
which describes 21.1.0.14. Results can therefore differ between machines;
|
|
66
|
+
`stub_source` says which inventory answered, and `source='shipped'` gives the
|
|
67
|
+
pinned one. Refreshing the shipped stub is the existing documented process in
|
|
68
|
+
`resolve-211-typed-api.md`.
|
package/install.py
CHANGED
|
@@ -37,7 +37,7 @@ from src.utils.update_check import (
|
|
|
37
37
|
|
|
38
38
|
# ─── Version ──────────────────────────────────────────────────────────────────
|
|
39
39
|
|
|
40
|
-
VERSION = "5.0
|
|
40
|
+
VERSION = "5.1.0"
|
|
41
41
|
# Only hard floor: mcp[cli] requires Python 3.10+. There is no upper bound —
|
|
42
42
|
# Resolve's scripting bridge loads into newer interpreters on recent builds
|
|
43
43
|
# (Python 3.14 verified against Resolve Studio 20.3.2). Older Resolve builds
|
package/package.json
CHANGED
package/src/granular/common.py
CHANGED
|
@@ -93,7 +93,7 @@ if not logging.getLogger().handlers:
|
|
|
93
93
|
handlers=[logging.StreamHandler()],
|
|
94
94
|
)
|
|
95
95
|
|
|
96
|
-
VERSION = "5.0
|
|
96
|
+
VERSION = "5.1.0"
|
|
97
97
|
logger = logging.getLogger("davinci-resolve-mcp")
|
|
98
98
|
logger.info(f"Starting DaVinci Resolve MCP Server v{VERSION}")
|
|
99
99
|
logger.info(f"Detected platform: {get_platform()}")
|
|
@@ -772,42 +772,56 @@ _PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(_
|
|
|
772
772
|
|
|
773
773
|
|
|
774
774
|
@mcp.tool(annotations=READ_ONLY_TOOL)
|
|
775
|
-
def search_resolve_api(pattern: str, kind: str = "all", limit: int = 50
|
|
776
|
-
|
|
775
|
+
def search_resolve_api(pattern: str, kind: str = "all", limit: int = 50,
|
|
776
|
+
source: str = "auto") -> Dict[str, Any]:
|
|
777
|
+
"""Search the Resolve typed API stub. Needs no connection.
|
|
777
778
|
|
|
778
779
|
`api_truth` answers what is broken; this answers what exists. Each hit also
|
|
779
780
|
reports whether THIS server references the method and in which files, so a
|
|
780
|
-
search doubles as a parity check.
|
|
781
|
+
search doubles as a parity check. The reply names the stub that answered
|
|
782
|
+
(`stub`, `stub_source`), because "absent" from an outdated inventory is not
|
|
783
|
+
the same as absent from the running build.
|
|
781
784
|
|
|
782
785
|
Args:
|
|
783
786
|
pattern: Case-insensitive regular expression, e.g. "marker" or "(Get|Set)Setting".
|
|
784
787
|
kind: 'all' (default), 'methods', or 'options' for TypedDicts only.
|
|
785
788
|
limit: Maximum results per section (capped at 200).
|
|
789
|
+
source: 'auto' (default) prefers the stub the installed Resolve ships and
|
|
790
|
+
falls back to the shipped copy; 'shipped' forces the pinned file;
|
|
791
|
+
'installed' refuses when no install is found.
|
|
786
792
|
"""
|
|
787
793
|
try:
|
|
788
|
-
return typed_api_search.search(_PROJECT_DIR, pattern, kind=kind, limit=limit
|
|
794
|
+
return typed_api_search.search(_PROJECT_DIR, pattern, kind=kind, limit=limit,
|
|
795
|
+
source=source)
|
|
789
796
|
except typed_api_search.TypedApiError as exc:
|
|
790
797
|
return {"error": str(exc)}
|
|
791
798
|
|
|
792
799
|
|
|
793
800
|
@mcp.tool(annotations=READ_ONLY_TOOL)
|
|
794
|
-
def describe_resolve_api(symbol: str) -> Dict[str, Any]:
|
|
801
|
+
def describe_resolve_api(symbol: str, source: str = "auto") -> Dict[str, Any]:
|
|
795
802
|
"""Full typed detail for one Resolve API symbol. Needs no connection.
|
|
796
803
|
|
|
797
804
|
Args:
|
|
798
805
|
symbol: 'Class.Method' (e.g. "Project.GetName"), a bare method name when
|
|
799
806
|
it is unambiguous, or a TypedDict name (e.g. "RenderSettings").
|
|
807
|
+
source: 'auto' (default) prefers the installed build's stub; 'shipped'
|
|
808
|
+
forces the pinned copy; 'installed' refuses without an install.
|
|
800
809
|
"""
|
|
801
810
|
try:
|
|
802
|
-
return typed_api_search.describe(_PROJECT_DIR, symbol)
|
|
811
|
+
return typed_api_search.describe(_PROJECT_DIR, symbol, source=source)
|
|
803
812
|
except typed_api_search.TypedApiError as exc:
|
|
804
813
|
return {"error": str(exc)}
|
|
805
814
|
|
|
806
815
|
|
|
807
816
|
@mcp.tool(annotations=READ_ONLY_TOOL)
|
|
808
|
-
def get_resolve_api_surface() -> Dict[str, Any]:
|
|
809
|
-
"""Counts and object list for the
|
|
817
|
+
def get_resolve_api_surface(source: str = "auto") -> Dict[str, Any]:
|
|
818
|
+
"""Counts and object list for the typed stub. Needs no connection.
|
|
819
|
+
|
|
820
|
+
Args:
|
|
821
|
+
source: 'auto' (default) prefers the installed build's stub; 'shipped'
|
|
822
|
+
forces the pinned copy; 'installed' refuses without an install.
|
|
823
|
+
"""
|
|
810
824
|
try:
|
|
811
|
-
return typed_api_search.summary(_PROJECT_DIR)
|
|
825
|
+
return typed_api_search.summary(_PROJECT_DIR, source=source)
|
|
812
826
|
except typed_api_search.TypedApiError as exc:
|
|
813
827
|
return {"error": str(exc)}
|
package/src/server.py
CHANGED
|
@@ -11,7 +11,7 @@ Usage:
|
|
|
11
11
|
python src/server.py --full # Start the 377-tool granular server instead
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
VERSION = "5.0
|
|
14
|
+
VERSION = "5.1.0"
|
|
15
15
|
|
|
16
16
|
import base64
|
|
17
17
|
import os
|
|
@@ -18706,15 +18706,20 @@ def resolve_control(action: str, params: Optional[Dict[str, Any]] = None) -> Dic
|
|
|
18706
18706
|
set_keyframe_mode(mode) -> {success}
|
|
18707
18707
|
quit() -> {success}
|
|
18708
18708
|
get_fairlight_presets() -> {presets}
|
|
18709
|
-
search_api(pattern, kind?, limit?) -> {methods, option_types, total_matches}
|
|
18710
|
-
— regex over the
|
|
18711
|
-
|
|
18712
|
-
|
|
18709
|
+
search_api(pattern, kind?, limit?, source?) -> {methods, option_types, total_matches, stub, stub_source}
|
|
18710
|
+
— regex over the Resolve typed stub. Each hit says whether THIS server
|
|
18711
|
+
references the method, and where, so it doubles as a parity check.
|
|
18712
|
+
kind: 'all' (default) | 'methods' | 'options'.
|
|
18713
|
+
source: 'auto' (default) reads the stub the installed Resolve ships and
|
|
18714
|
+
falls back to the shipped copy; 'shipped' forces the pinned file;
|
|
18715
|
+
'installed' refuses when no install is found. The reply names the stub
|
|
18716
|
+
that answered, because "absent" from an outdated inventory is not the
|
|
18717
|
+
same as absent from the running build.
|
|
18713
18718
|
No connection needed.
|
|
18714
|
-
describe_api(symbol) -> {signatures, stub_line, description, source_files}
|
|
18719
|
+
describe_api(symbol, source?) -> {signatures, stub_line, description, source_files, stub, stub_source}
|
|
18715
18720
|
— one 'Class.Method' or one TypedDict name. No connection needed.
|
|
18716
|
-
api_surface() -> {methods, option_types, option_fields, objects}
|
|
18717
|
-
— what the
|
|
18721
|
+
api_surface(source?) -> {methods, option_types, option_fields, objects, stub, stub_source}
|
|
18722
|
+
— what the answering stub contains. No connection needed.
|
|
18718
18723
|
set_high_priority(high?) -> {success, high_priority, signature, reversible, readback: null}
|
|
18719
18724
|
— script execution priority. high: true (default, the old meaning)
|
|
18720
18725
|
or false for normal. Resolve 21.1+ calls SetHighPriority(bool) and
|
|
@@ -18780,17 +18785,19 @@ def resolve_control(action: str, params: Optional[Dict[str, Any]] = None) -> Dic
|
|
|
18780
18785
|
try:
|
|
18781
18786
|
return typed_api_search.search(
|
|
18782
18787
|
project_dir, p.get("pattern"),
|
|
18783
|
-
kind=p.get("kind", "all"), limit=p.get("limit", 50)
|
|
18788
|
+
kind=p.get("kind", "all"), limit=p.get("limit", 50),
|
|
18789
|
+
source=p.get("source", "auto"))
|
|
18784
18790
|
except typed_api_search.TypedApiError as exc:
|
|
18785
18791
|
return _err(str(exc), code="TYPED_API_QUERY", category="invalid_input")
|
|
18786
18792
|
elif action == "describe_api":
|
|
18787
18793
|
try:
|
|
18788
|
-
return typed_api_search.describe(project_dir, p.get("symbol")
|
|
18794
|
+
return typed_api_search.describe(project_dir, p.get("symbol"),
|
|
18795
|
+
source=p.get("source", "auto"))
|
|
18789
18796
|
except typed_api_search.TypedApiError as exc:
|
|
18790
18797
|
return _err(str(exc), code="TYPED_API_QUERY", category="invalid_input")
|
|
18791
18798
|
elif action == "api_surface":
|
|
18792
18799
|
try:
|
|
18793
|
-
return typed_api_search.summary(project_dir)
|
|
18800
|
+
return typed_api_search.summary(project_dir, source=p.get("source", "auto"))
|
|
18794
18801
|
except typed_api_search.TypedApiError as exc:
|
|
18795
18802
|
return _err(str(exc), code="TYPED_API_QUERY", category="invalid_input")
|
|
18796
18803
|
elif action == "api_truth":
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Query the
|
|
1
|
+
"""Query the Resolve typed stub from inside the server.
|
|
2
2
|
|
|
3
3
|
PR #205 landed Blackmagic's `DaVinciResolveScript.pyi` in `docs/reference/`, and
|
|
4
4
|
`scripts/audit_typed_api.py` can turn it into a full inventory — but only from a
|
|
@@ -25,14 +25,70 @@ from typing import Any, Dict, List, Optional
|
|
|
25
25
|
|
|
26
26
|
STUB_RELATIVE = os.path.join("docs", "reference", "DaVinciResolveScript.pyi")
|
|
27
27
|
MAX_RESULTS = 200
|
|
28
|
+
STUB_SOURCES = ("auto", "shipped", "installed")
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
class TypedApiError(ValueError):
|
|
31
32
|
"""The stub is missing, unparseable, or the query was unusable."""
|
|
32
33
|
|
|
33
34
|
|
|
34
|
-
def
|
|
35
|
-
|
|
35
|
+
def installed_stub_path() -> Optional[str]:
|
|
36
|
+
"""The stub the installed Resolve writes next to its scripting API.
|
|
37
|
+
|
|
38
|
+
The copy in `docs/reference` is a snapshot of the build it was pinned at.
|
|
39
|
+
Resolve installs its own stub alongside the scripting API and refreshes it
|
|
40
|
+
with the build, so on a newer Resolve that file is the accurate inventory.
|
|
41
|
+
Reading it is what stops a 21.2 server from reporting 21.2 methods as
|
|
42
|
+
nonexistent — a wrong answer rather than an error, which is the worse
|
|
43
|
+
failure mode. An explicit RESOLVE_SCRIPT_API wins over the platform
|
|
44
|
+
default, same as everywhere else in this server.
|
|
45
|
+
|
|
46
|
+
Best effort: a broken or absent install must not take down the query path,
|
|
47
|
+
and the shipped copy still works without one.
|
|
48
|
+
"""
|
|
49
|
+
try:
|
|
50
|
+
from .platform import get_resolve_paths
|
|
51
|
+
|
|
52
|
+
api_path = (get_resolve_paths() or {}).get("api_path")
|
|
53
|
+
if api_path:
|
|
54
|
+
candidate = os.path.join(api_path, "DaVinciResolveScript.pyi")
|
|
55
|
+
if os.path.isfile(candidate):
|
|
56
|
+
return candidate
|
|
57
|
+
except Exception:
|
|
58
|
+
return None
|
|
59
|
+
return None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def stub_path(project_dir: str, source: str = "auto") -> Optional[str]:
|
|
63
|
+
"""Resolve which stub to read.
|
|
64
|
+
|
|
65
|
+
`auto` prefers the installed build's stub and falls back to the shipped
|
|
66
|
+
copy. `shipped` forces the pinned file — the inventory tests use it,
|
|
67
|
+
because they assert the 21.1 revision and would otherwise flip their
|
|
68
|
+
expected counts on any machine with a newer Resolve installed. `installed`
|
|
69
|
+
refuses instead of silently falling back, for callers that specifically
|
|
70
|
+
want the live build's inventory.
|
|
71
|
+
|
|
72
|
+
Returns None when the requested stub is not there; `load` turns that into
|
|
73
|
+
one error message naming both locations.
|
|
74
|
+
"""
|
|
75
|
+
if source not in STUB_SOURCES:
|
|
76
|
+
raise TypedApiError(
|
|
77
|
+
f"source must be one of {', '.join(STUB_SOURCES)}, not {source!r}"
|
|
78
|
+
)
|
|
79
|
+
if source in ("auto", "installed"):
|
|
80
|
+
installed = installed_stub_path()
|
|
81
|
+
if installed:
|
|
82
|
+
return installed
|
|
83
|
+
if source == "installed":
|
|
84
|
+
raise TypedApiError(
|
|
85
|
+
"No installed Resolve typed stub found. Resolve writes "
|
|
86
|
+
"DaVinciResolveScript.pyi next to its scripting API; set "
|
|
87
|
+
"RESOLVE_SCRIPT_API to that Scripting directory if this install "
|
|
88
|
+
"keeps it elsewhere."
|
|
89
|
+
)
|
|
90
|
+
shipped = os.path.join(project_dir, STUB_RELATIVE)
|
|
91
|
+
return shipped if os.path.isfile(shipped) else None
|
|
36
92
|
|
|
37
93
|
|
|
38
94
|
@lru_cache(maxsize=4)
|
|
@@ -78,14 +134,29 @@ def _inventory(path: str, mtime: float) -> Dict[str, Any]:
|
|
|
78
134
|
return {"methods": methods, "option_types": option_types}
|
|
79
135
|
|
|
80
136
|
|
|
81
|
-
def load(project_dir: str) -> Dict[str, Any]:
|
|
82
|
-
|
|
83
|
-
|
|
137
|
+
def load(project_dir: str, source: str = "auto") -> Dict[str, Any]:
|
|
138
|
+
"""Parse the stub, and say which copy answered.
|
|
139
|
+
|
|
140
|
+
`stub` and `stub_source` are added to the parsed inventory so every caller
|
|
141
|
+
can report them. The parsed inventory itself is cached and shared, so this
|
|
142
|
+
returns a copy rather than mutating it.
|
|
143
|
+
"""
|
|
144
|
+
path = stub_path(project_dir, source)
|
|
145
|
+
if path is None:
|
|
146
|
+
shipped = os.path.join(project_dir, STUB_RELATIVE)
|
|
84
147
|
raise TypedApiError(
|
|
85
|
-
|
|
86
|
-
"
|
|
148
|
+
"Typed API stub not found. Checked the installed Resolve stub "
|
|
149
|
+
"(none found) and the shipped copy at "
|
|
150
|
+
f"{shipped}. Run from a source checkout with the shipped stub, "
|
|
151
|
+
"install Resolve so its own stub exists, or set RESOLVE_SCRIPT_API "
|
|
152
|
+
"to the Scripting directory."
|
|
87
153
|
)
|
|
88
|
-
|
|
154
|
+
inventory = _inventory(path, os.path.getmtime(path))
|
|
155
|
+
return {
|
|
156
|
+
**inventory,
|
|
157
|
+
"stub": path,
|
|
158
|
+
"stub_source": "installed" if path == installed_stub_path() else "shipped",
|
|
159
|
+
}
|
|
89
160
|
|
|
90
161
|
|
|
91
162
|
@lru_cache(maxsize=4)
|
|
@@ -139,7 +210,7 @@ def _source_fingerprint(project_dir: str) -> str:
|
|
|
139
210
|
|
|
140
211
|
|
|
141
212
|
def search(project_dir: str, pattern: str, *, kind: str = "all",
|
|
142
|
-
limit: int = 50) -> Dict[str, Any]:
|
|
213
|
+
limit: int = 50, source: str = "auto") -> Dict[str, Any]:
|
|
143
214
|
"""Case-insensitive regex over method names, signatures, types and docs."""
|
|
144
215
|
if not isinstance(pattern, str) or not pattern.strip():
|
|
145
216
|
raise TypedApiError("pattern is required")
|
|
@@ -154,7 +225,7 @@ def search(project_dir: str, pattern: str, *, kind: str = "all",
|
|
|
154
225
|
except (TypeError, ValueError):
|
|
155
226
|
raise TypedApiError("limit must be an integer")
|
|
156
227
|
|
|
157
|
-
inventory = load(project_dir)
|
|
228
|
+
inventory = load(project_dir, source)
|
|
158
229
|
wrapped = _wrapped_names(project_dir, _source_fingerprint(project_dir))
|
|
159
230
|
|
|
160
231
|
methods: List[Dict[str, Any]] = []
|
|
@@ -199,23 +270,25 @@ def search(project_dir: str, pattern: str, *, kind: str = "all",
|
|
|
199
270
|
"truncated": total > limit,
|
|
200
271
|
"methods": methods[:limit],
|
|
201
272
|
"option_types": options[:limit],
|
|
202
|
-
"stub":
|
|
273
|
+
"stub": inventory["stub"],
|
|
274
|
+
"stub_source": inventory["stub_source"],
|
|
203
275
|
"note": ("referenced_in_this_server is executable syntax only — a name that "
|
|
204
276
|
"appears solely in a docstring or comment is not counted."),
|
|
205
277
|
}
|
|
206
278
|
|
|
207
279
|
|
|
208
|
-
def describe(project_dir: str, symbol: str) -> Dict[str, Any]:
|
|
280
|
+
def describe(project_dir: str, symbol: str, source: str = "auto") -> Dict[str, Any]:
|
|
209
281
|
"""Full detail for one `Class.Method` or one TypedDict name."""
|
|
210
282
|
if not isinstance(symbol, str) or not symbol.strip():
|
|
211
283
|
raise TypedApiError("symbol is required")
|
|
212
|
-
inventory = load(project_dir)
|
|
284
|
+
inventory = load(project_dir, source)
|
|
213
285
|
key = symbol.strip()
|
|
214
286
|
|
|
215
287
|
if key in inventory["option_types"]:
|
|
216
288
|
fields = inventory["option_types"][key]
|
|
217
289
|
return {"symbol": key, "kind": "option_type", "field_count": len(fields),
|
|
218
|
-
"fields": fields, "stub":
|
|
290
|
+
"fields": fields, "stub": inventory["stub"],
|
|
291
|
+
"stub_source": inventory["stub_source"]}
|
|
219
292
|
|
|
220
293
|
row = inventory["methods"].get(key)
|
|
221
294
|
if row is None:
|
|
@@ -229,8 +302,10 @@ def describe(project_dir: str, symbol: str) -> Dict[str, Any]:
|
|
|
229
302
|
)
|
|
230
303
|
else:
|
|
231
304
|
raise TypedApiError(
|
|
232
|
-
f"{symbol!r} is not in the
|
|
233
|
-
"find the right name
|
|
305
|
+
f"{symbol!r} is not in the typed stub that answered ({inventory['stub']}, "
|
|
306
|
+
f"source={inventory['stub_source']}). Use search to find the right name; "
|
|
307
|
+
"pass source='installed' to read the running build's inventory instead "
|
|
308
|
+
"of the shipped copy."
|
|
234
309
|
)
|
|
235
310
|
|
|
236
311
|
wrapped = _wrapped_names(project_dir, _source_fingerprint(project_dir))
|
|
@@ -244,15 +319,17 @@ def describe(project_dir: str, symbol: str) -> Dict[str, Any]:
|
|
|
244
319
|
"description": row["description"],
|
|
245
320
|
"referenced_in_this_server": bool(references),
|
|
246
321
|
"source_files": references,
|
|
247
|
-
"stub":
|
|
322
|
+
"stub": inventory["stub"],
|
|
323
|
+
"stub_source": inventory["stub_source"],
|
|
248
324
|
}
|
|
249
325
|
|
|
250
326
|
|
|
251
|
-
def summary(project_dir: str) -> Dict[str, Any]:
|
|
252
|
-
inventory = load(project_dir)
|
|
327
|
+
def summary(project_dir: str, source: str = "auto") -> Dict[str, Any]:
|
|
328
|
+
inventory = load(project_dir, source)
|
|
253
329
|
field_total = sum(len(fields) for fields in inventory["option_types"].values())
|
|
254
330
|
return {
|
|
255
|
-
"stub":
|
|
331
|
+
"stub": inventory["stub"],
|
|
332
|
+
"stub_source": inventory["stub_source"],
|
|
256
333
|
"methods": len(inventory["methods"]),
|
|
257
334
|
"option_types": len(inventory["option_types"]),
|
|
258
335
|
"option_fields": field_total,
|