studiograph 1.0.0
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 +18 -0
- package/dist/agent/orchestrator.d.ts +69 -0
- package/dist/agent/orchestrator.js +211 -0
- package/dist/agent/orchestrator.js.map +1 -0
- package/dist/agent/tools/graph-tools.d.ts +30 -0
- package/dist/agent/tools/graph-tools.js +536 -0
- package/dist/agent/tools/graph-tools.js.map +1 -0
- package/dist/auth/github.d.ts +53 -0
- package/dist/auth/github.js +180 -0
- package/dist/auth/github.js.map +1 -0
- package/dist/cli/commands/auth.d.ts +10 -0
- package/dist/cli/commands/auth.js +63 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/init.d.ts +7 -0
- package/dist/cli/commands/init.js +299 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/join.d.ts +14 -0
- package/dist/cli/commands/join.js +230 -0
- package/dist/cli/commands/join.js.map +1 -0
- package/dist/cli/commands/members.d.ts +11 -0
- package/dist/cli/commands/members.js +230 -0
- package/dist/cli/commands/members.js.map +1 -0
- package/dist/cli/commands/serve.d.ts +17 -0
- package/dist/cli/commands/serve.js +90 -0
- package/dist/cli/commands/serve.js.map +1 -0
- package/dist/cli/commands/start.d.ts +7 -0
- package/dist/cli/commands/start.js +381 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/sync.d.ts +10 -0
- package/dist/cli/commands/sync.js +121 -0
- package/dist/cli/commands/sync.js.map +1 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.js +31 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/graph.d.ts +169 -0
- package/dist/core/graph.js +558 -0
- package/dist/core/graph.js.map +1 -0
- package/dist/core/types.d.ts +216 -0
- package/dist/core/types.js +71 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/user-config.d.ts +31 -0
- package/dist/core/user-config.js +50 -0
- package/dist/core/user-config.js.map +1 -0
- package/dist/core/validation.d.ts +2371 -0
- package/dist/core/validation.js +432 -0
- package/dist/core/validation.js.map +1 -0
- package/dist/core/workspace-manager.d.ts +104 -0
- package/dist/core/workspace-manager.js +432 -0
- package/dist/core/workspace-manager.js.map +1 -0
- package/dist/core/workspace.d.ts +103 -0
- package/dist/core/workspace.js +306 -0
- package/dist/core/workspace.js.map +1 -0
- package/dist/server/index.d.ts +25 -0
- package/dist/server/index.js +84 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/plugin-loader.d.ts +31 -0
- package/dist/server/plugin-loader.js +81 -0
- package/dist/server/plugin-loader.js.map +1 -0
- package/dist/server/routes/chat.d.ts +11 -0
- package/dist/server/routes/chat.js +66 -0
- package/dist/server/routes/chat.js.map +1 -0
- package/dist/server/routes/graph-api.d.ts +9 -0
- package/dist/server/routes/graph-api.js +72 -0
- package/dist/server/routes/graph-api.js.map +1 -0
- package/dist/server/routes/webhook.d.ts +14 -0
- package/dist/server/routes/webhook.js +69 -0
- package/dist/server/routes/webhook.js.map +1 -0
- package/dist/services/assets/base.d.ts +69 -0
- package/dist/services/assets/base.js +113 -0
- package/dist/services/assets/base.js.map +1 -0
- package/dist/services/assets/index.d.ts +36 -0
- package/dist/services/assets/index.js +89 -0
- package/dist/services/assets/index.js.map +1 -0
- package/dist/services/assets/local.d.ts +42 -0
- package/dist/services/assets/local.js +161 -0
- package/dist/services/assets/local.js.map +1 -0
- package/dist/services/assets/r2.d.ts +36 -0
- package/dist/services/assets/r2.js +182 -0
- package/dist/services/assets/r2.js.map +1 -0
- package/dist/services/csv-service.d.ts +36 -0
- package/dist/services/csv-service.js +143 -0
- package/dist/services/csv-service.js.map +1 -0
- package/dist/services/git.d.ts +99 -0
- package/dist/services/git.js +306 -0
- package/dist/services/git.js.map +1 -0
- package/dist/services/github-provisioner.d.ts +30 -0
- package/dist/services/github-provisioner.js +89 -0
- package/dist/services/github-provisioner.js.map +1 -0
- package/dist/services/markdown.d.ts +82 -0
- package/dist/services/markdown.js +338 -0
- package/dist/services/markdown.js.map +1 -0
- package/dist/services/memory-service.d.ts +74 -0
- package/dist/services/memory-service.js +183 -0
- package/dist/services/memory-service.js.map +1 -0
- package/dist/utils/git.d.ts +28 -0
- package/dist/utils/git.js +55 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/preflight.d.ts +44 -0
- package/dist/utils/preflight.js +95 -0
- package/dist/utils/preflight.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for Studiograph workspace and repo management
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/**
|
|
6
|
+
* Base entity metadata (all entities have these fields)
|
|
7
|
+
*/
|
|
8
|
+
export declare const EntityBaseSchema: z.ZodObject<{
|
|
9
|
+
entity_type: z.ZodString;
|
|
10
|
+
entity_id: z.ZodString;
|
|
11
|
+
created_at: z.ZodString;
|
|
12
|
+
updated_at: z.ZodString;
|
|
13
|
+
created_by: z.ZodString;
|
|
14
|
+
updated_by: z.ZodString;
|
|
15
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
16
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
17
|
+
entity_type: z.ZodString;
|
|
18
|
+
entity_id: z.ZodString;
|
|
19
|
+
created_at: z.ZodString;
|
|
20
|
+
updated_at: z.ZodString;
|
|
21
|
+
created_by: z.ZodString;
|
|
22
|
+
updated_by: z.ZodString;
|
|
23
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
24
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
25
|
+
entity_type: z.ZodString;
|
|
26
|
+
entity_id: z.ZodString;
|
|
27
|
+
created_at: z.ZodString;
|
|
28
|
+
updated_at: z.ZodString;
|
|
29
|
+
created_by: z.ZodString;
|
|
30
|
+
updated_by: z.ZodString;
|
|
31
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
32
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
33
|
+
export type EntityBase = z.infer<typeof EntityBaseSchema>;
|
|
34
|
+
/**
|
|
35
|
+
* Repo types in Studiograph
|
|
36
|
+
*/
|
|
37
|
+
export declare enum RepoType {
|
|
38
|
+
PROJECT = "project",// One per client/project
|
|
39
|
+
FUNCTION = "function",// Business operations
|
|
40
|
+
SHARED_RESOURCE = "shared-resource"
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Repo configuration in registry
|
|
44
|
+
*/
|
|
45
|
+
export declare const RepoConfigSchema: z.ZodObject<{
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
type: z.ZodNativeEnum<typeof RepoType>;
|
|
48
|
+
path: z.ZodString;
|
|
49
|
+
description: z.ZodOptional<z.ZodString>;
|
|
50
|
+
access: z.ZodDefault<z.ZodEnum<["public", "team", "admin", "restricted"]>>;
|
|
51
|
+
github_url: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
name: string;
|
|
54
|
+
path: string;
|
|
55
|
+
type: RepoType;
|
|
56
|
+
access: "public" | "team" | "admin" | "restricted";
|
|
57
|
+
description?: string | undefined;
|
|
58
|
+
github_url?: string | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
name: string;
|
|
61
|
+
path: string;
|
|
62
|
+
type: RepoType;
|
|
63
|
+
description?: string | undefined;
|
|
64
|
+
access?: "public" | "team" | "admin" | "restricted" | undefined;
|
|
65
|
+
github_url?: string | undefined;
|
|
66
|
+
}>;
|
|
67
|
+
export type RepoConfig = z.infer<typeof RepoConfigSchema>;
|
|
68
|
+
export type RepoConfigInput = Omit<RepoConfig, 'path' | 'access'> & {
|
|
69
|
+
access?: RepoConfig['access'];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Workspace configuration
|
|
73
|
+
*/
|
|
74
|
+
export declare const WorkspaceConfigSchema: z.ZodObject<{
|
|
75
|
+
version: z.ZodString;
|
|
76
|
+
team_name: z.ZodString;
|
|
77
|
+
created_at: z.ZodString;
|
|
78
|
+
repos: z.ZodArray<z.ZodObject<{
|
|
79
|
+
name: z.ZodString;
|
|
80
|
+
type: z.ZodNativeEnum<typeof RepoType>;
|
|
81
|
+
path: z.ZodString;
|
|
82
|
+
description: z.ZodOptional<z.ZodString>;
|
|
83
|
+
access: z.ZodDefault<z.ZodEnum<["public", "team", "admin", "restricted"]>>;
|
|
84
|
+
github_url: z.ZodOptional<z.ZodString>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
name: string;
|
|
87
|
+
path: string;
|
|
88
|
+
type: RepoType;
|
|
89
|
+
access: "public" | "team" | "admin" | "restricted";
|
|
90
|
+
description?: string | undefined;
|
|
91
|
+
github_url?: string | undefined;
|
|
92
|
+
}, {
|
|
93
|
+
name: string;
|
|
94
|
+
path: string;
|
|
95
|
+
type: RepoType;
|
|
96
|
+
description?: string | undefined;
|
|
97
|
+
access?: "public" | "team" | "admin" | "restricted" | undefined;
|
|
98
|
+
github_url?: string | undefined;
|
|
99
|
+
}>, "many">;
|
|
100
|
+
model_provider: z.ZodOptional<z.ZodString>;
|
|
101
|
+
model_id: z.ZodOptional<z.ZodString>;
|
|
102
|
+
api_key: z.ZodOptional<z.ZodString>;
|
|
103
|
+
anthropic_api_key: z.ZodOptional<z.ZodString>;
|
|
104
|
+
r2_config: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
account_id: z.ZodOptional<z.ZodString>;
|
|
106
|
+
bucket: z.ZodOptional<z.ZodString>;
|
|
107
|
+
public_url: z.ZodOptional<z.ZodString>;
|
|
108
|
+
access_key_id: z.ZodOptional<z.ZodString>;
|
|
109
|
+
secret_access_key: z.ZodOptional<z.ZodString>;
|
|
110
|
+
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
account_id?: string | undefined;
|
|
112
|
+
bucket?: string | undefined;
|
|
113
|
+
public_url?: string | undefined;
|
|
114
|
+
access_key_id?: string | undefined;
|
|
115
|
+
secret_access_key?: string | undefined;
|
|
116
|
+
}, {
|
|
117
|
+
account_id?: string | undefined;
|
|
118
|
+
bucket?: string | undefined;
|
|
119
|
+
public_url?: string | undefined;
|
|
120
|
+
access_key_id?: string | undefined;
|
|
121
|
+
secret_access_key?: string | undefined;
|
|
122
|
+
}>>;
|
|
123
|
+
github: z.ZodOptional<z.ZodObject<{
|
|
124
|
+
org: z.ZodOptional<z.ZodString>;
|
|
125
|
+
}, "strip", z.ZodTypeAny, {
|
|
126
|
+
org?: string | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
org?: string | undefined;
|
|
129
|
+
}>>;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
created_at: string;
|
|
132
|
+
version: string;
|
|
133
|
+
team_name: string;
|
|
134
|
+
repos: {
|
|
135
|
+
name: string;
|
|
136
|
+
path: string;
|
|
137
|
+
type: RepoType;
|
|
138
|
+
access: "public" | "team" | "admin" | "restricted";
|
|
139
|
+
description?: string | undefined;
|
|
140
|
+
github_url?: string | undefined;
|
|
141
|
+
}[];
|
|
142
|
+
model_provider?: string | undefined;
|
|
143
|
+
model_id?: string | undefined;
|
|
144
|
+
api_key?: string | undefined;
|
|
145
|
+
anthropic_api_key?: string | undefined;
|
|
146
|
+
r2_config?: {
|
|
147
|
+
account_id?: string | undefined;
|
|
148
|
+
bucket?: string | undefined;
|
|
149
|
+
public_url?: string | undefined;
|
|
150
|
+
access_key_id?: string | undefined;
|
|
151
|
+
secret_access_key?: string | undefined;
|
|
152
|
+
} | undefined;
|
|
153
|
+
github?: {
|
|
154
|
+
org?: string | undefined;
|
|
155
|
+
} | undefined;
|
|
156
|
+
}, {
|
|
157
|
+
created_at: string;
|
|
158
|
+
version: string;
|
|
159
|
+
team_name: string;
|
|
160
|
+
repos: {
|
|
161
|
+
name: string;
|
|
162
|
+
path: string;
|
|
163
|
+
type: RepoType;
|
|
164
|
+
description?: string | undefined;
|
|
165
|
+
access?: "public" | "team" | "admin" | "restricted" | undefined;
|
|
166
|
+
github_url?: string | undefined;
|
|
167
|
+
}[];
|
|
168
|
+
model_provider?: string | undefined;
|
|
169
|
+
model_id?: string | undefined;
|
|
170
|
+
api_key?: string | undefined;
|
|
171
|
+
anthropic_api_key?: string | undefined;
|
|
172
|
+
r2_config?: {
|
|
173
|
+
account_id?: string | undefined;
|
|
174
|
+
bucket?: string | undefined;
|
|
175
|
+
public_url?: string | undefined;
|
|
176
|
+
access_key_id?: string | undefined;
|
|
177
|
+
secret_access_key?: string | undefined;
|
|
178
|
+
} | undefined;
|
|
179
|
+
github?: {
|
|
180
|
+
org?: string | undefined;
|
|
181
|
+
} | undefined;
|
|
182
|
+
}>;
|
|
183
|
+
export type WorkspaceConfig = z.infer<typeof WorkspaceConfigSchema>;
|
|
184
|
+
/**
|
|
185
|
+
* Entity with full data (frontmatter + content)
|
|
186
|
+
*/
|
|
187
|
+
export interface Entity extends EntityBase {
|
|
188
|
+
content?: string;
|
|
189
|
+
wikilinks?: string[];
|
|
190
|
+
[key: string]: any;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* User context for operations
|
|
194
|
+
*/
|
|
195
|
+
export interface User {
|
|
196
|
+
id: string;
|
|
197
|
+
name: string;
|
|
198
|
+
email: string;
|
|
199
|
+
role?: 'admin' | 'member' | 'guest';
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Git change tracking
|
|
203
|
+
*/
|
|
204
|
+
export interface GitChange {
|
|
205
|
+
operation: 'create' | 'update' | 'delete';
|
|
206
|
+
repo: string;
|
|
207
|
+
filePath: string;
|
|
208
|
+
entityType: string;
|
|
209
|
+
entityId: string;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Permission error thrown when user lacks access to a repository
|
|
213
|
+
*/
|
|
214
|
+
export declare class PermissionError extends Error {
|
|
215
|
+
constructor(message: string);
|
|
216
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for Studiograph workspace and repo management
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
/**
|
|
6
|
+
* Base entity metadata (all entities have these fields)
|
|
7
|
+
*/
|
|
8
|
+
export const EntityBaseSchema = z.object({
|
|
9
|
+
entity_type: z.string(),
|
|
10
|
+
entity_id: z.string().regex(/^[a-z0-9-]+$/, 'Entity ID must be kebab-case'),
|
|
11
|
+
created_at: z.string().datetime(),
|
|
12
|
+
updated_at: z.string().datetime(),
|
|
13
|
+
created_by: z.string(),
|
|
14
|
+
updated_by: z.string(),
|
|
15
|
+
tags: z.array(z.string()).optional(),
|
|
16
|
+
}).passthrough(); // Allow custom fields
|
|
17
|
+
/**
|
|
18
|
+
* Repo types in Studiograph
|
|
19
|
+
*/
|
|
20
|
+
export var RepoType;
|
|
21
|
+
(function (RepoType) {
|
|
22
|
+
RepoType["PROJECT"] = "project";
|
|
23
|
+
RepoType["FUNCTION"] = "function";
|
|
24
|
+
RepoType["SHARED_RESOURCE"] = "shared-resource";
|
|
25
|
+
})(RepoType || (RepoType = {}));
|
|
26
|
+
/**
|
|
27
|
+
* Repo configuration in registry
|
|
28
|
+
*/
|
|
29
|
+
export const RepoConfigSchema = z.object({
|
|
30
|
+
name: z.string(),
|
|
31
|
+
type: z.nativeEnum(RepoType),
|
|
32
|
+
path: z.string(), // Relative to workspace root
|
|
33
|
+
description: z.string().optional(),
|
|
34
|
+
access: z.enum(['public', 'team', 'admin', 'restricted']).default('team'),
|
|
35
|
+
github_url: z.string().optional(),
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Workspace configuration
|
|
39
|
+
*/
|
|
40
|
+
export const WorkspaceConfigSchema = z.object({
|
|
41
|
+
version: z.string(),
|
|
42
|
+
team_name: z.string(),
|
|
43
|
+
created_at: z.string().datetime(),
|
|
44
|
+
repos: z.array(RepoConfigSchema),
|
|
45
|
+
// Model configuration
|
|
46
|
+
model_provider: z.string().optional(), // e.g., 'anthropic', 'openai', 'google'
|
|
47
|
+
model_id: z.string().optional(), // e.g., 'claude-sonnet-4-5-20250929'
|
|
48
|
+
api_key: z.string().optional(), // Unified API key field
|
|
49
|
+
// Legacy field (deprecated, use api_key instead)
|
|
50
|
+
anthropic_api_key: z.string().optional(),
|
|
51
|
+
r2_config: z.object({
|
|
52
|
+
account_id: z.string().optional(),
|
|
53
|
+
bucket: z.string().optional(),
|
|
54
|
+
public_url: z.string().optional(),
|
|
55
|
+
access_key_id: z.string().optional(),
|
|
56
|
+
secret_access_key: z.string().optional(),
|
|
57
|
+
}).optional(),
|
|
58
|
+
github: z.object({
|
|
59
|
+
org: z.string().optional(),
|
|
60
|
+
}).optional(),
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Permission error thrown when user lacks access to a repository
|
|
64
|
+
*/
|
|
65
|
+
export class PermissionError extends Error {
|
|
66
|
+
constructor(message) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.name = 'PermissionError';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE,8BAA8B,CAAC;IAC3E,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB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,EAAE,EAAE,qCAAqC;IACtE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,wBAAwB;IACxD,iDAAiD;IACjD,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACxC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;QAClB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACjC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC7B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACjC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACpC,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACzC,CAAC,CAAC,QAAQ,EAAE;IACb,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC3B,CAAC,CAAC,QAAQ,EAAE;CACd,CAAC,CAAC;AAkCH;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-level configuration for Studiograph
|
|
3
|
+
*
|
|
4
|
+
* Stored at ~/.studiograph/user.json — never committed to git.
|
|
5
|
+
* Holds personal credentials and preferences that should not be shared
|
|
6
|
+
* with the team (API keys, preferred model, etc.).
|
|
7
|
+
*
|
|
8
|
+
* This mirrors the pattern established by ~/.studiograph/auth.json
|
|
9
|
+
* for GitHub tokens.
|
|
10
|
+
*/
|
|
11
|
+
export interface UserConfig {
|
|
12
|
+
model_provider?: string;
|
|
13
|
+
model_id?: string;
|
|
14
|
+
api_key?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const USER_CONFIG_PATH: string;
|
|
17
|
+
/**
|
|
18
|
+
* Load the user config from ~/.studiograph/user.json.
|
|
19
|
+
* Returns an empty object if the file does not exist or cannot be parsed.
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadUserConfig(): UserConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Persist the user config to ~/.studiograph/user.json with mode 0600
|
|
24
|
+
* (owner read/write only — keeps API keys off shared file systems).
|
|
25
|
+
*/
|
|
26
|
+
export declare function saveUserConfig(config: UserConfig): void;
|
|
27
|
+
/**
|
|
28
|
+
* Save model provider, model ID, and optional API key to user config.
|
|
29
|
+
* Merges with any existing user config so other fields are preserved.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setUserModelConfig(provider: string, modelId: string, apiKey?: string): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-level configuration for Studiograph
|
|
3
|
+
*
|
|
4
|
+
* Stored at ~/.studiograph/user.json — never committed to git.
|
|
5
|
+
* Holds personal credentials and preferences that should not be shared
|
|
6
|
+
* with the team (API keys, preferred model, etc.).
|
|
7
|
+
*
|
|
8
|
+
* This mirrors the pattern established by ~/.studiograph/auth.json
|
|
9
|
+
* for GitHub tokens.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
12
|
+
import { join } from 'path';
|
|
13
|
+
import { homedir } from 'os';
|
|
14
|
+
const USER_CONFIG_DIR = join(homedir(), '.studiograph');
|
|
15
|
+
export const USER_CONFIG_PATH = join(USER_CONFIG_DIR, 'user.json');
|
|
16
|
+
/**
|
|
17
|
+
* Load the user config from ~/.studiograph/user.json.
|
|
18
|
+
* Returns an empty object if the file does not exist or cannot be parsed.
|
|
19
|
+
*/
|
|
20
|
+
export function loadUserConfig() {
|
|
21
|
+
if (!existsSync(USER_CONFIG_PATH))
|
|
22
|
+
return {};
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(readFileSync(USER_CONFIG_PATH, 'utf-8'));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Persist the user config to ~/.studiograph/user.json with mode 0600
|
|
32
|
+
* (owner read/write only — keeps API keys off shared file systems).
|
|
33
|
+
*/
|
|
34
|
+
export function saveUserConfig(config) {
|
|
35
|
+
mkdirSync(USER_CONFIG_DIR, { recursive: true });
|
|
36
|
+
writeFileSync(USER_CONFIG_PATH, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Save model provider, model ID, and optional API key to user config.
|
|
40
|
+
* Merges with any existing user config so other fields are preserved.
|
|
41
|
+
*/
|
|
42
|
+
export function setUserModelConfig(provider, modelId, apiKey) {
|
|
43
|
+
const current = loadUserConfig();
|
|
44
|
+
current.model_provider = provider;
|
|
45
|
+
current.model_id = modelId;
|
|
46
|
+
if (apiKey)
|
|
47
|
+
current.api_key = apiKey;
|
|
48
|
+
saveUserConfig(current);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=user-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-config.js","sourceRoot":"","sources":["../../src/core/user-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAQ7B,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,cAAc,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,CA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