@snapback/cli 1.6.0 → 3.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 +120 -21
- 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-TDIHGKKL.js +1446 -0
- package/dist/auto-provision-organization-CXHL46P3.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-CBGOC6RV.js +293 -0
- package/dist/chunk-CPZWXRP2.js +4432 -0
- package/dist/{chunk-7JX6Y4TL.js → chunk-DPWFZNMY.js} +21 -34
- package/dist/{chunk-R7CUQ7CU.js → chunk-E6V6QKS7.js} +317 -33
- package/dist/chunk-FMWCFAY7.js +111 -0
- package/dist/chunk-GQ73B37K.js +314 -0
- package/dist/chunk-LIBBDBW5.js +6136 -0
- package/dist/chunk-O7HMAZ7L.js +3497 -0
- package/dist/chunk-PL4HF4M2.js +593 -0
- package/dist/chunk-Q4VC7GND.js +2300 -0
- package/dist/chunk-WS36HDEU.js +3735 -0
- package/dist/chunk-ZBQDE6WJ.js +108 -0
- package/dist/client-62E3L6DW.js +8 -0
- package/dist/dist-5LR7APG5.js +5 -0
- package/dist/dist-NFU5UJEW.js +9 -0
- package/dist/dist-OO5LJHL6.js +12 -0
- package/dist/index.js +61644 -37198
- 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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node --no-warnings=ExperimentalWarning
|
|
2
|
+
process.env.SNAPBACK_CLI='true';
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
5
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
6
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
7
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
@@ -7,7 +9,12 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
7
9
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
10
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9
11
|
});
|
|
12
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
13
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
+
};
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
10
19
|
|
|
11
|
-
export { __name, __require };
|
|
12
|
-
//# sourceMappingURL=chunk-RB7H4UQJ.js.map
|
|
13
|
-
//# sourceMappingURL=chunk-RB7H4UQJ.js.map
|
|
20
|
+
export { __commonJS, __export, __name, __require };
|
|
@@ -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 };
|