anpord 0.1.16 → 0.1.18
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.
- package/README.md +3 -3
- package/dist/api-context.cjs +1 -1
- package/dist/api-context.d.cts +1 -1
- package/dist/api-context.d.mts +1 -1
- package/dist/api-context.mjs +1 -1
- package/dist/{api-mocks-Bz3G00ve.d.cts → api-mocks-CAQFqUgY.d.cts} +2 -2
- package/dist/{api-mocks-Bz3G00ve.d.mts → api-mocks-CAQFqUgY.d.mts} +2 -2
- package/dist/{api-mocks-B3qngoqS.cjs → api-mocks-CuVw86Qw.cjs} +1 -1
- package/dist/{api-mocks-BfKw_hXc.mjs → api-mocks-wNUnpzJf.mjs} +1 -1
- package/dist/api-runtime.cjs +1 -1
- package/dist/api-runtime.d.cts +1 -1
- package/dist/api-runtime.d.mts +1 -1
- package/dist/api-runtime.mjs +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.mjs +1 -1
- package/dist/bin.cjs +8 -8
- package/dist/bin.mjs +8 -8
- package/dist/{calls-Drj_dZpu.d.cts → calls-6Z1EoEa-.d.cts} +1 -1
- package/dist/{calls-Drj_dZpu.d.mts → calls-6Z1EoEa-.d.mts} +1 -1
- package/dist/{calls-DYqBi5FA.d.cts → calls-DJGZJPrF.d.cts} +1 -1
- package/dist/{calls-DYqBi5FA.d.mts → calls-DJGZJPrF.d.mts} +1 -1
- package/dist/cli-runtime.cjs +9 -26
- package/dist/cli-runtime.mjs +5 -22
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/{client-C8tBcLYs.d.mts → client-DDYWBAma.d.mts} +48 -48
- package/dist/{client-YWKJd3f-.mjs → client-DE3YNtWc.mjs} +1 -1
- package/dist/{client-CfYNoI3L.cjs → client-DziJjMFh.cjs} +1 -1
- package/dist/{client-CMkx-LKC.d.cts → client-dRUs93gl.d.cts} +48 -48
- package/dist/{compiler-Dsltkkj5.mjs → compiler-WpuZwsp9.mjs} +152 -132
- package/dist/{compiler-4FKsNxZ-.cjs → compiler-XtLHSR2J.cjs} +168 -130
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/{eval-judges-JiC8cUCE.d.cts → eval-judges--be3T7fJ.d.cts} +2 -2
- package/dist/{eval-judges-JiC8cUCE.d.mts → eval-judges--be3T7fJ.d.mts} +2 -2
- package/dist/{eval-judges-BkmiVLLq.cjs → eval-judges-1zF4PVqV.cjs} +1 -1
- package/dist/{eval-judges-CwTvTq7N.mjs → eval-judges-Bee_ABJt.mjs} +1 -1
- package/dist/{eval-validations-CqMUt5ra.cjs → eval-validations-BdlPhudg.cjs} +1 -1
- package/dist/{eval-validations-Bmagd2y7.mjs → eval-validations-BvX9dkYh.mjs} +1 -1
- package/dist/eval.cjs +2 -2
- package/dist/eval.d.cts +3 -192
- package/dist/eval.d.mts +3 -192
- package/dist/eval.mjs +2 -2
- package/dist/{evals-api-kOuyIqvB.cjs → evals-api-CqhPZCr5.cjs} +2 -2
- package/dist/{evals-api-DDv4gXU1.mjs → evals-api-CsdU741J.mjs} +2 -2
- package/dist/index.cjs +48 -7
- package/dist/index.d.cts +11 -8
- package/dist/index.d.mts +11 -8
- package/dist/index.mjs +47 -8
- package/dist/mcp-runtime.cjs +9 -18
- package/dist/mcp-runtime.mjs +5 -14
- package/dist/mcp.d.cts +1 -1
- package/dist/mcp.d.mts +1 -1
- package/dist/mock-journal-Bnaozlx4.cjs +39 -0
- package/dist/mock-journal-rbsXfDRs.mjs +22 -0
- package/dist/{runtime-YVJP5P2r.cjs → runtime-CXcsGvwP.cjs} +2 -2
- package/dist/{runtime-C0_JPkef.mjs → runtime-DDUrsAI-.mjs} +2 -2
- package/dist/{source-Fg1h2VNn.mjs → source-BP11pzVV.mjs} +1 -1
- package/dist/{source-DvlGawEw.cjs → source-aW5nSo2h.cjs} +0 -12
- package/dist/source.cjs +1 -1
- package/dist/source.mjs +1 -1
- package/dist/{evals-api-Clbj_nEN.d.cts → types-2vK8mBga.d.cts} +116 -6
- package/dist/{evals-api-CfAA3cew.d.mts → types-C6yDL7ZQ.d.mts} +116 -6
- package/dist/validator-runtime.cjs +61 -35
- package/dist/validator-runtime.d.cts +1 -1
- package/dist/validator-runtime.d.mts +1 -1
- package/dist/validator-runtime.mjs +61 -35
- package/dist/validators.cjs +1 -1
- package/dist/validators.d.cts +1 -1
- package/dist/validators.d.mts +1 -1
- package/dist/validators.mjs +1 -1
- package/package.json +1 -1
- package/dist/types-BHokRQpg.d.mts +0 -112
- package/dist/types-UKEi5CCa.d.cts +0 -112
package/README.md
CHANGED
|
@@ -11,9 +11,9 @@ npm install anpord
|
|
|
11
11
|
## Define an eval
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import {
|
|
14
|
+
import { suite, empty } from "anpord";
|
|
15
15
|
|
|
16
|
-
export default
|
|
16
|
+
export default suite({
|
|
17
17
|
name: "greeting",
|
|
18
18
|
source: empty,
|
|
19
19
|
prompt: "{{task}}",
|
|
@@ -93,7 +93,7 @@ const correctness = judge({
|
|
|
93
93
|
name: "correctness",
|
|
94
94
|
harness: "codex",
|
|
95
95
|
model: "gpt-5.6-sol",
|
|
96
|
-
|
|
96
|
+
prompt: "The answer matches the reference without inventing facts.",
|
|
97
97
|
expected: "Ada",
|
|
98
98
|
choices: { correct: 1, incorrect: 0 },
|
|
99
99
|
});
|
package/dist/api-context.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_api_mocks = require("./api-mocks-
|
|
2
|
+
const require_api_mocks = require("./api-mocks-CuVw86Qw.cjs");
|
|
3
3
|
let effect = require("effect");
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
5
|
//#region src/mock-api/context.ts
|
package/dist/api-context.d.cts
CHANGED
package/dist/api-context.d.mts
CHANGED
package/dist/api-context.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ApiCall, n as API_MANIFEST, o as ApiManifest, t as API_JOURNAL } from "./api-mocks-
|
|
1
|
+
import { a as ApiCall, n as API_MANIFEST, o as ApiManifest, t as API_JOURNAL } from "./api-mocks-wNUnpzJf.mjs";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
//#region src/mock-api/context.ts
|
|
@@ -57,11 +57,11 @@ declare const ApiCall_base: Schema.Class<ApiCall, {
|
|
|
57
57
|
truncated: typeof Schema.Boolean;
|
|
58
58
|
}>>>;
|
|
59
59
|
}>, never, {
|
|
60
|
+
readonly api: string;
|
|
61
|
+
} & {
|
|
60
62
|
readonly startedAt: number;
|
|
61
63
|
} & {
|
|
62
64
|
readonly status: number;
|
|
63
|
-
} & {
|
|
64
|
-
readonly api: string;
|
|
65
65
|
} & {
|
|
66
66
|
readonly path: string;
|
|
67
67
|
} & {
|
|
@@ -57,11 +57,11 @@ declare const ApiCall_base: Schema.Class<ApiCall, {
|
|
|
57
57
|
truncated: typeof Schema.Boolean;
|
|
58
58
|
}>>>;
|
|
59
59
|
}>, never, {
|
|
60
|
+
readonly api: string;
|
|
61
|
+
} & {
|
|
60
62
|
readonly startedAt: number;
|
|
61
63
|
} & {
|
|
62
64
|
readonly status: number;
|
|
63
|
-
} & {
|
|
64
|
-
readonly api: string;
|
|
65
65
|
} & {
|
|
66
66
|
readonly path: string;
|
|
67
67
|
} & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_eval_validations = require("./eval-validations-
|
|
1
|
+
const require_eval_validations = require("./eval-validations-BdlPhudg.cjs");
|
|
2
2
|
let effect = require("effect");
|
|
3
3
|
//#region ../schema/src/domain/api-mocks.ts
|
|
4
4
|
const API_PROGRAM = "workspace/.anpord/api/program.json";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as ValidationValue } from "./eval-validations-
|
|
1
|
+
import { r as ValidationValue } from "./eval-validations-BvX9dkYh.mjs";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
//#region ../schema/src/domain/api-mocks.ts
|
|
4
4
|
const API_PROGRAM = "workspace/.anpord/api/program.json";
|
package/dist/api-runtime.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_runtime = require("./runtime-
|
|
2
|
+
const require_runtime = require("./runtime-CXcsGvwP.cjs");
|
|
3
3
|
exports.runApiServers = require_runtime.runApiServers;
|
|
4
4
|
exports.withApi = require_runtime.withApi;
|
package/dist/api-runtime.d.cts
CHANGED
package/dist/api-runtime.d.mts
CHANGED
package/dist/api-runtime.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as withApi, t as runApiServers } from "./runtime-
|
|
1
|
+
import { n as withApi, t as runApiServers } from "./runtime-DDUrsAI-.mjs";
|
|
2
2
|
export { runApiServers, withApi };
|
package/dist/api.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_runtime = require("./runtime-
|
|
2
|
+
const require_runtime = require("./runtime-CXcsGvwP.cjs");
|
|
3
3
|
exports.api = require_runtime.api;
|
|
4
4
|
exports.endpoint = require_runtime.endpoint;
|
|
5
5
|
exports.withApi = require_runtime.withApi;
|
package/dist/api.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ApiCall } from "./api-mocks-
|
|
1
|
+
import { t as ApiCall } from "./api-mocks-CAQFqUgY.cjs";
|
|
2
2
|
import { a as endpoint, i as api, n as ApiHandlerContext, r as EndpointDefinition, t as ApiDefinition } from "./define-NZvmQuIv.cjs";
|
|
3
3
|
import { withApi } from "./api-runtime.cjs";
|
|
4
4
|
export { type ApiCall, type ApiDefinition, type ApiHandlerContext, type EndpointDefinition, api, endpoint, withApi };
|
package/dist/api.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ApiCall } from "./api-mocks-
|
|
1
|
+
import { t as ApiCall } from "./api-mocks-CAQFqUgY.mjs";
|
|
2
2
|
import { a as endpoint, i as api, n as ApiHandlerContext, r as EndpointDefinition, t as ApiDefinition } from "./define-NZvmQuIv.mjs";
|
|
3
3
|
import { withApi } from "./api-runtime.mjs";
|
|
4
4
|
export { type ApiCall, type ApiDefinition, type ApiHandlerContext, type EndpointDefinition, api, endpoint, withApi };
|
package/dist/api.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as endpoint, n as withApi, r as api } from "./runtime-
|
|
1
|
+
import { i as endpoint, n as withApi, r as api } from "./runtime-DDUrsAI-.mjs";
|
|
2
2
|
export { api, endpoint, withApi };
|
package/dist/bin.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_client = require("./client-
|
|
3
|
-
const require_evals_api = require("./evals-api-
|
|
2
|
+
const require_client = require("./client-DziJjMFh.cjs");
|
|
3
|
+
const require_evals_api = require("./evals-api-CqhPZCr5.cjs");
|
|
4
4
|
const require_errors = require("./errors-BX1wry8K.cjs");
|
|
5
5
|
const require_config = require("./config.cjs");
|
|
6
|
-
const require_compiler = require("./compiler-
|
|
6
|
+
const require_compiler = require("./compiler-XtLHSR2J.cjs");
|
|
7
7
|
let effect = require("effect");
|
|
8
8
|
let _effect_platform = require("@effect/platform");
|
|
9
9
|
let _effect_cli = require("@effect/cli");
|
|
10
10
|
let _effect_platform_node = require("@effect/platform-node");
|
|
11
11
|
let yaml = require("yaml");
|
|
12
12
|
//#region package.json
|
|
13
|
-
var version$1 = "0.1.
|
|
13
|
+
var version$1 = "0.1.18";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region ../template/src/extract.ts
|
|
16
16
|
/** Reads escapes too, so text the renderer leaves literal is never reported as
|
|
@@ -262,7 +262,7 @@ const caseBlock$1 = (subject) => [
|
|
|
262
262
|
" },",
|
|
263
263
|
" },"
|
|
264
264
|
].join("\n");
|
|
265
|
-
const IMPORTS = "import {
|
|
265
|
+
const IMPORTS = "import { suite, files } from \"anpord\";";
|
|
266
266
|
const helpersBlock = [
|
|
267
267
|
"const has = (answer: string, needle: string) =>",
|
|
268
268
|
" answer.toLowerCase().includes(needle.toLowerCase());",
|
|
@@ -285,7 +285,7 @@ const renderEvalSuite = (file) => {
|
|
|
285
285
|
"",
|
|
286
286
|
...structured ? [helpersBlock, ""] : [],
|
|
287
287
|
...prose ? [placeholderBlock, ""] : [],
|
|
288
|
-
"export default
|
|
288
|
+
"export default suite({",
|
|
289
289
|
` name: ${quoted(slug$1(file.skill_name, "imported-suite"))},`,
|
|
290
290
|
" prompt: \"{{task}}\",",
|
|
291
291
|
" trials: 3,",
|
|
@@ -414,11 +414,11 @@ const caseBlock = (file) => [
|
|
|
414
414
|
].join("\n");
|
|
415
415
|
const suiteName = (files) => files.length === 1 ? slug(files[0]?.subject.name ?? "", "imported-suite") : "imported-suite";
|
|
416
416
|
const renderYamlSuite = (files) => `${[
|
|
417
|
-
"import {
|
|
417
|
+
"import { suite, files } from \"anpord\";",
|
|
418
418
|
"",
|
|
419
419
|
placeholderBlock,
|
|
420
420
|
"",
|
|
421
|
-
"export default
|
|
421
|
+
"export default suite({",
|
|
422
422
|
` name: ${quoted(suiteName(files))},`,
|
|
423
423
|
" prompt: \"{{task}}\",",
|
|
424
424
|
" trials: 3,",
|
package/dist/bin.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as ChannelName, o as PromptId, s as VersionNumber, t as AnpordApi } from "./client-
|
|
3
|
-
import { f as EvalTrigger, i as EvalRun } from "./evals-api-
|
|
2
|
+
import { a as ChannelName, o as PromptId, s as VersionNumber, t as AnpordApi } from "./client-DE3YNtWc.mjs";
|
|
3
|
+
import { f as EvalTrigger, i as EvalRun } from "./evals-api-CsdU741J.mjs";
|
|
4
4
|
import { i as tokenMatcher, r as asAnpordError } from "./errors-B0YknR5V.mjs";
|
|
5
5
|
import { ClientLayer, webUrlConfig } from "./config.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { r as compileEvalEffect } from "./compiler-WpuZwsp9.mjs";
|
|
7
7
|
import { Cause, Clock, Config, Console, Data, Duration, Effect, Layer, Option, ParseResult, Redacted, Ref, Schema } from "effect";
|
|
8
8
|
import { FetchHttpClient, FileSystem, HttpClient, HttpClientError, HttpClientRequest } from "@effect/platform";
|
|
9
9
|
import { Args, Command, Options } from "@effect/cli";
|
|
10
10
|
import { NodeContext, NodeRuntime } from "@effect/platform-node";
|
|
11
11
|
import { parseDocument } from "yaml";
|
|
12
12
|
//#region package.json
|
|
13
|
-
var version$1 = "0.1.
|
|
13
|
+
var version$1 = "0.1.18";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region ../template/src/extract.ts
|
|
16
16
|
/** Reads escapes too, so text the renderer leaves literal is never reported as
|
|
@@ -262,7 +262,7 @@ const caseBlock$1 = (subject) => [
|
|
|
262
262
|
" },",
|
|
263
263
|
" },"
|
|
264
264
|
].join("\n");
|
|
265
|
-
const IMPORTS = "import {
|
|
265
|
+
const IMPORTS = "import { suite, files } from \"anpord\";";
|
|
266
266
|
const helpersBlock = [
|
|
267
267
|
"const has = (answer: string, needle: string) =>",
|
|
268
268
|
" answer.toLowerCase().includes(needle.toLowerCase());",
|
|
@@ -285,7 +285,7 @@ const renderEvalSuite = (file) => {
|
|
|
285
285
|
"",
|
|
286
286
|
...structured ? [helpersBlock, ""] : [],
|
|
287
287
|
...prose ? [placeholderBlock, ""] : [],
|
|
288
|
-
"export default
|
|
288
|
+
"export default suite({",
|
|
289
289
|
` name: ${quoted(slug$1(file.skill_name, "imported-suite"))},`,
|
|
290
290
|
" prompt: \"{{task}}\",",
|
|
291
291
|
" trials: 3,",
|
|
@@ -414,11 +414,11 @@ const caseBlock = (file) => [
|
|
|
414
414
|
].join("\n");
|
|
415
415
|
const suiteName = (files) => files.length === 1 ? slug(files[0]?.subject.name ?? "", "imported-suite") : "imported-suite";
|
|
416
416
|
const renderYamlSuite = (files) => `${[
|
|
417
|
-
"import {
|
|
417
|
+
"import { suite, files } from \"anpord\";",
|
|
418
418
|
"",
|
|
419
419
|
placeholderBlock,
|
|
420
420
|
"",
|
|
421
|
-
"export default
|
|
421
|
+
"export default suite({",
|
|
422
422
|
` name: ${quoted(suiteName(files))},`,
|
|
423
423
|
" prompt: \"{{task}}\",",
|
|
424
424
|
" trials: 3,",
|
package/dist/cli-runtime.cjs
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_define = require("./define-CHx2lRp5.cjs");
|
|
3
|
+
const require_mock_journal = require("./mock-journal-Bnaozlx4.cjs");
|
|
3
4
|
let effect = require("effect");
|
|
4
|
-
let node_fs_promises = require("node:fs/promises");
|
|
5
|
-
let node_path = require("node:path");
|
|
6
5
|
//#region src/mock-cli/runtime.ts
|
|
7
6
|
const JOURNAL = ".anpord/cli-calls.jsonl";
|
|
8
|
-
const errorOf = (cause) => cause instanceof Error ? cause : new Error(String(cause));
|
|
9
|
-
const decode = (schema, value) => effect.Effect.tryPromise({
|
|
10
|
-
catch: errorOf,
|
|
11
|
-
try: async () => {
|
|
12
|
-
const result = await schema["~standard"].validate(value);
|
|
13
|
-
if (result.issues !== void 0) throw new Error(result.issues.map(({ message }) => message).join("; "));
|
|
14
|
-
return result.value;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
const append = (path, call) => effect.Effect.tryPromise({
|
|
18
|
-
catch: errorOf,
|
|
19
|
-
try: async () => {
|
|
20
|
-
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(path), { recursive: true });
|
|
21
|
-
await (0, node_fs_promises.appendFile)(path, `${JSON.stringify(call)}\n`);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
7
|
const commandHelp = (definition, item) => {
|
|
25
8
|
const options = Object.entries(item.options).map(([key, option]) => ` ${require_define.optionName(key, option)}${option.type === "string" ? " <value>" : ""}${option.description ? ` ${option.description}` : ""}`);
|
|
26
9
|
return [
|
|
@@ -88,15 +71,15 @@ const executeCli = (definition, args, journal = JOURNAL) => effect.Effect.gen(fu
|
|
|
88
71
|
let input = {};
|
|
89
72
|
return yield* effect.Effect.gen(function* () {
|
|
90
73
|
input = yield* effect.Effect.try({
|
|
91
|
-
catch: errorOf,
|
|
74
|
+
catch: require_mock_journal.errorOf,
|
|
92
75
|
try: () => parseOptions(item, rest)
|
|
93
76
|
});
|
|
94
|
-
const decoded = yield*
|
|
77
|
+
const decoded = yield* require_mock_journal.decodeStandard(item.inputSchema, input);
|
|
95
78
|
const output = yield* effect.Effect.tryPromise({
|
|
96
|
-
catch: errorOf,
|
|
79
|
+
catch: require_mock_journal.errorOf,
|
|
97
80
|
try: () => Promise.resolve(item.handler(decoded, { signal: new AbortController().signal }))
|
|
98
|
-
}).pipe(effect.Effect.flatMap((value) =>
|
|
99
|
-
yield*
|
|
81
|
+
}).pipe(effect.Effect.flatMap((value) => require_mock_journal.decodeStandard(item.outputSchema, value)));
|
|
82
|
+
yield* require_mock_journal.appendCall(journal, {
|
|
100
83
|
cli: definition.path,
|
|
101
84
|
command: item.path.join(" "),
|
|
102
85
|
input: decoded,
|
|
@@ -107,14 +90,14 @@ const executeCli = (definition, args, journal = JOURNAL) => effect.Effect.gen(fu
|
|
|
107
90
|
stderr: "",
|
|
108
91
|
stdout: `${JSON.stringify(output, null, 2) ?? String(output)}\n`
|
|
109
92
|
};
|
|
110
|
-
}).pipe(effect.Effect.catchAll((cause) =>
|
|
93
|
+
}).pipe(effect.Effect.catchAll((cause) => require_mock_journal.appendCall(journal, {
|
|
111
94
|
cli: definition.path,
|
|
112
95
|
command: item.path.join(" "),
|
|
113
|
-
error: errorOf(cause).message,
|
|
96
|
+
error: require_mock_journal.errorOf(cause).message,
|
|
114
97
|
input
|
|
115
98
|
}).pipe(effect.Effect.as({
|
|
116
99
|
exitCode: 1,
|
|
117
|
-
stderr: `${errorOf(cause).message}\n`,
|
|
100
|
+
stderr: `${require_mock_journal.errorOf(cause).message}\n`,
|
|
118
101
|
stdout: ""
|
|
119
102
|
}))));
|
|
120
103
|
}).pipe(effect.Effect.withSpan("CliMock.execute"), effect.Effect.runPromise);
|
package/dist/cli-runtime.mjs
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
1
|
import { r as optionName } from "./define-CLhfETBd.mjs";
|
|
2
|
+
import { n as decodeStandard, r as errorOf, t as appendCall } from "./mock-journal-rbsXfDRs.mjs";
|
|
2
3
|
import { Effect } from "effect";
|
|
3
|
-
import { appendFile, mkdir } from "node:fs/promises";
|
|
4
|
-
import { dirname } from "node:path";
|
|
5
4
|
//#region src/mock-cli/runtime.ts
|
|
6
5
|
const JOURNAL = ".anpord/cli-calls.jsonl";
|
|
7
|
-
const errorOf = (cause) => cause instanceof Error ? cause : new Error(String(cause));
|
|
8
|
-
const decode = (schema, value) => Effect.tryPromise({
|
|
9
|
-
catch: errorOf,
|
|
10
|
-
try: async () => {
|
|
11
|
-
const result = await schema["~standard"].validate(value);
|
|
12
|
-
if (result.issues !== void 0) throw new Error(result.issues.map(({ message }) => message).join("; "));
|
|
13
|
-
return result.value;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
const append = (path, call) => Effect.tryPromise({
|
|
17
|
-
catch: errorOf,
|
|
18
|
-
try: async () => {
|
|
19
|
-
await mkdir(dirname(path), { recursive: true });
|
|
20
|
-
await appendFile(path, `${JSON.stringify(call)}\n`);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
6
|
const commandHelp = (definition, item) => {
|
|
24
7
|
const options = Object.entries(item.options).map(([key, option]) => ` ${optionName(key, option)}${option.type === "string" ? " <value>" : ""}${option.description ? ` ${option.description}` : ""}`);
|
|
25
8
|
return [
|
|
@@ -90,12 +73,12 @@ const executeCli = (definition, args, journal = JOURNAL) => Effect.gen(function*
|
|
|
90
73
|
catch: errorOf,
|
|
91
74
|
try: () => parseOptions(item, rest)
|
|
92
75
|
});
|
|
93
|
-
const decoded = yield*
|
|
76
|
+
const decoded = yield* decodeStandard(item.inputSchema, input);
|
|
94
77
|
const output = yield* Effect.tryPromise({
|
|
95
78
|
catch: errorOf,
|
|
96
79
|
try: () => Promise.resolve(item.handler(decoded, { signal: new AbortController().signal }))
|
|
97
|
-
}).pipe(Effect.flatMap((value) =>
|
|
98
|
-
yield*
|
|
80
|
+
}).pipe(Effect.flatMap((value) => decodeStandard(item.outputSchema, value)));
|
|
81
|
+
yield* appendCall(journal, {
|
|
99
82
|
cli: definition.path,
|
|
100
83
|
command: item.path.join(" "),
|
|
101
84
|
input: decoded,
|
|
@@ -106,7 +89,7 @@ const executeCli = (definition, args, journal = JOURNAL) => Effect.gen(function*
|
|
|
106
89
|
stderr: "",
|
|
107
90
|
stdout: `${JSON.stringify(output, null, 2) ?? String(output)}\n`
|
|
108
91
|
};
|
|
109
|
-
}).pipe(Effect.catchAll((cause) =>
|
|
92
|
+
}).pipe(Effect.catchAll((cause) => appendCall(journal, {
|
|
110
93
|
cli: definition.path,
|
|
111
94
|
command: item.path.join(" "),
|
|
112
95
|
error: errorOf(cause).message,
|
package/dist/cli.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as CliCall } from "./calls-
|
|
1
|
+
import { t as CliCall } from "./calls-6Z1EoEa-.cjs";
|
|
2
2
|
import { a as cli, i as CliOption, n as CliDefinition, o as command, r as CliHandlerContext, t as CliCommandDefinition } from "./define-BEiYXrC5.cjs";
|
|
3
3
|
export { type CliCall, type CliCommandDefinition, type CliDefinition, type CliHandlerContext, type CliOption, cli, command };
|
package/dist/cli.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as CliCall } from "./calls-
|
|
1
|
+
import { t as CliCall } from "./calls-6Z1EoEa-.mjs";
|
|
2
2
|
import { a as cli, i as CliOption, n as CliDefinition, o as command, r as CliHandlerContext, t as CliCommandDefinition } from "./define-BEiYXrC5.mjs";
|
|
3
3
|
export { type CliCall, type CliCommandDefinition, type CliDefinition, type CliHandlerContext, type CliOption, cli, command };
|