@snapback/cli 1.6.0 → 3.0.1
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 +121 -22
- package/dist/SkippedTestDetector-AXTMWWHC.js +5 -0
- package/dist/SkippedTestDetector-QLSQV7K7.js +5 -0
- package/dist/analysis-6WTBZJH3.js +6 -0
- package/dist/analysis-C472LUGW.js +2475 -0
- package/dist/auth-UA7I3YE4.js +1446 -0
- package/dist/auto-provision-organization-6YF463TK.js +161 -0
- package/dist/{chunk-FVIYXFCL.js → chunk-4YTE4JEW.js} +2 -3
- package/dist/chunk-5EOPYJ4Y.js +12 -0
- package/dist/{chunk-ARVV3F4K.js → chunk-5SQA44V7.js} +1085 -18
- package/dist/{chunk-RB7H4UQJ.js → chunk-7ADPL4Q3.js} +10 -3
- package/dist/chunk-BE3HNVSV.js +2300 -0
- package/dist/chunk-BWWPGNZ5.js +5842 -0
- package/dist/chunk-CBGOC6RV.js +293 -0
- package/dist/{chunk-7JX6Y4TL.js → chunk-DPWFZNMY.js} +21 -34
- package/dist/{chunk-R7CUQ7CU.js → chunk-E6V6QKS7.js} +317 -33
- package/dist/chunk-GT4ZUCFR.js +111 -0
- package/dist/chunk-NOWJBG6X.js +3654 -0
- package/dist/chunk-O7HMAZ7L.js +3497 -0
- package/dist/chunk-PL4HF4M2.js +593 -0
- package/dist/chunk-V7B37PPD.js +4075 -0
- package/dist/chunk-YVZXPBSV.js +314 -0
- package/dist/chunk-ZBQDE6WJ.js +108 -0
- package/dist/client-RHDS6NOB.js +8 -0
- package/dist/dist-5LR7APG5.js +5 -0
- package/dist/dist-CUHOKNLS.js +12 -0
- package/dist/dist-RJE4RSZJ.js +9 -0
- package/dist/index.js +60568 -36578
- package/dist/local-service-adapter-AB3UYRUK.js +6 -0
- package/dist/pioneer-oauth-hook-V2JKEXM7.js +12 -0
- package/dist/{secure-credentials-IWQB6KU4.js → secure-credentials-UEPG7GWW.js} +2 -3
- package/dist/snapback-dir-MG7DTRMF.js +6 -0
- package/package.json +12 -11
- package/scripts/postinstall.mjs +2 -3
- package/dist/SkippedTestDetector-5WJZKZQ3.js +0 -5
- package/dist/SkippedTestDetector-5WJZKZQ3.js.map +0 -1
- package/dist/analysis-YI4UNUCM.js +0 -6
- package/dist/analysis-YI4UNUCM.js.map +0 -1
- package/dist/chunk-7JX6Y4TL.js.map +0 -1
- package/dist/chunk-ARVV3F4K.js.map +0 -1
- package/dist/chunk-EU2IZPOK.js +0 -13002
- package/dist/chunk-EU2IZPOK.js.map +0 -1
- package/dist/chunk-FVIYXFCL.js.map +0 -1
- package/dist/chunk-R7CUQ7CU.js.map +0 -1
- package/dist/chunk-RB7H4UQJ.js.map +0 -1
- package/dist/chunk-SOABQWAU.js +0 -385
- package/dist/chunk-SOABQWAU.js.map +0 -1
- package/dist/dist-O6EBXLN6.js +0 -5
- package/dist/dist-O6EBXLN6.js.map +0 -1
- package/dist/dist-PJVBBZTF.js +0 -5
- package/dist/dist-PJVBBZTF.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/learning-pruner-QC4CTJDX.js +0 -5
- package/dist/learning-pruner-QC4CTJDX.js.map +0 -1
- package/dist/secure-credentials-IWQB6KU4.js.map +0 -1
- package/dist/snapback-dir-V6MWXIW4.js +0 -5
- package/dist/snapback-dir-V6MWXIW4.js.map +0 -1
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
|
2
|
+
import { __name } from './chunk-7ADPL4Q3.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
process.env.SNAPBACK_CLI='true';
|
|
6
|
+
var LearningTypeSchema = z.enum([
|
|
7
|
+
"pattern",
|
|
8
|
+
"pitfall",
|
|
9
|
+
"efficiency",
|
|
10
|
+
"workflow",
|
|
11
|
+
"discovery"
|
|
12
|
+
]);
|
|
13
|
+
var LearningIntentSchema = z.enum([
|
|
14
|
+
"implement",
|
|
15
|
+
"debug",
|
|
16
|
+
"refactor",
|
|
17
|
+
"review"
|
|
18
|
+
]);
|
|
19
|
+
z.enum([
|
|
20
|
+
"add-flag",
|
|
21
|
+
"set-env",
|
|
22
|
+
"inject-validation",
|
|
23
|
+
"warn",
|
|
24
|
+
"suggest-file"
|
|
25
|
+
]);
|
|
26
|
+
var WarnSeveritySchema = z.enum([
|
|
27
|
+
"info",
|
|
28
|
+
"warning",
|
|
29
|
+
"error"
|
|
30
|
+
]);
|
|
31
|
+
var AddFlagPayloadSchema = z.object({
|
|
32
|
+
flag: z.string().min(1).describe("CLI flag to add, e.g. '--validate-expiry'"),
|
|
33
|
+
value: z.union([
|
|
34
|
+
z.string(),
|
|
35
|
+
z.boolean()
|
|
36
|
+
]).optional().describe("Flag value if applicable"),
|
|
37
|
+
reason: z.string().min(1).describe("Human-readable reason shown in verbose mode")
|
|
38
|
+
});
|
|
39
|
+
var SetEnvPayloadSchema = z.object({
|
|
40
|
+
key: z.string().min(1).regex(/^[A-Z_][A-Z0-9_]*$/, "Must be valid env var name"),
|
|
41
|
+
value: z.string().describe("Environment variable value"),
|
|
42
|
+
reason: z.string().min(1).describe("Human-readable reason shown in verbose mode")
|
|
43
|
+
});
|
|
44
|
+
var InjectValidationPayloadSchema = z.object({
|
|
45
|
+
validationType: z.string().min(1).describe("Validation type identifier, e.g. 'jwt-expiry', 'silent-catch'"),
|
|
46
|
+
targetFile: z.string().optional().describe("Optional file to target for validation"),
|
|
47
|
+
reason: z.string().min(1).describe("Human-readable reason shown in verbose mode")
|
|
48
|
+
});
|
|
49
|
+
var WarnPayloadSchema = z.object({
|
|
50
|
+
message: z.string().min(1).describe("Warning message to display"),
|
|
51
|
+
severity: WarnSeveritySchema.describe("Severity level affects display styling")
|
|
52
|
+
});
|
|
53
|
+
var SuggestFilePayloadSchema = z.object({
|
|
54
|
+
filePath: z.string().min(1).describe("Suggested file path, may contain {feature} placeholder"),
|
|
55
|
+
reason: z.string().min(1).describe("Human-readable reason for suggestion")
|
|
56
|
+
});
|
|
57
|
+
var LearningTriggerSchema = z.object({
|
|
58
|
+
commands: z.array(z.string()).optional().describe("Command names that trigger this learning, e.g. ['auth', 'deploy']"),
|
|
59
|
+
intent: z.array(LearningIntentSchema).optional().describe("Intent types that trigger this learning"),
|
|
60
|
+
filePatterns: z.array(z.string()).optional().describe("Glob patterns for file matching, e.g. ['**/*auth*.ts']"),
|
|
61
|
+
flags: z.array(z.string()).optional().describe("CLI flags that trigger this learning, e.g. ['--provider']"),
|
|
62
|
+
description: z.string().min(1).describe("Human-readable description for fuzzy matching")
|
|
63
|
+
});
|
|
64
|
+
var LearningActionSchema = z.discriminatedUnion("type", [
|
|
65
|
+
z.object({
|
|
66
|
+
type: z.literal("add-flag"),
|
|
67
|
+
payload: AddFlagPayloadSchema
|
|
68
|
+
}),
|
|
69
|
+
z.object({
|
|
70
|
+
type: z.literal("set-env"),
|
|
71
|
+
payload: SetEnvPayloadSchema
|
|
72
|
+
}),
|
|
73
|
+
z.object({
|
|
74
|
+
type: z.literal("inject-validation"),
|
|
75
|
+
payload: InjectValidationPayloadSchema
|
|
76
|
+
}),
|
|
77
|
+
z.object({
|
|
78
|
+
type: z.literal("warn"),
|
|
79
|
+
payload: WarnPayloadSchema
|
|
80
|
+
}),
|
|
81
|
+
z.object({
|
|
82
|
+
type: z.literal("suggest-file"),
|
|
83
|
+
payload: SuggestFilePayloadSchema
|
|
84
|
+
})
|
|
85
|
+
]);
|
|
86
|
+
var LearningSchema = z.object({
|
|
87
|
+
id: z.string().min(1).describe("Unique identifier for this learning"),
|
|
88
|
+
type: LearningTypeSchema.describe("Categorical classification"),
|
|
89
|
+
trigger: LearningTriggerSchema.describe("Conditions that activate this learning"),
|
|
90
|
+
action: LearningActionSchema.describe("Concrete action to execute"),
|
|
91
|
+
confidence: z.number().min(0).max(1).describe("Confidence score (0.0-1.0), static at creation"),
|
|
92
|
+
created: z.number().int().positive().describe("Creation timestamp (ms since epoch)"),
|
|
93
|
+
lastUsed: z.number().int().positive().optional().describe("Last usage timestamp (ms since epoch)"),
|
|
94
|
+
usageCount: z.number().int().nonnegative().default(0).describe("Number of times this learning was applied"),
|
|
95
|
+
tags: z.array(z.string()).default([]).describe("Searchable tags for categorization"),
|
|
96
|
+
archived: z.boolean().default(false).describe("Whether this learning is archived (excluded from matching)")
|
|
97
|
+
});
|
|
98
|
+
LearningSchema.omit({
|
|
99
|
+
id: true,
|
|
100
|
+
created: true,
|
|
101
|
+
lastUsed: true,
|
|
102
|
+
usageCount: true,
|
|
103
|
+
archived: true
|
|
104
|
+
}).extend({
|
|
105
|
+
tags: z.array(z.string()).optional().default([]),
|
|
106
|
+
archived: z.boolean().optional()
|
|
107
|
+
});
|
|
108
|
+
z.enum([
|
|
109
|
+
"observe",
|
|
110
|
+
"warn",
|
|
111
|
+
"apply-safe",
|
|
112
|
+
"apply-all",
|
|
113
|
+
"off"
|
|
114
|
+
]);
|
|
115
|
+
z.object({
|
|
116
|
+
workspaceId: z.string().min(1),
|
|
117
|
+
startedAt: z.number().int().positive(),
|
|
118
|
+
lastCommandAt: z.number().int().positive(),
|
|
119
|
+
appliedLearnings: z.array(z.string()).describe("Learning IDs applied in this session")
|
|
120
|
+
});
|
|
121
|
+
z.object({
|
|
122
|
+
workspaceId: z.string().min(1),
|
|
123
|
+
commandName: z.string().min(1),
|
|
124
|
+
args: z.record(z.unknown()).optional().describe("Parsed command arguments/flags"),
|
|
125
|
+
filesOrPaths: z.array(z.string()).optional().describe("Files involved in command"),
|
|
126
|
+
intent: LearningIntentSchema.optional().describe("User intent if known")
|
|
127
|
+
});
|
|
128
|
+
var SelectedLearningSchema = z.object({
|
|
129
|
+
id: z.string(),
|
|
130
|
+
title: z.string().describe("Human-readable title derived from trigger.description"),
|
|
131
|
+
type: LearningTypeSchema,
|
|
132
|
+
score: z.number().min(0).max(1),
|
|
133
|
+
action: LearningActionSchema,
|
|
134
|
+
tags: z.array(z.string())
|
|
135
|
+
});
|
|
136
|
+
z.object({
|
|
137
|
+
selectedLearnings: z.array(SelectedLearningSchema),
|
|
138
|
+
debug: z.object({
|
|
139
|
+
evaluatedCount: z.number().int().nonnegative(),
|
|
140
|
+
durationMs: z.number().nonnegative(),
|
|
141
|
+
skippedReason: z.string().optional()
|
|
142
|
+
}).optional()
|
|
143
|
+
});
|
|
144
|
+
var LearningTierSchema = z.enum([
|
|
145
|
+
"hot",
|
|
146
|
+
"warm",
|
|
147
|
+
"cold"
|
|
148
|
+
]);
|
|
149
|
+
var LearningPrioritySchema = z.enum([
|
|
150
|
+
"critical",
|
|
151
|
+
"high",
|
|
152
|
+
"medium",
|
|
153
|
+
"low"
|
|
154
|
+
]);
|
|
155
|
+
var LearningStorageTypeSchema = z.enum([
|
|
156
|
+
"pattern",
|
|
157
|
+
"pitfall",
|
|
158
|
+
"pit",
|
|
159
|
+
"architecture",
|
|
160
|
+
"performance",
|
|
161
|
+
"efficiency",
|
|
162
|
+
"discovery",
|
|
163
|
+
"workflow",
|
|
164
|
+
"best-practice"
|
|
165
|
+
]);
|
|
166
|
+
var LearningStorageSchema = z.object({
|
|
167
|
+
id: z.string().min(1).optional(),
|
|
168
|
+
type: LearningStorageTypeSchema,
|
|
169
|
+
trigger: z.union([
|
|
170
|
+
z.string(),
|
|
171
|
+
z.array(z.string())
|
|
172
|
+
]),
|
|
173
|
+
context: z.string().optional(),
|
|
174
|
+
problem: z.string().optional(),
|
|
175
|
+
solution: z.string().optional(),
|
|
176
|
+
action: z.string(),
|
|
177
|
+
related: z.array(z.string()).optional(),
|
|
178
|
+
source: z.string(),
|
|
179
|
+
timestamp: z.union([
|
|
180
|
+
z.string(),
|
|
181
|
+
z.number()
|
|
182
|
+
]).describe("ISO 8601 string or epoch number from storage"),
|
|
183
|
+
// Tiering metadata (optional)
|
|
184
|
+
tier: LearningTierSchema.optional(),
|
|
185
|
+
domain: z.string().optional(),
|
|
186
|
+
priority: LearningPrioritySchema.optional(),
|
|
187
|
+
keywords: z.array(z.string()).optional(),
|
|
188
|
+
// Usage tracking (optional)
|
|
189
|
+
accessCount: z.number().int().nonnegative().optional(),
|
|
190
|
+
lastAccessed: z.string().optional(),
|
|
191
|
+
relevanceScore: z.number().min(0).max(1).optional(),
|
|
192
|
+
appliedDate: z.string().optional()
|
|
193
|
+
});
|
|
194
|
+
var ChunkSourceTypeSchema = z.enum([
|
|
195
|
+
"learning",
|
|
196
|
+
"adr",
|
|
197
|
+
"pattern",
|
|
198
|
+
"violation"
|
|
199
|
+
]);
|
|
200
|
+
var ChunkStatusSchema = z.enum([
|
|
201
|
+
"active",
|
|
202
|
+
"deprecated",
|
|
203
|
+
"superseded"
|
|
204
|
+
]);
|
|
205
|
+
z.object({
|
|
206
|
+
id: z.string().describe("Unique chunk identifier"),
|
|
207
|
+
source_type: ChunkSourceTypeSchema.describe("Type of source this chunk came from"),
|
|
208
|
+
source_id: z.string().describe("ID of the source record"),
|
|
209
|
+
chunk_text: z.string().describe("The actual content text"),
|
|
210
|
+
context_text: z.string().optional().describe("Optional context surrounding the chunk"),
|
|
211
|
+
authority: z.number().min(0).max(1).describe("Authority score (0-1)"),
|
|
212
|
+
status: ChunkStatusSchema.describe("Current status of the chunk"),
|
|
213
|
+
created_at: z.string().describe("ISO 8601 creation timestamp"),
|
|
214
|
+
updated_at: z.string().describe("ISO 8601 update timestamp"),
|
|
215
|
+
metadata: z.record(z.unknown()).optional().describe("Optional JSON metadata")
|
|
216
|
+
});
|
|
217
|
+
var OutcomeTypeSchema = z.enum([
|
|
218
|
+
"accepted",
|
|
219
|
+
"ignored",
|
|
220
|
+
"test_pass",
|
|
221
|
+
"test_fail",
|
|
222
|
+
"violation_prevented"
|
|
223
|
+
]);
|
|
224
|
+
z.object({
|
|
225
|
+
id: z.string(),
|
|
226
|
+
chunk_id: z.string(),
|
|
227
|
+
outcome_type: OutcomeTypeSchema,
|
|
228
|
+
context: z.record(z.unknown()).optional(),
|
|
229
|
+
created_at: z.string()
|
|
230
|
+
});
|
|
231
|
+
var LearningApiSchema = z.object({
|
|
232
|
+
id: z.string().min(1).describe("Unique identifier"),
|
|
233
|
+
type: LearningTypeSchema.describe("Categorical classification"),
|
|
234
|
+
trigger: z.string().describe("Normalized trigger condition"),
|
|
235
|
+
action: z.string().describe("Action to take (human-readable)"),
|
|
236
|
+
confidence: z.number().min(0).max(1).describe("Confidence score (0.0-1.0)"),
|
|
237
|
+
created: z.number().int().positive().describe("Creation timestamp (ms since epoch)"),
|
|
238
|
+
source: z.string().describe("Where this learning originated"),
|
|
239
|
+
tags: z.array(z.string()).default([]).describe("Searchable tags"),
|
|
240
|
+
usageCount: z.number().int().nonnegative().default(0).describe("Times applied")
|
|
241
|
+
});
|
|
242
|
+
function normalizeLearningType(type) {
|
|
243
|
+
switch (type) {
|
|
244
|
+
case "pattern":
|
|
245
|
+
return "pattern";
|
|
246
|
+
case "pitfall":
|
|
247
|
+
case "pit":
|
|
248
|
+
return "pitfall";
|
|
249
|
+
case "efficiency":
|
|
250
|
+
case "performance":
|
|
251
|
+
return "efficiency";
|
|
252
|
+
case "workflow":
|
|
253
|
+
case "best-practice":
|
|
254
|
+
return "workflow";
|
|
255
|
+
case "discovery":
|
|
256
|
+
return "discovery";
|
|
257
|
+
case "architecture":
|
|
258
|
+
return "pattern";
|
|
259
|
+
// Architecture patterns map to pattern
|
|
260
|
+
default: {
|
|
261
|
+
return "pattern";
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
__name(normalizeLearningType, "normalizeLearningType");
|
|
266
|
+
function elevateLearningToApi(storage, options) {
|
|
267
|
+
const id = storage.id ?? `learning-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
268
|
+
const normalizedType = normalizeLearningType(storage.type);
|
|
269
|
+
const trigger = Array.isArray(storage.trigger) ? storage.trigger.join(", ") : storage.trigger;
|
|
270
|
+
let created;
|
|
271
|
+
if (typeof storage.timestamp === "string") {
|
|
272
|
+
const parsed = new Date(storage.timestamp);
|
|
273
|
+
created = Number.isNaN(parsed.getTime()) ? Date.now() : parsed.getTime();
|
|
274
|
+
} else {
|
|
275
|
+
created = storage.timestamp;
|
|
276
|
+
}
|
|
277
|
+
const confidence = storage.relevanceScore ?? (options?.relevanceBoost ?? 0.7) * (storage.accessCount ? Math.min(1, storage.accessCount / 10) : 0.5);
|
|
278
|
+
return {
|
|
279
|
+
id,
|
|
280
|
+
type: normalizedType,
|
|
281
|
+
trigger,
|
|
282
|
+
action: storage.action,
|
|
283
|
+
confidence: Math.round(confidence * 1e3) / 1e3,
|
|
284
|
+
created,
|
|
285
|
+
source: storage.source,
|
|
286
|
+
tags: storage.keywords ?? [],
|
|
287
|
+
usageCount: storage.accessCount ?? 0
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
__name(elevateLearningToApi, "elevateLearningToApi");
|
|
291
|
+
LearningStorageSchema.transform((storage) => elevateLearningToApi(storage)).pipe(LearningApiSchema);
|
|
292
|
+
|
|
293
|
+
export { LearningApiSchema };
|
|
@@ -1,32 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
|
2
|
-
import { __name } from './chunk-
|
|
2
|
+
import { __name } from './chunk-7ADPL4Q3.js';
|
|
3
3
|
import { mkdir, writeFile, access, constants, readFile, appendFile, stat } from 'fs/promises';
|
|
4
4
|
import { homedir } from 'os';
|
|
5
5
|
import { join, dirname } from 'path';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import { nanoid } from 'nanoid';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
const id = nanoid();
|
|
11
|
-
return prefix ? `${prefix}-${id}` : id;
|
|
12
|
-
}
|
|
13
|
-
__name(generateId, "generateId");
|
|
14
|
-
function slugify(description, maxLength = 30) {
|
|
15
|
-
return description.toLowerCase().trim().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, maxLength);
|
|
16
|
-
}
|
|
17
|
-
__name(slugify, "slugify");
|
|
18
|
-
function generateSnapshotId(description) {
|
|
19
|
-
if (description && description.length > 0) {
|
|
20
|
-
const slug = slugify(description);
|
|
21
|
-
if (slug.length > 0) {
|
|
22
|
-
return `snapshot-${slug}-${Date.now()}-${nanoid(9)}`;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return `snapshot-${Date.now()}-${nanoid(9)}`;
|
|
26
|
-
}
|
|
27
|
-
__name(generateSnapshotId, "generateSnapshotId");
|
|
28
|
-
|
|
29
|
-
// src/services/snapback-dir.ts
|
|
8
|
+
process.env.SNAPBACK_CLI='true';
|
|
30
9
|
var SNAPBACK_DIR = ".snapback";
|
|
31
10
|
var GLOBAL_SNAPBACK_DIR = ".snapback";
|
|
32
11
|
var WorkspaceConfigSchema = z.object({
|
|
@@ -259,7 +238,9 @@ async function deleteGlobalJson(relativePath) {
|
|
|
259
238
|
__name(deleteGlobalJson, "deleteGlobalJson");
|
|
260
239
|
async function getWorkspaceConfig(workspaceRoot) {
|
|
261
240
|
const data = await readSnapbackJson("config.json", workspaceRoot);
|
|
262
|
-
if (!data)
|
|
241
|
+
if (!data) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
263
244
|
const result = WorkspaceConfigSchema.safeParse(data);
|
|
264
245
|
return result.success ? result.data : null;
|
|
265
246
|
}
|
|
@@ -270,7 +251,9 @@ async function saveWorkspaceConfig(config, workspaceRoot) {
|
|
|
270
251
|
__name(saveWorkspaceConfig, "saveWorkspaceConfig");
|
|
271
252
|
async function getWorkspaceVitals(workspaceRoot) {
|
|
272
253
|
const data = await readSnapbackJson("vitals.json", workspaceRoot);
|
|
273
|
-
if (!data)
|
|
254
|
+
if (!data) {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
274
257
|
const result = WorkspaceVitalsSchema.safeParse(data);
|
|
275
258
|
return result.success ? result.data : null;
|
|
276
259
|
}
|
|
@@ -281,7 +264,9 @@ async function saveWorkspaceVitals(vitals, workspaceRoot) {
|
|
|
281
264
|
__name(saveWorkspaceVitals, "saveWorkspaceVitals");
|
|
282
265
|
async function getProtectedFiles(workspaceRoot) {
|
|
283
266
|
const data = await readSnapbackJson("protected.json", workspaceRoot);
|
|
284
|
-
if (!data)
|
|
267
|
+
if (!data) {
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
285
270
|
const result = z.array(ProtectedFileSchema).safeParse(data);
|
|
286
271
|
return result.success ? result.data : [];
|
|
287
272
|
}
|
|
@@ -292,7 +277,9 @@ async function saveProtectedFiles(files, workspaceRoot) {
|
|
|
292
277
|
__name(saveProtectedFiles, "saveProtectedFiles");
|
|
293
278
|
async function getCurrentSession(workspaceRoot) {
|
|
294
279
|
const data = await readSnapbackJson("session/current.json", workspaceRoot);
|
|
295
|
-
if (!data)
|
|
280
|
+
if (!data) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
296
283
|
const result = SessionStateSchema.safeParse(data);
|
|
297
284
|
return result.success ? result.data : null;
|
|
298
285
|
}
|
|
@@ -330,7 +317,7 @@ async function getViolations(workspaceRoot) {
|
|
|
330
317
|
__name(getViolations, "getViolations");
|
|
331
318
|
async function getCredentials() {
|
|
332
319
|
try {
|
|
333
|
-
const { getCredentialsSecure } = await import('./secure-credentials-
|
|
320
|
+
const { getCredentialsSecure } = await import('./secure-credentials-UEPG7GWW.js');
|
|
334
321
|
return await getCredentialsSecure();
|
|
335
322
|
} catch {
|
|
336
323
|
return readGlobalJson("credentials.json");
|
|
@@ -339,7 +326,7 @@ async function getCredentials() {
|
|
|
339
326
|
__name(getCredentials, "getCredentials");
|
|
340
327
|
async function saveCredentials(credentials) {
|
|
341
328
|
try {
|
|
342
|
-
const { saveCredentialsSecure } = await import('./secure-credentials-
|
|
329
|
+
const { saveCredentialsSecure } = await import('./secure-credentials-UEPG7GWW.js');
|
|
343
330
|
return await saveCredentialsSecure(credentials);
|
|
344
331
|
} catch {
|
|
345
332
|
await createGlobalDirectory();
|
|
@@ -349,7 +336,7 @@ async function saveCredentials(credentials) {
|
|
|
349
336
|
__name(saveCredentials, "saveCredentials");
|
|
350
337
|
async function clearCredentials() {
|
|
351
338
|
try {
|
|
352
|
-
const { clearCredentialsSecure } = await import('./secure-credentials-
|
|
339
|
+
const { clearCredentialsSecure } = await import('./secure-credentials-UEPG7GWW.js');
|
|
353
340
|
return await clearCredentialsSecure();
|
|
354
341
|
} catch {
|
|
355
342
|
await deleteGlobalJson("credentials.json");
|
|
@@ -358,7 +345,9 @@ async function clearCredentials() {
|
|
|
358
345
|
__name(clearCredentials, "clearCredentials");
|
|
359
346
|
async function getGlobalConfig() {
|
|
360
347
|
const data = await readGlobalJson("config.json");
|
|
361
|
-
if (!data)
|
|
348
|
+
if (!data) {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
362
351
|
const result = GlobalConfigSchema.safeParse(data);
|
|
363
352
|
return result.success ? result.data : null;
|
|
364
353
|
}
|
|
@@ -415,6 +404,4 @@ async function getStats(path) {
|
|
|
415
404
|
}
|
|
416
405
|
__name(getStats, "getStats");
|
|
417
406
|
|
|
418
|
-
export { GlobalConfigSchema, GlobalCredentialsSchema, LearningEntrySchema, ProtectedFileSchema, SessionStateSchema, ViolationEntrySchema, WorkspaceConfigSchema, WorkspaceVitalsSchema, appendSnapbackJsonl, clearCredentials, createGlobalDirectory, createSnapbackDirectory, deleteGlobalJson, endCurrentSession, findWorkspaceRoot,
|
|
419
|
-
//# sourceMappingURL=chunk-7JX6Y4TL.js.map
|
|
420
|
-
//# sourceMappingURL=chunk-7JX6Y4TL.js.map
|
|
407
|
+
export { GlobalConfigSchema, GlobalCredentialsSchema, LearningEntrySchema, ProtectedFileSchema, SessionStateSchema, ViolationEntrySchema, WorkspaceConfigSchema, WorkspaceVitalsSchema, appendSnapbackJsonl, clearCredentials, createGlobalDirectory, createSnapbackDirectory, deleteGlobalJson, endCurrentSession, findWorkspaceRoot, getCredentials, getCurrentSession, getGlobalConfig, getGlobalDir, getGlobalPath, getLearnings, getProtectedFiles, getStats, getViolations, getWorkspaceConfig, getWorkspaceDir, getWorkspacePath, getWorkspaceVitals, isLoggedIn, isSnapbackInitialized, loadSnapbackJsonl, pathExists, readGlobalJson, readSnapbackJson, recordLearning, recordViolation, saveCredentials, saveCurrentSession, saveGlobalConfig, saveProtectedFiles, saveWorkspaceConfig, saveWorkspaceVitals, writeGlobalJson, writeSnapbackJson };
|