@probelabs/probe 0.6.0-rc274 → 0.6.0-rc276

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.
@@ -31292,13 +31292,53 @@ var init_TaskManager = __esm({
31292
31292
  this.tasks = newTasks;
31293
31293
  }
31294
31294
  /**
31295
- * Create multiple tasks in batch
31295
+ * Create multiple tasks in batch, resolving user-provided IDs to auto-generated IDs.
31296
+ * If any task fails validation, no tasks are created (atomic operation).
31296
31297
  * @param {Object[]} tasksData - Array of task data objects
31297
31298
  * @returns {Task[]} Created tasks
31298
31299
  */
31299
31300
  createTasks(tasksData) {
31300
- const createdTasks = [];
31301
+ const hasDependencies = tasksData.some((t) => t.dependencies && t.dependencies.length > 0);
31302
+ if (hasDependencies) {
31303
+ for (let i = 0; i < tasksData.length; i++) {
31304
+ if (!tasksData[i].id) {
31305
+ throw new Error(`Task at index ${i} is missing required "id" field. When using dependencies, every task in the batch must have an "id" so other tasks can reference it.`);
31306
+ }
31307
+ }
31308
+ }
31309
+ const idMap = /* @__PURE__ */ new Map();
31310
+ const batchAutoIds = /* @__PURE__ */ new Set();
31311
+ let nextCounter = this.taskCounter;
31301
31312
  for (const taskData of tasksData) {
31313
+ nextCounter++;
31314
+ const autoId = `task-${nextCounter}`;
31315
+ batchAutoIds.add(autoId);
31316
+ if (taskData.id) {
31317
+ idMap.set(taskData.id, autoId);
31318
+ }
31319
+ }
31320
+ const resolvedTasksData = tasksData.map((taskData) => {
31321
+ const resolved = { ...taskData };
31322
+ delete resolved.id;
31323
+ if (resolved.dependencies) {
31324
+ resolved.dependencies = resolved.dependencies.map((depId) => {
31325
+ if (idMap.has(depId)) return idMap.get(depId);
31326
+ if (this.tasks.has(depId) || batchAutoIds.has(depId)) return depId;
31327
+ const batchIds = idMap.size > 0 ? Array.from(idMap.keys()).join(", ") : "(none provided)";
31328
+ throw new Error(`Dependency "${depId}" does not exist. Each task in the batch must have an "id" field, and dependencies must reference those IDs. Current batch IDs: ${batchIds}. Existing tasks: ${this._getAvailableTaskIds()}`);
31329
+ });
31330
+ }
31331
+ if (resolved.after) {
31332
+ if (idMap.has(resolved.after)) {
31333
+ resolved.after = idMap.get(resolved.after);
31334
+ } else if (!this.tasks.has(resolved.after) && !batchAutoIds.has(resolved.after)) {
31335
+ throw new Error(`Task "${resolved.after}" does not exist. Cannot insert after non-existent task. Available tasks: ${this._getAvailableTaskIds()}${idMap.size > 0 ? `, batch IDs: ${Array.from(idMap.keys()).join(", ")}` : ""}`);
31336
+ }
31337
+ }
31338
+ return resolved;
31339
+ });
31340
+ const createdTasks = [];
31341
+ for (const taskData of resolvedTasksData) {
31302
31342
  const task = this.createTask(taskData);
31303
31343
  createdTasks.push(task);
31304
31344
  }
@@ -31898,12 +31938,12 @@ var init_taskTool = __esm({
31898
31938
  "use strict";
31899
31939
  init_zod();
31900
31940
  taskItemSchema = external_exports.object({
31901
- id: external_exports.string().optional(),
31941
+ id: external_exports.string().describe('Unique task identifier. Use short descriptive slugs (e.g. "auth", "setup-db"). Dependencies reference these IDs.'),
31902
31942
  title: external_exports.string().optional(),
31903
31943
  description: external_exports.string().optional(),
31904
31944
  status: external_exports.enum(["pending", "in_progress", "completed", "cancelled"]).optional(),
31905
31945
  priority: external_exports.enum(["low", "medium", "high", "critical"]).optional(),
31906
- dependencies: external_exports.array(external_exports.string()).optional(),
31946
+ dependencies: external_exports.array(external_exports.string()).optional().describe("Array of task IDs (from this batch or previously created) that must complete before this task can start."),
31907
31947
  after: external_exports.string().optional()
31908
31948
  });
31909
31949
  taskSchema = external_exports.object({
@@ -132,14 +132,64 @@ export class TaskManager {
132
132
  }
133
133
 
134
134
  /**
135
- * Create multiple tasks in batch
135
+ * Create multiple tasks in batch, resolving user-provided IDs to auto-generated IDs.
136
+ * If any task fails validation, no tasks are created (atomic operation).
136
137
  * @param {Object[]} tasksData - Array of task data objects
137
138
  * @returns {Task[]} Created tasks
138
139
  */
139
140
  createTasks(tasksData) {
140
- const createdTasks = [];
141
+ // Validate that all batch items have an id when dependencies are used
142
+ const hasDependencies = tasksData.some(t => t.dependencies && t.dependencies.length > 0);
143
+ if (hasDependencies) {
144
+ for (let i = 0; i < tasksData.length; i++) {
145
+ if (!tasksData[i].id) {
146
+ throw new Error(`Task at index ${i} is missing required "id" field. When using dependencies, every task in the batch must have an "id" so other tasks can reference it.`);
147
+ }
148
+ }
149
+ }
141
150
 
151
+ // Build a mapping of user-provided IDs to future auto-generated IDs
152
+ const idMap = new Map();
153
+ const batchAutoIds = new Set();
154
+ let nextCounter = this.taskCounter;
142
155
  for (const taskData of tasksData) {
156
+ nextCounter++;
157
+ const autoId = `task-${nextCounter}`;
158
+ batchAutoIds.add(autoId);
159
+ if (taskData.id) {
160
+ idMap.set(taskData.id, autoId);
161
+ }
162
+ }
163
+
164
+ // Resolve dependencies and "after" references, then validate before creating anything
165
+ const resolvedTasksData = tasksData.map(taskData => {
166
+ const resolved = { ...taskData };
167
+ delete resolved.id; // Don't pass user ID to createTask
168
+
169
+ if (resolved.dependencies) {
170
+ resolved.dependencies = resolved.dependencies.map(depId => {
171
+ if (idMap.has(depId)) return idMap.get(depId);
172
+ // Check if it's already an existing task ID or a batch auto-generated ID
173
+ if (this.tasks.has(depId) || batchAutoIds.has(depId)) return depId;
174
+ const batchIds = idMap.size > 0 ? Array.from(idMap.keys()).join(', ') : '(none provided)';
175
+ throw new Error(`Dependency "${depId}" does not exist. Each task in the batch must have an "id" field, and dependencies must reference those IDs. Current batch IDs: ${batchIds}. Existing tasks: ${this._getAvailableTaskIds()}`);
176
+ });
177
+ }
178
+
179
+ if (resolved.after) {
180
+ if (idMap.has(resolved.after)) {
181
+ resolved.after = idMap.get(resolved.after);
182
+ } else if (!this.tasks.has(resolved.after) && !batchAutoIds.has(resolved.after)) {
183
+ throw new Error(`Task "${resolved.after}" does not exist. Cannot insert after non-existent task. Available tasks: ${this._getAvailableTaskIds()}${idMap.size > 0 ? `, batch IDs: ${Array.from(idMap.keys()).join(', ')}` : ''}`);
184
+ }
185
+ }
186
+
187
+ return resolved;
188
+ });
189
+
190
+ // All validation passed — create tasks
191
+ const createdTasks = [];
192
+ for (const taskData of resolvedTasksData) {
143
193
  const task = this.createTask(taskData);
144
194
  createdTasks.push(task);
145
195
  }
@@ -9,12 +9,12 @@ import { z } from 'zod';
9
9
  * Schema for a single task item in batch operations
10
10
  */
11
11
  export const taskItemSchema = z.object({
12
- id: z.string().optional(),
12
+ id: z.string().describe('Unique task identifier. Use short descriptive slugs (e.g. "auth", "setup-db"). Dependencies reference these IDs.'),
13
13
  title: z.string().optional(),
14
14
  description: z.string().optional(),
15
15
  status: z.enum(['pending', 'in_progress', 'completed', 'cancelled']).optional(),
16
16
  priority: z.enum(['low', 'medium', 'high', 'critical']).optional(),
17
- dependencies: z.array(z.string()).optional(),
17
+ dependencies: z.array(z.string()).optional().describe('Array of task IDs (from this batch or previously created) that must complete before this task can start.'),
18
18
  after: z.string().optional()
19
19
  });
20
20
 
@@ -58232,13 +58232,53 @@ var init_TaskManager = __esm({
58232
58232
  this.tasks = newTasks;
58233
58233
  }
58234
58234
  /**
58235
- * Create multiple tasks in batch
58235
+ * Create multiple tasks in batch, resolving user-provided IDs to auto-generated IDs.
58236
+ * If any task fails validation, no tasks are created (atomic operation).
58236
58237
  * @param {Object[]} tasksData - Array of task data objects
58237
58238
  * @returns {Task[]} Created tasks
58238
58239
  */
58239
58240
  createTasks(tasksData) {
58240
- const createdTasks = [];
58241
+ const hasDependencies = tasksData.some((t5) => t5.dependencies && t5.dependencies.length > 0);
58242
+ if (hasDependencies) {
58243
+ for (let i5 = 0; i5 < tasksData.length; i5++) {
58244
+ if (!tasksData[i5].id) {
58245
+ throw new Error(`Task at index ${i5} is missing required "id" field. When using dependencies, every task in the batch must have an "id" so other tasks can reference it.`);
58246
+ }
58247
+ }
58248
+ }
58249
+ const idMap = /* @__PURE__ */ new Map();
58250
+ const batchAutoIds = /* @__PURE__ */ new Set();
58251
+ let nextCounter = this.taskCounter;
58241
58252
  for (const taskData of tasksData) {
58253
+ nextCounter++;
58254
+ const autoId = `task-${nextCounter}`;
58255
+ batchAutoIds.add(autoId);
58256
+ if (taskData.id) {
58257
+ idMap.set(taskData.id, autoId);
58258
+ }
58259
+ }
58260
+ const resolvedTasksData = tasksData.map((taskData) => {
58261
+ const resolved = { ...taskData };
58262
+ delete resolved.id;
58263
+ if (resolved.dependencies) {
58264
+ resolved.dependencies = resolved.dependencies.map((depId) => {
58265
+ if (idMap.has(depId)) return idMap.get(depId);
58266
+ if (this.tasks.has(depId) || batchAutoIds.has(depId)) return depId;
58267
+ const batchIds = idMap.size > 0 ? Array.from(idMap.keys()).join(", ") : "(none provided)";
58268
+ throw new Error(`Dependency "${depId}" does not exist. Each task in the batch must have an "id" field, and dependencies must reference those IDs. Current batch IDs: ${batchIds}. Existing tasks: ${this._getAvailableTaskIds()}`);
58269
+ });
58270
+ }
58271
+ if (resolved.after) {
58272
+ if (idMap.has(resolved.after)) {
58273
+ resolved.after = idMap.get(resolved.after);
58274
+ } else if (!this.tasks.has(resolved.after) && !batchAutoIds.has(resolved.after)) {
58275
+ throw new Error(`Task "${resolved.after}" does not exist. Cannot insert after non-existent task. Available tasks: ${this._getAvailableTaskIds()}${idMap.size > 0 ? `, batch IDs: ${Array.from(idMap.keys()).join(", ")}` : ""}`);
58276
+ }
58277
+ }
58278
+ return resolved;
58279
+ });
58280
+ const createdTasks = [];
58281
+ for (const taskData of resolvedTasksData) {
58242
58282
  const task = this.createTask(taskData);
58243
58283
  createdTasks.push(task);
58244
58284
  }
@@ -58838,12 +58878,12 @@ var init_taskTool = __esm({
58838
58878
  "use strict";
58839
58879
  init_zod();
58840
58880
  taskItemSchema = external_exports.object({
58841
- id: external_exports.string().optional(),
58881
+ id: external_exports.string().describe('Unique task identifier. Use short descriptive slugs (e.g. "auth", "setup-db"). Dependencies reference these IDs.'),
58842
58882
  title: external_exports.string().optional(),
58843
58883
  description: external_exports.string().optional(),
58844
58884
  status: external_exports.enum(["pending", "in_progress", "completed", "cancelled"]).optional(),
58845
58885
  priority: external_exports.enum(["low", "medium", "high", "critical"]).optional(),
58846
- dependencies: external_exports.array(external_exports.string()).optional(),
58886
+ dependencies: external_exports.array(external_exports.string()).optional().describe("Array of task IDs (from this batch or previously created) that must complete before this task can start."),
58847
58887
  after: external_exports.string().optional()
58848
58888
  });
58849
58889
  taskSchema = external_exports.object({
package/cjs/index.cjs CHANGED
@@ -31368,13 +31368,53 @@ var init_TaskManager = __esm({
31368
31368
  this.tasks = newTasks;
31369
31369
  }
31370
31370
  /**
31371
- * Create multiple tasks in batch
31371
+ * Create multiple tasks in batch, resolving user-provided IDs to auto-generated IDs.
31372
+ * If any task fails validation, no tasks are created (atomic operation).
31372
31373
  * @param {Object[]} tasksData - Array of task data objects
31373
31374
  * @returns {Task[]} Created tasks
31374
31375
  */
31375
31376
  createTasks(tasksData) {
31376
- const createdTasks = [];
31377
+ const hasDependencies = tasksData.some((t5) => t5.dependencies && t5.dependencies.length > 0);
31378
+ if (hasDependencies) {
31379
+ for (let i5 = 0; i5 < tasksData.length; i5++) {
31380
+ if (!tasksData[i5].id) {
31381
+ throw new Error(`Task at index ${i5} is missing required "id" field. When using dependencies, every task in the batch must have an "id" so other tasks can reference it.`);
31382
+ }
31383
+ }
31384
+ }
31385
+ const idMap = /* @__PURE__ */ new Map();
31386
+ const batchAutoIds = /* @__PURE__ */ new Set();
31387
+ let nextCounter = this.taskCounter;
31377
31388
  for (const taskData of tasksData) {
31389
+ nextCounter++;
31390
+ const autoId = `task-${nextCounter}`;
31391
+ batchAutoIds.add(autoId);
31392
+ if (taskData.id) {
31393
+ idMap.set(taskData.id, autoId);
31394
+ }
31395
+ }
31396
+ const resolvedTasksData = tasksData.map((taskData) => {
31397
+ const resolved = { ...taskData };
31398
+ delete resolved.id;
31399
+ if (resolved.dependencies) {
31400
+ resolved.dependencies = resolved.dependencies.map((depId) => {
31401
+ if (idMap.has(depId)) return idMap.get(depId);
31402
+ if (this.tasks.has(depId) || batchAutoIds.has(depId)) return depId;
31403
+ const batchIds = idMap.size > 0 ? Array.from(idMap.keys()).join(", ") : "(none provided)";
31404
+ throw new Error(`Dependency "${depId}" does not exist. Each task in the batch must have an "id" field, and dependencies must reference those IDs. Current batch IDs: ${batchIds}. Existing tasks: ${this._getAvailableTaskIds()}`);
31405
+ });
31406
+ }
31407
+ if (resolved.after) {
31408
+ if (idMap.has(resolved.after)) {
31409
+ resolved.after = idMap.get(resolved.after);
31410
+ } else if (!this.tasks.has(resolved.after) && !batchAutoIds.has(resolved.after)) {
31411
+ throw new Error(`Task "${resolved.after}" does not exist. Cannot insert after non-existent task. Available tasks: ${this._getAvailableTaskIds()}${idMap.size > 0 ? `, batch IDs: ${Array.from(idMap.keys()).join(", ")}` : ""}`);
31412
+ }
31413
+ }
31414
+ return resolved;
31415
+ });
31416
+ const createdTasks = [];
31417
+ for (const taskData of resolvedTasksData) {
31378
31418
  const task = this.createTask(taskData);
31379
31419
  createdTasks.push(task);
31380
31420
  }
@@ -36080,12 +36120,12 @@ var init_taskTool = __esm({
36080
36120
  "use strict";
36081
36121
  init_zod();
36082
36122
  taskItemSchema = external_exports.object({
36083
- id: external_exports.string().optional(),
36123
+ id: external_exports.string().describe('Unique task identifier. Use short descriptive slugs (e.g. "auth", "setup-db"). Dependencies reference these IDs.'),
36084
36124
  title: external_exports.string().optional(),
36085
36125
  description: external_exports.string().optional(),
36086
36126
  status: external_exports.enum(["pending", "in_progress", "completed", "cancelled"]).optional(),
36087
36127
  priority: external_exports.enum(["low", "medium", "high", "critical"]).optional(),
36088
- dependencies: external_exports.array(external_exports.string()).optional(),
36128
+ dependencies: external_exports.array(external_exports.string()).optional().describe("Array of task IDs (from this batch or previously created) that must complete before this task can start."),
36089
36129
  after: external_exports.string().optional()
36090
36130
  });
36091
36131
  taskSchema = external_exports.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@probelabs/probe",
3
- "version": "0.6.0-rc274",
3
+ "version": "0.6.0-rc276",
4
4
  "description": "Node.js wrapper for the probe code search tool",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -132,14 +132,64 @@ export class TaskManager {
132
132
  }
133
133
 
134
134
  /**
135
- * Create multiple tasks in batch
135
+ * Create multiple tasks in batch, resolving user-provided IDs to auto-generated IDs.
136
+ * If any task fails validation, no tasks are created (atomic operation).
136
137
  * @param {Object[]} tasksData - Array of task data objects
137
138
  * @returns {Task[]} Created tasks
138
139
  */
139
140
  createTasks(tasksData) {
140
- const createdTasks = [];
141
+ // Validate that all batch items have an id when dependencies are used
142
+ const hasDependencies = tasksData.some(t => t.dependencies && t.dependencies.length > 0);
143
+ if (hasDependencies) {
144
+ for (let i = 0; i < tasksData.length; i++) {
145
+ if (!tasksData[i].id) {
146
+ throw new Error(`Task at index ${i} is missing required "id" field. When using dependencies, every task in the batch must have an "id" so other tasks can reference it.`);
147
+ }
148
+ }
149
+ }
141
150
 
151
+ // Build a mapping of user-provided IDs to future auto-generated IDs
152
+ const idMap = new Map();
153
+ const batchAutoIds = new Set();
154
+ let nextCounter = this.taskCounter;
142
155
  for (const taskData of tasksData) {
156
+ nextCounter++;
157
+ const autoId = `task-${nextCounter}`;
158
+ batchAutoIds.add(autoId);
159
+ if (taskData.id) {
160
+ idMap.set(taskData.id, autoId);
161
+ }
162
+ }
163
+
164
+ // Resolve dependencies and "after" references, then validate before creating anything
165
+ const resolvedTasksData = tasksData.map(taskData => {
166
+ const resolved = { ...taskData };
167
+ delete resolved.id; // Don't pass user ID to createTask
168
+
169
+ if (resolved.dependencies) {
170
+ resolved.dependencies = resolved.dependencies.map(depId => {
171
+ if (idMap.has(depId)) return idMap.get(depId);
172
+ // Check if it's already an existing task ID or a batch auto-generated ID
173
+ if (this.tasks.has(depId) || batchAutoIds.has(depId)) return depId;
174
+ const batchIds = idMap.size > 0 ? Array.from(idMap.keys()).join(', ') : '(none provided)';
175
+ throw new Error(`Dependency "${depId}" does not exist. Each task in the batch must have an "id" field, and dependencies must reference those IDs. Current batch IDs: ${batchIds}. Existing tasks: ${this._getAvailableTaskIds()}`);
176
+ });
177
+ }
178
+
179
+ if (resolved.after) {
180
+ if (idMap.has(resolved.after)) {
181
+ resolved.after = idMap.get(resolved.after);
182
+ } else if (!this.tasks.has(resolved.after) && !batchAutoIds.has(resolved.after)) {
183
+ throw new Error(`Task "${resolved.after}" does not exist. Cannot insert after non-existent task. Available tasks: ${this._getAvailableTaskIds()}${idMap.size > 0 ? `, batch IDs: ${Array.from(idMap.keys()).join(', ')}` : ''}`);
184
+ }
185
+ }
186
+
187
+ return resolved;
188
+ });
189
+
190
+ // All validation passed — create tasks
191
+ const createdTasks = [];
192
+ for (const taskData of resolvedTasksData) {
143
193
  const task = this.createTask(taskData);
144
194
  createdTasks.push(task);
145
195
  }
@@ -9,12 +9,12 @@ import { z } from 'zod';
9
9
  * Schema for a single task item in batch operations
10
10
  */
11
11
  export const taskItemSchema = z.object({
12
- id: z.string().optional(),
12
+ id: z.string().describe('Unique task identifier. Use short descriptive slugs (e.g. "auth", "setup-db"). Dependencies reference these IDs.'),
13
13
  title: z.string().optional(),
14
14
  description: z.string().optional(),
15
15
  status: z.enum(['pending', 'in_progress', 'completed', 'cancelled']).optional(),
16
16
  priority: z.enum(['low', 'medium', 'high', 'critical']).optional(),
17
- dependencies: z.array(z.string()).optional(),
17
+ dependencies: z.array(z.string()).optional().describe('Array of task IDs (from this batch or previously created) that must complete before this task can start.'),
18
18
  after: z.string().optional()
19
19
  });
20
20