Skip to content

The open source AI video agent: turns any coding agent into a video agent, with an editor to change anything it makes.

get: --path works from Git Bash on Windows (#194)

riverisbuilding14a47bf1daab
diff --git a/.changeset/get-path-git-bash.md b/.changeset/get-path-git-bash.md
new file mode 100644
index 0000000..5e2315a
--- /dev/null
+++ b/.changeset/get-path-git-bash.md
@@ -0,0 +1,5 @@
+---
+"openfilm": patch
+---
+
+`openfilm get call --path` also takes the path without its leading slash (`--path speech` is `/speech`), so it works from Git Bash on Windows, which turns an argument starting with `/` into a folder path. A path Git Bash turned that way now gets its own message: drop the leading slash or put `MSYS_NO_PATHCONV=1` in front of the command.
diff --git a/packages/openfilm/studio/server/custom-services.mjs b/packages/openfilm/studio/server/custom-services.mjs
index 78899c1..8b4e212 100644
--- a/packages/openfilm/studio/server/custom-services.mjs
+++ b/packages/openfilm/studio/server/custom-services.mjs
@@ -121,11 +121,17 @@ export const servicesHelp = (services) => services.map((s) => `--service ${s.id}
/* ── a request ───────────────────────────────────────────────────────────── */
/**
- * The address a path asks for, under the service's own: `/v1/audio/transcriptions?x=1` → its URL. Never another host,
- * never out of the service's path. @param {string} base @param {string} path
+ * The address a path asks for, under the service's own: `/v1/audio/transcriptions?x=1` (or without its leading /) → its
+ * URL. Never another host, never out of the service's path. @param {string} base @param {string} path
*/
export function targetOf(base, path) {
- if (!path.startsWith('/') || path.startsWith('//') || /[\\\u0000-\u001f#]/.test(path)) throw bad('--path starts with / and stays under the service, e.g. --path /v1/audio/transcriptions');
+ /* Git Bash on Windows turns an argument that starts with / into a folder path: /speech → C:/Program Files/Git/speech.
+ Not said back: its {key} is filled in by now */
+ if (/^[a-z]:[\\/]/i.test(path)) {
+ throw bad('Git Bash turned --path into a folder path: write it without its leading /, e.g. --path v1/audio/transcriptions, or put MSYS_NO_PATHCONV=1 in front of the command');
+ }
+ if (!path.startsWith('/') && !/^[a-z][a-z\d+.-]*:/i.test(path)) path = `/${path}`;
+ if (!path.startsWith('/') || path.startsWith('//') || /[\\\u0000-\u001f#]/.test(path)) throw bad('--path is a path under the service, e.g. --path /v1/audio/transcriptions');
const at = new URL(base);
const prefix = at.pathname.replace(/\/+$/, '');
const url = new URL(`${at.origin}${prefix}${path}`);
diff --git a/packages/openfilm/studio/server/custom-services.test.mjs b/packages/openfilm/studio/server/custom-services.test.mjs
index 436f5d1..13d61e9 100644
--- a/packages/openfilm/studio/server/custom-services.test.mjs
+++ b/packages/openfilm/studio/server/custom-services.test.mjs
@@ -52,7 +52,16 @@ test('a service is added with a name the command line calls it by; its key is ne
test('a request stays under the service\'s address', () => {
assert.equal(targetOf('http://h:1/v1', '/audio/x?y=1').href, 'http://h:1/v1/audio/x?y=1');
- for (const path of ['//evil.com/x', 'http://evil.com/', '/../admin', '/a/../../b', 'audio', '/a\\b']) assert.throws(() => targetOf('http://h:1/v1', path), path);
+ for (const path of ['//evil.com/x', 'http://evil.com/', 'localhost:8000/x', '/../admin', '/a/../../b', '../admin', 'a/../../b', '/a\\b']) {
+ assert.throws(() => targetOf('http://h:1/v1', path), /--path/, path);
+ }
+ /* without its leading /, as Git Bash leaves it */
+ assert.equal(targetOf('http://h:1/v1', 'audio/x?y=1').href, 'http://h:1/v1/audio/x?y=1');
+ assert.equal(targetOf('http://h:1/v1', '').href, targetOf('http://h:1/v1', '/').href);
+ /* with it, Git Bash made it a folder path: said so, with the two ways out */
+ for (const path of ['C:/Program Files/Git/speech', 'C:/Program Files/Git/', 'D:\\Git\\v1\\x']) {
+ assert.throws(() => targetOf('http://h:1/v1', path), /Git Bash turned --path into a folder path.*without its leading \/.*MSYS_NO_PATHCONV=1/, path);
+ }
});
test('JSON comes back as it is; the key goes in its header and never in what the agent reads', async () => {