workflow-ai 1.0.60 → 1.0.62
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/agent-templates/CLAUDE.md.tpl +58 -58
- package/agent-templates/QWEN.md.tpl +58 -58
- package/package.json +1 -1
- package/src/init.mjs +437 -437
- package/src/runner.mjs +1735 -1713
- package/src/scripts/archive-plan-tickets.js +102 -0
- package/src/scripts/check-anomalies.js +161 -0
- package/src/scripts/check-conditions.js +258 -0
- package/src/scripts/check-mcp.js +277 -0
- package/src/scripts/check-plan-decomposed.js +217 -0
- package/src/scripts/check-plan-templates.js +297 -0
- package/src/scripts/check-relevance.js +311 -0
- package/src/scripts/complete-plan.js +106 -0
- package/src/scripts/get-next-id.js +214 -0
- package/src/scripts/move-ticket.js +260 -0
- package/src/scripts/move-to-ready.js +115 -0
- package/src/scripts/move-to-review.js +151 -0
- package/src/scripts/pick-next-task.js +791 -0
- package/templates/ticket-template.md +3 -10
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* move-to-review.js — Перемещает тикет из in-progress/ в review/
|
|
5
|
+
*
|
|
6
|
+
* Читает ticket_id из контекста pipeline runner'а.
|
|
7
|
+
*
|
|
8
|
+
* Выводит результат:
|
|
9
|
+
* ---RESULT---
|
|
10
|
+
* status: moved | error
|
|
11
|
+
* ticket_id: IMPL-001
|
|
12
|
+
* ---RESULT---
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import fs from "fs";
|
|
16
|
+
import path from "path";
|
|
17
|
+
import { findProjectRoot } from "workflow-ai/lib/find-root.mjs";
|
|
18
|
+
import {
|
|
19
|
+
parseFrontmatter,
|
|
20
|
+
serializeFrontmatter,
|
|
21
|
+
printResult,
|
|
22
|
+
getLastReviewStatus,
|
|
23
|
+
} from "workflow-ai/lib/utils.mjs";
|
|
24
|
+
|
|
25
|
+
// Корень проекта
|
|
26
|
+
const PROJECT_DIR = findProjectRoot();
|
|
27
|
+
const TICKETS_DIR = path.join(PROJECT_DIR, ".workflow", "tickets");
|
|
28
|
+
const IN_PROGRESS_DIR = path.join(TICKETS_DIR, "in-progress");
|
|
29
|
+
const REVIEW_DIR = path.join(TICKETS_DIR, "review");
|
|
30
|
+
const ARCHIVE_DIR = path.join(TICKETS_DIR, "archive");
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Парсит ticket_id из промпта (контекста pipeline runner)
|
|
34
|
+
*/
|
|
35
|
+
function parseTicketId(prompt) {
|
|
36
|
+
const match = prompt.match(/ticket_id:\s*(\S+)/);
|
|
37
|
+
return match ? match[1].trim() : null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Перемещает тикет из in-progress/ в review/
|
|
42
|
+
*/
|
|
43
|
+
function moveToReview(ticketId) {
|
|
44
|
+
const sourcePath = path.join(IN_PROGRESS_DIR, `${ticketId}.md`);
|
|
45
|
+
const targetPath = path.join(REVIEW_DIR, `${ticketId}.md`);
|
|
46
|
+
|
|
47
|
+
if (!fs.existsSync(sourcePath)) {
|
|
48
|
+
// Ticket may have been moved by the agent — check other locations
|
|
49
|
+
const reviewPath = path.join(REVIEW_DIR, `${ticketId}.md`);
|
|
50
|
+
if (fs.existsSync(reviewPath)) {
|
|
51
|
+
return {
|
|
52
|
+
status: "skipped",
|
|
53
|
+
ticket_id: ticketId,
|
|
54
|
+
reason: `${ticketId} already in review/`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const donePath = path.join(TICKETS_DIR, "done", `${ticketId}.md`);
|
|
58
|
+
const archivePath = path.join(ARCHIVE_DIR, `${ticketId}.md`);
|
|
59
|
+
if (fs.existsSync(donePath)) {
|
|
60
|
+
// Проверяем, есть ли у тикета ревью — если нет, перемещаем в review/
|
|
61
|
+
const doneContent = fs.readFileSync(donePath, "utf8");
|
|
62
|
+
const reviewStatus = getLastReviewStatus(doneContent);
|
|
63
|
+
if (reviewStatus === null) {
|
|
64
|
+
// Тикет в done/ без ревью — агент переместил его самовольно, возвращаем в review/
|
|
65
|
+
if (!fs.existsSync(REVIEW_DIR)) {
|
|
66
|
+
fs.mkdirSync(REVIEW_DIR, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
const reviewTarget = path.join(REVIEW_DIR, `${ticketId}.md`);
|
|
69
|
+
fs.renameSync(donePath, reviewTarget);
|
|
70
|
+
console.log(
|
|
71
|
+
`[INFO] ${ticketId} was in done/ without review — moved to review/`,
|
|
72
|
+
);
|
|
73
|
+
return {
|
|
74
|
+
status: "moved",
|
|
75
|
+
ticket_id: ticketId,
|
|
76
|
+
from: "done",
|
|
77
|
+
to: "review",
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
status: "skipped",
|
|
82
|
+
ticket_id: ticketId,
|
|
83
|
+
reason: `${ticketId} already in done/ with review`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (fs.existsSync(archivePath)) {
|
|
87
|
+
return {
|
|
88
|
+
status: "skipped",
|
|
89
|
+
ticket_id: ticketId,
|
|
90
|
+
reason: `${ticketId} already in archive/`,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
status: "error",
|
|
95
|
+
ticket_id: ticketId,
|
|
96
|
+
error: `${ticketId} not found in in-progress/`,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const content = fs.readFileSync(sourcePath, "utf8");
|
|
101
|
+
const { frontmatter, body } = parseFrontmatter(content);
|
|
102
|
+
|
|
103
|
+
frontmatter.updated_at = new Date().toISOString();
|
|
104
|
+
|
|
105
|
+
const newContent = serializeFrontmatter(frontmatter) + body;
|
|
106
|
+
|
|
107
|
+
if (!fs.existsSync(REVIEW_DIR)) {
|
|
108
|
+
fs.mkdirSync(REVIEW_DIR, { recursive: true });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
fs.renameSync(sourcePath, targetPath);
|
|
112
|
+
fs.writeFileSync(targetPath, newContent, "utf8");
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
status: "moved",
|
|
116
|
+
ticket_id: ticketId,
|
|
117
|
+
from: "in-progress",
|
|
118
|
+
to: "review",
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function main() {
|
|
123
|
+
const rawArgs = process.argv.slice(2);
|
|
124
|
+
const prompt = rawArgs[0] || "";
|
|
125
|
+
|
|
126
|
+
const ticketId = parseTicketId(prompt);
|
|
127
|
+
|
|
128
|
+
if (!ticketId) {
|
|
129
|
+
console.error("[ERROR] No ticket_id in context");
|
|
130
|
+
printResult({ status: "error", error: "Missing ticket_id" });
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
console.log(`[INFO] Moving ${ticketId}: in-progress/ → review/`);
|
|
135
|
+
const result = moveToReview(ticketId);
|
|
136
|
+
printResult(result);
|
|
137
|
+
|
|
138
|
+
if (result.status === "error") {
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (result.status === "skipped") {
|
|
143
|
+
console.log(`[INFO] Skipped: ${result.reason}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
main().catch((e) => {
|
|
148
|
+
console.error(`[ERROR] ${e.message}`);
|
|
149
|
+
printResult({ status: "error", error: e.message });
|
|
150
|
+
process.exit(1);
|
|
151
|
+
});
|