@hasna/accounts 0.1.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.
@@ -0,0 +1,3 @@
1
+ /** Exclusive lock for apply operations (best-effort cross-process). */
2
+ export declare function withApplyLock<T>(fn: () => T): T;
3
+ //# sourceMappingURL=apply-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-lock.d.ts","sourceRoot":"","sources":["../../src/lib/apply-lock.ts"],"names":[],"mappings":"AASA,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CA8B/C"}
@@ -0,0 +1,11 @@
1
+ import type { Profile } from "../types.js";
2
+ export declare function appliedProfile(toolId: string): Profile | undefined;
3
+ /**
4
+ * Apply a profile's auth to the tool's live default paths (IDE-friendly).
5
+ * Snapshots the previously applied profile's auth before switching.
6
+ */
7
+ export declare function applyProfile(name: string, toolId?: string): {
8
+ profile: Profile;
9
+ previous?: string;
10
+ };
11
+ //# sourceMappingURL=apply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/lib/apply.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAa3C,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAKlE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAEnG"}
@@ -0,0 +1,12 @@
1
+ import type { ToolDef } from "../types.js";
2
+ /** Snapshot live Claude auth into a profile directory (used when switching away on apply). */
3
+ export declare function snapshotLiveAuthToProfile(profileDir: string, _tool: ToolDef): void;
4
+ /** @deprecated Use snapshotLiveAuthToProfile */
5
+ export declare function snapshotClaudeAuthToProfile(profileDir: string, tool: ToolDef): void;
6
+ /** Build auth snapshots from files already present in the profile config dir. */
7
+ export declare function ensureProfileAuthSnapshot(profileDir: string, tool: ToolDef): void;
8
+ export declare function profileHasAuth(profileDir: string, tool: ToolDef): boolean;
9
+ /** Restore profile auth snapshots onto live Claude paths. */
10
+ export declare function restoreClaudeAuthFromProfile(profileDir: string, tool: ToolDef, profileName?: string): void;
11
+ export declare function hasAuthSnapshot(profileDir: string): boolean;
12
+ //# sourceMappingURL=claude-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-auth.d.ts","sourceRoot":"","sources":["../../src/lib/claude-auth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA2E3C,8FAA8F;AAC9F,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAmBlF;AAED,gDAAgD;AAChD,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAEnF;AAED,iFAAiF;AACjF,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAejF;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAEzE;AAED,6DAA6D;AAC7D,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,OAAO,EACb,WAAW,CAAC,EAAE,MAAM,GACnB,IAAI,CAqDN;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAM3D"}
@@ -0,0 +1,21 @@
1
+ import type { ToolDef } from "../types.js";
2
+ export declare const CLAUDE_KEYCHAIN_SERVICE = "Claude Code-credentials";
3
+ export declare const ACCOUNTS_AUTH_DIR = ".accounts-auth";
4
+ export declare const OAUTH_SNAPSHOT = "oauth-account.json";
5
+ export declare const CREDENTIALS_SNAPSHOT = "credentials.json";
6
+ export declare const KEYCHAIN_SNAPSHOT = "keychain.json";
7
+ /** Root directory for live Claude auth files (home or ACCOUNTS_TEST_LIVE_DIR). */
8
+ export declare function liveClaudeBase(): string;
9
+ /** Live Claude Code paths (default install, no CLAUDE_CONFIG_DIR). */
10
+ export declare function liveClaudePaths(): {
11
+ configDir: string;
12
+ homeJson: string;
13
+ credentialsFile: string;
14
+ };
15
+ /** Account JSON paths for a profile config dir (handles parent ~/.claude.json layout). */
16
+ export declare function profileAccountJsonPaths(profileDir: string, tool: ToolDef): string[];
17
+ export declare function profileAuthDir(profileDir: string): string;
18
+ export declare function profileOAuthSnapshot(profileDir: string): string;
19
+ export declare function profileCredentialsSnapshot(profileDir: string): string;
20
+ export declare function profileKeychainSnapshot(profileDir: string): string;
21
+ //# sourceMappingURL=claude-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-layout.d.ts","sourceRoot":"","sources":["../../src/lib/claude-layout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AACjE,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAClD,eAAO,MAAM,cAAc,uBAAuB,CAAC;AACnD,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AACvD,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,kFAAkF;AAClF,wBAAgB,cAAc,IAAI,MAAM,CAGvC;AAED,sEAAsE;AACtE,wBAAgB,eAAe,IAAI;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAQlG;AAED,0FAA0F;AAC1F,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,CAKnF;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAElE"}
@@ -0,0 +1,12 @@
1
+ import type { ToolDef } from "../types.js";
2
+ /**
3
+ * Best-effort: read the account email a tool stored inside its config dir.
4
+ * For Claude Code this is `<dir>/.claude.json` -> oauthAccount.emailAddress.
5
+ *
6
+ * When `CLAUDE_CONFIG_DIR` is set, Claude Code writes `.claude.json` inside that
7
+ * dir. But the DEFAULT install keeps it one level up at `~/.claude.json` (next to
8
+ * the `~/.claude` dir). So when importing the tool's default dir we also check the
9
+ * parent dir. Returns undefined when no email can be found.
10
+ */
11
+ export declare function detectEmail(dir: string, tool: ToolDef): string | undefined;
12
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/lib/detect.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAS1E"}
@@ -0,0 +1,5 @@
1
+ import type { Profile, ToolDef } from "../types.js";
2
+ export declare function profileEnv(profile: Profile, tool: ToolDef): Record<string, string>;
3
+ export declare function formatEnvAssignments(env: Record<string, string>): string;
4
+ export declare function formatExportLines(env: Record<string, string>): string;
5
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/lib/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAMpD,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQlF;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAIxE;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAIrE"}
@@ -0,0 +1,13 @@
1
+ /** Single-quote a path for safe shell interpolation. */
2
+ export declare function shellQuotePath(path: string): string;
3
+ export declare function hookPath(): string;
4
+ export declare function hookScript(): string;
5
+ export declare function installHook(): {
6
+ path: string;
7
+ created: boolean;
8
+ };
9
+ export declare function uninstallHook(): boolean;
10
+ export declare function shellSnippet(): string;
11
+ /** Validate a profile name is safe for shell interpolation. */
12
+ export declare function isSafeProfileName(name: string): boolean;
13
+ //# sourceMappingURL=hook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../src/lib/hook.ts"],"names":[],"mappings":"AASA,wDAAwD;AACxD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,QAAQ,IAAI,MAAM,CAEjC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAyBnC;AAED,wBAAgB,WAAW,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAMhE;AAED,wBAAgB,aAAa,IAAI,OAAO,CAOvC;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD"}
@@ -0,0 +1,31 @@
1
+ export interface ImportOptions {
2
+ name?: string;
3
+ tool?: string;
4
+ dir?: string;
5
+ email?: string;
6
+ description?: string;
7
+ copy?: boolean;
8
+ }
9
+ /**
10
+ * Register an existing Claude (or tool) config directory as a profile.
11
+ * Default source is the tool's default dir (e.g. ~/.claude).
12
+ */
13
+ export declare function importProfile(opts: ImportOptions): {
14
+ name: string;
15
+ tool: string;
16
+ dir: string;
17
+ createdAt: string;
18
+ email?: string | undefined;
19
+ description?: string | undefined;
20
+ lastUsedAt?: string | undefined;
21
+ };
22
+ export declare function ensureProfileForLogin(name: string, toolId?: string): {
23
+ name: string;
24
+ tool: string;
25
+ dir: string;
26
+ createdAt: string;
27
+ email?: string | undefined;
28
+ description?: string | undefined;
29
+ lastUsedAt?: string | undefined;
30
+ };
31
+ //# sourceMappingURL=import-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-profile.d.ts","sourceRoot":"","sources":["../../src/lib/import-profile.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa;;;;;;;;EAqChD;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAe;;;;;;;;EAIxE"}
@@ -0,0 +1,13 @@
1
+ export declare function keychainSupported(): boolean;
2
+ export interface KeychainCredential {
3
+ service: string;
4
+ account: string;
5
+ secret: string;
6
+ }
7
+ /** Allowlist service/account before any keychain write (blocks store-name injection). */
8
+ export declare function assertAllowedKeychainCredential(cred: KeychainCredential): void;
9
+ /** Read Claude Code OAuth payload from macOS login keychain. */
10
+ export declare function readClaudeKeychain(): KeychainCredential | undefined;
11
+ /** Write Claude Code credentials into the login keychain (replaces existing entry). */
12
+ export declare function writeClaudeKeychain(cred: KeychainCredential): void;
13
+ //# sourceMappingURL=keychain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../src/lib/keychain.ts"],"names":[],"mappings":"AAKA,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,yFAAyF;AACzF,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAU9E;AAED,gEAAgE;AAChE,wBAAgB,kBAAkB,IAAI,kBAAkB,GAAG,SAAS,CAgBnE;AAgBD,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAqBlE"}
@@ -0,0 +1,16 @@
1
+ import type { Profile } from "../types.js";
2
+ export interface PickOptions {
3
+ tool?: string;
4
+ mode?: "apply" | "env" | "none";
5
+ }
6
+ /** Map CLI flags to pick mode (Commander `--no-act` → `act: false`). */
7
+ export declare function resolvePickMode(opts: {
8
+ env?: boolean;
9
+ act?: boolean;
10
+ }): PickOptions["mode"];
11
+ export interface PickResult {
12
+ profile: Profile;
13
+ mode: "apply" | "env" | "none";
14
+ }
15
+ export declare function pickProfile(opts?: PickOptions): Promise<PickResult | undefined>;
16
+ //# sourceMappingURL=pick.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../src/lib/pick.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAK3C,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;CACjC;AAED,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAI3F;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;CAChC;AAED,wBAAsB,WAAW,CAAC,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA8BzF"}
@@ -0,0 +1,40 @@
1
+ import { type Profile } from "../types.js";
2
+ /** Expand a leading `~` and resolve to an absolute path. */
3
+ export declare function expandPath(p: string): string;
4
+ export declare function listProfiles(toolId?: string): Profile[];
5
+ export declare function findProfile(name: string, toolId?: string): Profile | undefined;
6
+ export declare function getProfile(name: string, toolId?: string): Profile;
7
+ export interface AddOptions {
8
+ name: string;
9
+ tool?: string;
10
+ email?: string;
11
+ dir?: string;
12
+ description?: string;
13
+ }
14
+ export declare function addProfile(opts: AddOptions): Profile;
15
+ export interface RemoveOptions {
16
+ tool?: string;
17
+ purge?: boolean;
18
+ }
19
+ export declare function removeProfile(name: string, opts?: RemoveOptions | boolean): {
20
+ profile: Profile;
21
+ purged: boolean;
22
+ purgeNote?: string;
23
+ };
24
+ export declare function renameProfile(oldName: string, newName: string, toolId?: string): Profile;
25
+ export interface UpdateOptions {
26
+ tool?: string;
27
+ email?: string;
28
+ description?: string;
29
+ dir?: string;
30
+ }
31
+ export declare function updateProfile(name: string, opts: UpdateOptions): Profile;
32
+ /** Re-detect the account email from the profile's config dir. */
33
+ export declare function redetectEmail(name: string, toolId?: string): Profile;
34
+ /** Mark a profile as the active one for its tool. */
35
+ export declare function useProfile(name: string, toolId?: string): {
36
+ profile: Profile;
37
+ toolId: string;
38
+ };
39
+ export declare function currentProfile(toolId: string): Profile | undefined;
40
+ //# sourceMappingURL=profiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/lib/profiles.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAoC,MAAM,aAAa,CAAC;AAS7E,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAK5C;AAED,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CAIvD;AAMD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAG9E;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAajE;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAgCpD;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,aAAa,GAAG,OAAY,GACjC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAoC3D;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAyBxF;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAsBxE;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAiBpE;AAED,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAiB9F;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAKlE"}
@@ -0,0 +1,5 @@
1
+ /** Refuse writes through symlinks; optionally confine to a base directory. */
2
+ export declare function assertSafeWritePath(filePath: string, opts?: {
3
+ mustStayUnder?: string;
4
+ }): string;
5
+ //# sourceMappingURL=safe-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-path.d.ts","sourceRoot":"","sources":["../../src/lib/safe-path.ts"],"names":[],"mappings":"AAyCA,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAiB/F"}
@@ -0,0 +1,17 @@
1
+ import { type ToolDef } from "../types.js";
2
+ /**
3
+ * Built-in tools. Users can register more at runtime with `accounts tools add`,
4
+ * which persists them in the store — so the CLI scales to any app that reads a
5
+ * config dir from an environment variable, without a code change.
6
+ */
7
+ export declare const BUILTIN_TOOLS: ToolDef[];
8
+ export declare const DEFAULT_TOOL = "claude";
9
+ export declare function isBuiltinTool(id: string): boolean;
10
+ /** All tools: built-ins plus any user-registered ones (custom wins on id clash). */
11
+ export declare function listTools(): ToolDef[];
12
+ export declare function getTool(id: string): ToolDef;
13
+ /** Register (or update) a custom tool, persisted in the store. */
14
+ export declare function addCustomTool(def: ToolDef): ToolDef;
15
+ /** Remove a custom tool. Fails if profiles still reference it. */
16
+ export declare function removeCustomTool(id: string): void;
17
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/lib/tools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAgC,MAAM,aAAa,CAAC;AAGzE;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,OAAO,EA4DlC,CAAC;AAEF,eAAO,MAAM,YAAY,WAAW,CAAC;AAIrC,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,oFAAoF;AACpF,wBAAgB,SAAS,IAAI,OAAO,EAAE,CAMrC;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAS3C;AAED,kEAAkE;AAClE,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAanD;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAWjD"}
@@ -0,0 +1,10 @@
1
+ import { type Store } from "./types.js";
2
+ /** Base directory for all accounts state. Override with `ACCOUNTS_HOME`. */
3
+ export declare function accountsHome(): string;
4
+ /** Path to the registry file. Override with `ACCOUNTS_STORE_PATH`. */
5
+ export declare function storePath(): string;
6
+ /** Base directory under which managed profile config dirs are created. */
7
+ export declare function profilesDir(): string;
8
+ export declare function loadStore(): Store;
9
+ export declare function saveStore(store: Store): void;
10
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,KAAK,EAAiD,MAAM,YAAY,CAAC;AAWvF,4EAA4E;AAC5E,wBAAgB,YAAY,IAAI,MAAM,CAIrC;AAED,sEAAsE;AACtE,wBAAgB,SAAS,IAAI,MAAM,CAIlC;AAED,0EAA0E;AAC1E,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAID,wBAAgB,SAAS,IAAI,KAAK,CA+BjC;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAK5C"}
@@ -0,0 +1,196 @@
1
+ import { z } from "zod";
2
+ /** Profile name validator. */
3
+ export declare const profileNameSchema: z.ZodString;
4
+ /** Validator for a (custom) tool definition stored in the registry. */
5
+ export declare const toolDefSchema: z.ZodObject<{
6
+ id: z.ZodString;
7
+ label: z.ZodString;
8
+ envVar: z.ZodString;
9
+ extraEnv: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
10
+ defaultDir: z.ZodString;
11
+ bin: z.ZodString;
12
+ loginArgs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
13
+ loginHint: z.ZodOptional<z.ZodString>;
14
+ accountFile: z.ZodOptional<z.ZodString>;
15
+ emailPath: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ id: string;
18
+ label: string;
19
+ envVar: string;
20
+ defaultDir: string;
21
+ bin: string;
22
+ extraEnv?: Record<string, string> | undefined;
23
+ loginArgs?: string[] | undefined;
24
+ loginHint?: string | undefined;
25
+ accountFile?: string | undefined;
26
+ emailPath?: string[] | undefined;
27
+ }, {
28
+ id: string;
29
+ label: string;
30
+ envVar: string;
31
+ defaultDir: string;
32
+ bin: string;
33
+ extraEnv?: Record<string, string> | undefined;
34
+ loginArgs?: string[] | undefined;
35
+ loginHint?: string | undefined;
36
+ accountFile?: string | undefined;
37
+ emailPath?: string[] | undefined;
38
+ }>;
39
+ /**
40
+ * A supported app/tool. Each tool isolates its configuration in a directory
41
+ * pointed at by an environment variable (e.g. Claude Code reads
42
+ * `CLAUDE_CONFIG_DIR`). A "profile" is one such directory plus metadata.
43
+ * Tools are either built-in or registered at runtime via `accounts tools add`.
44
+ */
45
+ export type ToolDef = z.infer<typeof toolDefSchema>;
46
+ export declare const profileSchema: z.ZodObject<{
47
+ name: z.ZodString;
48
+ tool: z.ZodString;
49
+ email: z.ZodOptional<z.ZodString>;
50
+ dir: z.ZodString;
51
+ description: z.ZodOptional<z.ZodString>;
52
+ createdAt: z.ZodString;
53
+ lastUsedAt: z.ZodOptional<z.ZodString>;
54
+ }, "strip", z.ZodTypeAny, {
55
+ name: string;
56
+ tool: string;
57
+ dir: string;
58
+ createdAt: string;
59
+ email?: string | undefined;
60
+ description?: string | undefined;
61
+ lastUsedAt?: string | undefined;
62
+ }, {
63
+ name: string;
64
+ tool: string;
65
+ dir: string;
66
+ createdAt: string;
67
+ email?: string | undefined;
68
+ description?: string | undefined;
69
+ lastUsedAt?: string | undefined;
70
+ }>;
71
+ export type Profile = z.infer<typeof profileSchema>;
72
+ export declare const storeSchema: z.ZodObject<{
73
+ version: z.ZodLiteral<1>;
74
+ /** Map of toolId -> active profile name (for env/launch/shell). */
75
+ current: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
76
+ /**
77
+ * Map of toolId -> profile name last applied to the tool's live default paths
78
+ * (e.g. ~/.claude + ~/.claude.json on disk for IDE use).
79
+ */
80
+ applied: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
81
+ profiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
82
+ name: z.ZodString;
83
+ tool: z.ZodString;
84
+ email: z.ZodOptional<z.ZodString>;
85
+ dir: z.ZodString;
86
+ description: z.ZodOptional<z.ZodString>;
87
+ createdAt: z.ZodString;
88
+ lastUsedAt: z.ZodOptional<z.ZodString>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ name: string;
91
+ tool: string;
92
+ dir: string;
93
+ createdAt: string;
94
+ email?: string | undefined;
95
+ description?: string | undefined;
96
+ lastUsedAt?: string | undefined;
97
+ }, {
98
+ name: string;
99
+ tool: string;
100
+ dir: string;
101
+ createdAt: string;
102
+ email?: string | undefined;
103
+ description?: string | undefined;
104
+ lastUsedAt?: string | undefined;
105
+ }>, "many">>;
106
+ /** User-registered tools (apps) added at runtime, on top of built-ins. */
107
+ tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
108
+ id: z.ZodString;
109
+ label: z.ZodString;
110
+ envVar: z.ZodString;
111
+ extraEnv: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
112
+ defaultDir: z.ZodString;
113
+ bin: z.ZodString;
114
+ loginArgs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
115
+ loginHint: z.ZodOptional<z.ZodString>;
116
+ accountFile: z.ZodOptional<z.ZodString>;
117
+ emailPath: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
118
+ }, "strip", z.ZodTypeAny, {
119
+ id: string;
120
+ label: string;
121
+ envVar: string;
122
+ defaultDir: string;
123
+ bin: string;
124
+ extraEnv?: Record<string, string> | undefined;
125
+ loginArgs?: string[] | undefined;
126
+ loginHint?: string | undefined;
127
+ accountFile?: string | undefined;
128
+ emailPath?: string[] | undefined;
129
+ }, {
130
+ id: string;
131
+ label: string;
132
+ envVar: string;
133
+ defaultDir: string;
134
+ bin: string;
135
+ extraEnv?: Record<string, string> | undefined;
136
+ loginArgs?: string[] | undefined;
137
+ loginHint?: string | undefined;
138
+ accountFile?: string | undefined;
139
+ emailPath?: string[] | undefined;
140
+ }>, "many">>;
141
+ }, "strip", z.ZodTypeAny, {
142
+ version: 1;
143
+ current: Record<string, string>;
144
+ applied: Record<string, string>;
145
+ profiles: {
146
+ name: string;
147
+ tool: string;
148
+ dir: string;
149
+ createdAt: string;
150
+ email?: string | undefined;
151
+ description?: string | undefined;
152
+ lastUsedAt?: string | undefined;
153
+ }[];
154
+ tools: {
155
+ id: string;
156
+ label: string;
157
+ envVar: string;
158
+ defaultDir: string;
159
+ bin: string;
160
+ extraEnv?: Record<string, string> | undefined;
161
+ loginArgs?: string[] | undefined;
162
+ loginHint?: string | undefined;
163
+ accountFile?: string | undefined;
164
+ emailPath?: string[] | undefined;
165
+ }[];
166
+ }, {
167
+ version: 1;
168
+ current?: Record<string, string> | undefined;
169
+ applied?: Record<string, string> | undefined;
170
+ profiles?: {
171
+ name: string;
172
+ tool: string;
173
+ dir: string;
174
+ createdAt: string;
175
+ email?: string | undefined;
176
+ description?: string | undefined;
177
+ lastUsedAt?: string | undefined;
178
+ }[] | undefined;
179
+ tools?: {
180
+ id: string;
181
+ label: string;
182
+ envVar: string;
183
+ defaultDir: string;
184
+ bin: string;
185
+ extraEnv?: Record<string, string> | undefined;
186
+ loginArgs?: string[] | undefined;
187
+ loginHint?: string | undefined;
188
+ accountFile?: string | undefined;
189
+ emailPath?: string[] | undefined;
190
+ }[] | undefined;
191
+ }>;
192
+ export type Store = z.infer<typeof storeSchema>;
193
+ export declare class AccountsError extends Error {
194
+ constructor(message: string);
195
+ }
196
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,8BAA8B;AAC9B,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAE5C,uEAAuE;AACvE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWxB,CAAC;AAEH;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;EAQxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD,eAAO,MAAM,WAAW;;IAEtB,mEAAmE;;IAEnE;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGH,0EAA0E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE1E,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEhD,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B"}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@hasna/accounts",
3
+ "version": "0.1.2",
4
+ "description": "Manage and switch between multiple Claude Code (and other AI coding tool) profiles/accounts locally — isolated config dirs, per-account email, one-command switching.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "accounts": "dist/cli.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "LICENSE",
20
+ "README.md"
21
+ ],
22
+ "scripts": {
23
+ "build": "rm -rf dist && bun build src/cli.ts --outdir dist --target node && bun build src/index.ts --outdir dist --target node && tsc --emitDeclarationOnly --outDir dist",
24
+ "dev": "bun run src/cli.ts",
25
+ "typecheck": "tsc --noEmit",
26
+ "test": "bun test"
27
+ },
28
+ "keywords": [
29
+ "claude",
30
+ "claude-code",
31
+ "codex",
32
+ "opencode",
33
+ "cursor-agent",
34
+ "kimi-code",
35
+ "grok-build",
36
+ "profile",
37
+ "account",
38
+ "switcher",
39
+ "cli",
40
+ "ai",
41
+ "coding-agent",
42
+ "CLAUDE_CONFIG_DIR"
43
+ ],
44
+ "publishConfig": {
45
+ "registry": "https://registry.npmjs.org",
46
+ "access": "public"
47
+ },
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "https://github.com/hasna/accounts.git"
51
+ },
52
+ "homepage": "https://github.com/hasna/accounts",
53
+ "bugs": {
54
+ "url": "https://github.com/hasna/accounts/issues"
55
+ },
56
+ "engines": {
57
+ "node": ">=18",
58
+ "bun": ">=1.0.0"
59
+ },
60
+ "author": "Andrei Hasna <andrei@hasna.com>",
61
+ "license": "Apache-2.0",
62
+ "dependencies": {
63
+ "chalk": "^5.4.1",
64
+ "commander": "^13.1.0",
65
+ "zod": "^3.24.2"
66
+ },
67
+ "devDependencies": {
68
+ "@types/bun": "^1.2.4",
69
+ "typescript": "^5.7.3"
70
+ }
71
+ }