Package com.tnsai.tools.developer
Class DependencyTools
java.lang.Object
com.tnsai.tools.developer.DependencyTools
Function-shape dependency-management tools — package-version lookup,
semver comparison, and project-type detection. Replaces the most-useful
subset of the legacy
DependencyManagerTool + a slice of
ProjectAnalyzerTool (the type-detect operation).
Heavier legacy operations (check-outdated, audit, dep-tree) are
deferred — they require subprocess shelling to mvn / npm
and project-tree walking; consumers can compose dependency_latest +
a custom dep-graph reader for the same effect, or use the actual package
managers directly.
| Method | Backend | Auth | Idempotent |
|---|---|---|---|
dependencyLatest(java.lang.String, java.lang.String) | npm registry / PyPI / Maven Central REST | none | true |
dependencyCompare(java.lang.String, java.lang.String) | pure-JDK semver parse | — | true |
projectDetectType(java.lang.String) | filesystem probe (pom.xml / package.json / requirements.txt / build.gradle / Cargo.toml) | — | true |
- Since:
- 0.5.7 (Phase 2 batch 28 — built-in tool migration to function shape, see #188)
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor — uses public registries (no auth).DependencyTools(okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper) Full constructor for tests / shared HTTP. -
Method Summary
Modifier and TypeMethodDescriptiondependencyCompare(String current, String latest) dependencyLatest(String packageName, String type) projectDetectType(String path)
-
Constructor Details
-
DependencyTools
public DependencyTools()Default constructor — uses public registries (no auth). -
DependencyTools
public DependencyTools(okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper) Full constructor for tests / shared HTTP.
-
-
Method Details
-
dependencyLatest
@Tool(name="dependency_latest", description="Look up the latest published version of a package on the appropriate public registry. {type} \u2208 {npm, pip, maven}. For Maven, {packageName} is \"groupId:artifactId\" (e.g. \"dev.tnsai:tnsai-core\"). Returns the raw registry JSON. No auth required.", keywords={"dependency","latest","version","npm","pip","maven","registry"}, idempotent=true) public String dependencyLatest(@ToolParam(description="Package name (\"lodash\" / \"requests\" / \"groupId:artifactId\")") String packageName, @ToolParam(description="Package manager: npm / pip / maven") String type) throws IOException - Throws:
IOException
-
dependencyCompare
@Tool(name="dependency_compare", description="Compare two semver-like version strings and return the gap as a map: {kind: major/minor/patch/equal/downgrade, behind: <int>}. Both versions are parsed as dot-separated integer tuples (any non-numeric suffix after a dash is dropped). Pure-JDK; no network.", keywords={"version","compare","semver","diff"}, idempotent=true) public Map<String,Object> dependencyCompare(@ToolParam(description="Current version (e.g. \"1.2.3\")") String current, @ToolParam(description="Latest version (e.g. \"2.0.0\")") String latest) -
projectDetectType
@Tool(name="project_detect_type", description="Detect the project\'s type by probing for build files in {path} (defaults to JVM CWD). Returns the first match from this priority order: maven (pom.xml) \u2192 gradle (build.gradle / build.gradle.kts) \u2192 npm (package.json) \u2192 pip (requirements.txt / pyproject.toml) \u2192 cargo (Cargo.toml) \u2192 unknown. Pure-filesystem.", keywords={"project","detect","type","maven","gradle","npm","pip","cargo"}, idempotent=true) public String projectDetectType(@ToolParam(description="Project root path (defaults to JVM CWD)",required=false,defaultValue="") String path) throws IOException - Throws:
IOException
-