@acpus/core 0.1.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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/dist/compiler.d.ts +4 -0
  4. package/dist/compiler.d.ts.map +1 -0
  5. package/dist/compiler.js +526 -0
  6. package/dist/compiler.js.map +1 -0
  7. package/dist/diagnostics.d.ts +9 -0
  8. package/dist/diagnostics.d.ts.map +1 -0
  9. package/dist/diagnostics.js +16 -0
  10. package/dist/diagnostics.js.map +1 -0
  11. package/dist/duration.d.ts +14 -0
  12. package/dist/duration.d.ts.map +1 -0
  13. package/dist/duration.js +28 -0
  14. package/dist/duration.js.map +1 -0
  15. package/dist/expressions.d.ts +12 -0
  16. package/dist/expressions.d.ts.map +1 -0
  17. package/dist/expressions.js +108 -0
  18. package/dist/expressions.js.map +1 -0
  19. package/dist/index.d.ts +11 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +7 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/schedule.d.ts +3 -0
  24. package/dist/schedule.d.ts.map +1 -0
  25. package/dist/schedule.js +21 -0
  26. package/dist/schedule.js.map +1 -0
  27. package/dist/schema/dsl.d.ts +34 -0
  28. package/dist/schema/dsl.d.ts.map +1 -0
  29. package/dist/schema/dsl.js +231 -0
  30. package/dist/schema/dsl.js.map +1 -0
  31. package/dist/schema/helpers.d.ts +24 -0
  32. package/dist/schema/helpers.d.ts.map +1 -0
  33. package/dist/schema/helpers.js +61 -0
  34. package/dist/schema/helpers.js.map +1 -0
  35. package/dist/schema/index.d.ts +3 -0
  36. package/dist/schema/index.d.ts.map +1 -0
  37. package/dist/schema/index.js +3 -0
  38. package/dist/schema/index.js.map +1 -0
  39. package/dist/schema-validator.d.ts +29 -0
  40. package/dist/schema-validator.d.ts.map +1 -0
  41. package/dist/schema-validator.js +568 -0
  42. package/dist/schema-validator.js.map +1 -0
  43. package/dist/types.d.ts +120 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/types.js +2 -0
  46. package/dist/types.js.map +1 -0
  47. package/dist/workflow-schema.d.ts +10 -0
  48. package/dist/workflow-schema.d.ts.map +1 -0
  49. package/dist/workflow-schema.js +380 -0
  50. package/dist/workflow-schema.js.map +1 -0
  51. package/package.json +59 -0
@@ -0,0 +1,120 @@
1
+ export type DiagnosticSeverity = "error" | "warning";
2
+ export interface Diagnostic {
3
+ severity: DiagnosticSeverity;
4
+ code: string;
5
+ message: string;
6
+ path: string;
7
+ }
8
+ export interface CompileOptions {
9
+ sourcePath?: string;
10
+ strict?: boolean;
11
+ includeResolver?: (path: string, fromPath?: string) => string;
12
+ }
13
+ export interface CompileResult {
14
+ ok: boolean;
15
+ diagnostics: Diagnostic[];
16
+ ir?: AcpusIr;
17
+ schedule?: ScheduleSummary;
18
+ }
19
+ export interface LintResult {
20
+ ok: boolean;
21
+ diagnostics: Diagnostic[];
22
+ }
23
+ export interface WorkflowSpec {
24
+ version: number;
25
+ name: string;
26
+ description?: string;
27
+ input?: Record<string, unknown>;
28
+ agents?: Record<string, AgentSpec>;
29
+ workflow: {
30
+ steps: WorkflowStep[];
31
+ };
32
+ outputs?: Record<string, unknown>;
33
+ }
34
+ /**
35
+ * How an agent definition is driven at runtime:
36
+ * - `builtin` (default): acpx built-in adapter named by `use` (e.g. pi/claude/codex).
37
+ * - `command`: a custom ACP server launched via acpx `--agent "<use>"` escape hatch.
38
+ */
39
+ export type AgentType = "builtin" | "command";
40
+ export interface AgentSpec {
41
+ /** Routing kind; defaults to "builtin" when omitted. */
42
+ type?: AgentType;
43
+ /**
44
+ * For `builtin`: the acpx adapter name (e.g. "pi"). For `command`: the ACP
45
+ * server launch command.
46
+ */
47
+ use?: string;
48
+ model?: string;
49
+ cwd?: unknown;
50
+ env?: Record<string, unknown>;
51
+ tools_allowlist?: string[];
52
+ max_concurrency?: number;
53
+ }
54
+ export type WorkflowStep = Record<string, unknown> & {
55
+ id?: string;
56
+ };
57
+ export type IrNodeKind = "pipeline" | "run.agent" | "run.program" | "parallel" | "fanout" | "switch" | "loop" | "guard" | "approval" | "subworkflow";
58
+ export interface AcpusIr {
59
+ irVersion: 1;
60
+ astVersion: 1;
61
+ source: {
62
+ path?: string;
63
+ digest: string;
64
+ };
65
+ name: string;
66
+ description?: string;
67
+ input: Record<string, unknown>;
68
+ agents: Record<string, AgentSpec>;
69
+ root: IrNode;
70
+ outputs: Record<string, unknown>;
71
+ expressions: IrExpression[];
72
+ runtimeInput?: Record<string, unknown>;
73
+ }
74
+ export type OutputMerge = "map" | "array" | "selected" | "last";
75
+ export interface IrNode {
76
+ id: string;
77
+ kind: IrNodeKind;
78
+ nodePath: string[];
79
+ keyTemplate: NodeKeyTemplate;
80
+ outputMerge?: OutputMerge;
81
+ children?: IrNode[];
82
+ branches?: IrBranch[];
83
+ metadata: Record<string, unknown>;
84
+ }
85
+ export interface IrBranch {
86
+ id: string;
87
+ when?: string;
88
+ children: IrNode[];
89
+ }
90
+ export interface NodeKeyTemplate {
91
+ astVersion: 1;
92
+ nodePath: string;
93
+ loopRound?: true;
94
+ fanoutItemId?: true;
95
+ parallelBranchId?: true;
96
+ laneId?: true;
97
+ }
98
+ export interface IrExpression {
99
+ id: string;
100
+ source: string;
101
+ path: string;
102
+ references: string[];
103
+ }
104
+ export interface ScheduleSummary {
105
+ workflow: string;
106
+ nodes: ScheduleNode[];
107
+ }
108
+ export interface ScheduleNode {
109
+ id: string;
110
+ kind: IrNodeKind;
111
+ nodePath: string;
112
+ outputMerge?: OutputMerge;
113
+ children?: ScheduleNode[];
114
+ branches?: Array<{
115
+ id: string;
116
+ when?: string;
117
+ children: ScheduleNode[];
118
+ }>;
119
+ }
120
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,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
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * JSON Schema definition for Acpus workflow YAML specs.
3
+ *
4
+ * Covers structural validation: types, enums, required fields, unknown-field
5
+ * detection (additionalProperties: false), and if/then cross-field dependencies.
6
+ * Semantic validation (cross-references, DSL compilation, duration format)
7
+ * remains in the hand-written compiler code.
8
+ */
9
+ export declare const WORKFLOW_SCHEMA: Record<string, unknown>;
10
+ //# sourceMappingURL=workflow-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-schema.d.ts","sourceRoot":"","sources":["../src/workflow-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAwYnD,CAAC"}
@@ -0,0 +1,380 @@
1
+ /**
2
+ * JSON Schema definition for Acpus workflow YAML specs.
3
+ *
4
+ * Covers structural validation: types, enums, required fields, unknown-field
5
+ * detection (additionalProperties: false), and if/then cross-field dependencies.
6
+ * Semantic validation (cross-references, DSL compilation, duration format)
7
+ * remains in the hand-written compiler code.
8
+ */
9
+ export const WORKFLOW_SCHEMA = {
10
+ $defs: {
11
+ // ── Agent definition ──
12
+ agentSpec: {
13
+ type: "object",
14
+ additionalProperties: false,
15
+ properties: {
16
+ type: {
17
+ type: "string",
18
+ enum: ["builtin", "command"]
19
+ },
20
+ use: { type: "string" },
21
+ model: { type: "string" },
22
+ cwd: {}, // any type — runtime coercion
23
+ env: { type: "object" }, // free-form env vars
24
+ tools_allowlist: {
25
+ type: "array",
26
+ items: { type: "string" }
27
+ },
28
+ max_concurrency: {
29
+ type: "integer",
30
+ minimum: 1
31
+ }
32
+ },
33
+ required: ["use"]
34
+ },
35
+ // ── Step (oneOf dispatch) ──
36
+ step: {
37
+ type: "object",
38
+ required: ["id"],
39
+ properties: {
40
+ id: { type: "string", minLength: 1 }
41
+ },
42
+ oneOf: [
43
+ { $ref: "#/$defs/agentStep" },
44
+ { $ref: "#/$defs/programStep" },
45
+ { $ref: "#/$defs/parallelStep" },
46
+ { $ref: "#/$defs/fanoutStep" },
47
+ { $ref: "#/$defs/switchStep" },
48
+ { $ref: "#/$defs/loopStep" },
49
+ { $ref: "#/$defs/guardStep" },
50
+ { $ref: "#/$defs/approvalStep" },
51
+ { $ref: "#/$defs/subworkflowStep" }
52
+ ]
53
+ },
54
+ agentStep: {
55
+ type: "object",
56
+ additionalProperties: false,
57
+ required: ["run", "use", "prompt"],
58
+ properties: {
59
+ id: { type: "string", minLength: 1 },
60
+ run: { const: "agent" },
61
+ use: { type: "string" },
62
+ prompt: { type: "string" },
63
+ output: { type: "object" }, // free DSL — validated by compiler
64
+ retry: { $ref: "#/$defs/retrySpec" },
65
+ timeout: { $ref: "#/$defs/timeoutSpec" },
66
+ on_error: {
67
+ type: "string",
68
+ enum: ["fail", "retry", "skip"]
69
+ }
70
+ }
71
+ },
72
+ programStep: {
73
+ type: "object",
74
+ additionalProperties: false,
75
+ required: ["run", "cmd"],
76
+ properties: {
77
+ id: { type: "string", minLength: 1 },
78
+ run: { const: "program" },
79
+ cmd: {
80
+ oneOf: [
81
+ { type: "string" },
82
+ { type: "array", items: { type: "string" } }
83
+ ]
84
+ },
85
+ env: { type: "object" },
86
+ capture: { $ref: "#/$defs/captureSpec" },
87
+ output: { type: "object" }, // free DSL
88
+ retry: { $ref: "#/$defs/retrySpec" },
89
+ timeout: { $ref: "#/$defs/timeoutSpec" },
90
+ on_error: {
91
+ type: "string",
92
+ enum: ["fail", "retry", "skip"]
93
+ }
94
+ }
95
+ },
96
+ parallelStep: {
97
+ type: "object",
98
+ additionalProperties: false,
99
+ required: ["parallel"],
100
+ properties: {
101
+ id: { type: "string", minLength: 1 },
102
+ parallel: {
103
+ type: "array"
104
+ },
105
+ max_concurrency: {
106
+ type: "integer",
107
+ minimum: 1
108
+ },
109
+ join: {
110
+ type: "string",
111
+ enum: ["all", "race"]
112
+ }
113
+ }
114
+ },
115
+ fanoutStep: {
116
+ type: "object",
117
+ additionalProperties: false,
118
+ required: ["fanout"],
119
+ properties: {
120
+ id: { type: "string", minLength: 1 },
121
+ fanout: { $ref: "#/$defs/fanoutSpec" }
122
+ }
123
+ },
124
+ fanoutSpec: {
125
+ type: "object",
126
+ additionalProperties: false,
127
+ required: ["over", "do"],
128
+ properties: {
129
+ over: {
130
+ oneOf: [
131
+ { type: "string" },
132
+ { type: "array" }
133
+ ]
134
+ },
135
+ key: { type: "string" },
136
+ max_concurrency: {
137
+ type: "integer",
138
+ minimum: 1
139
+ },
140
+ join: {
141
+ type: "string",
142
+ enum: ["all", "race", "quorum"]
143
+ },
144
+ quorum: {
145
+ type: "integer",
146
+ minimum: 1
147
+ },
148
+ success_criteria: { $ref: "#/$defs/successCriteriaSpec" },
149
+ do: { type: "array" }
150
+ },
151
+ allOf: [
152
+ // join: quorum → quorum required
153
+ {
154
+ if: {
155
+ required: ["join"],
156
+ properties: { join: { const: "quorum" } }
157
+ },
158
+ then: { required: ["quorum"] }
159
+ }
160
+ ]
161
+ },
162
+ switchStep: {
163
+ type: "object",
164
+ additionalProperties: false,
165
+ required: ["switch"],
166
+ properties: {
167
+ id: { type: "string", minLength: 1 },
168
+ switch: { $ref: "#/$defs/switchSpec" }
169
+ }
170
+ },
171
+ switchSpec: {
172
+ type: "object",
173
+ additionalProperties: false,
174
+ properties: {
175
+ on: { type: "string" },
176
+ cases: {
177
+ type: "array",
178
+ items: { $ref: "#/$defs/switchCase" }
179
+ },
180
+ default: {
181
+ type: "object",
182
+ additionalProperties: false,
183
+ properties: {
184
+ do: { type: "array" }
185
+ }
186
+ }
187
+ }
188
+ },
189
+ switchCase: {
190
+ type: "object",
191
+ additionalProperties: false,
192
+ properties: {
193
+ when: {
194
+ oneOf: [
195
+ { type: "string" },
196
+ { type: "boolean" }
197
+ ]
198
+ },
199
+ do: { type: "array" }
200
+ }
201
+ },
202
+ loopStep: {
203
+ type: "object",
204
+ additionalProperties: false,
205
+ required: ["loop"],
206
+ properties: {
207
+ id: { type: "string", minLength: 1 },
208
+ loop: { $ref: "#/$defs/loopSpec" }
209
+ }
210
+ },
211
+ loopSpec: {
212
+ type: "object",
213
+ additionalProperties: false,
214
+ required: ["max_iterations"],
215
+ properties: {
216
+ until: {
217
+ oneOf: [
218
+ { type: "string" },
219
+ { type: "boolean" }
220
+ ]
221
+ },
222
+ max_iterations: { type: "number" },
223
+ do: { type: "array" }
224
+ }
225
+ },
226
+ guardStep: {
227
+ type: "object",
228
+ additionalProperties: false,
229
+ required: ["guard"],
230
+ properties: {
231
+ id: { type: "string", minLength: 1 },
232
+ guard: { $ref: "#/$defs/guardSpec" }
233
+ }
234
+ },
235
+ guardSpec: {
236
+ type: "object",
237
+ additionalProperties: false,
238
+ required: ["when", "then", "else"],
239
+ properties: {
240
+ when: {
241
+ oneOf: [
242
+ { type: "string" },
243
+ { type: "boolean" }
244
+ ]
245
+ },
246
+ then: { $ref: "#/$defs/guardAction" },
247
+ else: { $ref: "#/$defs/guardAction" },
248
+ message: { type: "string" }
249
+ }
250
+ },
251
+ guardAction: {
252
+ type: "string",
253
+ enum: ["continue", "fail", "complete"]
254
+ },
255
+ approvalStep: {
256
+ type: "object",
257
+ additionalProperties: false,
258
+ required: ["approval"],
259
+ properties: {
260
+ id: { type: "string", minLength: 1 },
261
+ approval: { $ref: "#/$defs/approvalSpec" }
262
+ }
263
+ },
264
+ approvalSpec: {
265
+ type: "object",
266
+ additionalProperties: false,
267
+ required: ["prompt"],
268
+ // A gate with no `timeout` waits indefinitely for a human decision.
269
+ // When `timeout` is set, `on_timeout` must specify the timeout policy.
270
+ dependencies: { timeout: ["on_timeout"] },
271
+ properties: {
272
+ prompt: { type: "string" },
273
+ timeout: { type: "string" }, // duration format validated by compiler
274
+ on_timeout: {
275
+ type: "string",
276
+ enum: ["fail", "escalate", "approve", "reject"]
277
+ }
278
+ }
279
+ },
280
+ subworkflowStep: {
281
+ type: "object",
282
+ additionalProperties: false,
283
+ required: ["subworkflow"],
284
+ properties: {
285
+ id: { type: "string", minLength: 1 },
286
+ subworkflow: { type: "string" },
287
+ input: { type: "object" } // free-form
288
+ }
289
+ },
290
+ // ── Shared sub-schemas ──
291
+ captureSpec: {
292
+ type: "object",
293
+ additionalProperties: false,
294
+ required: ["from", "parse"],
295
+ properties: {
296
+ from: {
297
+ type: "string",
298
+ enum: ["stdout", "file"]
299
+ },
300
+ parse: {
301
+ type: "string",
302
+ enum: ["json", "text"]
303
+ },
304
+ path: { type: "string" }
305
+ },
306
+ allOf: [
307
+ // from: file → path required
308
+ {
309
+ if: {
310
+ required: ["from"],
311
+ properties: { from: { const: "file" } }
312
+ },
313
+ then: { required: ["path"] }
314
+ }
315
+ ]
316
+ },
317
+ retrySpec: {
318
+ type: "object",
319
+ additionalProperties: false,
320
+ properties: {
321
+ max: {
322
+ type: "integer",
323
+ minimum: 0
324
+ },
325
+ backoff: { type: "string" } // duration format validated by compiler
326
+ }
327
+ },
328
+ timeoutSpec: {
329
+ oneOf: [
330
+ { type: "string" },
331
+ { type: "number", exclusiveMinimum: 0 }
332
+ ]
333
+ },
334
+ successCriteriaSpec: {
335
+ type: "object",
336
+ additionalProperties: false,
337
+ properties: {
338
+ min_success: {
339
+ type: "integer",
340
+ minimum: 1
341
+ }
342
+ }
343
+ }
344
+ },
345
+ // ── Top-level schema ──
346
+ type: "object",
347
+ additionalProperties: false,
348
+ required: ["version", "name", "workflow"],
349
+ properties: {
350
+ version: {
351
+ type: "number",
352
+ enum: [1]
353
+ },
354
+ name: { type: "string" },
355
+ description: { type: "string" },
356
+ input: { type: "object" }, // free DSL
357
+ agents: {
358
+ type: "object",
359
+ additionalProperties: {
360
+ $ref: "#/$defs/agentSpec"
361
+ }
362
+ },
363
+ workflow: {
364
+ type: "object",
365
+ additionalProperties: false,
366
+ required: ["steps"],
367
+ properties: {
368
+ steps: {
369
+ type: "array",
370
+ items: { $ref: "#/$defs/step" }
371
+ }
372
+ }
373
+ },
374
+ outputs: {
375
+ type: "object",
376
+ additionalProperties: { type: "string" }
377
+ }
378
+ }
379
+ };
380
+ //# sourceMappingURL=workflow-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-schema.js","sourceRoot":"","sources":["../src/workflow-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,eAAe,GAA4B;IACtD,KAAK,EAAE;QACL,yBAAyB;QACzB,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,KAAK;YAC3B,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;iBAC7B;gBACD,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACvB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,GAAG,EAAE,EAAE,EAAwB,8BAA8B;gBAC7D,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAQ,qBAAqB;gBACpD,eAAe,EAAE;oBACf,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBAC1B;gBACD,eAAe,EAAE;oBACf,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,CAAC;iBACX;aACF;YACD,QAAQ,EAAE,CAAC,KAAK,CAAC;SAClB;QAED,8BAA8B;QAC9B,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,CAAC,IAAI,CAAC;YAChB,UAAU,EAAE;gBACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;aACrC;YACD,KAAK,EAAE;gBACL,EAAE,IAAI,EAAE,mBAAmB,EAAE;gBAC7B,EAAE,IAAI,EAAE,qBAAqB,EAAE;gBAC/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gBACV,KAAK,EAAE;oBACL,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;iBAChC;aACF;SACF;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SACzC;KACF;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@acpus/core",
3
+ "version": "0.1.0",
4
+ "description": "Workflow Spec compiler and validation core for Acpus",
5
+ "keywords": [
6
+ "acp",
7
+ "workflow",
8
+ "compiler",
9
+ "schema",
10
+ "orchestrator"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "kkkyran",
14
+ "homepage": "https://github.com/kelvinschen/acpus#readme",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/kelvinschen/acpus.git",
18
+ "directory": "packages/core"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/kelvinschen/acpus/issues"
22
+ },
23
+ "type": "module",
24
+ "engines": {
25
+ "node": ">=22"
26
+ },
27
+ "exports": {
28
+ ".": {
29
+ "development": "./src/index.ts",
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
32
+ }
33
+ },
34
+ "main": "./dist/index.js",
35
+ "types": "./dist/index.d.ts",
36
+ "files": [
37
+ "dist",
38
+ "README.md",
39
+ "LICENSE"
40
+ ],
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "dependencies": {
45
+ "@marcbachmann/cel-js": "^7.6.1",
46
+ "ajv": "^8.20.0",
47
+ "ms": "^2.1.3",
48
+ "yaml": "^2.9.0"
49
+ },
50
+ "devDependencies": {
51
+ "@types/ms": "^2.1.0",
52
+ "@types/node": "^22.15.30"
53
+ },
54
+ "scripts": {
55
+ "build": "tsc -p tsconfig.json",
56
+ "typecheck": "tsc -p tsconfig.json --noEmit",
57
+ "clean": "rm -rf dist"
58
+ }
59
+ }