@musashishao/agent-kit 1.11.0 → 1.11.1

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.
@@ -30,7 +30,29 @@ from datetime import datetime
30
30
  # Constants
31
31
  # ============================================================================
32
32
 
33
- VERSION = "1.0.0"
33
+ def get_version() -> str:
34
+ """Get version from package.json to stay in sync with npm."""
35
+ try:
36
+ # Try to find package.json in parent directories
37
+ script_dir = Path(__file__).parent
38
+ for i in range(5): # Go up max 5 levels
39
+ pkg_path = script_dir / "package.json"
40
+ if pkg_path.exists():
41
+ with open(pkg_path, "r") as f:
42
+ return json.load(f).get("version", "1.0.0")
43
+ script_dir = script_dir.parent
44
+
45
+ # Try from .agent's parent (typical structure)
46
+ agent_parent = Path(__file__).parent.parent.parent
47
+ pkg_path = agent_parent / "package.json"
48
+ if pkg_path.exists():
49
+ with open(pkg_path, "r") as f:
50
+ return json.load(f).get("version", "1.0.0")
51
+ except Exception:
52
+ pass
53
+ return "1.0.0"
54
+
55
+ VERSION = get_version()
34
56
  BANNER = """
35
57
  ___ __ __ __ _ __
36
58
  / | ____ ____ ____ / /_ / //_/(_) /_
package/bin/agent-kit CHANGED
@@ -1,38 +1,139 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawn } = require('child_process');
3
+ /**
4
+ * Agent Kit CLI Entry Point
5
+ *
6
+ * Smart router that directs commands to the appropriate handler:
7
+ * - Basic commands (init, status, agents, skills, workflows, etc.) → cli.js
8
+ * - AI/Advanced commands (ai, memory, sync, autofix, etc.) → ak_cli.py
9
+ */
10
+
11
+ const { spawn, spawnSync } = require('child_process');
4
12
  const path = require('path');
5
13
  const fs = require('fs');
6
14
 
7
- // Path to the Python CLI script
8
- const scriptPath = path.join(__dirname, '..', '.agent', 'scripts', 'ak_cli.py');
15
+ // Get version from package.json
16
+ const packageJson = require('../package.json');
17
+ const VERSION = packageJson.version;
18
+
19
+ // Commands handled by cli.js (Node.js)
20
+ const CLI_JS_COMMANDS = [
21
+ 'init',
22
+ 'update',
23
+ 'status',
24
+ 'agents',
25
+ 'skills',
26
+ 'workflows',
27
+ 'doctor',
28
+ 'codex',
29
+ 'setup-codex',
30
+ 'mcp',
31
+ 'set-lang',
32
+ 'ai', // ai is a meta-command handled by cli.js which calls Python for subcommands
33
+ '--help', '-h',
34
+ '--version', '-v'
35
+ ];
9
36
 
10
- // Check if Python 3 is available
11
- const pythonCommand = process.platform === 'win32' ? 'python' : 'python3';
37
+ // Commands handled by ak_cli.py (Python) - these are direct subcommands
38
+ const PYTHON_CLI_COMMANDS = [
39
+ 'sync',
40
+ 'memory',
41
+ 'autofix',
42
+ 'dashboard',
43
+ 'setup-notebooklm',
44
+ 'setup-intel-verifier',
45
+ 'setup-memory-mcp',
46
+ 'setup-notion-mcp',
47
+ 'memory-sync',
48
+ 'notebooklm-status',
49
+ 'setup',
50
+ 'install'
51
+ ];
12
52
 
13
- // Forward all arguments
53
+ // Parse arguments
14
54
  const args = process.argv.slice(2);
55
+ const command = args[0];
56
+
57
+ // Special case: no command or help/version
58
+ if (!command || command === '--help' || command === '-h') {
59
+ runCliJs(args);
60
+ } else if (command === '--version' || command === '-v') {
61
+ console.log(`@musashishao/agent-kit v${VERSION}`);
62
+ process.exit(0);
63
+ } else if (CLI_JS_COMMANDS.includes(command)) {
64
+ runCliJs(args);
65
+ } else if (PYTHON_CLI_COMMANDS.includes(command)) {
66
+ runPythonCli(args);
67
+ } else {
68
+ // Unknown command - try cli.js first (it will show error)
69
+ runCliJs(args);
70
+ }
71
+
72
+ /**
73
+ * Run cli.js for basic commands
74
+ */
75
+ function runCliJs(args) {
76
+ const cliPath = path.join(__dirname, 'cli.js');
77
+
78
+ if (!fs.existsSync(cliPath)) {
79
+ console.error('❌ Error: cli.js not found. Package may be corrupted.');
80
+ process.exit(1);
81
+ }
82
+
83
+ // Execute cli.js with all arguments
84
+ require(cliPath);
85
+ }
15
86
 
16
- // Spawn the Python process
17
- const child = spawn(pythonCommand, [scriptPath, ...args], {
18
- stdio: 'inherit'
19
- });
20
-
21
- child.on('error', (err) => {
22
- if (err.code === 'ENOENT') {
23
- console.error(' Error: Python 3 not found. Please install Python 3.10+ to use Agent Kit.');
24
- console.error('Download: https://www.python.org/downloads/');
25
- } else {
26
- console.error('❌ Failed to start Agent Kit CLI:', err.message);
87
+ /**
88
+ * Run ak_cli.py for AI/advanced commands
89
+ */
90
+ function runPythonCli(args) {
91
+ // Try to find the Python script
92
+ const scriptPaths = [
93
+ // When running from installed package
94
+ path.join(__dirname, '..', '.agent', 'scripts', 'ak_cli.py'),
95
+ // When running from project with .agent folder
96
+ path.join(process.cwd(), '.agent', 'scripts', 'ak_cli.py')
97
+ ];
98
+
99
+ let scriptPath = null;
100
+ for (const p of scriptPaths) {
101
+ if (fs.existsSync(p)) {
102
+ scriptPath = p;
103
+ break;
104
+ }
27
105
  }
28
- process.exit(1);
29
- });
30
-
31
- child.on('exit', (code) => {
32
- if (code === 1) {
33
- // Suggest dependency check if generic failure
34
- // We can't easily detect ImportErrors from exit code alone without reading stderr,
35
- // but stdio inherit is better for UI.
106
+
107
+ if (!scriptPath) {
108
+ console.error('❌ Error: AI CLI script not found.');
109
+ console.error(' Make sure Agent Kit is properly installed.');
110
+ console.error(' Run: npx @musashishao/agent-kit init');
111
+ process.exit(1);
36
112
  }
37
- process.exit(code);
38
- });
113
+
114
+ // Check if Python 3 is available
115
+ const pythonCommand = process.platform === 'win32' ? 'python' : 'python3';
116
+
117
+ // Pass project root to Python CLI
118
+ const pythonArgs = [scriptPath, '--project-root', process.cwd(), ...args];
119
+
120
+ // Spawn the Python process
121
+ const child = spawn(pythonCommand, pythonArgs, {
122
+ stdio: 'inherit',
123
+ cwd: process.cwd()
124
+ });
125
+
126
+ child.on('error', (err) => {
127
+ if (err.code === 'ENOENT') {
128
+ console.error('❌ Error: Python 3 not found. Please install Python 3.10+ to use Agent Kit AI features.');
129
+ console.error(' Download: https://www.python.org/downloads/');
130
+ } else {
131
+ console.error('❌ Failed to start Agent Kit CLI:', err.message);
132
+ }
133
+ process.exit(1);
134
+ });
135
+
136
+ child.on('exit', (code) => {
137
+ process.exit(code || 0);
138
+ });
139
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@musashishao/agent-kit",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "description": "AI Agent templates - Skills, Agents, Workflows, and AI-Ready Data Infrastructure Gateway",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -14,9 +14,6 @@
14
14
  ".agent/agents",
15
15
  ".agent/dashboard",
16
16
  ".agent/mcp",
17
- ".agent/mcp-gateway/dist",
18
- ".agent/mcp-gateway/package.json",
19
- ".agent/mcp-gateway/src",
20
17
  ".agent/rules",
21
18
  ".agent/scripts",
22
19
  ".agent/skills",