@elaraai/e3-cli 0.0.1-beta.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.md +50 -0
- package/README.md +93 -0
- package/dist/src/cli-test-helpers.d.ts +17 -0
- package/dist/src/cli-test-helpers.d.ts.map +1 -0
- package/dist/src/cli-test-helpers.js +48 -0
- package/dist/src/cli-test-helpers.js.map +1 -0
- package/dist/src/cli.d.ts +7 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +144 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/convert.d.ts +11 -0
- package/dist/src/commands/convert.d.ts.map +1 -0
- package/dist/src/commands/convert.impl.d.ts +30 -0
- package/dist/src/commands/convert.impl.d.ts.map +1 -0
- package/dist/src/commands/convert.impl.js +193 -0
- package/dist/src/commands/convert.impl.js.map +1 -0
- package/dist/src/commands/convert.js +11 -0
- package/dist/src/commands/convert.js.map +1 -0
- package/dist/src/commands/gc.d.ts +12 -0
- package/dist/src/commands/gc.d.ts.map +1 -0
- package/dist/src/commands/gc.js +44 -0
- package/dist/src/commands/gc.js.map +1 -0
- package/dist/src/commands/get.d.ts +11 -0
- package/dist/src/commands/get.d.ts.map +1 -0
- package/dist/src/commands/get.js +60 -0
- package/dist/src/commands/get.js.map +1 -0
- package/dist/src/commands/init.d.ts +9 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +33 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/list.d.ts +9 -0
- package/dist/src/commands/list.d.ts.map +1 -0
- package/dist/src/commands/list.js +54 -0
- package/dist/src/commands/list.js.map +1 -0
- package/dist/src/commands/logs.d.ts +11 -0
- package/dist/src/commands/logs.d.ts.map +1 -0
- package/dist/src/commands/logs.js +179 -0
- package/dist/src/commands/logs.js.map +1 -0
- package/dist/src/commands/package.d.ts +23 -0
- package/dist/src/commands/package.d.ts.map +1 -0
- package/dist/src/commands/package.js +78 -0
- package/dist/src/commands/package.js.map +1 -0
- package/dist/src/commands/run.d.ts +12 -0
- package/dist/src/commands/run.d.ts.map +1 -0
- package/dist/src/commands/run.js +99 -0
- package/dist/src/commands/run.js.map +1 -0
- package/dist/src/commands/set.d.ts +11 -0
- package/dist/src/commands/set.d.ts.map +1 -0
- package/dist/src/commands/set.js +124 -0
- package/dist/src/commands/set.js.map +1 -0
- package/dist/src/commands/start.d.ts +13 -0
- package/dist/src/commands/start.d.ts.map +1 -0
- package/dist/src/commands/start.js +86 -0
- package/dist/src/commands/start.js.map +1 -0
- package/dist/src/commands/status.d.ts +9 -0
- package/dist/src/commands/status.d.ts.map +1 -0
- package/dist/src/commands/status.js +58 -0
- package/dist/src/commands/status.js.map +1 -0
- package/dist/src/commands/workspace.d.ts +30 -0
- package/dist/src/commands/workspace.d.ts.map +1 -0
- package/dist/src/commands/workspace.js +96 -0
- package/dist/src/commands/workspace.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/utils.d.ts +42 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +99 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +45 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Elara AI Pty Ltd
|
|
4
|
+
|
|
5
|
+
## License
|
|
6
|
+
|
|
7
|
+
**Licensor:** Elara AI Pty Ltd
|
|
8
|
+
|
|
9
|
+
**Licensed Work:** @elaraai/e3-cli
|
|
10
|
+
|
|
11
|
+
**Change Date:** Four years from the date of each release
|
|
12
|
+
|
|
13
|
+
**Change License:** AGPL-3.0
|
|
14
|
+
|
|
15
|
+
## Terms
|
|
16
|
+
|
|
17
|
+
The Licensed Work is provided under the terms of the Business Source License 1.1 as detailed below.
|
|
18
|
+
|
|
19
|
+
### Grant of Rights
|
|
20
|
+
|
|
21
|
+
The Licensor grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work.
|
|
22
|
+
|
|
23
|
+
### Production Use Limitation
|
|
24
|
+
|
|
25
|
+
**"Production Use"** means any use by or on behalf of a for-profit entity, other than for evaluation, testing, or development purposes.
|
|
26
|
+
|
|
27
|
+
Production Use requires a separate commercial license from the Licensor.
|
|
28
|
+
|
|
29
|
+
### Change Date
|
|
30
|
+
|
|
31
|
+
On the Change Date (four years after each release), the Licensed Work will be made available under the Change License (AGPL-3.0).
|
|
32
|
+
|
|
33
|
+
### No Warranty
|
|
34
|
+
|
|
35
|
+
THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. THE LICENSOR DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
36
|
+
|
|
37
|
+
## Commercial Licensing
|
|
38
|
+
|
|
39
|
+
To obtain a commercial license for Production Use, contact:
|
|
40
|
+
|
|
41
|
+
**Email:** support@elara.ai
|
|
42
|
+
**Website:** https://elaraai.com
|
|
43
|
+
|
|
44
|
+
## Governing Law
|
|
45
|
+
|
|
46
|
+
This license is governed by the laws of New South Wales, Australia.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
*Elara AI Pty Ltd*
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @elaraai/e3-cli
|
|
2
|
+
|
|
3
|
+
Command-line interface for e3 (East Execution Engine).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @elaraai/e3-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
### Repository
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
e3 init <repo> # Initialize a new repository
|
|
17
|
+
e3 status <repo> # Show repository status
|
|
18
|
+
e3 gc <repo> [--dry-run] # Remove unreferenced objects
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Packages
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
e3 package import <repo> <zip> # Import package from .zip
|
|
25
|
+
e3 package export <repo> <pkg> <zip> # Export package to .zip
|
|
26
|
+
e3 package list <repo> # List installed packages
|
|
27
|
+
e3 package remove <repo> <pkg> # Remove a package
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Workspaces
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
e3 workspace create <repo> <name> # Create empty workspace
|
|
34
|
+
e3 workspace deploy <repo> <ws> <pkg> # Deploy package to workspace
|
|
35
|
+
e3 workspace export <repo> <ws> <zip> # Export workspace as package
|
|
36
|
+
e3 workspace list <repo> # List workspaces
|
|
37
|
+
e3 workspace remove <repo> <ws> # Remove workspace
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Data
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
e3 list <repo> [path] # List workspaces or tree contents
|
|
44
|
+
e3 get <repo> <path> [-f format] # Get dataset value (east/json/beast2)
|
|
45
|
+
e3 set <repo> <path> <file> # Set dataset value from file
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Execution
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
e3 run <repo> <task> [inputs...] # Run task ad-hoc
|
|
52
|
+
e3 start <repo> <ws> # Execute tasks in workspace
|
|
53
|
+
e3 logs <repo> <path> [--follow] # View task logs
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Utilities
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
e3 convert [input] --to <format> # Convert between .east/.json/.beast2
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Example
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Initialize repository and import a package
|
|
66
|
+
e3 init ./my-project
|
|
67
|
+
e3 package import ./my-project ./greeting-pkg-1.0.0.zip
|
|
68
|
+
|
|
69
|
+
# Create workspace and deploy package
|
|
70
|
+
e3 workspace create ./my-project dev
|
|
71
|
+
e3 workspace deploy ./my-project dev greeting-pkg@1.0.0
|
|
72
|
+
|
|
73
|
+
# Set input and run
|
|
74
|
+
e3 set ./my-project dev.inputs.name ./name.east
|
|
75
|
+
e3 start ./my-project dev
|
|
76
|
+
|
|
77
|
+
# Get results
|
|
78
|
+
e3 get ./my-project dev.tasks.shout.output
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Related Repos
|
|
82
|
+
|
|
83
|
+
- **[east](https://github.com/elaraai/east)** - East language core
|
|
84
|
+
- **[east-node](https://github.com/elaraai/east-node)** - Node.js runtime and platform functions
|
|
85
|
+
- **[east-py](https://github.com/elaraai/east-py)** - Python runtime and data science
|
|
86
|
+
|
|
87
|
+
## About Elara
|
|
88
|
+
|
|
89
|
+
e3-cli is developed by [Elara AI](https://elaraai.com/), an AI-powered platform that creates economic digital twins of businesses. e3 powers the execution layer of Elara solutions, enabling durable and efficient execution of East programs across multiple runtimes.
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
BSL 1.1. See [LICENSE.md](./LICENSE.md).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Create a temporary directory for CLI testing
|
|
7
|
+
*/
|
|
8
|
+
export declare function createTestDir(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Remove a temporary test directory
|
|
11
|
+
*/
|
|
12
|
+
export declare function removeTestDir(testDir: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Write a test file to the test directory
|
|
15
|
+
*/
|
|
16
|
+
export declare function writeTestFile(testDir: string, filename: string, content: string | Buffer): string;
|
|
17
|
+
//# sourceMappingURL=cli-test-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-test-helpers.d.ts","sourceRoot":"","sources":["../../src/cli-test-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAKtC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAMnD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,MAAM,GACvB,MAAM,CAIR"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Test helpers for CLI command testing
|
|
7
|
+
*
|
|
8
|
+
* Provides utilities for:
|
|
9
|
+
* - Creating temporary test directories
|
|
10
|
+
* - Writing test input files
|
|
11
|
+
* - Cleaning up after tests
|
|
12
|
+
*/
|
|
13
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
14
|
+
import { join } from 'node:path';
|
|
15
|
+
import { tmpdir } from 'node:os';
|
|
16
|
+
import { writeFileSync } from 'node:fs';
|
|
17
|
+
/**
|
|
18
|
+
* Track parent temp directories for cleanup
|
|
19
|
+
*/
|
|
20
|
+
const tempDirParents = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* Create a temporary directory for CLI testing
|
|
23
|
+
*/
|
|
24
|
+
export function createTestDir() {
|
|
25
|
+
const parentDir = mkdtempSync(join(tmpdir(), 'e3-cli-test-'));
|
|
26
|
+
const testDir = join(parentDir, 'test');
|
|
27
|
+
tempDirParents.set(testDir, parentDir);
|
|
28
|
+
return testDir;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Remove a temporary test directory
|
|
32
|
+
*/
|
|
33
|
+
export function removeTestDir(testDir) {
|
|
34
|
+
const parentDir = tempDirParents.get(testDir);
|
|
35
|
+
if (parentDir) {
|
|
36
|
+
rmSync(parentDir, { recursive: true, force: true });
|
|
37
|
+
tempDirParents.delete(testDir);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Write a test file to the test directory
|
|
42
|
+
*/
|
|
43
|
+
export function writeTestFile(testDir, filename, content) {
|
|
44
|
+
const filePath = join(testDir, filename);
|
|
45
|
+
writeFileSync(filePath, content);
|
|
46
|
+
return filePath;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=cli-test-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-test-helpers.js","sourceRoot":"","sources":["../../src/cli-test-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;GAEG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEjD;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACxC,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACvC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,SAAS,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,QAAgB,EAChB,OAAwB;IAExB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AAEA;;;GAGG"}
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
4
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* e3 CLI - East Execution Engine command-line interface
|
|
8
|
+
*
|
|
9
|
+
* All commands take a repository path as the first argument (`.` for current directory).
|
|
10
|
+
*/
|
|
11
|
+
import { Command } from 'commander';
|
|
12
|
+
import { initCommand } from './commands/init.js';
|
|
13
|
+
import { packageCommand } from './commands/package.js';
|
|
14
|
+
import { workspaceCommand } from './commands/workspace.js';
|
|
15
|
+
import { listCommand } from './commands/list.js';
|
|
16
|
+
import { getCommand } from './commands/get.js';
|
|
17
|
+
import { setCommand } from './commands/set.js';
|
|
18
|
+
import { startCommand } from './commands/start.js';
|
|
19
|
+
import { runCommand } from './commands/run.js';
|
|
20
|
+
import { logsCommand } from './commands/logs.js';
|
|
21
|
+
import { statusCommand } from './commands/status.js';
|
|
22
|
+
import { gcCommand } from './commands/gc.js';
|
|
23
|
+
import { convertCommand } from './commands/convert.js';
|
|
24
|
+
const program = new Command();
|
|
25
|
+
program
|
|
26
|
+
.name('e3')
|
|
27
|
+
.description('East Execution Engine - Execute tasks across multiple runtimes')
|
|
28
|
+
.version('0.0.1-alpha.0');
|
|
29
|
+
// Repository commands
|
|
30
|
+
program
|
|
31
|
+
.command('init <repo>')
|
|
32
|
+
.description('Initialize a new e3 repository')
|
|
33
|
+
.action(initCommand);
|
|
34
|
+
program
|
|
35
|
+
.command('status <repo>')
|
|
36
|
+
.description('Show repository status (packages, workspaces)')
|
|
37
|
+
.action(statusCommand);
|
|
38
|
+
program
|
|
39
|
+
.command('gc <repo>')
|
|
40
|
+
.description('Remove unreferenced objects')
|
|
41
|
+
.option('--dry-run', 'Report what would be deleted without deleting')
|
|
42
|
+
.option('--min-age <ms>', 'Minimum file age in ms before deletion', '60000')
|
|
43
|
+
.action(gcCommand);
|
|
44
|
+
// Package commands
|
|
45
|
+
program
|
|
46
|
+
.command('package')
|
|
47
|
+
.description('Package operations')
|
|
48
|
+
.addCommand(new Command('import')
|
|
49
|
+
.description('Import package from .zip file')
|
|
50
|
+
.argument('<repo>', 'Repository path')
|
|
51
|
+
.argument('<zipPath>', 'Path to .zip file')
|
|
52
|
+
.action(packageCommand.import))
|
|
53
|
+
.addCommand(new Command('export')
|
|
54
|
+
.description('Export package to .zip file')
|
|
55
|
+
.argument('<repo>', 'Repository path')
|
|
56
|
+
.argument('<pkg>', 'Package name[@version]')
|
|
57
|
+
.argument('<zipPath>', 'Output .zip path')
|
|
58
|
+
.action(packageCommand.export))
|
|
59
|
+
.addCommand(new Command('list')
|
|
60
|
+
.description('List installed packages')
|
|
61
|
+
.argument('<repo>', 'Repository path')
|
|
62
|
+
.action(packageCommand.list))
|
|
63
|
+
.addCommand(new Command('remove')
|
|
64
|
+
.description('Remove a package')
|
|
65
|
+
.argument('<repo>', 'Repository path')
|
|
66
|
+
.argument('<pkg>', 'Package name[@version]')
|
|
67
|
+
.action(packageCommand.remove));
|
|
68
|
+
// Workspace commands
|
|
69
|
+
program
|
|
70
|
+
.command('workspace')
|
|
71
|
+
.description('Workspace operations')
|
|
72
|
+
.addCommand(new Command('create')
|
|
73
|
+
.description('Create an empty workspace')
|
|
74
|
+
.argument('<repo>', 'Repository path')
|
|
75
|
+
.argument('<name>', 'Workspace name')
|
|
76
|
+
.action(workspaceCommand.create))
|
|
77
|
+
.addCommand(new Command('deploy')
|
|
78
|
+
.description('Deploy a package to a workspace')
|
|
79
|
+
.argument('<repo>', 'Repository path')
|
|
80
|
+
.argument('<ws>', 'Workspace name')
|
|
81
|
+
.argument('<pkg>', 'Package name[@version]')
|
|
82
|
+
.action(workspaceCommand.deploy))
|
|
83
|
+
.addCommand(new Command('export')
|
|
84
|
+
.description('Export workspace as a package')
|
|
85
|
+
.argument('<repo>', 'Repository path')
|
|
86
|
+
.argument('<ws>', 'Workspace name')
|
|
87
|
+
.argument('<zipPath>', 'Output .zip path')
|
|
88
|
+
.option('--name <name>', 'Package name (default: deployed package name)')
|
|
89
|
+
.option('--version <version>', 'Package version (default: auto-generated)')
|
|
90
|
+
.action(workspaceCommand.export))
|
|
91
|
+
.addCommand(new Command('list')
|
|
92
|
+
.description('List workspaces')
|
|
93
|
+
.argument('<repo>', 'Repository path')
|
|
94
|
+
.action(workspaceCommand.list))
|
|
95
|
+
.addCommand(new Command('remove')
|
|
96
|
+
.description('Remove a workspace')
|
|
97
|
+
.argument('<repo>', 'Repository path')
|
|
98
|
+
.argument('<ws>', 'Workspace name')
|
|
99
|
+
.action(workspaceCommand.remove));
|
|
100
|
+
// Dataset commands
|
|
101
|
+
program
|
|
102
|
+
.command('list <repo> [path]')
|
|
103
|
+
.description('List workspaces or tree contents at path (ws.path.to.tree)')
|
|
104
|
+
.action(listCommand);
|
|
105
|
+
program
|
|
106
|
+
.command('get <repo> <path>')
|
|
107
|
+
.description('Get dataset value at path (ws.path.to.dataset)')
|
|
108
|
+
.option('-f, --format <format>', 'Output format: east, json, beast2', 'east')
|
|
109
|
+
.action(getCommand);
|
|
110
|
+
program
|
|
111
|
+
.command('set <repo> <path> <file>')
|
|
112
|
+
.description('Set dataset value from file (ws.path.to.dataset)')
|
|
113
|
+
.option('--type <typespec>', 'Type specification in .east format (required for .json/.csv files)')
|
|
114
|
+
.action(setCommand);
|
|
115
|
+
// Execution commands
|
|
116
|
+
program
|
|
117
|
+
.command('run <repo> <task> [inputs...]')
|
|
118
|
+
.description('Run task ad-hoc (task format: pkg/task or pkg@version/task)')
|
|
119
|
+
.option('-o, --output <path>', 'Output file path')
|
|
120
|
+
.option('--force', 'Force re-execution even if cached')
|
|
121
|
+
.action(runCommand);
|
|
122
|
+
program
|
|
123
|
+
.command('start <repo> <ws>')
|
|
124
|
+
.description('Execute tasks in a workspace')
|
|
125
|
+
.option('--filter <pattern>', 'Only run tasks matching pattern')
|
|
126
|
+
.option('--concurrency <n>', 'Max concurrent tasks', '4')
|
|
127
|
+
.option('--force', 'Force re-execution even if cached')
|
|
128
|
+
.action(startCommand);
|
|
129
|
+
program
|
|
130
|
+
.command('logs <repo> <path>')
|
|
131
|
+
.description('View task logs (path format: ws or ws.taskName)')
|
|
132
|
+
.option('--follow', 'Follow log output')
|
|
133
|
+
.action(logsCommand);
|
|
134
|
+
// Utility commands
|
|
135
|
+
program
|
|
136
|
+
.command('convert [input]')
|
|
137
|
+
.description('Convert between .east, .json, and .beast2 formats')
|
|
138
|
+
.option('--from <format>', 'Input format: east, json, beast2 (default: auto-detect)')
|
|
139
|
+
.option('--to <format>', 'Output format: east, json, beast2', 'east')
|
|
140
|
+
.option('-o, --output <path>', 'Output file path (default: stdout)')
|
|
141
|
+
.option('--type <typespec>', 'Type specification in .east format')
|
|
142
|
+
.action(convertCommand);
|
|
143
|
+
program.parse();
|
|
144
|
+
//# sourceMappingURL=cli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AC;KAC1B,WAAW,CAAC,mDAAmD,CAAC;KAChE,MAAM,CAAC,iBAAiB,EAAE,yDAAyD,CAAC;KACpF,MAAM,CAAC,eAAe,EAAE,mCAAmC,EAAE,MAAM,CAAC;KACpE,MAAM,CAAC,qBAAqB,EAAE,oCAAoC,CAAC;KACnE,MAAM,CAAC,mBAAmB,EAAE,oCAAoC,CAAC;KACjE,MAAM,CAAC,cAAc,CAAC,CAAC;AAE1B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* e3 convert command - Transform data between .east, .json, and .beast2 formats
|
|
7
|
+
*
|
|
8
|
+
* Re-exports the existing convert logic.
|
|
9
|
+
*/
|
|
10
|
+
export { convertFile as convertCommand } from './convert.impl.js';
|
|
11
|
+
//# sourceMappingURL=convert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/commands/convert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* e3 convert command - Transform data between .east, .json, and .beast2 formats
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Output format type (type is output-only)
|
|
6
|
+
*/
|
|
7
|
+
export type ConvertFormat = 'east' | 'json' | 'beast2' | 'type';
|
|
8
|
+
/**
|
|
9
|
+
* Input format type (no 'type' as input)
|
|
10
|
+
*/
|
|
11
|
+
export type InputFormat = 'east' | 'json' | 'beast2';
|
|
12
|
+
/**
|
|
13
|
+
* Conversion result
|
|
14
|
+
*/
|
|
15
|
+
export interface ConvertResult {
|
|
16
|
+
success: boolean;
|
|
17
|
+
data?: string | Buffer;
|
|
18
|
+
format?: ConvertFormat;
|
|
19
|
+
error?: Error;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Core logic for converting between formats
|
|
23
|
+
* Supports .beast2 (self-describing), .east (with parseInferred or --type), .json (with --type), and stdin
|
|
24
|
+
*/
|
|
25
|
+
export declare function convertCore(inputPath: string | null, toFormat: ConvertFormat, outputPath?: string, typeSpec?: string, fromFormat?: InputFormat): Promise<ConvertResult>;
|
|
26
|
+
/**
|
|
27
|
+
* CLI handler for the convert command
|
|
28
|
+
*/
|
|
29
|
+
export declare function convertFile(inputPath: string | undefined, toFormat?: ConvertFormat, outputPath?: string, typeSpec?: string, fromFormat?: InputFormat): Promise<void>;
|
|
30
|
+
//# sourceMappingURL=convert.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.impl.d.ts","sourceRoot":"","sources":["../../../src/commands/convert.impl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEhE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAcD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,QAAQ,EAAE,aAAa,EACvB,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,aAAa,CAAC,CAmJxB;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,QAAQ,GAAE,aAAsB,EAChC,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* e3 convert command - Transform data between .east, .json, and .beast2 formats
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs/promises';
|
|
5
|
+
import { decodeBeast2, printFor, toJSONFor, parseFor, fromJSONFor, encodeBeast2For, parseInferred, printType, } from '@elaraai/east';
|
|
6
|
+
/**
|
|
7
|
+
* Detect format from file extension
|
|
8
|
+
*/
|
|
9
|
+
function detectFormat(filePath) {
|
|
10
|
+
const ext = filePath.slice(filePath.lastIndexOf('.'));
|
|
11
|
+
if (ext === '.east')
|
|
12
|
+
return 'east';
|
|
13
|
+
if (ext === '.json')
|
|
14
|
+
return 'json';
|
|
15
|
+
if (ext === '.beast2')
|
|
16
|
+
return 'beast2';
|
|
17
|
+
throw new Error(`Cannot detect format from extension: ${ext} (expected .east, .json, or .beast2)`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Core logic for converting between formats
|
|
21
|
+
* Supports .beast2 (self-describing), .east (with parseInferred or --type), .json (with --type), and stdin
|
|
22
|
+
*/
|
|
23
|
+
export async function convertCore(inputPath, toFormat, outputPath, typeSpec, fromFormat) {
|
|
24
|
+
try {
|
|
25
|
+
let type;
|
|
26
|
+
let value;
|
|
27
|
+
let detectedFormat;
|
|
28
|
+
// Read input data
|
|
29
|
+
let inputData;
|
|
30
|
+
if (inputPath === null) {
|
|
31
|
+
// Read from stdin
|
|
32
|
+
const chunks = [];
|
|
33
|
+
for await (const chunk of process.stdin) {
|
|
34
|
+
chunks.push(chunk);
|
|
35
|
+
}
|
|
36
|
+
inputData = Buffer.concat(chunks);
|
|
37
|
+
// Detect format if not explicitly specified
|
|
38
|
+
if (fromFormat) {
|
|
39
|
+
detectedFormat = fromFormat;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Try to detect format from content
|
|
43
|
+
if (inputData.length > 0 && inputData[0] === 0x42) {
|
|
44
|
+
// Beast2 files typically start with 'B' (0x42) magic byte
|
|
45
|
+
detectedFormat = 'beast2';
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// Assume text format - default to .east unless explicitly JSON-like
|
|
49
|
+
const content = inputData.toString('utf-8').trim();
|
|
50
|
+
// Only treat as JSON if it looks like a JSON object with quotes around keys
|
|
51
|
+
if (content.startsWith('{') && content.includes('"')) {
|
|
52
|
+
detectedFormat = 'json';
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// Default to .east (handles arrays, structs, primitives, etc.)
|
|
56
|
+
detectedFormat = 'east';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// Read from file
|
|
63
|
+
inputData = await fs.readFile(inputPath);
|
|
64
|
+
// Use explicit format if provided, otherwise detect from extension
|
|
65
|
+
if (fromFormat) {
|
|
66
|
+
detectedFormat = fromFormat;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
detectedFormat = detectFormat(inputPath);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Parse type specification if provided (in .east format)
|
|
73
|
+
let providedType;
|
|
74
|
+
if (typeSpec) {
|
|
75
|
+
const [parsedType, _] = parseInferred(typeSpec);
|
|
76
|
+
providedType = parsedType;
|
|
77
|
+
}
|
|
78
|
+
// Decode input based on format
|
|
79
|
+
if (detectedFormat === 'beast2') {
|
|
80
|
+
// Beast2 is self-describing
|
|
81
|
+
const decoded = decodeBeast2(inputData);
|
|
82
|
+
type = decoded.type;
|
|
83
|
+
value = decoded.value;
|
|
84
|
+
}
|
|
85
|
+
else if (detectedFormat === 'east') {
|
|
86
|
+
// For .east, try parseInferred first, then use providedType
|
|
87
|
+
const content = inputData.toString('utf-8');
|
|
88
|
+
if (providedType) {
|
|
89
|
+
// Use provided type
|
|
90
|
+
const parser = parseFor(providedType);
|
|
91
|
+
const result = parser(content);
|
|
92
|
+
if (!result.success) {
|
|
93
|
+
throw new Error(`Failed to parse .east with provided type: ${result.error}`);
|
|
94
|
+
}
|
|
95
|
+
type = providedType;
|
|
96
|
+
value = result.value;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
// Use parseInferred
|
|
100
|
+
const [parsedType, parsedValue] = parseInferred(content);
|
|
101
|
+
type = parsedType;
|
|
102
|
+
value = parsedValue;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// JSON format - requires type
|
|
107
|
+
if (!providedType) {
|
|
108
|
+
throw new Error('JSON format requires --type to be specified');
|
|
109
|
+
}
|
|
110
|
+
const content = inputData.toString('utf-8');
|
|
111
|
+
const jsonValue = JSON.parse(content);
|
|
112
|
+
const fromJSON = fromJSONFor(providedType);
|
|
113
|
+
type = providedType;
|
|
114
|
+
value = fromJSON(jsonValue);
|
|
115
|
+
}
|
|
116
|
+
// If already in target format and no output path, just return
|
|
117
|
+
// (but not if outputting type, which is always computed)
|
|
118
|
+
if (detectedFormat === toFormat && !outputPath && inputPath !== null) {
|
|
119
|
+
return {
|
|
120
|
+
success: true,
|
|
121
|
+
data: inputData,
|
|
122
|
+
format: toFormat,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
// Encode to target format
|
|
126
|
+
let outputData;
|
|
127
|
+
if (toFormat === 'type') {
|
|
128
|
+
// Output the type instead of the value (always in .east format)
|
|
129
|
+
const typeString = printType(type);
|
|
130
|
+
outputData = typeString;
|
|
131
|
+
}
|
|
132
|
+
else if (toFormat === 'east') {
|
|
133
|
+
const printer = printFor(type);
|
|
134
|
+
outputData = printer(value);
|
|
135
|
+
}
|
|
136
|
+
else if (toFormat === 'json') {
|
|
137
|
+
const toJSON = toJSONFor(type);
|
|
138
|
+
const jsonResult = toJSON(value);
|
|
139
|
+
outputData = JSON.stringify(jsonResult, null, 2);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// beast2
|
|
143
|
+
const encoder = encodeBeast2For(type);
|
|
144
|
+
outputData = Buffer.from(encoder(value));
|
|
145
|
+
}
|
|
146
|
+
// Write to output file if specified
|
|
147
|
+
if (outputPath) {
|
|
148
|
+
if (outputData instanceof Buffer) {
|
|
149
|
+
await fs.writeFile(outputPath, outputData);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
await fs.writeFile(outputPath, outputData, 'utf-8');
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
success: true,
|
|
156
|
+
format: toFormat,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
success: true,
|
|
161
|
+
data: outputData,
|
|
162
|
+
format: toFormat,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
return {
|
|
167
|
+
success: false,
|
|
168
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* CLI handler for the convert command
|
|
174
|
+
*/
|
|
175
|
+
export async function convertFile(inputPath, toFormat = 'east', outputPath, typeSpec, fromFormat) {
|
|
176
|
+
// If no input path, use stdin
|
|
177
|
+
const actualInputPath = inputPath === undefined || inputPath === '-' ? null : inputPath;
|
|
178
|
+
const result = await convertCore(actualInputPath, toFormat, outputPath, typeSpec, fromFormat);
|
|
179
|
+
if (!result.success) {
|
|
180
|
+
console.error(`Error: Failed to convert: ${result.error?.message}`);
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
// Output the data to stdout if no output file specified
|
|
184
|
+
if (!outputPath && result.data) {
|
|
185
|
+
if (result.data instanceof Buffer) {
|
|
186
|
+
process.stdout.write(result.data);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
console.log(result.data);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=convert.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.impl.js","sourceRoot":"","sources":["../../../src/commands/convert.impl.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,WAAW,EACX,eAAe,EACf,aAAa,EAEb,SAAS,GACV,MAAM,eAAe,CAAC;AAsBvB;;GAEG;AACH,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,IAAI,GAAG,KAAK,OAAO;QAAE,OAAO,MAAM,CAAC;IACnC,IAAI,GAAG,KAAK,OAAO;QAAE,OAAO,MAAM,CAAC;IACnC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAEvC,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,sCAAsC,CAAC,CAAC;AACrG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,SAAwB,EACxB,QAAuB,EACvB,UAAmB,EACnB,QAAiB,EACjB,UAAwB;IAExB,IAAI,CAAC;QACH,IAAI,IAAS,CAAC;QACd,IAAI,KAAU,CAAC;QACf,IAAI,cAA2B,CAAC;QAEhC,kBAAkB;QAClB,IAAI,SAAiB,CAAC;QACtB,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACvB,kBAAkB;YAClB,MAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,IAAI,KAAK,EAAE,MAAM,KAA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,EAAE,CAAC;QAC/B,IAAI,MAAM,CAAC,IAAI,YAAY,MAAM,EAAE,CAAC;YAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* e3 convert command - Transform data between .east, .json, and .beast2 formats
|
|
7
|
+
*
|
|
8
|
+
* Re-exports the existing convert logic.
|
|
9
|
+
*/
|
|
10
|
+
export { convertFile as convertCommand } from './convert.impl.js';
|
|
11
|
+
//# sourceMappingURL=convert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../../../src/commands/convert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|