start-ai-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 +21 -0
- package/README.md +60 -0
- package/bin/start-ai-cli.js +170 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
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,60 @@
|
|
|
1
|
+
# start-ai-cli
|
|
2
|
+
|
|
3
|
+
Open Codex CLI, Claude Code, and Cursor CLI from the current directory in one Windows Terminal window.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Windows
|
|
8
|
+
- Node.js 18 or newer
|
|
9
|
+
- Windows Terminal available as `wt.exe`
|
|
10
|
+
- Codex CLI available as `codex`
|
|
11
|
+
- Claude Code CLI available as `claude`
|
|
12
|
+
- Cursor CLI available as `agent`
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g start-ai-cli
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For local development from this directory:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm link
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
Run the command from the project directory you want both tools to use:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
start-ai-cli
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
It opens Windows Terminal with three tabs:
|
|
35
|
+
|
|
36
|
+
- `Codex`, running `codex`
|
|
37
|
+
- `Claude`, running `claude`
|
|
38
|
+
- `Cursor`, running `agent`
|
|
39
|
+
|
|
40
|
+
## Options
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
start-ai-cli --help
|
|
44
|
+
start-ai-cli --version
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Development
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm test
|
|
51
|
+
npm run pack:dry-run
|
|
52
|
+
npm run publish:dry-run
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Publish
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm login --registry=https://registry.npmjs.org/
|
|
59
|
+
npm publish
|
|
60
|
+
```
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
4
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
5
|
+
import { dirname, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const COMMAND = 'start-ai-cli';
|
|
9
|
+
|
|
10
|
+
const REQUIRED_COMMANDS = [
|
|
11
|
+
{ command: 'wt.exe', label: 'Windows Terminal (wt.exe)' },
|
|
12
|
+
{ command: 'codex', label: 'Codex CLI (codex)' },
|
|
13
|
+
{ command: 'claude', label: 'Claude Code CLI (claude)' },
|
|
14
|
+
{ command: 'agent', label: 'Cursor CLI (agent)' }
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const HELP_TEXT = `Usage:
|
|
18
|
+
${COMMAND}
|
|
19
|
+
${COMMAND} --help
|
|
20
|
+
${COMMAND} --version
|
|
21
|
+
|
|
22
|
+
Opens Windows Terminal with three tabs in the current directory:
|
|
23
|
+
- Codex: runs "codex"
|
|
24
|
+
- Claude: runs "claude"
|
|
25
|
+
- Cursor: runs "agent"
|
|
26
|
+
|
|
27
|
+
Requirements:
|
|
28
|
+
- Windows
|
|
29
|
+
- Windows Terminal (wt.exe)
|
|
30
|
+
- Codex CLI available as "codex"
|
|
31
|
+
- Claude Code CLI available as "claude"
|
|
32
|
+
- Cursor CLI available as "agent"
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export function parseArgs(args) {
|
|
36
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
37
|
+
return { action: 'help' };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
41
|
+
return { action: 'version' };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const unknown = args.filter((arg) => arg.startsWith('-'));
|
|
45
|
+
if (unknown.length > 0) {
|
|
46
|
+
return { action: 'error', message: `Unknown option: ${unknown.join(', ')}` };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { action: 'open' };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function getPackageVersion() {
|
|
53
|
+
const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
|
|
54
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
55
|
+
return packageJson.version;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function buildWtArgs({ cwd, codexCommand = 'codex', claudeCommand = 'claude', cursorCommand = 'agent' }) {
|
|
59
|
+
return [
|
|
60
|
+
'new-tab',
|
|
61
|
+
'--title',
|
|
62
|
+
'Codex',
|
|
63
|
+
'-d',
|
|
64
|
+
cwd,
|
|
65
|
+
'powershell.exe',
|
|
66
|
+
'-NoExit',
|
|
67
|
+
'-Command',
|
|
68
|
+
codexCommand,
|
|
69
|
+
';',
|
|
70
|
+
'new-tab',
|
|
71
|
+
'--title',
|
|
72
|
+
'Claude',
|
|
73
|
+
'-d',
|
|
74
|
+
cwd,
|
|
75
|
+
'powershell.exe',
|
|
76
|
+
'-NoExit',
|
|
77
|
+
'-Command',
|
|
78
|
+
claudeCommand,
|
|
79
|
+
';',
|
|
80
|
+
'new-tab',
|
|
81
|
+
'--title',
|
|
82
|
+
'Cursor',
|
|
83
|
+
'-d',
|
|
84
|
+
cwd,
|
|
85
|
+
'powershell.exe',
|
|
86
|
+
'-NoExit',
|
|
87
|
+
'-Command',
|
|
88
|
+
cursorCommand
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function commandExists(command, { env = process.env } = {}) {
|
|
93
|
+
const result = spawnSync('where.exe', [command], {
|
|
94
|
+
env,
|
|
95
|
+
stdio: 'ignore',
|
|
96
|
+
windowsHide: true
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return result.status === 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function getMissingRequirements({ platform = process.platform, env = process.env } = {}) {
|
|
103
|
+
if (platform !== 'win32') {
|
|
104
|
+
return ['Windows is required.'];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return REQUIRED_COMMANDS
|
|
108
|
+
.filter(({ command }) => !commandExists(command, { env }))
|
|
109
|
+
.map(({ label }) => `${label} was not found in PATH.`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function launchTerminals({ cwd = process.cwd(), env = process.env } = {}) {
|
|
113
|
+
const child = spawn('wt.exe', buildWtArgs({ cwd }), {
|
|
114
|
+
cwd,
|
|
115
|
+
env,
|
|
116
|
+
detached: true,
|
|
117
|
+
stdio: 'ignore',
|
|
118
|
+
windowsHide: false
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
child.unref();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function main(args = process.argv.slice(2), options = {}) {
|
|
125
|
+
const parsed = parseArgs(args);
|
|
126
|
+
|
|
127
|
+
if (parsed.action === 'help') {
|
|
128
|
+
console.log(HELP_TEXT.trimEnd());
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (parsed.action === 'version') {
|
|
133
|
+
console.log(getPackageVersion());
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (parsed.action === 'error') {
|
|
138
|
+
console.error(parsed.message);
|
|
139
|
+
console.error(`Run "${COMMAND} --help" for usage.`);
|
|
140
|
+
return 1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const missing = getMissingRequirements(options);
|
|
144
|
+
if (missing.length > 0) {
|
|
145
|
+
console.error(`${COMMAND} cannot start:`);
|
|
146
|
+
for (const message of missing) {
|
|
147
|
+
console.error(`- ${message}`);
|
|
148
|
+
}
|
|
149
|
+
return 1;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
launchTerminals(options);
|
|
153
|
+
console.log('Opened Codex CLI, Claude Code, and Cursor CLI in Windows Terminal.');
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function isEntrypoint(argvPath = process.argv[1], moduleUrl = import.meta.url) {
|
|
158
|
+
if (!argvPath) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const argvRealPath = realpathSync(resolve(argvPath));
|
|
163
|
+
const moduleRealPath = realpathSync(fileURLToPath(moduleUrl));
|
|
164
|
+
|
|
165
|
+
return argvRealPath === moduleRealPath;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (isEntrypoint()) {
|
|
169
|
+
process.exitCode = main();
|
|
170
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "start-ai-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Open Codex CLI, Claude Code, and Cursor CLI in Windows Terminal tabs from the current directory.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"start-ai-cli": "bin/start-ai-cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node --test",
|
|
11
|
+
"pack:dry-run": "npm pack --dry-run",
|
|
12
|
+
"publish:dry-run": "npm publish --dry-run"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin/",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"codex",
|
|
21
|
+
"claude",
|
|
22
|
+
"cursor",
|
|
23
|
+
"cli",
|
|
24
|
+
"terminal",
|
|
25
|
+
"windows-terminal"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/guoxiao0521/open-ai-cli.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/guoxiao0521/open-ai-cli/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/guoxiao0521/open-ai-cli#readme",
|
|
36
|
+
"os": [
|
|
37
|
+
"win32"
|
|
38
|
+
],
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"registry": "https://registry.npmjs.org/"
|
|
44
|
+
}
|
|
45
|
+
}
|