@cocorograph/hub-agent 0.6.54 → 0.6.55
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/package.json +1 -1
- package/src/profiles.mjs +24 -11
package/package.json
CHANGED
package/src/profiles.mjs
CHANGED
|
@@ -197,27 +197,40 @@ export async function addProfile(opts = {}) {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
/**
|
|
200
|
-
* プロファイルの
|
|
200
|
+
* プロファイルの `.claude.json` から最後にログインしていたアカウント情報を読む。
|
|
201
201
|
* Claude Code がログイン時に oauthAccount を書き込むため、「このディレクトリで最後に
|
|
202
202
|
* 使われたアカウント」のメタ情報として UI 表示に使える (認証トークンそのものではない)。
|
|
203
203
|
* ファイルが無い・壊れている・未ログインなら null。
|
|
204
204
|
*
|
|
205
|
+
* ⚠️ パスの罠: Claude Code は `.claude.json` を CLAUDE_CONFIG_DIR 指定時のみ
|
|
206
|
+
* `<configDir>/.claude.json` に置き、既定プロファイルでは `~/.claude.json`
|
|
207
|
+
* (ホーム直下、`~/.claude/` の外) に置く。一律 `<configDir>/.claude.json` を読むと
|
|
208
|
+
* 既定プロファイルだけ常に null になる (2026-06-07 実バグ: Cockpit のアカウント
|
|
209
|
+
* 切替 UI で既定プロファイルのみメール・組織が表示されなかった)。
|
|
210
|
+
*
|
|
205
211
|
* @param {string} configDir
|
|
206
212
|
* @returns {Promise<{email: string|null, organization: string|null}|null>}
|
|
207
213
|
*/
|
|
208
214
|
export async function readProfileAccount(configDir) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
const candidates = [path.join(configDir, ".claude.json")]
|
|
216
|
+
if (path.resolve(configDir) === defaultConfigDir()) {
|
|
217
|
+
candidates.push(path.join(os.homedir(), ".claude.json"))
|
|
218
|
+
}
|
|
219
|
+
for (const file of candidates) {
|
|
220
|
+
try {
|
|
221
|
+
const raw = await fs.readFile(file, "utf-8")
|
|
222
|
+
const oa = JSON.parse(raw)?.oauthAccount
|
|
223
|
+
if (!oa || typeof oa !== "object") continue
|
|
224
|
+
return {
|
|
225
|
+
email: typeof oa.emailAddress === "string" ? oa.emailAddress : null,
|
|
226
|
+
organization:
|
|
227
|
+
typeof oa.organizationName === "string" ? oa.organizationName : null,
|
|
228
|
+
}
|
|
229
|
+
} catch {
|
|
230
|
+
/* 次の候補へ */
|
|
217
231
|
}
|
|
218
|
-
} catch {
|
|
219
|
-
return null
|
|
220
232
|
}
|
|
233
|
+
return null
|
|
221
234
|
}
|
|
222
235
|
|
|
223
236
|
/**
|