@4yi-dev/cli 0.1.19 → 0.1.20
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/README.md +2 -0
- package/package.json +1 -1
- package/src/connect.mjs +17 -0
package/README.md
CHANGED
|
@@ -37,6 +37,8 @@ Both packages install the `4yi` command. The dev package points at `https://xcla
|
|
|
37
37
|
|
|
38
38
|
On macOS, `4yi connect claude` also configures an installed Claude Desktop through its official third-party Gateway mode. The Desktop credential helper reads the current token from `~/.4yi/config.json`; the token is not copied into Claude's configuration. Quit and reopen Claude Desktop only after its active tasks finish. Third-party mode has a separate session list from the normal Claude profile. Run `4yi restore claude`, then reopen Claude Desktop, to return to the previous profile and session list.
|
|
39
39
|
|
|
40
|
+
`4yi restore claude` skips backup snapshots that were themselves created while 4YI was active, so repeated `connect` calls still return to the latest official configuration. After restoring, quit every running Claude Code and Claude App process and open a new terminal: an existing process has already loaded `ANTHROPIC_*` into memory, and Claude's `/logout` command does not override provider environment variables.
|
|
41
|
+
|
|
40
42
|
`--scope project` changes only the project's Claude Code settings and never changes the global Claude Desktop profile.
|
|
41
43
|
|
|
42
44
|
Codex CLI and Codex App share the same Codex home on native Windows (`%USERPROFILE%\\.codex`). Microsoft Store/AppX installations may not expose a conventional executable path, but that detection does not gate the shared configuration update. While the external 4YI provider supplies authentication, Codex App may hide its `Log out` action because there is no App-managed provider credential to clear.
|
package/package.json
CHANGED
package/src/connect.mjs
CHANGED
|
@@ -269,6 +269,19 @@ function backupGroups(target, home) {
|
|
|
269
269
|
|
|
270
270
|
function latestBackups(target, home) {
|
|
271
271
|
const groups = backupGroups(target, home);
|
|
272
|
+
if (target === "claude") {
|
|
273
|
+
return groups.find((group) => !group.some(({ record }) => {
|
|
274
|
+
if (typeof record.content !== "string") return false;
|
|
275
|
+
try {
|
|
276
|
+
const value = JSON.parse(record.content);
|
|
277
|
+
return value?.env?.CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY === "1"
|
|
278
|
+
|| value?.appliedId === CLAUDE_DESKTOP_PROFILE_ID
|
|
279
|
+
|| value?.inferenceCredentialHelper?.includes("/.4yi/helpers/claude-desktop-credential");
|
|
280
|
+
} catch {
|
|
281
|
+
return record.content.includes("$HOME/.4yi/config.json");
|
|
282
|
+
}
|
|
283
|
+
})) || [];
|
|
284
|
+
}
|
|
272
285
|
if (target !== "codex") return groups[0] || [];
|
|
273
286
|
|
|
274
287
|
// Older CLI releases created a fresh backup every time `connect codex` ran,
|
|
@@ -722,6 +735,7 @@ export function restoreConnection({ target = "all", home = os.homedir(), stdout
|
|
|
722
735
|
const normalized = normalizeTarget(target);
|
|
723
736
|
if (normalized === "claude") {
|
|
724
737
|
restoreOne("claude", home, stdout);
|
|
738
|
+
stdout("Claude 已恢复为官方配置。请退出所有 Claude Code/Claude App 进程并打开新终端;当前终端继承的 ANTHROPIC_* 环境变量无法由子进程清除,/logout 也不会覆盖它们。");
|
|
725
739
|
return { restoredClaude: true, restoredCodex: false };
|
|
726
740
|
}
|
|
727
741
|
if (normalized === "codex") {
|
|
@@ -731,6 +745,9 @@ export function restoreConnection({ target = "all", home = os.homedir(), stdout
|
|
|
731
745
|
const restoredClaude = restoreOne("claude", home, stdout, { required: false });
|
|
732
746
|
const restoredCodex = restoreOne("codex", home, stdout, { required: false });
|
|
733
747
|
if (!restoredClaude && !restoredCodex) throw new Error("No Claude or Codex backup found.");
|
|
748
|
+
if (restoredClaude) {
|
|
749
|
+
stdout("Claude 已恢复为官方配置。请退出所有 Claude Code/Claude App 进程并打开新终端;当前终端继承的 ANTHROPIC_* 环境变量无法由子进程清除,/logout 也不会覆盖它们。");
|
|
750
|
+
}
|
|
734
751
|
return { restoredClaude, restoredCodex };
|
|
735
752
|
}
|
|
736
753
|
|