agency-lang 0.0.2 → 0.0.4
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/{backends → lib/backends}/typescriptGenerator.js +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/builtinFunctions/fetch.d.ts +4 -0
- package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/fetch.js +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/builtinFunctions/fetchJSON.d.ts +4 -0
- package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/fetchJSON.js +1 -1
- package/dist/scripts/agency.d.ts +2 -0
- package/dist/scripts/agency.js +118 -0
- package/dist/scripts/generateGraph.d.ts +1 -0
- package/dist/scripts/generateGraph.js +24 -0
- package/dist/scripts/generateTypescript.d.ts +1 -0
- package/dist/scripts/generateTypescript.js +24 -0
- package/package.json +10 -7
- package/dist/templates/backends/typescriptGenerator/builtinFunctions/fetch.d.ts +0 -4
- package/dist/templates/backends/typescriptGenerator/builtinFunctions/fetchJSON.d.ts +0 -4
- /package/dist/{backends → lib/backends}/baseGenerator.d.ts +0 -0
- /package/dist/{backends → lib/backends}/baseGenerator.js +0 -0
- /package/dist/{backends → lib/backends}/graphGenerator.d.ts +0 -0
- /package/dist/{backends → lib/backends}/graphGenerator.integration.test.d.ts +0 -0
- /package/dist/{backends → lib/backends}/graphGenerator.integration.test.js +0 -0
- /package/dist/{backends → lib/backends}/graphGenerator.js +0 -0
- /package/dist/{backends → lib/backends}/index.d.ts +0 -0
- /package/dist/{backends → lib/backends}/index.js +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator/builtins.d.ts +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator/builtins.js +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator/typeToString.d.ts +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator/typeToString.js +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator/typeToZodSchema.d.ts +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator/typeToZodSchema.js +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator.d.ts +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator.integration.test.d.ts +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator.integration.test.js +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator.test.d.ts +0 -0
- /package/dist/{backends → lib/backends}/typescriptGenerator.test.js +0 -0
- /package/dist/{backends → lib/backends}/utils.d.ts +0 -0
- /package/dist/{backends → lib/backends}/utils.js +0 -0
- /package/dist/{generate-graph-file.d.ts → lib/generate-graph-file.d.ts} +0 -0
- /package/dist/{generate-graph-file.js → lib/generate-graph-file.js} +0 -0
- /package/dist/{generate-ts-file.d.ts → lib/generate-ts-file.d.ts} +0 -0
- /package/dist/{generate-ts-file.js → lib/generate-ts-file.js} +0 -0
- /package/dist/{index.d.ts → lib/index.d.ts} +0 -0
- /package/dist/{index.js → lib/index.js} +0 -0
- /package/dist/{parser.d.ts → lib/parser.d.ts} +0 -0
- /package/dist/{parser.js → lib/parser.js} +0 -0
- /package/dist/{parser.test.d.ts → lib/parser.test.d.ts} +0 -0
- /package/dist/{parser.test.js → lib/parser.test.js} +0 -0
- /package/dist/{parsers → lib/parsers}/access.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/access.js +0 -0
- /package/dist/{parsers → lib/parsers}/access.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/access.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/assignment.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/assignment.js +0 -0
- /package/dist/{parsers → lib/parsers}/body.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/body.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/comment.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/comment.js +0 -0
- /package/dist/{parsers → lib/parsers}/comment.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/comment.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/dataStructures.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/dataStructures.js +0 -0
- /package/dist/{parsers → lib/parsers}/dataStructures.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/dataStructures.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/function.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/function.js +0 -0
- /package/dist/{parsers → lib/parsers}/function.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/function.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/functionCall.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/functionCall.js +0 -0
- /package/dist/{parsers → lib/parsers}/functionCall.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/functionCall.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/importStatement.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/importStatement.js +0 -0
- /package/dist/{parsers → lib/parsers}/importStatement.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/importStatement.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/literals.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/literals.js +0 -0
- /package/dist/{parsers → lib/parsers}/literals.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/literals.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/matchBlock.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/matchBlock.js +0 -0
- /package/dist/{parsers → lib/parsers}/matchBlock.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/matchBlock.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/parserUtils.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/parserUtils.js +0 -0
- /package/dist/{parsers → lib/parsers}/returnStatement.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/returnStatement.js +0 -0
- /package/dist/{parsers → lib/parsers}/tools.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/tools.js +0 -0
- /package/dist/{parsers → lib/parsers}/tools.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/tools.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/typeHints.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/typeHints.js +0 -0
- /package/dist/{parsers → lib/parsers}/typeHints.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/typeHints.test.js +0 -0
- /package/dist/{parsers → lib/parsers}/utils.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/utils.js +0 -0
- /package/dist/{parsers → lib/parsers}/whileLoop.test.d.ts +0 -0
- /package/dist/{parsers → lib/parsers}/whileLoop.test.js +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/builtinTools.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/builtinTools.js +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/conditionalEdge.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/conditionalEdge.js +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/edge.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/edge.js +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/goToNode.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/goToNode.js +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/graphNode.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/graphNode.js +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/imports.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/imports.js +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/node.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/node.js +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/promptNode.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/promptNode.js +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/startNode.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/graphGenerator/startNode.js +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/input.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/input.js +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/read.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/read.js +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinTools.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinTools.js +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/functionDefinition.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/functionDefinition.js +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/imports.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/imports.js +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/promptFunction.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/promptFunction.js +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/tool.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/tool.js +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/toolCall.d.ts +0 -0
- /package/dist/{templates → lib/templates}/backends/typescriptGenerator/toolCall.js +0 -0
- /package/dist/{types → lib/types}/access.d.ts +0 -0
- /package/dist/{types → lib/types}/access.js +0 -0
- /package/dist/{types → lib/types}/dataStructures.d.ts +0 -0
- /package/dist/{types → lib/types}/dataStructures.js +0 -0
- /package/dist/{types → lib/types}/function.d.ts +0 -0
- /package/dist/{types → lib/types}/function.js +0 -0
- /package/dist/{types → lib/types}/graphNode.d.ts +0 -0
- /package/dist/{types → lib/types}/graphNode.js +0 -0
- /package/dist/{types → lib/types}/importStatement.d.ts +0 -0
- /package/dist/{types → lib/types}/importStatement.js +0 -0
- /package/dist/{types → lib/types}/literals.d.ts +0 -0
- /package/dist/{types → lib/types}/literals.js +0 -0
- /package/dist/{types → lib/types}/matchBlock.d.ts +0 -0
- /package/dist/{types → lib/types}/matchBlock.js +0 -0
- /package/dist/{types → lib/types}/returnStatement.d.ts +0 -0
- /package/dist/{types → lib/types}/returnStatement.js +0 -0
- /package/dist/{types → lib/types}/tools.d.ts +0 -0
- /package/dist/{types → lib/types}/tools.js +0 -0
- /package/dist/{types → lib/types}/typeHints.d.ts +0 -0
- /package/dist/{types → lib/types}/typeHints.js +0 -0
- /package/dist/{types → lib/types}/whileLoop.d.ts +0 -0
- /package/dist/{types → lib/types}/whileLoop.js +0 -0
- /package/dist/{types.d.ts → lib/types.d.ts} +0 -0
- /package/dist/{types.js → lib/types.js} +0 -0
- /package/dist/{utils.d.ts → lib/utils.d.ts} +0 -0
- /package/dist/{utils.js → lib/utils.js} +0 -0
|
@@ -164,7 +164,7 @@ export class TypeScriptGenerator extends BaseGenerator {
|
|
|
164
164
|
return renderTool.default({
|
|
165
165
|
name: functionName,
|
|
166
166
|
description: node.docString?.value || "No description provided.",
|
|
167
|
-
properties: Object.keys(properties).length > 0 ? JSON.stringify(properties) : "",
|
|
167
|
+
properties: Object.keys(properties).length > 0 ? JSON.stringify(properties) : "{}",
|
|
168
168
|
requiredParameters: parameters.map((p) => `"${p}"`).join(","),
|
|
169
169
|
});
|
|
170
170
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const template = "async function _builtinFetch(url: string, args: any = {}): any {\n const result = await fetch(url, args);\n try {\n const text = await result.text();\n return text;\n } catch (e) {\n throw new Error(`Failed to get text from ${url}: ${e}`);\n }\n}";
|
|
2
|
+
export type TemplateType = {};
|
|
3
|
+
declare const render: (args: TemplateType) => string;
|
|
4
|
+
export default render;
|
package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/fetch.js
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Source: lib/templates/backends/typescriptGenerator/builtinFunctions/fetch.mustache
|
|
3
3
|
// Any manual changes will be lost.
|
|
4
4
|
import { apply } from "typestache";
|
|
5
|
-
export const template = `async function _builtinFetch(url: string, args: any): any {
|
|
5
|
+
export const template = `async function _builtinFetch(url: string, args: any = {}): any {
|
|
6
6
|
const result = await fetch(url, args);
|
|
7
7
|
try {
|
|
8
8
|
const text = await result.text();
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const template = "async function _builtinFetchJSON(url: string, args: any = {}): any {\n const result = await fetch(url, args);\n try {\n const json = await result.json();\n return json;\n } catch (e) {\n throw new Error(`Failed to parse JSON from ${url}: ${e}`);\n }\n}";
|
|
2
|
+
export type TemplateType = {};
|
|
3
|
+
declare const render: (args: TemplateType) => string;
|
|
4
|
+
export default render;
|
package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/fetchJSON.js
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Source: lib/templates/backends/typescriptGenerator/builtinFunctions/fetchJSON.mustache
|
|
3
3
|
// Any manual changes will be lost.
|
|
4
4
|
import { apply } from "typestache";
|
|
5
|
-
export const template = `async function _builtinFetchJSON(url: string, args: any): any {
|
|
5
|
+
export const template = `async function _builtinFetchJSON(url: string, args: any = {}): any {
|
|
6
6
|
const result = await fetch(url, args);
|
|
7
7
|
try {
|
|
8
8
|
const json = await result.json();
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import { parseAgency } from "../lib/parser.js";
|
|
5
|
+
import { generateGraph } from "../lib/index.js";
|
|
6
|
+
function help() {
|
|
7
|
+
console.log(`
|
|
8
|
+
Agency Language CLI
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
agency help Show this help message
|
|
12
|
+
agency compile <input> [output] Compile .agency file to TypeScript
|
|
13
|
+
agency run <input> [output] Compile and run .agency file
|
|
14
|
+
agency <input> Compile and run .agency file (shorthand)
|
|
15
|
+
|
|
16
|
+
Arguments:
|
|
17
|
+
input Path to .agency input file
|
|
18
|
+
output Path to output .ts file (optional)
|
|
19
|
+
Default: <input-name>.ts
|
|
20
|
+
|
|
21
|
+
Examples:
|
|
22
|
+
agency help Show help
|
|
23
|
+
agency compile script.agency Compile to script.ts
|
|
24
|
+
agency compile script.agency out.ts Compile to out.ts
|
|
25
|
+
agency run script.agency Compile and run script.agency
|
|
26
|
+
agency script.agency Compile and run (shorthand)
|
|
27
|
+
`);
|
|
28
|
+
}
|
|
29
|
+
function compile(inputFile, outputFile) {
|
|
30
|
+
// Validate input file
|
|
31
|
+
if (!fs.existsSync(inputFile)) {
|
|
32
|
+
console.error(`Error: Input file '${inputFile}' not found`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
// Determine output file name
|
|
36
|
+
const output = outputFile || inputFile.replace(".agency", ".ts");
|
|
37
|
+
// Read and parse the Agency file
|
|
38
|
+
const contents = fs.readFileSync(inputFile, "utf-8");
|
|
39
|
+
const parseResult = parseAgency(contents);
|
|
40
|
+
// Check if parsing was successful
|
|
41
|
+
if (!parseResult.success) {
|
|
42
|
+
console.error("Parse error:");
|
|
43
|
+
console.error(parseResult);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
const parsedProgram = parseResult.result;
|
|
47
|
+
// Generate TypeScript code
|
|
48
|
+
const generatedCode = generateGraph(parsedProgram);
|
|
49
|
+
// Write to output file
|
|
50
|
+
fs.writeFileSync(output, generatedCode, "utf-8");
|
|
51
|
+
console.log(`Generated ${output} from ${inputFile}`);
|
|
52
|
+
return output;
|
|
53
|
+
}
|
|
54
|
+
function run(inputFile, outputFile) {
|
|
55
|
+
// Compile the file
|
|
56
|
+
const output = compile(inputFile, outputFile);
|
|
57
|
+
// Run the generated TypeScript file with Node.js
|
|
58
|
+
console.log(`Running ${output}...`);
|
|
59
|
+
console.log("---");
|
|
60
|
+
const nodeProcess = spawn("node", [output], {
|
|
61
|
+
stdio: "inherit",
|
|
62
|
+
shell: false,
|
|
63
|
+
});
|
|
64
|
+
nodeProcess.on("error", (error) => {
|
|
65
|
+
console.error(`Failed to run ${output}:`, error);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
});
|
|
68
|
+
nodeProcess.on("exit", (code) => {
|
|
69
|
+
if (code !== 0) {
|
|
70
|
+
process.exit(code || 1);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Main CLI logic
|
|
75
|
+
function main() {
|
|
76
|
+
const args = process.argv.slice(2);
|
|
77
|
+
// No arguments - show help
|
|
78
|
+
if (args.length === 0) {
|
|
79
|
+
help();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const command = args[0];
|
|
83
|
+
switch (command) {
|
|
84
|
+
case "help":
|
|
85
|
+
case "--help":
|
|
86
|
+
case "-h":
|
|
87
|
+
help();
|
|
88
|
+
break;
|
|
89
|
+
case "compile":
|
|
90
|
+
if (args.length < 2) {
|
|
91
|
+
console.error("Error: 'compile' command requires an input file");
|
|
92
|
+
console.error("Usage: agency compile <input> [output]");
|
|
93
|
+
process.exit(1);
|
|
94
|
+
}
|
|
95
|
+
compile(args[1], args[2]);
|
|
96
|
+
break;
|
|
97
|
+
case "run":
|
|
98
|
+
if (args.length < 2) {
|
|
99
|
+
console.error("Error: 'run' command requires an input file");
|
|
100
|
+
console.error("Usage: agency run <input> [output]");
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
run(args[1], args[2]);
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
// If first arg is not a recognized command, treat it as a file to run
|
|
107
|
+
if (command.endsWith(".agency") || fs.existsSync(command)) {
|
|
108
|
+
run(command, args[1]);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
console.error(`Error: Unknown command '${command}'`);
|
|
112
|
+
console.error("Run 'agency help' for usage information");
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import { parseAgency } from "../lib/parser.js";
|
|
3
|
+
import { getDebugMessage } from "tarsec";
|
|
4
|
+
import { exit } from "process";
|
|
5
|
+
import { generateGraph } from "../lib/backends/graphGenerator.js";
|
|
6
|
+
// Get filename from command line arguments
|
|
7
|
+
const filename = process.argv[2];
|
|
8
|
+
if (!filename) {
|
|
9
|
+
console.error("Usage: node index.ts <filename>");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
// Read file contents
|
|
13
|
+
const contents = fs.readFileSync(filename, "utf-8");
|
|
14
|
+
// Parse with agencyParser
|
|
15
|
+
const result = parseAgency(contents);
|
|
16
|
+
if (!result.success) {
|
|
17
|
+
const message = getDebugMessage();
|
|
18
|
+
if (message) {
|
|
19
|
+
console.error("Debug Info:\n" + message);
|
|
20
|
+
}
|
|
21
|
+
exit(1);
|
|
22
|
+
}
|
|
23
|
+
const code = generateGraph(result.result);
|
|
24
|
+
console.log(code);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import { parseAgency } from "../lib/parser.js";
|
|
3
|
+
import { getDebugMessage } from "tarsec";
|
|
4
|
+
import { generateTypeScript } from "../lib/backends/typescriptGenerator.js";
|
|
5
|
+
import { exit } from "process";
|
|
6
|
+
// Get filename from command line arguments
|
|
7
|
+
const filename = process.argv[2];
|
|
8
|
+
if (!filename) {
|
|
9
|
+
console.error("Usage: node index.ts <filename>");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
// Read file contents
|
|
13
|
+
const contents = fs.readFileSync(filename, "utf-8");
|
|
14
|
+
// Parse with agencyParser
|
|
15
|
+
const result = parseAgency(contents);
|
|
16
|
+
if (!result.success) {
|
|
17
|
+
const message = getDebugMessage();
|
|
18
|
+
if (message) {
|
|
19
|
+
console.error("Debug Info:\n" + message);
|
|
20
|
+
}
|
|
21
|
+
exit(1);
|
|
22
|
+
}
|
|
23
|
+
const code = generateTypeScript(result.result);
|
|
24
|
+
console.log(code);
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agency-lang",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "The Agency language",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "vitest",
|
|
8
8
|
"test:run": "vitest run",
|
|
9
9
|
"build": "rm -rf dist/ && tsc && tsc-alias",
|
|
10
|
-
"start": "node dist/index.js",
|
|
10
|
+
"start": "node dist/lib/index.js",
|
|
11
11
|
"templates": "typestache ./lib/templates",
|
|
12
12
|
"typecheck": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"agency": "./dist/scripts/agency.js"
|
|
16
|
+
},
|
|
14
17
|
"repository": {
|
|
15
18
|
"type": "git",
|
|
16
19
|
"url": "git+https://github.com/egonSchiele/agency-lang.git"
|
|
@@ -20,13 +23,13 @@
|
|
|
20
23
|
],
|
|
21
24
|
"exports": {
|
|
22
25
|
".": {
|
|
23
|
-
"import": "./dist/index.js",
|
|
24
|
-
"require": "./dist/index.js",
|
|
25
|
-
"types": "./dist/index.d.ts"
|
|
26
|
+
"import": "./dist/lib/index.js",
|
|
27
|
+
"require": "./dist/lib/index.js",
|
|
28
|
+
"types": "./dist/lib/index.d.ts"
|
|
26
29
|
}
|
|
27
30
|
},
|
|
28
31
|
"type": "module",
|
|
29
|
-
"types": "./dist/index.d.ts",
|
|
32
|
+
"types": "./dist/lib/index.d.ts",
|
|
30
33
|
"keywords": [],
|
|
31
34
|
"author": "Aditya Bhargava",
|
|
32
35
|
"license": "ISC",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const template = "async function _builtinFetch(url: string, args: any): any {\n const result = await fetch(url, args);\n try {\n const text = await result.text();\n return text;\n } catch (e) {\n throw new Error(`Failed to get text from ${url}: ${e}`);\n }\n}";
|
|
2
|
-
export type TemplateType = {};
|
|
3
|
-
declare const render: (args: TemplateType) => string;
|
|
4
|
-
export default render;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const template = "async function _builtinFetchJSON(url: string, args: any): any {\n const result = await fetch(url, args);\n try {\n const json = await result.json();\n return json;\n } catch (e) {\n throw new Error(`Failed to parse JSON from ${url}: ${e}`);\n }\n}";
|
|
2
|
-
export type TemplateType = {};
|
|
3
|
-
declare const render: (args: TemplateType) => string;
|
|
4
|
-
export default render;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/input.d.ts
RENAMED
|
File without changes
|
/package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/input.js
RENAMED
|
File without changes
|
/package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/read.d.ts
RENAMED
|
File without changes
|
/package/dist/{templates → lib/templates}/backends/typescriptGenerator/builtinFunctions/read.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{templates → lib/templates}/backends/typescriptGenerator/functionDefinition.d.ts
RENAMED
|
File without changes
|
/package/dist/{templates → lib/templates}/backends/typescriptGenerator/functionDefinition.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|