Skip to content

Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.

MCP: port_unit takes language "ts", as analyze and the tools spell it (#1426)

qenjuquany2f4842b5cf78
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3c70060d..5139f258 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
## Unreleased
+- The MCP `port_unit` prompt takes `"language": "ts"`, the name `analyze --json` reports and every
+ tool's `lang` takes, and adds the TypeScript notes; `typescript` still works. Its argument
+ description and its error list `ts`. Before, `ts` was refused as an invalid parameter.
- `bench` mixed verdicts now recommend `rust-anything enable <crate> --only <faster>` for languages that `enable` switches (instead of `bridge --keep`, which refuses an existing crate) and pass the crate folder to `rust-anything diff <crate>` hints (#1356 by @m3lonxd).
- PowerShell keeps functions with `[char]`, `[System.Char]`, or character array parameters in
PowerShell. Bridging those parameters as strings produced inputs that failed to bind (#1342).
@@ -25,6 +28,8 @@
Python units, the ones `enable` can switch on in part, and tell other languages to keep calling
the original for the slower functions, instead of `bridge --keep`, which refuses an existing
crate. Its `diff` hints name the crate: `rust-anything diff <crate>` (#1356 by @m3lonxd).
+ description and its error list `ts`. Before, `ts` was refused as an invalid parameter (#1329 by
+ @nmnhut0208).
- `obligations --evidence` ends with `1 of 3 obligations has no recorded case` for a single
one. With no obligations at all, it and `app record` say that none were listed and point to
`rust-anything obligations` for the families it could not enumerate, instead of `0 of 0`, which
diff --git a/src/mcp_prompts.rs b/src/mcp_prompts.rs
index b983b966..d31ca344 100644
--- a/src/mcp_prompts.rs
+++ b/src/mcp_prompts.rs
@@ -98,23 +98,27 @@ pub fn get(name: &str, arguments: &Value) -> Result<Value, String> {
}))
}
-/// The skill's `languages/<name>.md` files, each as `(name, text)`, in the order they ship.
-fn languages() -> impl Iterator<Item = (&'static str, &'static str)> {
+/// The skill's `languages/<file>.md` files, each as `(name, file, text)`, in the order they ship.
+/// `name` is the language as analyze and the tools spell it: `typescript.md` is `ts`.
+fn languages() -> impl Iterator<Item = (&'static str, &'static str, &'static str)> {
crate::setup::SKILL_FILES.iter().filter_map(|(file, text)| {
- Some((file.strip_prefix("languages/")?.strip_suffix(".md")?, *text))
+ let file = file.strip_prefix("languages/")?.strip_suffix(".md")?;
+ let name = if file == "typescript" { "ts" } else { file };
+ Some((name, file, *text))
})
}
-/// The names `language` accepts: every language file the skill ships.
+/// The names `language` lists: one per language file the skill ships, spelled as the tools do.
fn language_names() -> Vec<&'static str> {
- languages().map(|(name, _)| name).collect()
+ languages().map(|(name, _, _)| name).collect()
}
-/// `languages/<name>.md` from the skill, or the names there are.
+/// `languages/<name>.md` from the skill, or the names there are. Takes the tools' name for the
+/// language or the file's (`ts` or `typescript`).
fn language_file(name: &str) -> Result<&'static str, String> {
languages()
- .find(|(lang, _)| *lang == name)
- .map(|(_, text)| text)
+ .find(|(lang, file, _)| *lang == name || *file == name)
+ .map(|(_, _, text)| text)
.ok_or_else(|| {
format!(
"`language` is one of {}, not `{name}`",
@@ -152,8 +156,16 @@ mod tests {
let python = include_str!("../skills/rust-anything/languages/python.md");
assert!(!text(json!({ "path": dir })).contains(python.trim()));
assert!(text(json!({ "path": dir, "language": "python" })).contains(python.trim()));
+ let typescript = include_str!("../skills/rust-anything/languages/typescript.md");
+ for name in ["ts", "typescript"] {
+ assert!(
+ text(json!({ "path": dir, "language": name })).contains(typescript.trim()),
+ "{name}"
+ );
+ }
let err = get("port_unit", &json!({ "path": dir, "language": "cobol" })).unwrap_err();
- assert!(err.contains("typescript"), "{err}");
+ assert!(err.contains("is one of ts, "), "{err}");
+ assert!(!err.contains("typescript"), "{err}");
}
#[test]
@@ -164,6 +176,8 @@ mod tests {
.to_string();
let names = language_names();
assert!(names.contains(&"swift"), "{names:?}");
+ assert!(names.contains(&"ts"), "{names:?}");
+ assert!(!description.contains("typescript"), "{description}");
for name in &names {
assert!(description.contains(name), "{name}: {description}");
}