@musashishao/agent-kit 1.11.0 → 1.11.2
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/.agent/scripts/ak_cli.py +23 -1
- package/.agent/scripts/setup_notebooklm_mcp.py +72 -5
- package/bin/agent-kit +128 -27
- package/package.json +1 -4
package/.agent/scripts/ak_cli.py
CHANGED
|
@@ -30,7 +30,29 @@ from datetime import datetime
|
|
|
30
30
|
# Constants
|
|
31
31
|
# ============================================================================
|
|
32
32
|
|
|
33
|
-
|
|
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
|
/ | ____ ____ ____ / /_ / //_/(_) /_
|
|
@@ -43,7 +43,7 @@ def get_platform_info() -> Dict[str, Path]:
|
|
|
43
43
|
"vscode_config": home / ".vscode/mcp.json",
|
|
44
44
|
"agent_kit_config": cwd / ".agent/mcp/config/mcp-config.json",
|
|
45
45
|
"antigravity_config": home / ".gemini/antigravity/mcp_config.json",
|
|
46
|
-
"codex_config": home / ".codex/
|
|
46
|
+
"codex_config": home / ".codex/config.toml", # Codex uses TOML format
|
|
47
47
|
"python_exe": "python",
|
|
48
48
|
"pip_exe": "pip",
|
|
49
49
|
}
|
|
@@ -56,7 +56,7 @@ def get_platform_info() -> Dict[str, Path]:
|
|
|
56
56
|
"vscode_config": home / ".vscode/mcp.json",
|
|
57
57
|
"agent_kit_config": cwd / ".agent/mcp/config/mcp-config.json",
|
|
58
58
|
"antigravity_config": Path(os.environ.get("LOCALAPPDATA", home)) / "Google/Antigravity/mcp_config.json",
|
|
59
|
-
"codex_config": Path(os.environ.get("LOCALAPPDATA", home)) / "Codex/
|
|
59
|
+
"codex_config": Path(os.environ.get("LOCALAPPDATA", home)) / "Codex/config.toml", # Codex uses TOML
|
|
60
60
|
"python_exe": "python.exe",
|
|
61
61
|
"pip_exe": "pip.exe",
|
|
62
62
|
}
|
|
@@ -231,6 +231,65 @@ def update_json_config(file_path: Path, server_name: str, config_data: Dict) ->
|
|
|
231
231
|
return False
|
|
232
232
|
|
|
233
233
|
|
|
234
|
+
def update_toml_config(file_path: Path, server_name: str, python_path: str, wrapper_path: str, profile: str) -> bool:
|
|
235
|
+
"""Update a TOML config file with server config (for Codex CLI)."""
|
|
236
|
+
try:
|
|
237
|
+
file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
238
|
+
|
|
239
|
+
# Read existing content
|
|
240
|
+
lines = []
|
|
241
|
+
if file_path.exists():
|
|
242
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
|
243
|
+
lines = f.readlines()
|
|
244
|
+
|
|
245
|
+
# Check if server already exists
|
|
246
|
+
server_header = f'[mcp_servers.{server_name}]'
|
|
247
|
+
server_exists = any(server_header in line for line in lines)
|
|
248
|
+
|
|
249
|
+
if server_exists:
|
|
250
|
+
# Remove existing server config
|
|
251
|
+
new_lines = []
|
|
252
|
+
skip_section = False
|
|
253
|
+
for line in lines:
|
|
254
|
+
if server_header in line:
|
|
255
|
+
skip_section = True
|
|
256
|
+
continue
|
|
257
|
+
elif skip_section and line.strip().startswith('['):
|
|
258
|
+
skip_section = False
|
|
259
|
+
|
|
260
|
+
if not skip_section:
|
|
261
|
+
new_lines.append(line)
|
|
262
|
+
lines = new_lines
|
|
263
|
+
|
|
264
|
+
# Build TOML config for server
|
|
265
|
+
# Escape backslashes for Windows paths
|
|
266
|
+
py_path_escaped = python_path.replace('\\', '\\\\')
|
|
267
|
+
wrapper_escaped = wrapper_path.replace('\\', '\\\\')
|
|
268
|
+
|
|
269
|
+
toml_config = f'''
|
|
270
|
+
[mcp_servers.{server_name}]
|
|
271
|
+
command = "{py_path_escaped}"
|
|
272
|
+
args = ["-u", "-W", "ignore", "{wrapper_escaped}"]
|
|
273
|
+
env = {{ "PYTHONUNBUFFERED" = "1", "PYTHONWARNINGS" = "ignore", "NOTEBOOKLM_PROFILE" = "{profile}" }}
|
|
274
|
+
startup_timeout_sec = 60
|
|
275
|
+
'''
|
|
276
|
+
|
|
277
|
+
# Append new config
|
|
278
|
+
content = ''.join(lines)
|
|
279
|
+
if not content.endswith('\n'):
|
|
280
|
+
content += '\n'
|
|
281
|
+
content += toml_config
|
|
282
|
+
|
|
283
|
+
with open(file_path, 'w', encoding='utf-8') as f:
|
|
284
|
+
f.write(content)
|
|
285
|
+
|
|
286
|
+
return True
|
|
287
|
+
|
|
288
|
+
except Exception as e:
|
|
289
|
+
print(f" ⚠️ Không thể cập nhật {file_path.name}: {e}")
|
|
290
|
+
return False
|
|
291
|
+
|
|
292
|
+
|
|
234
293
|
def run_auth_check(python_path: str) -> bool:
|
|
235
294
|
"""Check if NotebookLM auth is configured."""
|
|
236
295
|
try:
|
|
@@ -310,15 +369,15 @@ def main():
|
|
|
310
369
|
# 8. Update client configs
|
|
311
370
|
print("\n🔗 Đang cấu hình các app AI...")
|
|
312
371
|
|
|
313
|
-
|
|
372
|
+
# JSON-based configs
|
|
373
|
+
json_configs = [
|
|
314
374
|
(platform_info["claude_config"], "notebooklm-mcp", "Claude"),
|
|
315
375
|
(platform_info["cursor_config"], "notebooklm-mcp", "Cursor"),
|
|
316
376
|
(platform_info["vscode_config"], "notebooklm-mcp", "VS Code"),
|
|
317
377
|
(platform_info.get("antigravity_config"), "notebooklm", "Antigravity"),
|
|
318
|
-
(platform_info.get("codex_config"), "notebooklm", "Codex"),
|
|
319
378
|
]
|
|
320
379
|
|
|
321
|
-
for config_path, server_name, app_name in
|
|
380
|
+
for config_path, server_name, app_name in json_configs:
|
|
322
381
|
if not config_path:
|
|
323
382
|
continue
|
|
324
383
|
if update_json_config(config_path, server_name, server_config):
|
|
@@ -326,6 +385,14 @@ def main():
|
|
|
326
385
|
else:
|
|
327
386
|
print(f" ⚠️ {app_name} (bỏ qua)")
|
|
328
387
|
|
|
388
|
+
# TOML-based configs (Codex CLI)
|
|
389
|
+
codex_config = platform_info.get("codex_config")
|
|
390
|
+
if codex_config:
|
|
391
|
+
if update_toml_config(codex_config, "notebooklm", python_path, wrapper_path, profile):
|
|
392
|
+
print(f" ✅ Codex CLI")
|
|
393
|
+
else:
|
|
394
|
+
print(f" ⚠️ Codex CLI (bỏ qua)")
|
|
395
|
+
|
|
329
396
|
# 9. Update Agent Kit config
|
|
330
397
|
ak_config = platform_info["agent_kit_config"]
|
|
331
398
|
if ak_config.exists():
|
package/bin/agent-kit
CHANGED
|
@@ -1,38 +1,139 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
//
|
|
8
|
-
const
|
|
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
|
-
//
|
|
11
|
-
const
|
|
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
|
-
//
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "1.11.2",
|
|
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",
|