mobbdev 1.0.204 → 1.0.205

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.
@@ -1,5 +1,172 @@
1
1
  import * as Yargs from 'yargs';
2
+ import z from 'zod';
2
3
 
4
+ declare const PromptItemZ: z.ZodObject<{
5
+ type: z.ZodEnum<["USER_PROMPT", "AI_RESPONSE", "TOOL_EXECUTION"]>;
6
+ attachedFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
7
+ relativePath: z.ZodString;
8
+ startLine: z.ZodOptional<z.ZodNumber>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ relativePath: string;
11
+ startLine?: number | undefined;
12
+ }, {
13
+ relativePath: string;
14
+ startLine?: number | undefined;
15
+ }>, "many">>;
16
+ tokens: z.ZodOptional<z.ZodObject<{
17
+ inputCount: z.ZodNumber;
18
+ outputCount: z.ZodNumber;
19
+ }, "strip", z.ZodTypeAny, {
20
+ inputCount: number;
21
+ outputCount: number;
22
+ }, {
23
+ inputCount: number;
24
+ outputCount: number;
25
+ }>>;
26
+ text: z.ZodOptional<z.ZodString>;
27
+ date: z.ZodOptional<z.ZodDate>;
28
+ tool: z.ZodOptional<z.ZodObject<{
29
+ name: z.ZodString;
30
+ parameters: z.ZodString;
31
+ result: z.ZodString;
32
+ rawArguments: z.ZodOptional<z.ZodString>;
33
+ accepted: z.ZodOptional<z.ZodBoolean>;
34
+ }, "strip", z.ZodTypeAny, {
35
+ name: string;
36
+ parameters: string;
37
+ result: string;
38
+ rawArguments?: string | undefined;
39
+ accepted?: boolean | undefined;
40
+ }, {
41
+ name: string;
42
+ parameters: string;
43
+ result: string;
44
+ rawArguments?: string | undefined;
45
+ accepted?: boolean | undefined;
46
+ }>>;
47
+ }, "strip", z.ZodTypeAny, {
48
+ type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION";
49
+ date?: Date | undefined;
50
+ attachedFiles?: {
51
+ relativePath: string;
52
+ startLine?: number | undefined;
53
+ }[] | undefined;
54
+ tokens?: {
55
+ inputCount: number;
56
+ outputCount: number;
57
+ } | undefined;
58
+ text?: string | undefined;
59
+ tool?: {
60
+ name: string;
61
+ parameters: string;
62
+ result: string;
63
+ rawArguments?: string | undefined;
64
+ accepted?: boolean | undefined;
65
+ } | undefined;
66
+ }, {
67
+ type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION";
68
+ date?: Date | undefined;
69
+ attachedFiles?: {
70
+ relativePath: string;
71
+ startLine?: number | undefined;
72
+ }[] | undefined;
73
+ tokens?: {
74
+ inputCount: number;
75
+ outputCount: number;
76
+ } | undefined;
77
+ text?: string | undefined;
78
+ tool?: {
79
+ name: string;
80
+ parameters: string;
81
+ result: string;
82
+ rawArguments?: string | undefined;
83
+ accepted?: boolean | undefined;
84
+ } | undefined;
85
+ }>;
86
+ type PromptItem = z.infer<typeof PromptItemZ>;
87
+ declare const PromptItemArrayZ: z.ZodArray<z.ZodObject<{
88
+ type: z.ZodEnum<["USER_PROMPT", "AI_RESPONSE", "TOOL_EXECUTION"]>;
89
+ attachedFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
90
+ relativePath: z.ZodString;
91
+ startLine: z.ZodOptional<z.ZodNumber>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ relativePath: string;
94
+ startLine?: number | undefined;
95
+ }, {
96
+ relativePath: string;
97
+ startLine?: number | undefined;
98
+ }>, "many">>;
99
+ tokens: z.ZodOptional<z.ZodObject<{
100
+ inputCount: z.ZodNumber;
101
+ outputCount: z.ZodNumber;
102
+ }, "strip", z.ZodTypeAny, {
103
+ inputCount: number;
104
+ outputCount: number;
105
+ }, {
106
+ inputCount: number;
107
+ outputCount: number;
108
+ }>>;
109
+ text: z.ZodOptional<z.ZodString>;
110
+ date: z.ZodOptional<z.ZodDate>;
111
+ tool: z.ZodOptional<z.ZodObject<{
112
+ name: z.ZodString;
113
+ parameters: z.ZodString;
114
+ result: z.ZodString;
115
+ rawArguments: z.ZodOptional<z.ZodString>;
116
+ accepted: z.ZodOptional<z.ZodBoolean>;
117
+ }, "strip", z.ZodTypeAny, {
118
+ name: string;
119
+ parameters: string;
120
+ result: string;
121
+ rawArguments?: string | undefined;
122
+ accepted?: boolean | undefined;
123
+ }, {
124
+ name: string;
125
+ parameters: string;
126
+ result: string;
127
+ rawArguments?: string | undefined;
128
+ accepted?: boolean | undefined;
129
+ }>>;
130
+ }, "strip", z.ZodTypeAny, {
131
+ type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION";
132
+ date?: Date | undefined;
133
+ attachedFiles?: {
134
+ relativePath: string;
135
+ startLine?: number | undefined;
136
+ }[] | undefined;
137
+ tokens?: {
138
+ inputCount: number;
139
+ outputCount: number;
140
+ } | undefined;
141
+ text?: string | undefined;
142
+ tool?: {
143
+ name: string;
144
+ parameters: string;
145
+ result: string;
146
+ rawArguments?: string | undefined;
147
+ accepted?: boolean | undefined;
148
+ } | undefined;
149
+ }, {
150
+ type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION";
151
+ date?: Date | undefined;
152
+ attachedFiles?: {
153
+ relativePath: string;
154
+ startLine?: number | undefined;
155
+ }[] | undefined;
156
+ tokens?: {
157
+ inputCount: number;
158
+ outputCount: number;
159
+ } | undefined;
160
+ text?: string | undefined;
161
+ tool?: {
162
+ name: string;
163
+ parameters: string;
164
+ result: string;
165
+ rawArguments?: string | undefined;
166
+ accepted?: boolean | undefined;
167
+ } | undefined;
168
+ }>, "many">;
169
+ type PromptItemArray = z.infer<typeof PromptItemArrayZ>;
3
170
  type UploadAiBlameOptions = {
4
171
  prompt: string[];
5
172
  inference: string[];
@@ -10,6 +177,13 @@ type UploadAiBlameOptions = {
10
177
  'tool-name'?: string[];
11
178
  };
12
179
  declare function uploadAiBlameBuilder(args: Yargs.Argv<unknown>): Yargs.Argv<UploadAiBlameOptions>;
13
- declare function uploadAiBlameHandler(args: UploadAiBlameOptions): Promise<void>;
180
+ declare function uploadAiBlameHandlerFromExtension(args: {
181
+ prompts: PromptItemArray;
182
+ inference: string;
183
+ model: string;
184
+ tool: string;
185
+ responseTime: string;
186
+ }): Promise<void>;
187
+ declare function uploadAiBlameHandler(args: UploadAiBlameOptions, exitOnError?: boolean): Promise<void>;
14
188
 
15
- export { type UploadAiBlameOptions, uploadAiBlameBuilder, uploadAiBlameHandler };
189
+ export { type PromptItem, type PromptItemArray, type UploadAiBlameOptions, uploadAiBlameBuilder, uploadAiBlameHandler, uploadAiBlameHandlerFromExtension };
@@ -92,9 +92,11 @@ var init_GitService = __esm({
92
92
  });
93
93
 
94
94
  // src/args/commands/upload_ai_blame.ts
95
- import fs5 from "fs/promises";
95
+ import fsPromises2 from "fs/promises";
96
96
  import path6 from "path";
97
97
  import chalk2 from "chalk";
98
+ import { withFile } from "tmp-promise";
99
+ import z27 from "zod";
98
100
 
99
101
  // src/features/analysis/upload-file.ts
100
102
  import Debug7 from "debug";
@@ -5560,6 +5562,29 @@ async function createAuthenticatedMcpGQLClient({
5560
5562
  }
5561
5563
 
5562
5564
  // src/args/commands/upload_ai_blame.ts
5565
+ var PromptItemZ = z27.object({
5566
+ type: z27.enum(["USER_PROMPT", "AI_RESPONSE", "TOOL_EXECUTION"]),
5567
+ attachedFiles: z27.array(
5568
+ z27.object({
5569
+ relativePath: z27.string(),
5570
+ startLine: z27.number().optional()
5571
+ })
5572
+ ).optional(),
5573
+ tokens: z27.object({
5574
+ inputCount: z27.number(),
5575
+ outputCount: z27.number()
5576
+ }).optional(),
5577
+ text: z27.string().optional(),
5578
+ date: z27.date().optional(),
5579
+ tool: z27.object({
5580
+ name: z27.string(),
5581
+ parameters: z27.string(),
5582
+ result: z27.string(),
5583
+ rawArguments: z27.string().optional(),
5584
+ accepted: z27.boolean().optional()
5585
+ }).optional()
5586
+ });
5587
+ var PromptItemArrayZ = z27.array(PromptItemZ);
5563
5588
  function uploadAiBlameBuilder(args) {
5564
5589
  return args.option("prompt", {
5565
5590
  type: "string",
@@ -5589,17 +5614,44 @@ function uploadAiBlameBuilder(args) {
5589
5614
  describe: chalk2.bold("Tool/IDE name(s) (optional, one per session)")
5590
5615
  }).strict();
5591
5616
  }
5592
- async function uploadAiBlameHandler(args) {
5617
+ async function uploadAiBlameHandlerFromExtension(args) {
5618
+ const uploadArgs = {
5619
+ prompt: [],
5620
+ inference: [],
5621
+ model: [],
5622
+ toolName: [],
5623
+ aiResponseAt: []
5624
+ };
5625
+ await withFile(async (promptFile) => {
5626
+ await fsPromises2.writeFile(
5627
+ promptFile.path,
5628
+ JSON.stringify(args.prompts, null, 2),
5629
+ "utf-8"
5630
+ );
5631
+ uploadArgs.prompt.push(promptFile.path);
5632
+ await withFile(async (inferenceFile) => {
5633
+ await fsPromises2.writeFile(inferenceFile.path, args.inference, "utf-8");
5634
+ uploadArgs.inference.push(inferenceFile.path);
5635
+ uploadArgs.model.push(args.model);
5636
+ uploadArgs.toolName.push(args.tool);
5637
+ uploadArgs.aiResponseAt.push(args.responseTime);
5638
+ await uploadAiBlameHandler(uploadArgs, false);
5639
+ });
5640
+ });
5641
+ }
5642
+ async function uploadAiBlameHandler(args, exitOnError = true) {
5593
5643
  const prompts = args.prompt || [];
5594
5644
  const inferences = args.inference || [];
5595
5645
  const models = args.model || [];
5596
5646
  const tools = args.toolName || args["tool-name"] || [];
5597
5647
  const responseTimes = args.aiResponseAt || args["ai-response-at"] || [];
5598
5648
  if (prompts.length !== inferences.length) {
5599
- console.error(
5600
- chalk2.red("prompt and inference must have the same number of entries")
5601
- );
5602
- process.exit(1);
5649
+ const errorMsg = "prompt and inference must have the same number of entries";
5650
+ console.error(chalk2.red(errorMsg));
5651
+ if (exitOnError) {
5652
+ process.exit(1);
5653
+ }
5654
+ throw new Error(errorMsg);
5603
5655
  }
5604
5656
  const nowIso = (/* @__PURE__ */ new Date()).toISOString();
5605
5657
  const sessions = [];
@@ -5607,10 +5659,17 @@ async function uploadAiBlameHandler(args) {
5607
5659
  const promptPath = String(prompts[i]);
5608
5660
  const inferencePath = String(inferences[i]);
5609
5661
  try {
5610
- await Promise.all([fs5.access(promptPath), fs5.access(inferencePath)]);
5662
+ await Promise.all([
5663
+ fsPromises2.access(promptPath),
5664
+ fsPromises2.access(inferencePath)
5665
+ ]);
5611
5666
  } catch {
5612
- console.error(chalk2.red(`File not found for session ${i + 1}`));
5613
- process.exit(1);
5667
+ const errorMsg = `File not found for session ${i + 1}`;
5668
+ console.error(chalk2.red(errorMsg));
5669
+ if (exitOnError) {
5670
+ process.exit(1);
5671
+ }
5672
+ throw new Error(errorMsg);
5614
5673
  }
5615
5674
  sessions.push({
5616
5675
  promptFileName: path6.basename(promptPath),
@@ -5624,10 +5683,12 @@ async function uploadAiBlameHandler(args) {
5624
5683
  const initRes = await gqlClient.uploadAIBlameInferencesInitRaw({ sessions });
5625
5684
  const uploadSessions = initRes.uploadAIBlameInferencesInit?.uploadSessions ?? [];
5626
5685
  if (uploadSessions.length !== sessions.length) {
5627
- console.error(
5628
- chalk2.red("Init failed to return expected number of sessions")
5629
- );
5630
- process.exit(1);
5686
+ const errorMsg = "Init failed to return expected number of sessions";
5687
+ console.error(chalk2.red(errorMsg));
5688
+ if (exitOnError) {
5689
+ process.exit(1);
5690
+ }
5691
+ throw new Error(errorMsg);
5631
5692
  }
5632
5693
  for (let i = 0; i < uploadSessions.length; i++) {
5633
5694
  const us = uploadSessions[i];
@@ -5662,16 +5723,17 @@ async function uploadAiBlameHandler(args) {
5662
5723
  });
5663
5724
  const status = finRes?.finalizeAIBlameInferencesUpload?.status;
5664
5725
  if (status !== "OK") {
5665
- console.error(
5666
- chalk2.red(
5667
- `Finalize failed: ${finRes?.finalizeAIBlameInferencesUpload?.error || "unknown error"}`
5668
- )
5669
- );
5670
- process.exit(1);
5726
+ const errorMsg = finRes?.finalizeAIBlameInferencesUpload?.error || "unknown error";
5727
+ console.error(chalk2.red(errorMsg));
5728
+ if (exitOnError) {
5729
+ process.exit(1);
5730
+ }
5731
+ throw new Error(errorMsg);
5671
5732
  }
5672
5733
  console.log(chalk2.green("AI Blame uploads finalized successfully"));
5673
5734
  }
5674
5735
  export {
5675
5736
  uploadAiBlameBuilder,
5676
- uploadAiBlameHandler
5737
+ uploadAiBlameHandler,
5738
+ uploadAiBlameHandlerFromExtension
5677
5739
  };
package/dist/index.mjs CHANGED
@@ -19226,9 +19226,34 @@ async function addScmTokenHandler(args) {
19226
19226
  }
19227
19227
 
19228
19228
  // src/args/commands/upload_ai_blame.ts
19229
- import fs18 from "fs/promises";
19229
+ import fsPromises3 from "fs/promises";
19230
19230
  import path16 from "path";
19231
19231
  import chalk10 from "chalk";
19232
+ import { withFile } from "tmp-promise";
19233
+ import z38 from "zod";
19234
+ var PromptItemZ = z38.object({
19235
+ type: z38.enum(["USER_PROMPT", "AI_RESPONSE", "TOOL_EXECUTION"]),
19236
+ attachedFiles: z38.array(
19237
+ z38.object({
19238
+ relativePath: z38.string(),
19239
+ startLine: z38.number().optional()
19240
+ })
19241
+ ).optional(),
19242
+ tokens: z38.object({
19243
+ inputCount: z38.number(),
19244
+ outputCount: z38.number()
19245
+ }).optional(),
19246
+ text: z38.string().optional(),
19247
+ date: z38.date().optional(),
19248
+ tool: z38.object({
19249
+ name: z38.string(),
19250
+ parameters: z38.string(),
19251
+ result: z38.string(),
19252
+ rawArguments: z38.string().optional(),
19253
+ accepted: z38.boolean().optional()
19254
+ }).optional()
19255
+ });
19256
+ var PromptItemArrayZ = z38.array(PromptItemZ);
19232
19257
  function uploadAiBlameBuilder(args) {
19233
19258
  return args.option("prompt", {
19234
19259
  type: "string",
@@ -19258,17 +19283,19 @@ function uploadAiBlameBuilder(args) {
19258
19283
  describe: chalk10.bold("Tool/IDE name(s) (optional, one per session)")
19259
19284
  }).strict();
19260
19285
  }
19261
- async function uploadAiBlameHandler(args) {
19286
+ async function uploadAiBlameHandler(args, exitOnError = true) {
19262
19287
  const prompts = args.prompt || [];
19263
19288
  const inferences = args.inference || [];
19264
19289
  const models = args.model || [];
19265
19290
  const tools = args.toolName || args["tool-name"] || [];
19266
19291
  const responseTimes = args.aiResponseAt || args["ai-response-at"] || [];
19267
19292
  if (prompts.length !== inferences.length) {
19268
- console.error(
19269
- chalk10.red("prompt and inference must have the same number of entries")
19270
- );
19271
- process.exit(1);
19293
+ const errorMsg = "prompt and inference must have the same number of entries";
19294
+ console.error(chalk10.red(errorMsg));
19295
+ if (exitOnError) {
19296
+ process.exit(1);
19297
+ }
19298
+ throw new Error(errorMsg);
19272
19299
  }
19273
19300
  const nowIso = (/* @__PURE__ */ new Date()).toISOString();
19274
19301
  const sessions = [];
@@ -19276,10 +19303,17 @@ async function uploadAiBlameHandler(args) {
19276
19303
  const promptPath = String(prompts[i]);
19277
19304
  const inferencePath = String(inferences[i]);
19278
19305
  try {
19279
- await Promise.all([fs18.access(promptPath), fs18.access(inferencePath)]);
19306
+ await Promise.all([
19307
+ fsPromises3.access(promptPath),
19308
+ fsPromises3.access(inferencePath)
19309
+ ]);
19280
19310
  } catch {
19281
- console.error(chalk10.red(`File not found for session ${i + 1}`));
19282
- process.exit(1);
19311
+ const errorMsg = `File not found for session ${i + 1}`;
19312
+ console.error(chalk10.red(errorMsg));
19313
+ if (exitOnError) {
19314
+ process.exit(1);
19315
+ }
19316
+ throw new Error(errorMsg);
19283
19317
  }
19284
19318
  sessions.push({
19285
19319
  promptFileName: path16.basename(promptPath),
@@ -19293,10 +19327,12 @@ async function uploadAiBlameHandler(args) {
19293
19327
  const initRes = await gqlClient.uploadAIBlameInferencesInitRaw({ sessions });
19294
19328
  const uploadSessions = initRes.uploadAIBlameInferencesInit?.uploadSessions ?? [];
19295
19329
  if (uploadSessions.length !== sessions.length) {
19296
- console.error(
19297
- chalk10.red("Init failed to return expected number of sessions")
19298
- );
19299
- process.exit(1);
19330
+ const errorMsg = "Init failed to return expected number of sessions";
19331
+ console.error(chalk10.red(errorMsg));
19332
+ if (exitOnError) {
19333
+ process.exit(1);
19334
+ }
19335
+ throw new Error(errorMsg);
19300
19336
  }
19301
19337
  for (let i = 0; i < uploadSessions.length; i++) {
19302
19338
  const us = uploadSessions[i];
@@ -19331,12 +19367,12 @@ async function uploadAiBlameHandler(args) {
19331
19367
  });
19332
19368
  const status = finRes?.finalizeAIBlameInferencesUpload?.status;
19333
19369
  if (status !== "OK") {
19334
- console.error(
19335
- chalk10.red(
19336
- `Finalize failed: ${finRes?.finalizeAIBlameInferencesUpload?.error || "unknown error"}`
19337
- )
19338
- );
19339
- process.exit(1);
19370
+ const errorMsg = finRes?.finalizeAIBlameInferencesUpload?.error || "unknown error";
19371
+ console.error(chalk10.red(errorMsg));
19372
+ if (exitOnError) {
19373
+ process.exit(1);
19374
+ }
19375
+ throw new Error(errorMsg);
19340
19376
  }
19341
19377
  console.log(chalk10.green("AI Blame uploads finalized successfully"));
19342
19378
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.0.204",
3
+ "version": "1.0.205",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "git+https://github.com/mobb-dev/bugsy.git",
6
6
  "main": "dist/index.mjs",
@@ -92,6 +92,7 @@
92
92
  "snyk": "1.1300.0",
93
93
  "tar": "6.2.1",
94
94
  "tmp": "0.2.5",
95
+ "tmp-promise": "3.0.3",
95
96
  "undici": "6.21.3",
96
97
  "uuid": "11.1.0",
97
98
  "ws": "8.18.3",