openagentflow 0.1.2 → 0.1.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/cli/index.js CHANGED
@@ -17,11 +17,13 @@
17
17
  * langgraph Generate executable LangGraph Python code
18
18
  */
19
19
 
20
- import { readFileSync, writeFileSync, existsSync, unlinkSync } from 'fs';
20
+ import { readFileSync, writeFileSync, existsSync, unlinkSync, realpathSync } from 'fs';
21
21
  import { resolve, basename, join } from 'path';
22
+ import { fileURLToPath } from 'url';
22
23
  import { execSync, spawn } from 'child_process';
23
24
  import os from 'os';
24
25
  import { Compiler } from '../compiler/compiler.js';
26
+ import { VERSION } from '../compiler/version.js';
25
27
  import { LangGraphAdapter } from '../adapters/langgraph/index.js';
26
28
  import { resolveEnvHierarchy, setupAuth } from './env.js';
27
29
 
@@ -41,7 +43,7 @@ const colors = {
41
43
  // ─── Helpers ───────────────────────────────────────────────────────────────────
42
44
 
43
45
  function printBanner() {
44
- console.log(`${colors.cyan}${colors.bold}OpenAgentFlow${colors.reset} ${colors.dim}v0.1.0${colors.reset}`);
46
+ console.log(`${colors.cyan}${colors.bold}OpenAgentFlow${colors.reset} ${colors.dim}v${VERSION}${colors.reset}`);
45
47
  console.log();
46
48
  }
47
49
 
@@ -456,17 +458,27 @@ function cmdRun(filePath, flags, positional = []) {
456
458
  }
457
459
  }
458
460
 
459
- function getPythonCommand() {
461
+ export function getPythonCommand() {
460
462
  if (process.env.VIRTUAL_ENV) {
461
463
  const venvWin = join(process.env.VIRTUAL_ENV, 'Scripts', 'python.exe');
462
464
  const venvPosix = join(process.env.VIRTUAL_ENV, 'bin', 'python');
463
465
  if (existsSync(venvWin)) return venvWin;
464
466
  if (existsSync(venvPosix)) return venvPosix;
465
467
  }
466
- const localWin = join(process.cwd(), '.venv', 'Scripts', 'python.exe');
467
- const localPosix = join(process.cwd(), '.venv', 'bin', 'python');
468
- if (existsSync(localWin)) return localWin;
469
- if (existsSync(localPosix)) return localPosix;
468
+ for (const venvDir of ['.venv', 'venv']) {
469
+ const localWin = join(process.cwd(), venvDir, 'Scripts', 'python.exe');
470
+ const localPosix = join(process.cwd(), venvDir, 'bin', 'python');
471
+ if (existsSync(localWin)) return localWin;
472
+ if (existsSync(localPosix)) return localPosix;
473
+ }
474
+ for (const cmd of ['python3', 'python']) {
475
+ try {
476
+ execSync(`${cmd} --version`, { stdio: 'ignore' });
477
+ return cmd;
478
+ } catch (e) {
479
+ // try next
480
+ }
481
+ }
470
482
  return 'python';
471
483
  }
472
484
 
@@ -535,7 +547,7 @@ function main() {
535
547
  }
536
548
 
537
549
  if (rawArgs.includes('--version') || rawArgs.includes('-v')) {
538
- console.log('0.1.0');
550
+ console.log(VERSION);
539
551
  process.exit(0);
540
552
  }
541
553
 
@@ -577,4 +589,15 @@ function main() {
577
589
  }
578
590
  }
579
591
 
580
- main();
592
+ let isMain = false;
593
+ try {
594
+ if (process.argv[1]) {
595
+ const argPath = realpathSync(resolve(process.argv[1]));
596
+ const modPath = realpathSync(resolve(fileURLToPath(import.meta.url)));
597
+ isMain = argPath === modPath;
598
+ }
599
+ } catch (e) {}
600
+
601
+ if (isMain) {
602
+ main();
603
+ }
package/compiler/index.js CHANGED
@@ -5,3 +5,4 @@
5
5
  export { Compiler, CompilationResult } from './compiler.js';
6
6
  export { SemanticValidator, Diagnostic, ValidationResult } from './validator.js';
7
7
  export { IRGenerator } from './ir-generator.js';
8
+ export { VERSION, getVersion } from './version.js';
@@ -7,7 +7,9 @@
7
7
  * Pipeline: Validated AST → [IR Generator] → IR (JSON)
8
8
  */
9
9
 
10
- const IR_VERSION = '0.1.0';
10
+ import { VERSION } from './version.js';
11
+
12
+ const IR_VERSION = VERSION;
11
13
 
12
14
  export class IRGenerator {
13
15
  /**
@@ -0,0 +1,26 @@
1
+ /**
2
+ * OpenAgentFlow Version Utility
3
+ *
4
+ * Dynamically loads and caches the current version from package.json
5
+ * to ensure a single source of truth across the compiler, CLI, and adapters.
6
+ */
7
+
8
+ import { readFileSync } from 'fs';
9
+ import { resolve, dirname } from 'path';
10
+ import { fileURLToPath } from 'url';
11
+
12
+ let cachedVersion = null;
13
+
14
+ export function getVersion() {
15
+ if (cachedVersion !== null) return cachedVersion;
16
+ try {
17
+ const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
18
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
19
+ cachedVersion = pkg.version || '0.1.0';
20
+ } catch {
21
+ cachedVersion = '0.1.0';
22
+ }
23
+ return cachedVersion;
24
+ }
25
+
26
+ export const VERSION = getVersion();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openagentflow",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "An open, portable specification for describing AI agent workflows using a human-readable text language.",
5
5
  "type": "module",
6
6
  "main": "compiler/index.js",
@@ -24,6 +24,9 @@
24
24
  ],
25
25
  "scripts": {
26
26
  "test": "node --test tests/**/*.test.js",
27
+ "test:update-snapshots": "node -e \"process.env.UPDATE_SNAPSHOTS='1'; import('./tests/snapshot.test.js')\"",
28
+ "preversion": "npm test",
29
+ "version": "npm run test:update-snapshots && git add tests/snapshots",
27
30
  "oaf": "node cli/index.js"
28
31
  },
29
32
  "keywords": [
@@ -37,6 +40,18 @@
37
40
  "openagentflow"
38
41
  ],
39
42
  "license": "MIT",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/OpenAgentFlow/OpenAgentFlow.git"
46
+ },
47
+ "bugs": {
48
+ "url": "https://github.com/OpenAgentFlow/OpenAgentFlow/issues"
49
+ },
50
+ "homepage": "https://github.com/OpenAgentFlow/OpenAgentFlow#readme",
51
+ "publishConfig": {
52
+ "access": "public",
53
+ "provenance": true
54
+ },
40
55
  "engines": {
41
56
  "node": ">=18.0.0"
42
57
  }