@gitpagedocs/tools 1.1.55 → 1.1.56

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 CHANGED
@@ -1,37 +1,37 @@
1
- {
2
- "name": "@gitpagedocs/tools",
3
- "version": "1.1.55",
4
- "type": "module",
5
- "description": "Shared business-logic core for Git Page Docs (consumed by frontend, cli and mcp). Ships TypeScript source; consume via tsx or a TS-aware bundler.",
6
- "main": "./src/index.ts",
7
- "types": "./src/index.ts",
8
- "exports": {
9
- ".": "./src/index.ts",
10
- "./ai": "./src/ai/index.ts",
11
- "./errors": "./src/errors/index.ts",
12
- "./ports": "./src/ports/index.ts",
13
- "./crypto/web": "./src/crypto/web.ts",
14
- "./security/web": "./src/security/web.ts",
15
- "./cache/web": "./src/cache/web-storage-cache.ts"
16
- },
17
- "files": [
18
- "src",
19
- "README.md"
20
- ],
21
- "engines": {
22
- "node": ">=20"
23
- },
24
- "scripts": {
25
- "typecheck": "tsc --noEmit -p tsconfig.json"
26
- },
27
- "repository": {
28
- "type": "git",
29
- "url": "git+https://github.com/Vidigal-code/git-page-docs.git",
30
- "directory": "tools"
31
- },
32
- "author": "Vidigal-code",
33
- "license": "ISC",
34
- "publishConfig": {
35
- "access": "public"
36
- }
37
- }
1
+ {
2
+ "name": "@gitpagedocs/tools",
3
+ "version": "1.1.56",
4
+ "type": "module",
5
+ "description": "Shared business-logic core for Git Page Docs (consumed by frontend, cli and mcp). Ships TypeScript source; consume via tsx or a TS-aware bundler.",
6
+ "main": "./src/index.ts",
7
+ "types": "./src/index.ts",
8
+ "exports": {
9
+ ".": "./src/index.ts",
10
+ "./ai": "./src/ai/index.ts",
11
+ "./errors": "./src/errors/index.ts",
12
+ "./ports": "./src/ports/index.ts",
13
+ "./crypto/web": "./src/crypto/web.ts",
14
+ "./security/web": "./src/security/web.ts",
15
+ "./cache/web": "./src/cache/web-storage-cache.ts"
16
+ },
17
+ "files": [
18
+ "src",
19
+ "README.md"
20
+ ],
21
+ "engines": {
22
+ "node": ">=20"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/Vidigal-code/git-page-docs.git",
27
+ "directory": "tools"
28
+ },
29
+ "author": "Vidigal-code",
30
+ "license": "ISC",
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "scripts": {
35
+ "typecheck": "tsc --noEmit -p tsconfig.json"
36
+ }
37
+ }
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ export * from "./cache";
15
15
  export * from "./security";
16
16
  export * from "./config";
17
17
  export * from "./constants";
18
+ export * from "./platform";
18
19
 
19
20
  // Phase 5 — shared AI system.
20
21
  export * from "./ai";
@@ -0,0 +1 @@
1
+ export * from "./user-config-dir";
@@ -0,0 +1,48 @@
1
+ import os from "node:os";
2
+ import path from "node:path";
3
+
4
+ /** Environment variable that overrides the resolved user config directory. */
5
+ export const USER_CONFIG_DIR_ENV_VAR = "GITPAGEDOCS_CONFIG_DIR";
6
+
7
+ /** Directory name that holds gitpagedocs user-level configuration. */
8
+ export const USER_CONFIG_APP_DIR = "gitpagedocs";
9
+
10
+ export interface UserConfigDirContext {
11
+ /** Platform id (defaults to `process.platform`). */
12
+ platform?: NodeJS.Platform;
13
+ /** Environment map (defaults to `process.env`). */
14
+ env?: NodeJS.ProcessEnv;
15
+ /** User home directory (defaults to `os.homedir()`). */
16
+ homeDir?: string;
17
+ }
18
+
19
+ /**
20
+ * Resolve the per-user gitpagedocs configuration directory following each
21
+ * platform's convention:
22
+ *
23
+ * - Windows: `%APPDATA%\gitpagedocs`
24
+ * - macOS: `~/Library/Application Support/gitpagedocs`
25
+ * - Linux and others: `$XDG_CONFIG_HOME/gitpagedocs` or `~/.config/gitpagedocs`
26
+ *
27
+ * The `GITPAGEDOCS_CONFIG_DIR` environment variable overrides all of the above.
28
+ */
29
+ export function resolveUserConfigDir(context: UserConfigDirContext = {}): string {
30
+ const env = context.env ?? process.env;
31
+ const override = env[USER_CONFIG_DIR_ENV_VAR]?.trim();
32
+ if (override) return path.resolve(override);
33
+
34
+ const platform = context.platform ?? process.platform;
35
+ const homeDir = context.homeDir ?? os.homedir();
36
+
37
+ if (platform === "win32") {
38
+ const appData = env.APPDATA?.trim() || path.join(homeDir, "AppData", "Roaming");
39
+ return path.join(appData, USER_CONFIG_APP_DIR);
40
+ }
41
+
42
+ if (platform === "darwin") {
43
+ return path.join(homeDir, "Library", "Application Support", USER_CONFIG_APP_DIR);
44
+ }
45
+
46
+ const configHome = env.XDG_CONFIG_HOME?.trim() || path.join(homeDir, ".config");
47
+ return path.join(configHome, USER_CONFIG_APP_DIR);
48
+ }