agentic-sdlc-mcp 1.3.0 → 1.4.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/LICENSE +21 -0
- package/README.md +233 -240
- package/dist/config.d.ts +4 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +117 -23
- package/dist/config.js.map +1 -1
- package/dist/github/context.d.ts +41 -0
- package/dist/github/context.d.ts.map +1 -1
- package/dist/github/context.js +191 -3
- package/dist/github/context.js.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/tools/agent-handoff.d.ts +5 -41
- package/dist/tools/agent-handoff.d.ts.map +1 -1
- package/dist/tools/branch-protection-status.d.ts +17 -25
- package/dist/tools/branch-protection-status.d.ts.map +1 -1
- package/dist/tools/create-issue-set.d.ts +6 -46
- package/dist/tools/create-issue-set.d.ts.map +1 -1
- package/dist/tools/create-pr-summary.d.ts +3 -11
- package/dist/tools/create-pr-summary.d.ts.map +1 -1
- package/dist/tools/plan-from-context.d.ts +65 -32
- package/dist/tools/plan-from-context.d.ts.map +1 -1
- package/dist/tools/plan-from-context.js +545 -61
- package/dist/tools/plan-from-context.js.map +1 -1
- package/dist/tools/prepare-work-item.d.ts +6 -30
- package/dist/tools/prepare-work-item.d.ts.map +1 -1
- package/dist/tools/quality-gate-status.d.ts +11 -107
- package/dist/tools/quality-gate-status.d.ts.map +1 -1
- package/dist/tools/release-readiness.d.ts +8 -15
- package/dist/tools/release-readiness.d.ts.map +1 -1
- package/dist/tools/repo-context.d.ts +21 -30
- package/dist/tools/repo-context.d.ts.map +1 -1
- package/dist/tools/repo-context.js +86 -4
- package/dist/tools/repo-context.js.map +1 -1
- package/dist/tools/review-pr.d.ts +20 -28
- package/dist/tools/review-pr.d.ts.map +1 -1
- package/dist/tools/security-triage.d.ts +12 -46
- package/dist/tools/security-triage.d.ts.map +1 -1
- package/dist/tools/workflow-permissions-audit.d.ts +16 -24
- package/dist/tools/workflow-permissions-audit.d.ts.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
* Tool: plan_from_context
|
|
3
3
|
*
|
|
4
4
|
* Handler extracted as `buildPlan` and `handlePlanFromContext` for testing.
|
|
5
|
+
*
|
|
6
|
+
* Supports `workType` (docs/feature/bugfix/refactor/security/release/infra):
|
|
7
|
+
* each type gets a distinct phase-by-phase template rather than one
|
|
8
|
+
* one-size-fits-all plan -- a docs-only task should not default to requiring
|
|
9
|
+
* code unit tests, while a bugfix task must always include repro + regression
|
|
10
|
+
* tests. When the caller does not pass `workType` explicitly, it is inferred
|
|
11
|
+
* from `goal` + `acceptanceCriteria` via a conservative keyword heuristic
|
|
12
|
+
* (see `inferWorkType`), and the inference itself (confidence, reasoning,
|
|
13
|
+
* whether clarification is needed) is surfaced in the output rather than
|
|
14
|
+
* hidden -- callers should not have to trust a silent guess.
|
|
5
15
|
*/
|
|
6
16
|
import { z } from "zod";
|
|
7
17
|
import { resolveRepo, handleGitHubError } from "../github/client.js";
|
|
@@ -9,10 +19,17 @@ import { fetchRepoContext } from "../github/context.js";
|
|
|
9
19
|
// ---------------------------------------------------------------------------
|
|
10
20
|
// Schema
|
|
11
21
|
// ---------------------------------------------------------------------------
|
|
22
|
+
const WORK_TYPES = ["docs", "feature", "bugfix", "refactor", "security", "release", "infra"];
|
|
12
23
|
export const PlanFromContextInputSchema = z.object({
|
|
13
24
|
goal: z.string().min(5).describe("The user goal or feature request to plan around."),
|
|
14
25
|
owner: z.string().optional().describe("GitHub owner. Falls back to GITHUB_OWNER."),
|
|
15
26
|
repo: z.string().optional().describe("GitHub repo. Falls back to GITHUB_REPO."),
|
|
27
|
+
workType: z
|
|
28
|
+
.enum(WORK_TYPES)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Explicit task category: docs, feature, bugfix, refactor, security, release, or infra. " +
|
|
31
|
+
"If omitted, it is inferred from `goal` + `acceptanceCriteria` -- check the output's " +
|
|
32
|
+
"`confidence` and `needsClarification` fields rather than assuming the guess is correct."),
|
|
16
33
|
constraints: z.array(z.string()).optional()
|
|
17
34
|
.describe("Technical or business constraints."),
|
|
18
35
|
acceptanceCriteria: z.array(z.string()).optional()
|
|
@@ -26,6 +43,10 @@ export const PlanFromContextOutputSchema = {
|
|
|
26
43
|
repo: z.string(),
|
|
27
44
|
defaultBranch: z.string(),
|
|
28
45
|
language: z.string().nullable(),
|
|
46
|
+
workType: z.enum(WORK_TYPES),
|
|
47
|
+
confidence: z.enum(["high", "medium", "low"]),
|
|
48
|
+
reasoning: z.string(),
|
|
49
|
+
needsClarification: z.boolean(),
|
|
29
50
|
constraints: z.array(z.string()),
|
|
30
51
|
acceptanceCriteria: z.array(z.string()),
|
|
31
52
|
phases: z.array(z.object({
|
|
@@ -37,67 +58,525 @@ export const PlanFromContextOutputSchema = {
|
|
|
37
58
|
risks: z.array(z.string()),
|
|
38
59
|
};
|
|
39
60
|
// ---------------------------------------------------------------------------
|
|
40
|
-
//
|
|
61
|
+
// workType inference (pure, exported for testing)
|
|
41
62
|
// ---------------------------------------------------------------------------
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Keyword signals per non-`feature` work type, English + Chinese (this project
|
|
65
|
+
* ships bilingual docs, and goals are often phrased in either language). `feature`
|
|
66
|
+
* has no keyword list -- it is the fallback when no other category matches,
|
|
67
|
+
* since "add"/"implement"-style phrasing is too generic to score reliably.
|
|
68
|
+
*
|
|
69
|
+
* English entries are matched as whole words/phrases (see `hasWholeWordMatch`),
|
|
70
|
+
* so common inflections ("fix" -> "fixes"/"fixed", "permission" -> "permissions")
|
|
71
|
+
* are listed explicitly rather than relying on a bare stem match, which would
|
|
72
|
+
* also match unrelated words like "prefix" or "fixed-price".
|
|
73
|
+
*/
|
|
74
|
+
const WORK_TYPE_KEYWORDS = {
|
|
75
|
+
docs: ["document", "documents", "documentation", "docs", "readme", "guide", "文档", "说明文档", "教程", "指南"],
|
|
76
|
+
bugfix: [
|
|
77
|
+
"bugfix",
|
|
78
|
+
"bug",
|
|
79
|
+
"bugs",
|
|
80
|
+
"fix",
|
|
81
|
+
"fixes",
|
|
82
|
+
"broken",
|
|
83
|
+
"regression",
|
|
84
|
+
"crash",
|
|
85
|
+
"crashes",
|
|
86
|
+
"not working",
|
|
87
|
+
"修复",
|
|
88
|
+
"缺陷",
|
|
89
|
+
"报错",
|
|
90
|
+
"崩溃",
|
|
91
|
+
"回归",
|
|
92
|
+
],
|
|
93
|
+
refactor: ["refactor", "refactoring", "restructure", "cleanup", "simplify", "reorganize", "重构", "简化", "整理"],
|
|
94
|
+
security: [
|
|
95
|
+
"security",
|
|
96
|
+
"secure",
|
|
97
|
+
"vulnerable",
|
|
98
|
+
"vulnerability",
|
|
99
|
+
"vulnerabilities",
|
|
100
|
+
"secret",
|
|
101
|
+
"secrets",
|
|
102
|
+
"permission",
|
|
103
|
+
"permissions",
|
|
104
|
+
"audit",
|
|
105
|
+
"exploit",
|
|
106
|
+
"cve",
|
|
107
|
+
"安全",
|
|
108
|
+
"漏洞",
|
|
109
|
+
"权限",
|
|
110
|
+
"密钥",
|
|
111
|
+
"审计",
|
|
112
|
+
],
|
|
113
|
+
release: ["release", "changelog", "rollback", "发布", "版本", "回滚", "变更日志"],
|
|
114
|
+
infra: [
|
|
115
|
+
"workflow",
|
|
116
|
+
"workflows",
|
|
117
|
+
"pipeline",
|
|
118
|
+
"ci/cd",
|
|
119
|
+
"infrastructure",
|
|
120
|
+
"deploy",
|
|
121
|
+
"deployment",
|
|
122
|
+
"docker",
|
|
123
|
+
"terraform",
|
|
124
|
+
"github actions",
|
|
125
|
+
"工作流",
|
|
126
|
+
"基础设施",
|
|
127
|
+
"部署",
|
|
128
|
+
"流水线",
|
|
129
|
+
],
|
|
130
|
+
};
|
|
131
|
+
/** Keywords made up entirely of CJK ideographs -- matched as a plain substring (see `hasWholeWordMatch`). */
|
|
132
|
+
const CJK_KEYWORD_PATTERN = /^[一-鿿]+$/;
|
|
133
|
+
/** Tie-break priority when multiple categories score equally (first wins), matching the ROADMAP's listed order. */
|
|
134
|
+
const WORK_TYPE_PRIORITY = [
|
|
135
|
+
"docs",
|
|
136
|
+
"bugfix",
|
|
137
|
+
"refactor",
|
|
138
|
+
"security",
|
|
139
|
+
"release",
|
|
140
|
+
"infra",
|
|
141
|
+
];
|
|
142
|
+
/** Characters that count as "word-ish" for the purposes of an English word-boundary check. */
|
|
143
|
+
function isWordChar(ch) {
|
|
144
|
+
if (!ch)
|
|
145
|
+
return false;
|
|
146
|
+
return /[a-z0-9]/i.test(ch);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* True if `keyword` occurs in `text` as a whole word/phrase -- i.e. not
|
|
150
|
+
* immediately preceded or followed by another word character. Plain
|
|
151
|
+
* `String.includes` would let short English keywords like "fix" or "secret"
|
|
152
|
+
* match inside unrelated words ("prefix", "fixed-price", "secret santa"),
|
|
153
|
+
* silently mis-categorising ordinary feature requests as bugfix/security.
|
|
154
|
+
*
|
|
155
|
+
* Pure-CJK keywords (e.g. "修复") are matched as a plain substring instead:
|
|
156
|
+
* Chinese text has no whitespace between words, so every character adjacent
|
|
157
|
+
* to a CJK match is itself a "word character" and a Latin-style boundary
|
|
158
|
+
* check would never succeed. Multi-character CJK keywords are specific
|
|
159
|
+
* enough on their own that substring matching does not meaningfully
|
|
160
|
+
* increase the false-positive rate here.
|
|
161
|
+
*/
|
|
162
|
+
function hasWholeWordMatch(text, keyword) {
|
|
163
|
+
if (CJK_KEYWORD_PATTERN.test(keyword)) {
|
|
164
|
+
return text.includes(keyword);
|
|
165
|
+
}
|
|
166
|
+
let fromIndex = 0;
|
|
167
|
+
while (true) {
|
|
168
|
+
const idx = text.indexOf(keyword, fromIndex);
|
|
169
|
+
if (idx === -1)
|
|
170
|
+
return false;
|
|
171
|
+
const before = idx > 0 ? text[idx - 1] : undefined;
|
|
172
|
+
const after = idx + keyword.length < text.length ? text[idx + keyword.length] : undefined;
|
|
173
|
+
if (!isWordChar(before) && !isWordChar(after))
|
|
174
|
+
return true;
|
|
175
|
+
fromIndex = idx + 1;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function countKeywordMatches(text, keywords) {
|
|
179
|
+
return keywords.reduce((n, kw) => (hasWholeWordMatch(text, kw) ? n + 1 : n), 0);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Infer a `workType` from free-text goal + acceptance criteria when the caller
|
|
183
|
+
* did not pass one explicitly. Conservative by design: ties or zero signal
|
|
184
|
+
* fall back to `feature` with `needsClarification: true` rather than guessing
|
|
185
|
+
* confidently, so callers know to double-check rather than trust a silent
|
|
186
|
+
* default.
|
|
187
|
+
*/
|
|
188
|
+
export function inferWorkType(goal, acceptanceCriteria, explicit) {
|
|
189
|
+
if (explicit) {
|
|
190
|
+
return {
|
|
191
|
+
workType: explicit,
|
|
192
|
+
confidence: "high",
|
|
193
|
+
reasoning: "workType was explicitly provided by the caller.",
|
|
194
|
+
needsClarification: false,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const text = [goal, ...acceptanceCriteria].join(" ").toLowerCase();
|
|
198
|
+
const scored = WORK_TYPE_PRIORITY.map((wt) => ({
|
|
199
|
+
workType: wt,
|
|
200
|
+
score: countKeywordMatches(text, WORK_TYPE_KEYWORDS[wt]),
|
|
201
|
+
}));
|
|
202
|
+
const maxScore = Math.max(...scored.map((s) => s.score));
|
|
203
|
+
if (maxScore === 0) {
|
|
204
|
+
return {
|
|
205
|
+
workType: "feature",
|
|
206
|
+
confidence: "low",
|
|
207
|
+
reasoning: "No docs/bugfix/refactor/security/release/infra keyword signals were found in the goal or " +
|
|
208
|
+
"acceptance criteria; defaulting to \"feature\". Pass `workType` explicitly if this is wrong.",
|
|
209
|
+
needsClarification: true,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
const topMatches = scored.filter((s) => s.score === maxScore);
|
|
213
|
+
const picked = topMatches[0].workType;
|
|
214
|
+
if (topMatches.length > 1) {
|
|
215
|
+
return {
|
|
216
|
+
workType: picked,
|
|
217
|
+
confidence: "low",
|
|
218
|
+
reasoning: `Multiple work types matched with equal signal (${topMatches.map((m) => m.workType).join(", ")}); ` +
|
|
219
|
+
`defaulting to "${picked}". Pass \`workType\` explicitly to disambiguate.`,
|
|
220
|
+
needsClarification: true,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
workType: picked,
|
|
225
|
+
confidence: maxScore >= 2 ? "high" : "medium",
|
|
226
|
+
reasoning: `Matched ${maxScore} keyword(s) associated with "${picked}" in the goal/acceptance criteria.`,
|
|
227
|
+
needsClarification: false,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
const PHASE_TEMPLATES_BY_WORK_TYPE = {
|
|
231
|
+
feature: {
|
|
232
|
+
plan: {
|
|
233
|
+
tasks: [
|
|
234
|
+
"Clarify requirements and acceptance criteria",
|
|
235
|
+
"Identify affected components and files",
|
|
236
|
+
"Define API contracts or data model changes",
|
|
237
|
+
"Review existing tests and coverage",
|
|
238
|
+
"List risks and unknowns",
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
create: {
|
|
242
|
+
tasks: [
|
|
243
|
+
"Create a feature branch from the default branch",
|
|
244
|
+
"Implement the required changes",
|
|
245
|
+
"Add unit tests for new logic",
|
|
246
|
+
"Update inline documentation and comments",
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
test: {
|
|
250
|
+
tasks: [
|
|
251
|
+
"Run the full test suite locally",
|
|
252
|
+
"Verify no regression in existing tests",
|
|
253
|
+
"Write integration tests if applicable",
|
|
254
|
+
"Test edge cases and error paths",
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
review: {
|
|
258
|
+
tasks: [
|
|
259
|
+
"Create a pull request with a clear description",
|
|
260
|
+
"Self-review the diff for unintended changes",
|
|
261
|
+
"Request review from at least one team member",
|
|
262
|
+
"Address all review comments",
|
|
263
|
+
],
|
|
264
|
+
},
|
|
265
|
+
optimize: {
|
|
266
|
+
tasks: [
|
|
267
|
+
"Profile the affected code path if performance-sensitive",
|
|
268
|
+
"Look for obvious algorithmic improvements",
|
|
269
|
+
"Ensure no unnecessary dependencies were added",
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
secure: {
|
|
273
|
+
tasks: [
|
|
274
|
+
"Run Dependabot or dependency audit",
|
|
275
|
+
"Check for secret leakage in diffs",
|
|
276
|
+
"Verify input validation and error handling",
|
|
277
|
+
"Review access control changes if any",
|
|
278
|
+
],
|
|
279
|
+
},
|
|
51
280
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
281
|
+
docs: {
|
|
282
|
+
plan: {
|
|
283
|
+
tasks: [
|
|
284
|
+
"Read existing README/docs and identify gaps",
|
|
285
|
+
"Clarify terminology and target audience",
|
|
286
|
+
"List acceptance criteria for the documentation change",
|
|
287
|
+
],
|
|
288
|
+
},
|
|
289
|
+
create: {
|
|
290
|
+
tasks: [
|
|
291
|
+
"Write or update the documentation",
|
|
292
|
+
"Add or update examples",
|
|
293
|
+
"Check terminology consistency across docs",
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
test: {
|
|
297
|
+
tasks: [
|
|
298
|
+
"Verify all code snippets and commands in the docs are runnable",
|
|
299
|
+
"Check for broken links and outdated references",
|
|
300
|
+
"Run a diff/lint check for formatting issues (e.g. `git diff --check`)",
|
|
301
|
+
],
|
|
302
|
+
},
|
|
303
|
+
review: {
|
|
304
|
+
tasks: [
|
|
305
|
+
"Open a PR describing what changed and why",
|
|
306
|
+
"Self-review rendered markdown for formatting issues",
|
|
307
|
+
"Confirm no unrelated content changes were bundled in",
|
|
308
|
+
],
|
|
309
|
+
},
|
|
310
|
+
optimize: {
|
|
311
|
+
tasks: ["Trim redundant sections", "Ensure consistent heading structure"],
|
|
312
|
+
},
|
|
313
|
+
secure: {
|
|
314
|
+
tasks: [
|
|
315
|
+
"Confirm no secrets, tokens, or credentials appear in the docs",
|
|
316
|
+
"Verify no internal-only URLs or private information are exposed",
|
|
317
|
+
],
|
|
318
|
+
},
|
|
59
319
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
320
|
+
bugfix: {
|
|
321
|
+
plan: {
|
|
322
|
+
tasks: [
|
|
323
|
+
"Reproduce the bug reliably and document exact repro steps",
|
|
324
|
+
"Identify the root cause, not just the symptom",
|
|
325
|
+
"Determine blast radius: what else might be affected",
|
|
326
|
+
],
|
|
327
|
+
},
|
|
328
|
+
create: {
|
|
329
|
+
tasks: [
|
|
330
|
+
"Implement the minimal fix for the root cause",
|
|
331
|
+
"Avoid unrelated refactors in the same change",
|
|
332
|
+
"Add a regression test that fails before the fix and passes after",
|
|
333
|
+
],
|
|
334
|
+
},
|
|
335
|
+
test: {
|
|
336
|
+
tasks: [
|
|
337
|
+
"Run the new regression test plus the full existing suite",
|
|
338
|
+
"Verify the original repro steps no longer reproduce the bug",
|
|
339
|
+
"Check related edge cases the same root cause might affect",
|
|
340
|
+
],
|
|
341
|
+
},
|
|
342
|
+
review: {
|
|
343
|
+
tasks: [
|
|
344
|
+
"Explain the root cause and fix approach in the PR description",
|
|
345
|
+
"Link the bug report / issue",
|
|
346
|
+
"Confirm the regression test is included in the diff",
|
|
347
|
+
],
|
|
348
|
+
},
|
|
349
|
+
optimize: {
|
|
350
|
+
tasks: ["Confirm the fix does not introduce a performance regression"],
|
|
351
|
+
},
|
|
352
|
+
secure: {
|
|
353
|
+
tasks: [
|
|
354
|
+
"Confirm the bug was not itself a security issue (escalate if it was)",
|
|
355
|
+
"Check whether the same root cause exists elsewhere in the codebase",
|
|
356
|
+
],
|
|
357
|
+
},
|
|
67
358
|
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
359
|
+
refactor: {
|
|
360
|
+
plan: {
|
|
361
|
+
tasks: [
|
|
362
|
+
"Confirm current behaviour is fully covered by existing tests before changing anything",
|
|
363
|
+
"Define the target structure and why it is better",
|
|
364
|
+
"Confirm no public API / contract changes are intended",
|
|
365
|
+
],
|
|
366
|
+
},
|
|
367
|
+
create: {
|
|
368
|
+
tasks: [
|
|
369
|
+
"Make the change in small, reviewable, incremental commits",
|
|
370
|
+
"Keep behaviour identical -- no functional changes bundled in",
|
|
371
|
+
],
|
|
372
|
+
},
|
|
373
|
+
test: {
|
|
374
|
+
tasks: [
|
|
375
|
+
"Run the full existing test suite after every incremental commit",
|
|
376
|
+
"Add characterization tests first if coverage is insufficient",
|
|
377
|
+
"Confirm no observable behaviour changed",
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
review: {
|
|
381
|
+
tasks: [
|
|
382
|
+
"Explain in the PR why the refactor is worth the risk",
|
|
383
|
+
"Highlight any public API surface touched, even if unchanged in behaviour",
|
|
384
|
+
"Call out anything intentionally left out of scope",
|
|
385
|
+
],
|
|
386
|
+
},
|
|
387
|
+
optimize: {
|
|
388
|
+
tasks: ["Check whether the refactor incidentally improves or regresses performance"],
|
|
389
|
+
},
|
|
390
|
+
secure: {
|
|
391
|
+
tasks: ["Confirm no access-control or validation logic was silently altered"],
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
security: {
|
|
395
|
+
plan: {
|
|
396
|
+
tasks: [
|
|
397
|
+
"Define the threat model: what is being protected, from whom",
|
|
398
|
+
"Identify affected permissions, secrets, and trust boundaries",
|
|
399
|
+
"List the specific attack scenarios this change should close",
|
|
400
|
+
],
|
|
401
|
+
},
|
|
402
|
+
create: {
|
|
403
|
+
tasks: [
|
|
404
|
+
"Implement the fix with least-privilege as the default",
|
|
405
|
+
"Avoid introducing new secrets or credentials in code or config",
|
|
406
|
+
"Add input validation at trust boundaries",
|
|
407
|
+
],
|
|
408
|
+
},
|
|
409
|
+
test: {
|
|
410
|
+
tasks: [
|
|
411
|
+
"Add tests for the specific attack scenarios identified in Plan",
|
|
412
|
+
"Test both the vulnerable-input and legitimate-input paths",
|
|
413
|
+
"Run a dependency audit (npm audit or equivalent) for related packages",
|
|
414
|
+
],
|
|
415
|
+
},
|
|
416
|
+
review: {
|
|
417
|
+
tasks: [
|
|
418
|
+
"Request a security-focused review, not just a functional one",
|
|
419
|
+
"Confirm no secrets or credentials appear in the diff",
|
|
420
|
+
"Document the before/after risk in the PR description",
|
|
421
|
+
],
|
|
422
|
+
},
|
|
423
|
+
optimize: {
|
|
424
|
+
tasks: ["Confirm the fix does not degrade performance in a way that invites a new DoS vector"],
|
|
425
|
+
},
|
|
426
|
+
secure: {
|
|
427
|
+
tasks: [
|
|
428
|
+
"Re-run security_triage / workflow_permissions_audit as applicable",
|
|
429
|
+
"Confirm the fix is deployed with least-privilege permissions",
|
|
430
|
+
"Verify no other code path shares the same vulnerable pattern",
|
|
431
|
+
],
|
|
432
|
+
},
|
|
75
433
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
434
|
+
release: {
|
|
435
|
+
plan: {
|
|
436
|
+
tasks: [
|
|
437
|
+
"Confirm scope: what is included in this release and what is deferred",
|
|
438
|
+
"Identify breaking changes and required migration notes",
|
|
439
|
+
"Draft the version bump (semver) and rationale",
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
create: {
|
|
443
|
+
tasks: [
|
|
444
|
+
"Update CHANGELOG.md with all notable changes",
|
|
445
|
+
"Bump the version in package.json / relevant manifests",
|
|
446
|
+
"Prepare a release notes draft",
|
|
447
|
+
],
|
|
448
|
+
},
|
|
449
|
+
test: {
|
|
450
|
+
tasks: [
|
|
451
|
+
"Confirm CI is green on the release commit (quality_gate_status)",
|
|
452
|
+
"Run the full test suite and smoke test on the release artifact",
|
|
453
|
+
"Verify no open release-blocking issues remain",
|
|
454
|
+
],
|
|
455
|
+
},
|
|
456
|
+
review: {
|
|
457
|
+
tasks: [
|
|
458
|
+
"Get release approval from the designated release manager",
|
|
459
|
+
"Confirm the rollback plan is documented and understood",
|
|
460
|
+
"Verify tag naming matches the project convention",
|
|
461
|
+
],
|
|
462
|
+
},
|
|
463
|
+
optimize: {
|
|
464
|
+
tasks: ["Confirm no debug/dev-only code paths are enabled in the release build"],
|
|
465
|
+
},
|
|
466
|
+
secure: {
|
|
467
|
+
tasks: [
|
|
468
|
+
"Run security_triage for open critical/high alerts before tagging",
|
|
469
|
+
"Confirm no secrets are embedded in the release artifact",
|
|
470
|
+
"Document the rollback plan (release_readiness_check template)",
|
|
471
|
+
],
|
|
472
|
+
},
|
|
82
473
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
474
|
+
infra: {
|
|
475
|
+
plan: {
|
|
476
|
+
tasks: [
|
|
477
|
+
"Identify affected workflows, environments, and permissions",
|
|
478
|
+
"Define least-privilege target permissions for any token/credential involved",
|
|
479
|
+
"Plan a rollback path before making the change",
|
|
480
|
+
],
|
|
481
|
+
},
|
|
482
|
+
create: {
|
|
483
|
+
tasks: [
|
|
484
|
+
"Implement the infra/workflow change with least-privilege permissions",
|
|
485
|
+
"Avoid `write-all` or overly broad scopes",
|
|
486
|
+
"Document any new environment variables or secrets required",
|
|
487
|
+
],
|
|
488
|
+
},
|
|
489
|
+
test: {
|
|
490
|
+
tasks: [
|
|
491
|
+
"Test the workflow change on a branch/PR before merging to the default branch",
|
|
492
|
+
"Verify the change behaves correctly under both success and failure paths",
|
|
493
|
+
"Confirm no secrets are printed to logs",
|
|
494
|
+
],
|
|
495
|
+
},
|
|
496
|
+
review: {
|
|
497
|
+
tasks: [
|
|
498
|
+
"Run workflow_permissions_audit on the changed workflow files",
|
|
499
|
+
"Explain the blast radius if this workflow is compromised or misconfigured",
|
|
500
|
+
"Confirm the rollback plan in the PR description",
|
|
501
|
+
],
|
|
502
|
+
},
|
|
503
|
+
optimize: {
|
|
504
|
+
tasks: ["Confirm the change does not needlessly increase CI runtime or cost"],
|
|
505
|
+
},
|
|
506
|
+
secure: {
|
|
507
|
+
tasks: [
|
|
508
|
+
"Re-run workflow_permissions_audit after the change",
|
|
509
|
+
"Confirm `pull_request_target` is not combined with write permissions",
|
|
510
|
+
"Verify branch protection still enforces required checks after the change",
|
|
511
|
+
],
|
|
512
|
+
},
|
|
90
513
|
},
|
|
91
514
|
};
|
|
515
|
+
/** Per-workType suggested issue titles. The `feature` case matches the pre-workType default wording. */
|
|
516
|
+
function buildSuggestedIssues(goal, workType) {
|
|
517
|
+
switch (workType) {
|
|
518
|
+
case "docs":
|
|
519
|
+
return [
|
|
520
|
+
`[Plan] Identify documentation gaps and audience for: ${goal}`,
|
|
521
|
+
`[Create] Write/update documentation for: ${goal}`,
|
|
522
|
+
`[Test] Verify examples and links for: ${goal}`,
|
|
523
|
+
`[Review] Proofread and confirm no sensitive info leaked for: ${goal}`,
|
|
524
|
+
];
|
|
525
|
+
case "bugfix":
|
|
526
|
+
return [
|
|
527
|
+
`[Plan] Reproduce and identify root cause for: ${goal}`,
|
|
528
|
+
`[Create] Implement minimal fix for: ${goal}`,
|
|
529
|
+
`[Test] Add regression test for: ${goal}`,
|
|
530
|
+
`[Review] Explain root cause and fix in the PR for: ${goal}`,
|
|
531
|
+
];
|
|
532
|
+
case "refactor":
|
|
533
|
+
return [
|
|
534
|
+
`[Plan] Confirm existing test coverage before refactor: ${goal}`,
|
|
535
|
+
`[Create] Refactor incrementally with no behaviour change: ${goal}`,
|
|
536
|
+
`[Test] Confirm full suite passes after each commit: ${goal}`,
|
|
537
|
+
`[Review] Explain refactor rationale and API impact: ${goal}`,
|
|
538
|
+
];
|
|
539
|
+
case "security":
|
|
540
|
+
return [
|
|
541
|
+
`[Plan] Define threat model for: ${goal}`,
|
|
542
|
+
`[Create] Implement least-privilege fix for: ${goal}`,
|
|
543
|
+
`[Test] Add attack-scenario tests for: ${goal}`,
|
|
544
|
+
`[Secure] Security review and re-audit for: ${goal}`,
|
|
545
|
+
];
|
|
546
|
+
case "release":
|
|
547
|
+
return [
|
|
548
|
+
`[Plan] Confirm release scope and breaking changes for: ${goal}`,
|
|
549
|
+
`[Create] Update CHANGELOG and bump version for: ${goal}`,
|
|
550
|
+
`[Test] Confirm CI green and smoke test for: ${goal}`,
|
|
551
|
+
`[Secure] Run security triage before tagging: ${goal}`,
|
|
552
|
+
];
|
|
553
|
+
case "infra":
|
|
554
|
+
return [
|
|
555
|
+
`[Plan] Identify affected workflows/permissions for: ${goal}`,
|
|
556
|
+
`[Create] Implement least-privilege infra change for: ${goal}`,
|
|
557
|
+
`[Test] Test workflow on a branch before merge for: ${goal}`,
|
|
558
|
+
`[Review] Run workflow_permissions_audit for: ${goal}`,
|
|
559
|
+
];
|
|
560
|
+
case "feature":
|
|
561
|
+
default:
|
|
562
|
+
return [
|
|
563
|
+
`[Plan] Define acceptance criteria and technical approach for: ${goal}`,
|
|
564
|
+
`[Create] Implement: ${goal}`,
|
|
565
|
+
`[Test] Add tests for: ${goal}`,
|
|
566
|
+
`[Secure] Security review for: ${goal}`,
|
|
567
|
+
];
|
|
568
|
+
}
|
|
569
|
+
}
|
|
92
570
|
// ---------------------------------------------------------------------------
|
|
93
571
|
// Pure helpers (exported for testing)
|
|
94
572
|
// ---------------------------------------------------------------------------
|
|
95
|
-
/** Build the phase-by-phase plan. Pure
|
|
96
|
-
export function buildPlan(goal, repoName) {
|
|
97
|
-
|
|
573
|
+
/** Build the phase-by-phase plan for a given workType (defaults to "feature" for backward compatibility). Pure -- no I/O. */
|
|
574
|
+
export function buildPlan(goal, repoName, workType = "feature") {
|
|
575
|
+
const template = PHASE_TEMPLATES_BY_WORK_TYPE[workType] ?? PHASE_TEMPLATES_BY_WORK_TYPE.feature;
|
|
576
|
+
return Object.keys(template).map((phase) => ({
|
|
98
577
|
phase,
|
|
99
578
|
summary: `${phase.charAt(0).toUpperCase() + phase.slice(1)} phase for: ${goal} (${repoName})`,
|
|
100
|
-
tasks:
|
|
579
|
+
tasks: template[phase].tasks,
|
|
101
580
|
}));
|
|
102
581
|
}
|
|
103
582
|
// ---------------------------------------------------------------------------
|
|
@@ -108,13 +587,9 @@ export async function handlePlanFromContext(params, fetchContext) {
|
|
|
108
587
|
const acceptance = params.acceptanceCriteria ?? [];
|
|
109
588
|
const ref = resolveRepo(params.owner, params.repo);
|
|
110
589
|
const ctx = await fetchContext({ ...ref });
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
`[Create] Implement: ${params.goal}`,
|
|
115
|
-
`[Test] Add tests for: ${params.goal}`,
|
|
116
|
-
`[Secure] Security review for: ${params.goal}`,
|
|
117
|
-
];
|
|
590
|
+
const inference = inferWorkType(params.goal, acceptance, params.workType);
|
|
591
|
+
const plan = buildPlan(params.goal, ctx.fullName, inference.workType);
|
|
592
|
+
const suggestedIssues = buildSuggestedIssues(params.goal, inference.workType);
|
|
118
593
|
const risks = [
|
|
119
594
|
"Unknown scope may expand during implementation",
|
|
120
595
|
"Existing tests may need updating",
|
|
@@ -125,6 +600,10 @@ export async function handlePlanFromContext(params, fetchContext) {
|
|
|
125
600
|
repo: ctx.fullName,
|
|
126
601
|
defaultBranch: ctx.defaultBranch,
|
|
127
602
|
language: ctx.language ?? null,
|
|
603
|
+
workType: inference.workType,
|
|
604
|
+
confidence: inference.confidence,
|
|
605
|
+
reasoning: inference.reasoning,
|
|
606
|
+
needsClarification: inference.needsClarification,
|
|
128
607
|
constraints,
|
|
129
608
|
acceptanceCriteria: acceptance,
|
|
130
609
|
phases: plan,
|
|
@@ -137,10 +616,14 @@ export async function handlePlanFromContext(params, fetchContext) {
|
|
|
137
616
|
`**Repository:** ${ctx.fullName}`,
|
|
138
617
|
`**Default branch:** \`${ctx.defaultBranch}\``,
|
|
139
618
|
`**Language:** ${ctx.language ?? "unknown"}`,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
`Goal: **${params.goal}**`,
|
|
619
|
+
`**Work type:** ${inference.workType} (confidence: ${inference.confidence})`,
|
|
620
|
+
`**Reasoning:** ${inference.reasoning}`,
|
|
143
621
|
];
|
|
622
|
+
if (inference.needsClarification) {
|
|
623
|
+
lines.push("", `> [NEEDS CLARIFICATION] Low confidence in the inferred work type ("${inference.workType}"). ` +
|
|
624
|
+
"Consider passing `workType` explicitly, or confirm this categorisation before proceeding.");
|
|
625
|
+
}
|
|
626
|
+
lines.push("", "## Background", `Goal: **${params.goal}**`);
|
|
144
627
|
if (constraints.length > 0) {
|
|
145
628
|
lines.push("", "### Constraints");
|
|
146
629
|
constraints.forEach((c) => lines.push(`- ${c}`));
|
|
@@ -163,17 +646,18 @@ export async function handlePlanFromContext(params, fetchContext) {
|
|
|
163
646
|
export function registerPlanFromContextTool(server) {
|
|
164
647
|
server.registerTool("plan_from_context", {
|
|
165
648
|
title: "Generate SDLC Plan from Context",
|
|
166
|
-
description: `Generate a structured Agentic SDLC plan (Plan->Create->Test->Review->Optimize->Secure) from a goal and repo context.
|
|
649
|
+
description: `Generate a structured Agentic SDLC plan (Plan->Create->Test->Review->Optimize->Secure) from a goal and repo context. The plan is tailored to a \`workType\` (docs/feature/bugfix/refactor/security/release/infra) -- e.g. docs tasks do not default to requiring code unit tests, while bugfix tasks always include repro + regression tests.
|
|
167
650
|
|
|
168
|
-
Template-based
|
|
651
|
+
Template-based -- no LLM call needed. Reads basic repo metadata to enrich the plan.
|
|
169
652
|
|
|
170
653
|
Args:
|
|
171
654
|
- goal (string): The user's goal or feature description (required).
|
|
172
655
|
- owner, repo: Repo coordinates (fall back to env vars).
|
|
656
|
+
- workType (string?): Explicit task category. If omitted, inferred from goal + acceptanceCriteria -- check the output's \`confidence\`/\`needsClarification\` rather than assuming the guess is correct.
|
|
173
657
|
- constraints (string[]?): Technical or business constraints.
|
|
174
658
|
- acceptanceCriteria (string[]?): Explicit acceptance criteria.
|
|
175
659
|
|
|
176
|
-
Returns: Phase-by-phase SDLC plan
|
|
660
|
+
Returns: Phase-by-phase SDLC plan tailored to the (inferred or explicit) work type, plus structured output including workType/confidence/reasoning/needsClarification.`,
|
|
177
661
|
inputSchema: PlanFromContextInputSchema,
|
|
178
662
|
outputSchema: PlanFromContextOutputSchema,
|
|
179
663
|
annotations: {
|