JS CLI ignores --model-config-url and --model-config-path
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.2k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 20
Description
### Summary
The JS CLI accepts `--model-config-url` and `--model-config-path`, but those values are not forwarded to `Magika.create()`.
In `js/magika-cli.ts`, Commander defines these flags:
- `--model-config-url `
- `--model-config-path `
With Commander, those options are exposed as `flags.modelConfigUrl` and `flags.modelConfigPath`.
However, the CLI currently passes `flags.configUrl` and `flags.configPath` into `Magika.create()`, so the custom config flags are ignored and the default config is used instead.
### Evidence
Current CLI wiring on `main`:
```ts
const magika = await Magika.create({
modelURL: flags.modelUrl,
modelPath: flags.modelPath,
modelConfigURL: flags.configUrl,
modelConfigPath: flags.configPath,
});
```
Commander exposes the parsed option names as `modelConfigUrl` / `modelConfigPath` for these flags. Minimal repro:
```js
const { program } = require("commander");
program.option("--model-config-url ");
program.option("--model-config-path ");
program.parse([
"node",
"test",
"--model-config-url",
"https://example.invalid/config.json",
"--model-config-path",
"/tmp/config.json",
]);
console.log(program.opts());
```
This prints:
```js
{
modelConfigUrl: 'https://example.invalid/config.json',
modelConfigPath: '/tmp/config.json'
}
```
The JS library itself expects `modelConfigURL` / `modelConfigPath` and reads those exact fields in the loader.
### Regression history
This looks like a regression introduced during the JS CLI/config rename work:
- `a3c4f6b` added JS CLI support for custom model/config loading.
- `aa62093` renamed the JS API fields from `config*` to `modelConfig*`.
- `2be21b1` renamed the CLI flags to `--model-config-*`, but the code still reads `flags.configUrl` / `flags.configPath`.
I also confirmed the bug is present in `js-v0.3.1`, `js-v0.3.2`, and current `main`.
### Expected behavior
Passing either `--model-config-url` or `--model-config-path` should override the default model config.
### Suggested fix
```ts
const magika = await Magika.create({
modelURL: flags.modelUrl,
modelPath: flags.modelPath,
modelConfigURL: flags.modelConfigUrl,
modelConfigPath: flags.modelConfigPath,
});
```
### Testing gap
`js/test/magika-cli.test.ts` currently covers help/basic execution, but it does not exercise either custom model config flag.
Contributor guide
Research direction
Start in js/magika-cli.ts at the main command wiring and compare the Commander option names with the arguments passed to Magika.create(). Then inspect js/test/magika-cli.test.ts and run the existing CLI tests. Done means both custom model-config flags reach the library and regression coverage exercises them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 86/100