libero-mcp 0.2.19 → 0.2.20
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.
|
@@ -94,8 +94,15 @@ export function createTaskTools(db) {
|
|
|
94
94
|
// S46: difficulty/priority 默认 medium,校验入参合法值
|
|
95
95
|
const difficulty = normalizeDiff(input.difficulty);
|
|
96
96
|
const priority = normalizePrio(input.priority);
|
|
97
|
+
// S46 fix: 同 parent 下 order_index 单调递增(避免 created_at 精度问题导致排序 flaky)
|
|
98
|
+
const parentFilter = input.parent_id ? "AND parent_id = ?" : "AND parent_id IS NULL";
|
|
99
|
+
const parentParams = input.parent_id ? [input.parent_id] : [];
|
|
100
|
+
const maxOrderRow = db
|
|
101
|
+
.prepare(`SELECT COALESCE(MAX(order_index), -1) as max_idx FROM tasks WHERE user_id = ? ${parentFilter} AND deleted_at IS NULL`)
|
|
102
|
+
.get(userId, ...parentParams);
|
|
103
|
+
const orderIndex = maxOrderRow.max_idx + 1;
|
|
97
104
|
db.prepare(`INSERT INTO tasks (id, user_id, parent_id, title, status, est_minutes, category_id, linked_timeblock_id, order_index, difficulty, priority, created_at, updated_at, deleted_at)
|
|
98
|
-
VALUES (?, ?, ?, ?, 'draft', ?, NULL, NULL,
|
|
105
|
+
VALUES (?, ?, ?, ?, 'draft', ?, NULL, NULL, ?, ?, ?, ?, ?, NULL)`).run(id, userId, input.parent_id ?? null, input.title, input.est_minutes ?? null, orderIndex, difficulty, priority, now, now);
|
|
99
106
|
const row = getTaskRow(id);
|
|
100
107
|
return {
|
|
101
108
|
...rowToTask(row),
|