relayax-cli 0.3.45 → 0.3.46
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/dist/lib/config.js +18 -10
- package/dist/prompts/_setup-cli.md +18 -0
- package/package.json +1 -1
package/dist/lib/config.js
CHANGED
|
@@ -22,7 +22,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
22
22
|
const os_1 = __importDefault(require("os"));
|
|
23
23
|
const ai_tools_js_1 = require("./ai-tools.js");
|
|
24
24
|
exports.API_URL = 'https://www.relayax.com';
|
|
25
|
-
const GLOBAL_RELAY_DIR = path_1.default.join(os_1.default.homedir(), '.relay');
|
|
25
|
+
const GLOBAL_RELAY_DIR = path_1.default.join(process.env.RELAY_HOME ?? os_1.default.homedir(), '.relay');
|
|
26
26
|
/**
|
|
27
27
|
* 설치 경로를 결정한다.
|
|
28
28
|
* 1. --path 옵션이 있으면 그대로 사용
|
|
@@ -31,17 +31,18 @@ const GLOBAL_RELAY_DIR = path_1.default.join(os_1.default.homedir(), '.relay');
|
|
|
31
31
|
*/
|
|
32
32
|
function getInstallPath(override) {
|
|
33
33
|
if (override) {
|
|
34
|
+
const homeDir = process.env.RELAY_HOME ?? os_1.default.homedir();
|
|
34
35
|
const resolved = override.startsWith('~')
|
|
35
|
-
? path_1.default.join(
|
|
36
|
+
? path_1.default.join(homeDir, override.slice(1))
|
|
36
37
|
: path_1.default.resolve(override);
|
|
37
38
|
return resolved;
|
|
38
39
|
}
|
|
39
|
-
const
|
|
40
|
-
const detected = (0, ai_tools_js_1.detectAgentCLIs)(
|
|
40
|
+
const projectRoot = getProjectRoot();
|
|
41
|
+
const detected = (0, ai_tools_js_1.detectAgentCLIs)(projectRoot);
|
|
41
42
|
if (detected.length >= 1) {
|
|
42
|
-
return path_1.default.join(
|
|
43
|
+
return path_1.default.join(projectRoot, detected[0].skillsDir);
|
|
43
44
|
}
|
|
44
|
-
return
|
|
45
|
+
return projectRoot;
|
|
45
46
|
}
|
|
46
47
|
/** ~/.relay/ — 글로벌 (token, CLI cache) */
|
|
47
48
|
function ensureGlobalRelayDir() {
|
|
@@ -49,9 +50,13 @@ function ensureGlobalRelayDir() {
|
|
|
49
50
|
fs_1.default.mkdirSync(GLOBAL_RELAY_DIR, { recursive: true });
|
|
50
51
|
}
|
|
51
52
|
}
|
|
53
|
+
/** 프로젝트 루트 경로 (RELAY_PROJECT_PATH > cwd) */
|
|
54
|
+
function getProjectRoot() {
|
|
55
|
+
return process.env.RELAY_PROJECT_PATH ?? process.cwd();
|
|
56
|
+
}
|
|
52
57
|
/** cwd/.relay/ — 프로젝트 로컬 (installed.json, agents/) */
|
|
53
58
|
function ensureProjectRelayDir() {
|
|
54
|
-
const dir = path_1.default.join(
|
|
59
|
+
const dir = path_1.default.join(getProjectRoot(), '.relay');
|
|
55
60
|
if (!fs_1.default.existsSync(dir)) {
|
|
56
61
|
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
57
62
|
}
|
|
@@ -90,7 +95,7 @@ function saveToken(token) {
|
|
|
90
95
|
fs_1.default.writeFileSync(tokenFile, JSON.stringify({ access_token: token }), { mode: 0o600 });
|
|
91
96
|
fs_1.default.chmodSync(tokenFile, 0o600);
|
|
92
97
|
}
|
|
93
|
-
const LOCK_FILE = path_1.default.join(
|
|
98
|
+
const LOCK_FILE = path_1.default.join(GLOBAL_RELAY_DIR, '.token.lock');
|
|
94
99
|
const LOCK_TIMEOUT = 15000; // 15s
|
|
95
100
|
/**
|
|
96
101
|
* 파일 기반 lock — 여러 CLI 프로세스가 동시에 refresh하는 것을 방지.
|
|
@@ -154,6 +159,9 @@ async function doRefresh(refreshToken) {
|
|
|
154
159
|
* - refresh 실패해도 access_token이 아직 유효하면 계속 사용
|
|
155
160
|
*/
|
|
156
161
|
async function getValidToken() {
|
|
162
|
+
// RELAY_TOKEN 환경변수가 있으면 최우선 사용 (sandbox/CI 환경)
|
|
163
|
+
if (process.env.RELAY_TOKEN)
|
|
164
|
+
return process.env.RELAY_TOKEN;
|
|
157
165
|
// 매번 파일에서 새로 읽음 (다른 프로세스가 갱신했을 수 있으므로)
|
|
158
166
|
const data = loadTokenData();
|
|
159
167
|
if (!data)
|
|
@@ -218,7 +226,7 @@ function normalizeInstalledRegistry(raw) {
|
|
|
218
226
|
}
|
|
219
227
|
/** 프로젝트 로컬 installed.json 읽기 */
|
|
220
228
|
function loadInstalled() {
|
|
221
|
-
const file = path_1.default.join(
|
|
229
|
+
const file = path_1.default.join(getProjectRoot(), '.relay', 'installed.json');
|
|
222
230
|
if (!fs_1.default.existsSync(file)) {
|
|
223
231
|
return {};
|
|
224
232
|
}
|
|
@@ -232,7 +240,7 @@ function loadInstalled() {
|
|
|
232
240
|
/** 프로젝트 로컬 installed.json 쓰기 */
|
|
233
241
|
function saveInstalled(registry) {
|
|
234
242
|
ensureProjectRelayDir();
|
|
235
|
-
const file = path_1.default.join(
|
|
243
|
+
const file = path_1.default.join(getProjectRoot(), '.relay', 'installed.json');
|
|
236
244
|
fs_1.default.writeFileSync(file, JSON.stringify(registry, null, 2));
|
|
237
245
|
}
|
|
238
246
|
// ─── 글로벌 레지스트리 ───
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## Step 0. 환경 감지
|
|
2
|
+
|
|
3
|
+
sandbox 환경(Cowork, Codex 등)에서는 `$HOME`이 격리될 수 있습니다.
|
|
4
|
+
아래 명령어로 확인하세요:
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
ls ~/.relay/token 2>/dev/null && echo "token-ok" || echo "token-missing"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
`token-missing`이면, 이 세션에서 `relay login --device`로 새로 로그인해야 합니다.
|
|
11
|
+
이미 로그인한 토큰이 있다면 환경변수로 전달할 수도 있습니다:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
export RELAY_TOKEN=<토큰>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`token-ok`이면 이 단계를 건너뛰세요.
|
|
18
|
+
|
|
1
19
|
## Step 1. Relay CLI 설치
|
|
2
20
|
|
|
3
21
|
relay CLI가 설치되어 있지 않다면:
|