@drift-ci/cli 1.3.1 → 1.3.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAoDD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAe1D;AAGD,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CA+CnD"}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
const CONFIG_TEMPLATE = (provider, model) => `version: 1
|
|
3
|
+
const CONFIG_TEMPLATE = (provider, model, suitePath) => `version: 1
|
|
4
4
|
provider:
|
|
5
5
|
name: ${provider}
|
|
6
6
|
model: ${model}
|
|
@@ -18,8 +18,12 @@ baseline:
|
|
|
18
18
|
concurrency: 5
|
|
19
19
|
timeoutMs: 30000
|
|
20
20
|
|
|
21
|
-
suite:
|
|
21
|
+
suite: ${yamlString(suitePath)}
|
|
22
22
|
`;
|
|
23
|
+
/** Plain YAML scalar for ordinary paths; a JSON (= YAML double-quoted) string when plain would misparse. */
|
|
24
|
+
function yamlString(s) {
|
|
25
|
+
return /^[\w./-][\w ./-]*$/.test(s) && !s.endsWith(' ') ? s : JSON.stringify(s);
|
|
26
|
+
}
|
|
23
27
|
const SUITE_TEMPLATE = `version: 1
|
|
24
28
|
id: example
|
|
25
29
|
name: Example suite
|
|
@@ -31,9 +35,14 @@ cases:
|
|
|
31
35
|
input: Say hello
|
|
32
36
|
expected: Hello
|
|
33
37
|
`;
|
|
34
|
-
const GITIGNORE_TEMPLATE = `# drift-ci ephemeral state — baselines at
|
|
38
|
+
const GITIGNORE_TEMPLATE = (dir) => `# drift-ci ephemeral state — baselines at ${dir}/baseline/ ARE committed.
|
|
35
39
|
runs/
|
|
36
40
|
`;
|
|
41
|
+
const DEFAULT_DIR = '.drift';
|
|
42
|
+
/** Forward-slash path, quoted for a POSIX shell only when it needs it. */
|
|
43
|
+
function shellArg(path) {
|
|
44
|
+
return /^[\w@%+=:,./-]+$/.test(path) ? path : "'" + path.replace(/'/g, "'\\''") + "'";
|
|
45
|
+
}
|
|
37
46
|
/* c8 ignore start -- Commander wiring; covered by the CLI E2E in a subprocess. */
|
|
38
47
|
export function registerInitCommand(program) {
|
|
39
48
|
program
|
|
@@ -51,10 +60,13 @@ export function registerInitCommand(program) {
|
|
|
51
60
|
export function executeInit(opts) {
|
|
52
61
|
mkdirSync(opts.dir, { recursive: true });
|
|
53
62
|
mkdirSync(join(opts.dir, 'baseline'), { recursive: true });
|
|
63
|
+
// Paths as the user typed them, with forward slashes: they go into config.yaml and shell hints.
|
|
64
|
+
const dir = opts.dir.replace(/\\/g, '/').replace(/\/+$/, '') || '.';
|
|
65
|
+
const suitePath = `${dir}/suite.yaml`;
|
|
54
66
|
const files = [
|
|
55
|
-
{ path: join(opts.dir, 'config.yaml'), content: CONFIG_TEMPLATE(opts.provider, opts.model) },
|
|
67
|
+
{ path: join(opts.dir, 'config.yaml'), content: CONFIG_TEMPLATE(opts.provider, opts.model, suitePath) },
|
|
56
68
|
{ path: join(opts.dir, 'suite.yaml'), content: SUITE_TEMPLATE },
|
|
57
|
-
{ path: join(opts.dir, '.gitignore'), content: GITIGNORE_TEMPLATE },
|
|
69
|
+
{ path: join(opts.dir, '.gitignore'), content: GITIGNORE_TEMPLATE(dir) },
|
|
58
70
|
];
|
|
59
71
|
const written = [];
|
|
60
72
|
const skipped = [];
|
|
@@ -78,15 +90,15 @@ export function executeInit(opts) {
|
|
|
78
90
|
console.log(` wrote ${p}`);
|
|
79
91
|
for (const p of skipped)
|
|
80
92
|
console.log(` skipped ${p} (already exists; pass --force to overwrite)`);
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
?
|
|
84
|
-
:
|
|
93
|
+
// run/baseline default to .drift/*, so a custom --dir must be passed explicitly.
|
|
94
|
+
const flags = dir === DEFAULT_DIR
|
|
95
|
+
? ''
|
|
96
|
+
: ` --config ${shellArg(`${dir}/config.yaml`)} --baseline-dir ${shellArg(`${dir}/baseline`)} --runs-dir ${shellArg(`${dir}/runs`)}`;
|
|
85
97
|
console.log('\nNext steps:');
|
|
86
|
-
console.log(
|
|
98
|
+
console.log(` 1. Edit ${suitePath} with your own cases.`);
|
|
87
99
|
console.log(' 2. Set ANTHROPIC_API_KEY (or your provider equivalent).');
|
|
88
|
-
console.log(
|
|
89
|
-
console.log(` 4. npx @drift-ci/cli baseline init ${
|
|
90
|
-
console.log(
|
|
100
|
+
console.log(` 3. npx @drift-ci/cli run${flags}`);
|
|
101
|
+
console.log(` 4. npx @drift-ci/cli baseline init ${shellArg(suitePath)}${flags} # once scores look right`);
|
|
102
|
+
console.log(` 5. git add ${shellArg(`${dir}/baseline`)} && git commit`);
|
|
91
103
|
}
|
|
92
104
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","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AAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC7B,OAAO,CAAC,GAAG,CAAC,aAAa,SAAS,uBAAuB,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;IACzE,OAAO,CAAC,GAAG,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,CAAC,wCAAwC,QAAQ,CAAC,SAAS,CAAC,GAAG,KAAK,6BAA6B,CAAC,CAAC;IAC9G,OAAO,CAAC,GAAG,CAAC,gBAAgB,QAAQ,CAAC,GAAG,GAAG,WAAW,CAAC,gBAAgB,CAAC,CAAC;AAC3E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drift-ci/cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Behaviour regression testing for LLM applications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/Drift-CI/drift-ci#readme",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"ink": "^8.0.0",
|
|
24
24
|
"js-yaml": "^5.5.0",
|
|
25
25
|
"react": "^19.3.1",
|
|
26
|
-
"@drift-ci/core": "1.
|
|
26
|
+
"@drift-ci/core": "1.4.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^26.6.6",
|