@goreal-ai/echo-pdk-cli 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Echo PDK
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # @goreal-ai/echo-pdk-cli
2
+
3
+ **Echo PDK CLI** - Command-line interface for Echo, a Domain Specific Language for dynamic prompt templating.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @goreal-ai/echo-pdk-cli
9
+ # or
10
+ npx @goreal-ai/echo-pdk-cli <command>
11
+ ```
12
+
13
+ ## Commands
14
+
15
+ ### Render a Template
16
+
17
+ ```bash
18
+ echopdk render template.echo --context context.json
19
+ ```
20
+
21
+ Renders an Echo template with the provided context and outputs the result.
22
+
23
+ **Options:**
24
+ - `--context, -c` - Path to JSON file with context variables
25
+ - `--output, -o` - Output file (defaults to stdout)
26
+
27
+ ### Validate Syntax
28
+
29
+ ```bash
30
+ echopdk validate template.echo
31
+ ```
32
+
33
+ Validates the syntax of an Echo template without rendering it.
34
+
35
+ ## Example
36
+
37
+ **template.echo:**
38
+ ```
39
+ Hello {{name}}!
40
+
41
+ [#IF {{role}} #equals(admin)]
42
+ You have full access.
43
+ [ELSE]
44
+ Welcome to our platform.
45
+ [END IF]
46
+ ```
47
+
48
+ **context.json:**
49
+ ```json
50
+ {
51
+ "name": "Alice",
52
+ "role": "admin"
53
+ }
54
+ ```
55
+
56
+ **Run:**
57
+ ```bash
58
+ echopdk render template.echo -c context.json
59
+ ```
60
+
61
+ **Output:**
62
+ ```
63
+ Hello Alice!
64
+
65
+ You have full access.
66
+ ```
67
+
68
+ ## Related Packages
69
+
70
+ | Package | Description |
71
+ |---------|-------------|
72
+ | [@goreal-ai/echo-pdk](https://www.npmjs.com/package/@goreal-ai/echo-pdk) | Core rendering engine |
73
+ | [@goreal-ai/echo-pdk-language](https://www.npmjs.com/package/@goreal-ai/echo-pdk-language) | Language definition and schema |
74
+
75
+ ## Documentation
76
+
77
+ Full documentation available at [GitHub](https://github.com/GoReal-AI/echo-pdk)
78
+
79
+ ## License
80
+
81
+ MIT
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @fileoverview Render Command - Render an Echo template
3
+ *
4
+ * Usage:
5
+ * echopdk render template.echo --context '{"name": "Alice"}'
6
+ * echopdk render template.echo --context-file context.json
7
+ * echopdk render template.echo --context-file context.json --output result.txt
8
+ */
9
+ interface RenderOptions {
10
+ context?: string;
11
+ contextFile?: string;
12
+ output?: string;
13
+ strict?: boolean;
14
+ trim?: boolean;
15
+ }
16
+ /**
17
+ * Render command handler.
18
+ */
19
+ export declare function renderCommand(templatePath: string, options: RenderOptions): Promise<void>;
20
+ export {};
21
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/commands/render.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,UAAU,aAAa;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAMD;;GAEG;AACH,wBAAsB,aAAa,CACjC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CA0Cf"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * @fileoverview Render Command - Render an Echo template
3
+ *
4
+ * Usage:
5
+ * echopdk render template.echo --context '{"name": "Alice"}'
6
+ * echopdk render template.echo --context-file context.json
7
+ * echopdk render template.echo --context-file context.json --output result.txt
8
+ */
9
+ import { readFile, writeFile } from 'fs/promises';
10
+ import { createEcho } from '@goreal-ai/echo-pdk';
11
+ import chalk from 'chalk';
12
+ import ora from 'ora';
13
+ // =============================================================================
14
+ // COMMAND IMPLEMENTATION
15
+ // =============================================================================
16
+ /**
17
+ * Render command handler.
18
+ */
19
+ export async function renderCommand(templatePath, options) {
20
+ const spinner = ora('Rendering template...').start();
21
+ try {
22
+ // 1. Load template
23
+ const template = await loadTemplate(templatePath);
24
+ // 2. Load context
25
+ const context = await loadContext(options);
26
+ // 3. Create Echo instance
27
+ const echo = createEcho({
28
+ strict: options.strict,
29
+ });
30
+ // 4. Render
31
+ spinner.text = 'Rendering...';
32
+ const result = await echo.render(template, context);
33
+ // 5. Apply post-processing
34
+ let output = result;
35
+ if (options.trim) {
36
+ output = output.trim();
37
+ }
38
+ spinner.succeed('Template rendered successfully');
39
+ // 6. Output result
40
+ if (options.output) {
41
+ await writeFile(options.output, output, 'utf-8');
42
+ console.log(chalk.green(`Output written to: ${options.output}`));
43
+ }
44
+ else {
45
+ console.log('\n' + chalk.bold('Output:'));
46
+ console.log(chalk.gray('─'.repeat(40)));
47
+ console.log(output);
48
+ console.log(chalk.gray('─'.repeat(40)));
49
+ }
50
+ }
51
+ catch (error) {
52
+ spinner.fail('Render failed');
53
+ console.error(chalk.red(error.message));
54
+ process.exit(1);
55
+ }
56
+ }
57
+ // =============================================================================
58
+ // HELPERS
59
+ // =============================================================================
60
+ /**
61
+ * Load template from file.
62
+ */
63
+ async function loadTemplate(path) {
64
+ try {
65
+ return await readFile(path, 'utf-8');
66
+ }
67
+ catch (error) {
68
+ throw new Error(`Failed to load template: ${path}`);
69
+ }
70
+ }
71
+ /**
72
+ * Load context from options.
73
+ */
74
+ async function loadContext(options) {
75
+ // From --context JSON string
76
+ if (options.context) {
77
+ try {
78
+ return JSON.parse(options.context);
79
+ }
80
+ catch {
81
+ throw new Error('Invalid JSON in --context option');
82
+ }
83
+ }
84
+ // From --context-file
85
+ if (options.contextFile) {
86
+ try {
87
+ const content = await readFile(options.contextFile, 'utf-8');
88
+ return JSON.parse(content);
89
+ }
90
+ catch {
91
+ throw new Error(`Failed to load context file: ${options.contextFile}`);
92
+ }
93
+ }
94
+ // No context provided
95
+ return {};
96
+ }
97
+ // =============================================================================
98
+ // IMPLEMENTATION NOTES
99
+ // =============================================================================
100
+ /*
101
+ NEXT STEPS TO IMPLEMENT:
102
+
103
+ 1. STREAMING OUTPUT
104
+ For large templates, stream the output instead of buffering.
105
+
106
+ 2. ENVIRONMENT VARIABLES
107
+ Support reading context from environment:
108
+ --env prefix=MY_VAR_
109
+
110
+ 3. MULTIPLE TEMPLATES
111
+ Support glob patterns for batch rendering:
112
+ echopdk render "templates/*.echo" --context-file context.json --output-dir dist/
113
+
114
+ 4. STDIN INPUT
115
+ Support reading template from stdin:
116
+ cat template.echo | echopdk render - --context '{"name": "Alice"}'
117
+
118
+ 5. PROGRESS REPORTING
119
+ For AI judge conditions, show progress:
120
+ "Evaluating AI conditions... (3/5)"
121
+ */
122
+ //# sourceMappingURL=render.js.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AAC;QAChE,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED,sBAAsB;IACtB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAA4B,CAAC;QACxD,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,gCAAgC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAED,sBAAsB;IACtB,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;EAqBE"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @fileoverview Validate Command - Validate Echo template syntax
3
+ *
4
+ * Usage:
5
+ * echopdk validate template.echo
6
+ * echopdk validate template.echo --strict
7
+ */
8
+ interface ValidateOptions {
9
+ strict?: boolean;
10
+ }
11
+ /**
12
+ * Validate command handler.
13
+ */
14
+ export declare function validateCommand(templatePath: string, options: ValidateOptions): Promise<void>;
15
+ export {};
16
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,UAAU,eAAe;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAMD;;GAEG;AACH,wBAAsB,eAAe,CACnC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,IAAI,CAAC,CAkDf"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @fileoverview Validate Command - Validate Echo template syntax
3
+ *
4
+ * Usage:
5
+ * echopdk validate template.echo
6
+ * echopdk validate template.echo --strict
7
+ */
8
+ import { readFile } from 'fs/promises';
9
+ import { createEcho } from '@goreal-ai/echo-pdk';
10
+ import chalk from 'chalk';
11
+ // =============================================================================
12
+ // COMMAND IMPLEMENTATION
13
+ // =============================================================================
14
+ /**
15
+ * Validate command handler.
16
+ */
17
+ export async function validateCommand(templatePath, options) {
18
+ try {
19
+ // 1. Load template
20
+ const template = await loadTemplate(templatePath);
21
+ // 2. Create Echo instance
22
+ const echo = createEcho();
23
+ // 3. Validate
24
+ const result = echo.validate(template);
25
+ // 4. Report results
26
+ if (result.valid) {
27
+ console.log(chalk.green('✓') + ` ${templatePath} is valid`);
28
+ // Show warnings if any
29
+ if (result.warnings.length > 0) {
30
+ console.log('\n' + chalk.yellow('Warnings:'));
31
+ for (const warning of result.warnings) {
32
+ printDiagnostic(warning, 'warning', template);
33
+ }
34
+ if (options.strict) {
35
+ console.log(chalk.yellow('\n⚠ Warnings treated as errors in strict mode'));
36
+ process.exit(1);
37
+ }
38
+ }
39
+ }
40
+ else {
41
+ console.log(chalk.red('✗') + ` ${templatePath} has errors`);
42
+ console.log('\n' + chalk.red('Errors:'));
43
+ for (const error of result.errors) {
44
+ printDiagnostic(error, 'error', template);
45
+ }
46
+ if (result.warnings.length > 0) {
47
+ console.log('\n' + chalk.yellow('Warnings:'));
48
+ for (const warning of result.warnings) {
49
+ printDiagnostic(warning, 'warning', template);
50
+ }
51
+ }
52
+ process.exit(1);
53
+ }
54
+ }
55
+ catch (error) {
56
+ console.error(chalk.red('Error: ') + error.message);
57
+ process.exit(1);
58
+ }
59
+ }
60
+ // =============================================================================
61
+ // HELPERS
62
+ // =============================================================================
63
+ /**
64
+ * Load template from file.
65
+ */
66
+ async function loadTemplate(path) {
67
+ try {
68
+ return await readFile(path, 'utf-8');
69
+ }
70
+ catch (error) {
71
+ throw new Error(`Failed to load template: ${path}`);
72
+ }
73
+ }
74
+ /**
75
+ * Print a diagnostic (error or warning) with source context.
76
+ */
77
+ function printDiagnostic(diagnostic, type, source) {
78
+ const color = type === 'error' ? chalk.red : chalk.yellow;
79
+ const symbol = type === 'error' ? '✗' : '⚠';
80
+ console.log(`\n${color(symbol)} [${diagnostic.code}] ${diagnostic.message}`);
81
+ if (diagnostic.location) {
82
+ const { startLine, startColumn } = diagnostic.location;
83
+ const lines = source.split('\n');
84
+ const line = lines[startLine - 1];
85
+ if (line) {
86
+ console.log(chalk.gray(` ${startLine} │ `) + line);
87
+ console.log(chalk.gray(` │ `) + ' '.repeat(startColumn - 1) + color('^'));
88
+ }
89
+ }
90
+ }
91
+ // =============================================================================
92
+ // IMPLEMENTATION NOTES
93
+ // =============================================================================
94
+ /*
95
+ NEXT STEPS TO IMPLEMENT:
96
+
97
+ 1. GLOB PATTERNS
98
+ Support validating multiple files:
99
+ echopdk validate "templates/*.echo"
100
+
101
+ 2. JSON/SARIF OUTPUT
102
+ For CI integration:
103
+ echopdk validate template.echo --format json
104
+ echopdk validate template.echo --format sarif
105
+
106
+ 3. FIX SUGGESTIONS
107
+ Some errors might be auto-fixable:
108
+ echopdk validate template.echo --fix
109
+
110
+ 4. WATCH MODE
111
+ Re-validate on file changes:
112
+ echopdk validate template.echo --watch
113
+
114
+ 5. CUSTOM RULES
115
+ Load validation rules from config:
116
+ echopdk validate template.echo --config echo.config.yaml
117
+ */
118
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,gFAAgF;AAChF,yBAAyB;AACzB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,YAAoB,EACpB,OAAwB;IAExB,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CAAC,KAAK,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IAE7E,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;QACxB,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,QAAQ,CAAC;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;QAElC,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACpD,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAChE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;EAuBE"}
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview Echo CLI - Command-line interface
4
+ *
5
+ * This is the main entry point for the Echo CLI.
6
+ * It uses Commander.js to define commands and options.
7
+ *
8
+ * COMMANDS:
9
+ * - render: Render a template with context
10
+ * - validate: Validate template syntax
11
+ * - debug: Show AST and evaluation trace
12
+ * - watch: Watch mode for development
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG"}
package/dist/index.js ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview Echo CLI - Command-line interface
4
+ *
5
+ * This is the main entry point for the Echo CLI.
6
+ * It uses Commander.js to define commands and options.
7
+ *
8
+ * COMMANDS:
9
+ * - render: Render a template with context
10
+ * - validate: Validate template syntax
11
+ * - debug: Show AST and evaluation trace
12
+ * - watch: Watch mode for development
13
+ */
14
+ import { Command } from 'commander';
15
+ import { renderCommand } from './commands/render.js';
16
+ import { validateCommand } from './commands/validate.js';
17
+ // =============================================================================
18
+ // CLI SETUP
19
+ // =============================================================================
20
+ const program = new Command();
21
+ program
22
+ .name('echopdk')
23
+ .description('Echo PDK - Dynamic prompt templating DSL')
24
+ .version('0.1.0');
25
+ // =============================================================================
26
+ // COMMANDS
27
+ // =============================================================================
28
+ // Render command
29
+ program
30
+ .command('render <template>')
31
+ .description('Render an Echo template with context')
32
+ .option('-c, --context <json>', 'Context as JSON string')
33
+ .option('-f, --context-file <path>', 'Path to context JSON file')
34
+ .option('-o, --output <path>', 'Output file path (stdout if not specified)')
35
+ .option('--strict', 'Fail on any error', false)
36
+ .option('--trim', 'Trim whitespace from output', false)
37
+ .action(renderCommand);
38
+ // Validate command
39
+ program
40
+ .command('validate <template>')
41
+ .description('Validate an Echo template syntax')
42
+ .option('--strict', 'Treat warnings as errors', false)
43
+ .action(validateCommand);
44
+ // Debug command
45
+ program
46
+ .command('debug <template>')
47
+ .description('Show AST and evaluation trace for a template')
48
+ .option('-c, --context <json>', 'Context as JSON string')
49
+ .option('-f, --context-file <path>', 'Path to context JSON file')
50
+ .option('--ast', 'Show only the AST')
51
+ .option('--tokens', 'Show only the tokens')
52
+ .action(async (template, options) => {
53
+ // TODO: Implement debug command
54
+ console.log('Debug command not yet implemented');
55
+ console.log('Template:', template);
56
+ console.log('Options:', options);
57
+ });
58
+ // Watch command
59
+ program
60
+ .command('watch <template>')
61
+ .description('Watch mode - re-render on file changes')
62
+ .option('-c, --context <json>', 'Context as JSON string')
63
+ .option('-f, --context-file <path>', 'Path to context JSON file')
64
+ .action(async (template, options) => {
65
+ // TODO: Implement watch command
66
+ console.log('Watch command not yet implemented');
67
+ console.log('Template:', template);
68
+ console.log('Options:', options);
69
+ });
70
+ // =============================================================================
71
+ // RUN
72
+ // =============================================================================
73
+ program.parse();
74
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,0CAA0C,CAAC;KACvD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAEhF,iBAAiB;AACjB,OAAO;KACJ,OAAO,CAAC,mBAAmB,CAAC;KAC5B,WAAW,CAAC,sCAAsC,CAAC;KACnD,MAAM,CAAC,sBAAsB,EAAE,wBAAwB,CAAC;KACxD,MAAM,CAAC,2BAA2B,EAAE,2BAA2B,CAAC;KAChE,MAAM,CAAC,qBAAqB,EAAE,4CAA4C,CAAC;KAC3E,MAAM,CAAC,UAAU,EAAE,mBAAmB,EAAE,KAAK,CAAC;KAC9C,MAAM,CAAC,QAAQ,EAAE,6BAA6B,EAAE,KAAK,CAAC;KACtD,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,mBAAmB;AACnB,OAAO;KACJ,OAAO,CAAC,qBAAqB,CAAC;KAC9B,WAAW,CAAC,kCAAkC,CAAC;KAC/C,MAAM,CAAC,UAAU,EAAE,0BAA0B,EAAE,KAAK,CAAC;KACrD,MAAM,CAAC,eAAe,CAAC,CAAC;AAE3B,gBAAgB;AAChB,OAAO;KACJ,OAAO,CAAC,kBAAkB,CAAC;KAC3B,WAAW,CAAC,8CAA8C,CAAC;KAC3D,MAAM,CAAC,sBAAsB,EAAE,wBAAwB,CAAC;KACxD,MAAM,CAAC,2BAA2B,EAAE,2BAA2B,CAAC;KAChE,MAAM,CAAC,OAAO,EAAE,mBAAmB,CAAC;KACpC,MAAM,CAAC,UAAU,EAAE,sBAAsB,CAAC;KAC1C,MAAM,CAAC,KAAK,EAAE,QAAgB,EAAE,OAAgC,EAAE,EAAE;IACnE,gCAAgC;IAChC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC;AAEL,gBAAgB;AAChB,OAAO;KACJ,OAAO,CAAC,kBAAkB,CAAC;KAC3B,WAAW,CAAC,wCAAwC,CAAC;KACrD,MAAM,CAAC,sBAAsB,EAAE,wBAAwB,CAAC;KACxD,MAAM,CAAC,2BAA2B,EAAE,2BAA2B,CAAC;KAChE,MAAM,CAAC,KAAK,EAAE,QAAgB,EAAE,OAAgC,EAAE,EAAE;IACnE,gCAAgC;IAChC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC;AAEL,gFAAgF;AAChF,MAAM;AACN,gFAAgF;AAEhF,OAAO,CAAC,KAAK,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@goreal-ai/echo-pdk-cli",
3
+ "version": "0.1.0",
4
+ "description": "Echo PDK command-line interface",
5
+ "type": "module",
6
+ "bin": {
7
+ "echopdk": "./dist/index.js"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "files": [
12
+ "dist",
13
+ "README.md"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/GoReal-AI/echo-pdk.git",
18
+ "directory": "packages/cli"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/GoReal-AI/echo-pdk/issues"
22
+ },
23
+ "homepage": "https://github.com/GoReal-AI/echo-pdk#readme",
24
+ "author": "GoReal.AI",
25
+ "dependencies": {
26
+ "commander": "^12.0.0",
27
+ "chalk": "^5.3.0",
28
+ "ora": "^8.0.0",
29
+ "@goreal-ai/echo-pdk": "0.2.3"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^20.10.0",
33
+ "typescript": "^5.3.0",
34
+ "vitest": "^2.0.0"
35
+ },
36
+ "keywords": [
37
+ "echo",
38
+ "pdk",
39
+ "cli",
40
+ "prompt"
41
+ ],
42
+ "license": "MIT",
43
+ "scripts": {
44
+ "build": "tsc",
45
+ "dev": "tsc --watch",
46
+ "test": "vitest run",
47
+ "test:watch": "vitest",
48
+ "lint": "eslint src --ext .ts",
49
+ "lint:fix": "eslint src --ext .ts --fix",
50
+ "typecheck": "tsc --noEmit",
51
+ "clean": "rm -rf dist"
52
+ }
53
+ }