@styx-api/core 0.6.1 → 0.7.0
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/dist/index.cjs +2079 -147
- package/dist/index.d.cts +41 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +41 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2078 -148
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/backend/argtype/__fixtures__/microsyntax.argtype +15 -0
- package/src/backend/argtype/__fixtures__/subcommands.argtype +25 -0
- package/src/backend/argtype/argtype.ts +45 -0
- package/src/backend/argtype/emit.ts +725 -0
- package/src/backend/argtype/index.ts +2 -0
- package/src/backend/index.ts +1 -0
- package/src/frontend/argtype/__fixtures__/bet.argtype +103 -0
- package/src/frontend/argtype/ast.ts +101 -0
- package/src/frontend/argtype/doc.ts +56 -0
- package/src/frontend/argtype/frontmatter.ts +193 -0
- package/src/frontend/argtype/index.ts +1 -0
- package/src/frontend/argtype/lexer.ts +244 -0
- package/src/frontend/argtype/lower.ts +561 -0
- package/src/frontend/argtype/parser-frontend.ts +51 -0
- package/src/frontend/argtype/parser.ts +487 -0
- package/src/frontend/argtype/template.ts +147 -0
- package/src/frontend/detect-format.ts +28 -3
- package/src/index.ts +23 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styx-api/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Styx compiler core: parses CLI tool descriptors (e.g. Boutiques), optimizes an IR, solves typed parameter bindings, and generates type-safe wrappers (TypeScript, Python, JSON Schema). Part of the Styx/NiWrap ecosystem.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"styx",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
exe: "cut"
|
|
3
|
+
version: "9.0"
|
|
4
|
+
extensions:
|
|
5
|
+
- mediatypes
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
/// Cut fields from each line, exercising join micro-syntax and media types
|
|
9
|
+
cut: seq(
|
|
10
|
+
input: path.mediaType("text/plain"),
|
|
11
|
+
seq("--fields=", fields: rep(int).join(",")).join(),
|
|
12
|
+
opt("-d", delimiter: str),
|
|
13
|
+
defines: rep(seq(str, "=", str).join("")),
|
|
14
|
+
out: path.mediaType("application/json").mediaType("text/csv"),
|
|
15
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
exe: "vcs"
|
|
3
|
+
version: "1.2.0"
|
|
4
|
+
authors:
|
|
5
|
+
- "VCS Authors"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
/// Mini version control with subcommands
|
|
9
|
+
vcs: alt(
|
|
10
|
+
/// Record changes to the repository
|
|
11
|
+
commit: seq(
|
|
12
|
+
"commit",
|
|
13
|
+
opt("-m", message: str),
|
|
14
|
+
opt("--amend"),
|
|
15
|
+
opt("--author", author: str),
|
|
16
|
+
),
|
|
17
|
+
/// Publish local commits to a remote
|
|
18
|
+
push: seq(
|
|
19
|
+
"push",
|
|
20
|
+
opt("-u", upstream: str),
|
|
21
|
+
opt("--force"),
|
|
22
|
+
remote: str = "origin",
|
|
23
|
+
branch: str,
|
|
24
|
+
),
|
|
25
|
+
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CodegenContext } from "../../manifest/index.js";
|
|
2
|
+
import type { Backend, EmittedApp } from "../backend.js";
|
|
3
|
+
import { Scope } from "../scope.js";
|
|
4
|
+
import { snakeCase } from "../string-case.js";
|
|
5
|
+
import { generateArgtype } from "./emit.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A per-tool file stem, so co-located tools in a catalog build don't clobber one
|
|
9
|
+
* another's `descriptor.argtype`. Standalone single-tool builds (no scope) keep
|
|
10
|
+
* the bare name. Mirrors the JSON Schema backend's `schemaStem`.
|
|
11
|
+
*/
|
|
12
|
+
function argtypeStem(ctx: CodegenContext, scope?: Scope): string | undefined {
|
|
13
|
+
const id = ctx.app?.id;
|
|
14
|
+
if (!id || !scope) return undefined;
|
|
15
|
+
return scope.add(snakeCase(id) || "descriptor");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Serialization backend: emit argtype sugar-DSL source from the IR + `AppMeta`.
|
|
20
|
+
*
|
|
21
|
+
* The dogfooding / round-trip counterpart to the argtype frontend. Like the
|
|
22
|
+
* Boutiques backend it only needs the IR (`ctx.expr`) and app metadata
|
|
23
|
+
* (`ctx.app`), never the solved bindings, so it ignores the rest of the context.
|
|
24
|
+
*/
|
|
25
|
+
export class ArgtypeBackend implements Backend {
|
|
26
|
+
readonly name = "argtype";
|
|
27
|
+
readonly target = "argtype";
|
|
28
|
+
|
|
29
|
+
/** One scope per package so per-tool file stems stay unique in the suite dir. */
|
|
30
|
+
newPackageScope(): Scope {
|
|
31
|
+
return new Scope();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
emitApp(ctx: CodegenContext, scope?: Scope): EmittedApp {
|
|
35
|
+
const { source, warnings } = generateArgtype(ctx.expr, ctx.app);
|
|
36
|
+
const stem = argtypeStem(ctx, scope);
|
|
37
|
+
const filename = stem ? `${stem}.argtype` : "descriptor.argtype";
|
|
38
|
+
return {
|
|
39
|
+
meta: ctx.app,
|
|
40
|
+
files: new Map([[filename, source]]),
|
|
41
|
+
errors: [],
|
|
42
|
+
warnings,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|