@konductro/codex-plugin 2.3.0 → 2.5.0-rc.1

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/README.md CHANGED
@@ -68,6 +68,8 @@ Skills are guided, multi-step workflows invoked by asking Codex naturally:
68
68
  | `konductro-profile-repository` | Scan the current repo and submit its profile to Konductro |
69
69
  | `konductro-start-ticket` | Pick up an assigned ticket and start work |
70
70
  | `konductro-bug-enrich` | Enrich a bug ticket with technical analysis — explores codebase and submits structured context |
71
+ | `konductro-demand-analysis` | Size a demand against the real code and propose the phases the forum will commit to |
72
+ | `konductro-test-pack` | Turn a story's acceptance criteria into Test Library cases, checked against the library, added once you approve the plan |
71
73
 
72
74
  ## Tools
73
75
 
@@ -154,9 +156,22 @@ These are answers, not errors — none of them is worth retrying as-is.
154
156
  | Tool | What it does |
155
157
  |---|---|
156
158
  | `list_tech_analysis_tasks` | List your pending technical analysis assignments |
157
- | `get_task_context` | Load requirements and project context for a technical analysis task |
159
+ | `get_task_context` | Load requirements and project context for a technical analysis task, plus the requester's context message when a refresh was asked for |
158
160
  | `submit_tech_analysis` | Submit your analysis document back to Konductro |
159
161
 
162
+ ### Demand Analysis
163
+
164
+ A demand sits above projects: a business request that has passed the demand forum and now
165
+ needs sizing against the real code before the forum will commit to it. Unlike a phase's
166
+ analysis, the repositories are not known in advance — deciding which projects the work
167
+ lands in is part of the job.
168
+
169
+ | Tool | What it does |
170
+ |---|---|
171
+ | `list_demand_analyses` | List the demand analyses assigned to you |
172
+ | `get_demand_analysis_context` | Load the pitch as the requester answered it, what the forum asked, and every repository in the workspace |
173
+ | `submit_demand_analysis` | Submit the analysis, the repositories the change actually touches, and the phases you propose |
174
+
160
175
  ### Story Decomposition
161
176
 
162
177
  | Tool | What it does |
@@ -185,6 +200,16 @@ These are answers, not errors — none of them is worth retrying as-is.
185
200
  | `get_bug_for_enrichment` | Load a bug ticket and project context for enrichment |
186
201
  | `submit_bug_enrichment` | Submit structured technical enrichment for a bug ticket |
187
202
 
203
+ ### Test Library
204
+
205
+ Writing needs the tester or SDM role on the project. Cases and steps go live in the library straight away.
206
+
207
+ | Tool | What it does |
208
+ |---|---|
209
+ | `get_story_test_context` | Load a story's acceptance criteria with the project's areas and live cases, and whether you can write |
210
+ | `create_test_area` | Create a functional area (refused with AREA_EXISTS if the name is taken) |
211
+ | `add_test_case` | Add a new case to an area, or add steps to the end of an existing case |
212
+
188
213
  ## Updating
189
214
 
190
215
  Update to the latest version the same way you installed:
@@ -196,6 +221,15 @@ konductro-codex-setup --url https://platform.konductro.com --token <your-cli-tok
196
221
 
197
222
  Restart Codex after updating.
198
223
 
224
+ Codex runs a copy of the whole plugin that setup makes, so `npm install` alone does not upgrade it: always run `konductro-codex-setup` again after installing.
225
+
226
+ To try a prerelease (for example 2.5.0-rc.1, which adds the Test Library tools and the `konductro-test-pack` skill and needs a Konductro environment with the KON-894 API), install from `next` and run setup again:
227
+
228
+ ```bash
229
+ npm install -g @konductro/codex-plugin@next
230
+ konductro-codex-setup --url <your-konductro-url> --token <your-cli-token>
231
+ ```
232
+
199
233
  ## Troubleshooting
200
234
 
201
235
  | Problem | Solution |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konductro/codex-plugin",
3
- "version": "2.3.0",
3
+ "version": "2.5.0-rc.1",
4
4
  "description": "Codex plugin for the Konductro platform: technical analysis, delivery tasks, repository profiling, and prototype workflows.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -32,6 +32,24 @@ function loadFileConfig() {
32
32
  const fileConfig = loadFileConfig();
33
33
  const KONDUCTRO_URL = (process.env.KONDUCTRO_URL || fileConfig.url || fileConfig.konductroUrl || '').replace(/\/$/, '');
34
34
  const CLI_TOKEN = process.env.KONDUCTRO_CLI_TOKEN || fileConfig.token || fileConfig.cliToken || '';
35
+
36
+ /*
37
+ * What this plugin tells the server it is, on every request.
38
+ *
39
+ * READ FROM package.json, never a constant. The server's refusal of an outdated plugin is
40
+ * based on this string, so a hand-maintained copy that drifts from the published version
41
+ * is worse than no header at all: it would be believed.
42
+ *
43
+ * `readFileSync` rather than a JSON import assertion, whose syntax differs between Node 18
44
+ * and 20 and would break for whichever developers are on the other one.
45
+ *
46
+ * The shape is `<plugin>/<version>` and is identical across all four plugins, so the
47
+ * server parses one format rather than four.
48
+ */
49
+ const PLUGIN_VERSION = JSON.parse(
50
+ readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
51
+ ).version;
52
+ const PLUGIN_ID = `codex/${PLUGIN_VERSION}`;
35
53
  const NOT_CONFIGURED_MESSAGE =
36
54
  'Konductro is not configured. Run `konductro-codex-setup --url <URL> --token <TOKEN>`, or set KONDUCTRO_URL and KONDUCTRO_CLI_TOKEN in the MCP server environment.';
37
55
 
@@ -39,6 +57,7 @@ async function konductroFetch(path, options = {}) {
39
57
  const url = `${KONDUCTRO_URL}${path}`;
40
58
  const headers = {
41
59
  'Authorization': `Bearer ${CLI_TOKEN}`,
60
+ 'X-Konductro-Plugin': PLUGIN_ID,
42
61
  ...options.headers,
43
62
  };
44
63
  // Only set Content-Type and default body for methods that send JSON
@@ -73,6 +92,8 @@ async function konductroFetch(path, options = {}) {
73
92
  // Zod's flatten() on a validation failure. Kept so a refusal can name the offending
74
93
  // field instead of saying "Validation failed" and leaving the agent to guess.
75
94
  err.details = parsed?.details ?? null;
95
+ // KON-897: AREA_EXISTS names the area that already has the name.
96
+ err.areaId = parsed?.areaId ?? null;
76
97
  throw err;
77
98
  }
78
99
 
@@ -111,6 +132,15 @@ function refusalText(err) {
111
132
  return 'Refused: your role on this project is read-only (viewer or stakeholder), so you cannot create or change work items here. Ask an SDM to give you a writing role on the project.';
112
133
  case 'NOT_PROJECT_MEMBER':
113
134
  return 'Refused: you are not a member of this project, so you cannot create or change work items in it. Ask an SDM to add you to the project team.';
135
+ // KON-608: the demand-analysis refusals. A demand is assigned to ONE person, and
136
+ // the stage moves on without them, so both of these are ordinary outcomes rather
137
+ // than faults — they need to read as "here is where it went", not as an error.
138
+ case 'NOT_ASSIGNED':
139
+ return 'Refused: this demand analysis is assigned to somebody else. `list_demand_analyses` shows the ones that are yours. If it should be yours, ask the demand forum chair to reassign it.';
140
+ case 'WRONG_STAGE':
141
+ return 'Refused: this demand is not waiting on a technical analysis. It has either been sized already or gone back to the forum, so there is nothing to submit — check the demand in Konductro to see where it got to.';
142
+ case 'PROJECT_NOT_FOUND':
143
+ return 'Refused: one of the projects in your proposed phases is not in this workspace. Use the projectId values from `get_demand_analysis_context`, which lists every repository and the project it belongs to.';
114
144
  default:
115
145
  return null;
116
146
  }
@@ -226,7 +256,7 @@ server.tool(
226
256
  }
227
257
 
228
258
  const taskList = tasks.map((t, i) =>
229
- `${i + 1}. **${t.projectName}** — ${t.phaseName}\n Client: ${t.clientName}\n Phase ID: ${t.phaseId}\n ${t.hasExistingDraft ? '(has existing draft)' : '(new analysis)'}`
259
+ `${i + 1}. **${t.projectName}** — ${t.phaseName}\n Client: ${t.clientName}\n Phase ID: ${t.phaseId}\n ${t.refreshRequested ? '(refresh requested)' : t.hasExistingDraft ? '(has existing draft)' : '(new analysis)'}`
230
260
  ).join('\n\n');
231
261
 
232
262
  return {
@@ -256,6 +286,25 @@ server.tool(
256
286
  if (context.phase.description) contextText += `**Description:** ${context.phase.description}\n`;
257
287
  contextText += `\n`;
258
288
 
289
+ // KON-320: a refresh was requested, so this is a revision of an approved
290
+ // analysis rather than a first pass. Sits above the repositories and the
291
+ // previous document deliberately — it changes what is being asked for, so
292
+ // it has to be read before the material it applies to. Absent on a normal
293
+ // task, in which case the output is exactly what it was before.
294
+ if (context.refreshContext) {
295
+ const { requestedBy, message } = context.refreshContext;
296
+ contextText += `### Refresh Requested\n\n`;
297
+ contextText += `A refresh of this technical analysis was requested`;
298
+ if (requestedBy) contextText += ` by ${requestedBy}`;
299
+ contextText += `.\n\n`;
300
+ if (message) {
301
+ contextText += `**Context from the requester:**\n\n${message}\n\n`;
302
+ } else {
303
+ contextText += `No further context was given.\n\n`;
304
+ }
305
+ contextText += `Revise the existing analysis below rather than starting over.\n\n`;
306
+ }
307
+
259
308
  if (context.repositories.length > 0) {
260
309
  contextText += `### Repositories\n\n`;
261
310
  for (const repo of context.repositories) {
@@ -282,6 +331,8 @@ server.tool(
282
331
  }
283
332
  }
284
333
 
334
+ contextText += renderDocumentTemplate(context.documentTemplate);
335
+
285
336
  return {
286
337
  content: [{
287
338
  type: 'text',
@@ -291,6 +342,51 @@ server.tool(
291
342
  }
292
343
  );
293
344
 
345
+ /**
346
+ * The document structure this workspace requires, as the agent must read it.
347
+ *
348
+ * APPENDED, never woven into the blob above. Four plugins share that server response and
349
+ * the agent's prompt is sensitive to its shape, so everything before this point is
350
+ * byte-identical to what it has always been. A workspace with no template gets an empty
351
+ * string here and therefore exactly today's context.
352
+ *
353
+ * THE WORDING IS IDENTICAL IN ALL FOUR PLUGINS, deliberately. The story this belongs to
354
+ * requires the same behaviour from Claude, Amazon Q, Codex and Cursor, and four separately
355
+ * worded prompts is precisely how that stops being true. Change it here and copy it, do
356
+ * not improve it in one place.
357
+ *
358
+ * Standing content is reproduced WORD FOR WORD rather than summarised. It is usually a
359
+ * compliance clause the workspace requires verbatim, which is the whole reason the field
360
+ * exists.
361
+ */
362
+ function renderDocumentTemplate(template) {
363
+ if (!template) return '';
364
+
365
+ let text = `### Required Document Structure\n\n`;
366
+ text += `This workspace requires technical analysis documents to follow **${template.name}** `;
367
+ text += `(v${template.version}). Produce these sections, in this order, using these exact headings.\n\n`;
368
+
369
+ for (const [index, section] of template.sections.entries()) {
370
+ text += `${index + 1}. **${section.title}**`;
371
+ if (section.intent) text += ` — ${section.intent}`;
372
+ if (section.mustCover) text += ` _(must cover: do not produce the document until you can answer this)_`;
373
+ text += `\n`;
374
+ if (section.diagram && section.diagram !== 'none') {
375
+ const kind = section.diagram === 'any' ? 'a Mermaid diagram of whichever type fits' : `a Mermaid ${section.diagram} diagram`;
376
+ text += ` Include ${kind} inside this section.\n`;
377
+ }
378
+ if (section.standingContent) {
379
+ text += ` Reproduce this text inside the section, word for word:\n`;
380
+ text += ` > ${section.standingContent.split('\n').join('\n > ')}\n`;
381
+ }
382
+ }
383
+
384
+ text += `\nThis structure replaces any default you would otherwise use. `;
385
+ text += `The sections marked "must cover" are what your exploration and your questions `;
386
+ text += `must be able to answer before you produce the document.\n\n`;
387
+ return text;
388
+ }
389
+
294
390
  // Tool: Submit tech analysis
295
391
  server.tool(
296
392
  'submit_tech_analysis',
@@ -315,6 +411,151 @@ server.tool(
315
411
  }
316
412
  );
317
413
 
414
+ // ══ DEMAND ANALYSIS ════════════════════════════════════════════════════════
415
+ //
416
+ // The demand-level counterpart of the three tools above. A DEMAND has no project yet —
417
+ // which projects it lands in is decided at IT Eval, from what this analysis finds — so
418
+ // the context carries the whole workspace's repositories and the submission reports
419
+ // which of them the change actually touches.
420
+ //
421
+ // All three go through workItemCall, like the KON-519 tools: it asserts the token is
422
+ // configured, turns a refusal into a sentence via refusalText, and keeps 401 separate
423
+ // because an expired token is a setup problem rather than a permission one. Written
424
+ // bare, a 403 from an analysis assigned to somebody else surfaced as an unhandled
425
+ // error rather than an answer.
426
+
427
+ /** A demand question and its answer, or a plain note that it was left blank. */
428
+ function answerLine(q) {
429
+ const answer = q.answer && String(q.answer).trim() ? q.answer : '_Not answered._';
430
+ return [`**${q.question}**`, q.help ? `_${q.help}_` : null, '', answer].filter((l) => l !== null).join('\n');
431
+ }
432
+
433
+ // Tool: List pending demand analyses
434
+ server.tool(
435
+ 'list_demand_analyses',
436
+ 'List demand technical analyses assigned to you in Konductro. A demand sits above projects: it is a business request that has passed the demand forum and now needs sizing against the real code.',
437
+ {},
438
+ async () => workItemCall(async () => {
439
+ const { tasks } = await konductroFetch('/api/cli/demand-analyses');
440
+
441
+ if (!tasks || tasks.length === 0) {
442
+ return 'No demand analyses assigned to you.';
443
+ }
444
+
445
+ const lines = tasks.map((t) => {
446
+ const parts = [`### ${t.key} — ${t.title}`];
447
+ if (t.businessUnit) parts.push(`**Business unit:** ${t.businessUnit}`);
448
+ if (t.nextSitting) parts.push(`**Back at the forum:** ${new Date(t.nextSitting).toISOString().slice(0, 10)}`);
449
+ if (t.startWith && t.startWith.length) parts.push(`**Start with:** ${t.startWith.join(', ')}`);
450
+ if (t.askedFor) parts.push(`**They asked:** ${t.askedFor}`);
451
+ parts.push(`\`get_demand_analysis_context\` with demandId ${t.key} to load it.`);
452
+ return parts.join('\n');
453
+ });
454
+
455
+ return `## Demand analyses assigned to you (${tasks.length})\n\n${lines.join('\n\n')}`;
456
+ })
457
+ );
458
+
459
+ // Tool: Load one demand's analysis context
460
+ server.tool(
461
+ 'get_demand_analysis_context',
462
+ "Load everything needed to run a demand's technical analysis: the pitch as the requester answered it, the workspace's own questions, what the forum asked you to answer, and every repository in the workspace.",
463
+ {
464
+ demandId: z.string().describe('The demand key (e.g. DEM-4) or its UUID, from list_demand_analyses'),
465
+ },
466
+ async ({ demandId }) => workItemCall(async () => {
467
+ const ctx = await konductroFetch(`/api/cli/demand-analyses/${demandId}/context`);
468
+ const d = ctx && ctx.demand;
469
+ if (!d) {
470
+ return `No demand context came back for ${demandId}. Check the key, and that the analysis is assigned to you.`;
471
+ }
472
+
473
+ const repos = (ctx.repositories || [])
474
+ .map((r) => `- \`${r.name}\` (${r.projectName}${r.type ? `, ${r.type}` : ''}) — ${r.url}\n projectId: \`${r.projectId}\``)
475
+ .join('\n') || '- None linked to any project yet';
476
+
477
+ const conversation = (ctx.conversation || [])
478
+ .map((c) => `- **${c.by}**${c.kind === 'amendment' ? ' (amendment)' : ''}: ${c.body}`)
479
+ .join('\n');
480
+
481
+ // THE PITCH AS THE WORKSPACE ACTUALLY ASKED IT.
482
+ //
483
+ // This renders ctx.template, not the demand's own columns. Every workspace writes
484
+ // its own pitch template — questions it added, questions it deleted, its own
485
+ // wording — and the demand is answered against the version it was RAISED on. The
486
+ // backend maps the nine shipped answers into that same template (KON-604), so this
487
+ // one shape carries both, in the order the requester saw.
488
+ //
489
+ // Reading the columns instead would have dropped every question the workspace added
490
+ // — "Which regulator requires this?" would be invisible to the analysis — which is
491
+ // the whole point of the templating feature. The backend had exactly this bug and it
492
+ // was caught in review; the same mistake is available here.
493
+ const pitch = ctx.template
494
+ ? [
495
+ `_Answered against **${ctx.template.name}** v${ctx.template.version}._`,
496
+ ...(ctx.template.sections || []).map((section) => [
497
+ `## ${section.name}`,
498
+ section.help ? `_${section.help}_` : null,
499
+ '',
500
+ (section.questions || []).map(answerLine).join('\n\n'),
501
+ ].filter((l) => l !== null).join('\n')),
502
+ ].join('\n\n')
503
+ // A demand raised before templates existed has none pinned. Fall back to the
504
+ // columns rather than showing the analyst nothing.
505
+ : [
506
+ '## What they need', d.need || 'Not given',
507
+ '', '## What happens today', d.currentState || 'Not given',
508
+ '', '## Who it affects', [d.affects, d.affectsWho].filter(Boolean).join(' — ') || 'Not given',
509
+ '', '## How they would know it worked', d.successLooksLike || 'Not given',
510
+ ].join('\n');
511
+
512
+ return [
513
+ `# ${d.key} — ${d.title}`,
514
+ '',
515
+ `**Raised by:** ${d.raisedBy}${d.businessUnit ? ` (${d.businessUnit})` : ''}`,
516
+ '',
517
+ pitch,
518
+ '',
519
+ '## What the forum asked you to answer',
520
+ ctx.askedFor || 'Nothing specific. Answer the pitch.',
521
+ '',
522
+ '## Where to start looking',
523
+ (ctx.startWith && ctx.startWith.length) ? ctx.startWith.map((r) => `\`${r}\``).join(', ') : 'Nothing named — use your judgement.',
524
+ '',
525
+ '## Every repository in this workspace',
526
+ 'The starting point above is a hint, not a boundary. Report what the change ACTUALLY touches.',
527
+ '',
528
+ repos,
529
+ conversation ? `\n## Conversation on the demand\n${conversation}` : '',
530
+ ].join('\n');
531
+ })
532
+ );
533
+
534
+ // Tool: Submit a demand analysis
535
+ server.tool(
536
+ 'submit_demand_analysis',
537
+ 'Push a finished demand technical analysis back to Konductro: what you found, which repositories the change actually touches, and the phase breakdown you propose. The breakdown is a PROPOSAL — the demand forum decides at IT Eval.',
538
+ {
539
+ demandId: z.string().describe('The demand key (e.g. DEM-4) or its UUID'),
540
+ summary: z.string().describe('What the analysis found, in markdown. What is already there, what has to change, the risks, and the assumptions the estimate rests on.'),
541
+ foundRepos: z.array(z.string()).optional().describe('The repositories the change actually touches, by name. Not the ones you were told to start with.'),
542
+ proposedPhases: z.array(z.object({
543
+ name: z.string().describe('What this phase delivers'),
544
+ projectId: z.string().uuid().optional().describe('The project it lands in, from the context. Omit if it genuinely belongs nowhere yet.'),
545
+ points: z.number().int().min(0).max(1000).describe('Story points for this phase alone. Never send a total; Konductro derives it.'),
546
+ why: z.string().optional().describe('Why it is its own phase rather than part of another'),
547
+ })).optional().describe('The phases you propose. A phase belongs to ONE project; work spanning two projects is two phases.'),
548
+ },
549
+ async ({ demandId, summary, foundRepos, proposedPhases }) => workItemCall(async () => {
550
+ const result = await konductroFetch(`/api/cli/demand-analyses/${demandId}/submit`, {
551
+ method: 'POST',
552
+ body: JSON.stringify({ summary, foundRepos, proposedPhases }),
553
+ });
554
+
555
+ return `## Demand analysis submitted\n\n${result.message}\n\n- Demand: ${result.key}\n- Submitted: ${result.submittedAt}\n\nThe demand forum has been notified and can now record the IT Eval.`;
556
+ })
557
+ );
558
+
318
559
  // Tool: List pending decomposition tasks
319
560
  server.tool(
320
561
  'list_decomposition_tasks',
@@ -1304,6 +1545,127 @@ server.tool(
1304
1545
  }
1305
1546
  );
1306
1547
 
1548
+ // ─── KON-897: Test Library ──────────────────────────────────────────────────
1549
+ //
1550
+ // A tester turns a story's acceptance criteria into Test Library cases from the CLI. Cases,
1551
+ // added steps and areas go straight into the library: the tester's approval of the plan in
1552
+ // /test-pack is the review. Writes need the tester or SDM role on the project.
1553
+
1554
+ /**
1555
+ * Like workItemCall, except that a refusal is passed through EXACTLY as the backend wrote
1556
+ * it. These routes answer 403 INSUFFICIENT_ROLE for a missing PROJECT role (tester or SDM),
1557
+ * which refusalText would turn into a sentence about viewer seats, and 409 CASE_ARCHIVED or
1558
+ * AREA_EXISTS whose own sentences already say what to do.
1559
+ */
1560
+ async function testLibraryCall(fn) {
1561
+ try {
1562
+ assertAuthConfigured();
1563
+ return { content: [{ type: 'text', text: await fn() }] };
1564
+ } catch (err) {
1565
+ if (err.status === 401) {
1566
+ return {
1567
+ content: [{ type: 'text', text: 'Not authenticated: Konductro rejected the CLI token. It may be expired or revoked. Create a new one in Konductro under your profile and update KONDUCTRO_CLI_TOKEN. This is a setup problem, not a permissions one.' }],
1568
+ isError: true,
1569
+ };
1570
+ }
1571
+ if (err.status === 403 || err.status === 404 || err.status === 409 || (err.status === 400 && err.code !== 'INVALID_BODY')) {
1572
+ const extra = err.code === 'AREA_EXISTS' && err.areaId ? ` Existing area id: ${err.areaId}.` : '';
1573
+ const sentence = /[.!?]$/.test(err.message) ? err.message : `${err.message}.`;
1574
+ return { content: [{ type: 'text', text: `Refused (${err.code ?? err.status}): ${sentence}${extra}` }] };
1575
+ }
1576
+ const text = err.setup
1577
+ ? err.message
1578
+ : `Failed: ${err.code === 'INVALID_BODY' ? validationText(err) : err.message}`;
1579
+ return { content: [{ type: 'text', text }], isError: true };
1580
+ }
1581
+ }
1582
+
1583
+ function renderStoryTestContext(ctx) {
1584
+ const lines = [];
1585
+ lines.push(`## ${ctx.story.key}: ${ctx.story.title}`, '');
1586
+ lines.push(`Project id: ${ctx.projectId}`);
1587
+ lines.push(`You can write to this Test Library: ${ctx.canWrite ? 'yes' : 'NO (needs the tester or SDM role on the project)'}`, '');
1588
+ lines.push('### Acceptance criteria', '');
1589
+ const acs = ctx.story.acceptanceCriteria ?? [];
1590
+ if (acs.length === 0) lines.push('(none recorded on the story)');
1591
+ acs.forEach((ac, i) => lines.push(`${i + 1}. ${ac}`));
1592
+ lines.push('', '### Test Library', '');
1593
+ if (ctx.areas.length === 0) lines.push('No functional areas yet.');
1594
+ for (const area of ctx.areas) {
1595
+ lines.push(`#### ${area.name} (area id ${area.id}, ${area.cases.length} case${area.cases.length === 1 ? '' : 's'})`);
1596
+ if (area.description) lines.push(area.description);
1597
+ for (const c of area.cases) {
1598
+ lines.push(`- **${c.name}** (case id ${c.id})${c.description ? `: ${c.description}` : ''}`);
1599
+ for (const s of c.steps) lines.push(` ${s.index + 1}. ${s.description}`);
1600
+ }
1601
+ lines.push('');
1602
+ }
1603
+ return lines.join('\n');
1604
+ }
1605
+
1606
+ server.tool(
1607
+ 'get_story_test_context',
1608
+ "Load a story by key (e.g. KON-784) with its acceptance criteria, plus its project's Test Library: functional areas and their live cases with steps (archived cases are left out). Also says whether you may write to the library (tester or SDM on the project). Call this first when building test cases for a story.",
1609
+ {
1610
+ storyKey: z.string().describe('The story key, e.g. KON-784'),
1611
+ },
1612
+ async ({ storyKey }) => testLibraryCall(async () => {
1613
+ const ctx = await konductroFetch(`/api/cli/stories/${encodeURIComponent(storyKey.trim())}/test-context`);
1614
+ return renderStoryTestContext(ctx);
1615
+ }),
1616
+ );
1617
+
1618
+ server.tool(
1619
+ 'create_test_area',
1620
+ "Create a functional area in a project's Test Library when no existing area fits. Tester or SDM only. An area with the same name (ignoring case) is refused with AREA_EXISTS and that area's id. Only call this after the user has agreed the new area.",
1621
+ {
1622
+ projectId: z.string().describe('The project id from get_story_test_context'),
1623
+ name: z.string().describe('A short domain name, e.g. "Refunds" (2 to 100 characters)'),
1624
+ description: z.string().optional().describe('One line on what the area covers'),
1625
+ sourceStoryKey: z.string().optional().describe('The story this area is for, e.g. KON-784'),
1626
+ },
1627
+ async ({ projectId, name, description, sourceStoryKey }) => testLibraryCall(async () => {
1628
+ const area = await konductroFetch(`/api/cli/projects/${encodeURIComponent(projectId)}/test-library/areas`, {
1629
+ method: 'POST',
1630
+ body: JSON.stringify({ name, description, sourceStoryKey }),
1631
+ });
1632
+ return `Created area **${area.name}** (area id ${area.id}).`;
1633
+ }),
1634
+ );
1635
+
1636
+ server.tool(
1637
+ 'add_test_case',
1638
+ "Add ONE test case to a project's Test Library, live straight away. mode new_case adds a case to an area (needs areaId and name); mode extend_case adds steps to the end of an existing case (needs caseId). Steps are 1 to 50, each an action followed by its expected result. Tester or SDM only. An archived case is refused with CASE_ARCHIVED. Only call this after the user has approved the plan.",
1639
+ {
1640
+ projectId: z.string().describe('The project id from get_story_test_context'),
1641
+ mode: z.enum(['new_case', 'extend_case']).describe('new_case adds a case; extend_case adds steps to an existing case'),
1642
+ areaId: z.string().optional().describe('For new_case: the area id'),
1643
+ caseId: z.string().optional().describe('For extend_case: the existing case id'),
1644
+ name: z.string().optional().describe('For new_case: a short, scenario-style name (3 to 200 characters)'),
1645
+ description: z.string().optional().describe('For new_case: optional context for whoever runs it'),
1646
+ steps: z.array(z.string()).describe('Ordered steps, each up to 500 characters, e.g. "Submit a R100,00 payment. Expected: one retry is logged."'),
1647
+ sourceStoryKey: z.string().describe('The story these steps come from, e.g. KON-784'),
1648
+ },
1649
+ async ({ projectId, mode, areaId, caseId, name, description, steps, sourceStoryKey }) => testLibraryCall(async () => {
1650
+ if (mode === 'new_case' && (!areaId || !name)) {
1651
+ return 'Refused: new_case needs areaId and name. NOTHING WAS ADDED.';
1652
+ }
1653
+ if (mode === 'extend_case' && !caseId) {
1654
+ return 'Refused: extend_case needs caseId. NOTHING WAS ADDED.';
1655
+ }
1656
+ const body = mode === 'new_case'
1657
+ ? { mode, areaId, name, description, steps: steps.map((d) => ({ description: d })), sourceStoryKey }
1658
+ : { mode, caseId, steps: steps.map((d) => ({ description: d })), sourceStoryKey };
1659
+ const res = await konductroFetch(`/api/cli/projects/${encodeURIComponent(projectId)}/test-library/cases`, {
1660
+ method: 'POST',
1661
+ body: JSON.stringify(body),
1662
+ });
1663
+ const verb = mode === 'new_case' ? `Added case **${res.case.name}**` : `Added ${steps.length} step${steps.length === 1 ? '' : 's'} to **${res.case.name}**`;
1664
+ const list = res.case.steps.map((s) => `${s.index + 1}. ${s.description}`).join('\n');
1665
+ return `${verb} (case id ${res.case.id}). It now has ${res.case.steps.length} steps:\n${list}`;
1666
+ }),
1667
+ );
1668
+
1307
1669
  // Start the server
1308
1670
  async function main() {
1309
1671
  const transport = new StdioServerTransport();
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: konductro-demand-analysis
3
+ description: Size a Konductro DEMAND against the real code. Use when an architect has been assigned a demand technical analysis — a business request that has passed the demand forum and now needs to be broken into phases and estimated before the forum will commit to it.
4
+ allowed-tools: Read, Grep, Glob, Bash, mcp__konductro__list_demand_analyses, mcp__konductro__get_demand_analysis_context, mcp__konductro__submit_demand_analysis
5
+ ---
6
+
7
+ # Konductro Demand Analysis
8
+
9
+ A demand is a business request that sits ABOVE projects. It has passed the demand forum,
10
+ and the forum will not commit to it until somebody has read the actual code and said what
11
+ it entails. That is this job.
12
+
13
+ ## What makes this different from a phase's technical analysis
14
+
15
+ A phase already belongs to a project, so its repositories are known. **A demand does not.**
16
+ Which projects the work lands in is decided at IT Eval, FROM WHAT YOU FIND. So:
17
+
18
+ - The context lists **every repository in the workspace**, not a project's few.
19
+ - The "start with" list is a hint from whoever assigned it. It is not a boundary, and it
20
+ is regularly wrong: the work turns out to be in a repository nobody expected.
21
+ - You report which repositories the change **actually touches**. That is what the forum
22
+ reads, and it is stored separately from the hint you were given.
23
+
24
+ ## Workflow
25
+
26
+ ### Step 1: See what is assigned
27
+
28
+ Call `list_demand_analyses`. Present the list and ask which one to work on. Each shows
29
+ what the forum asked to have answered and when it is next sitting — that date is the
30
+ deadline, so say it out loud.
31
+
32
+ ### Step 2: Load the context
33
+
34
+ Call `get_demand_analysis_context` with the demand key. Read the whole thing before
35
+ touching any code. It carries:
36
+
37
+ - The pitch, in the business's own words, and what happens today
38
+ - The value case: who it affects, and what it costs to not have it
39
+ - What the forum specifically asked you to answer
40
+ - Every repository in the workspace, with its project
41
+
42
+ **Say the value case back to the user in one line.** An estimate has to be proportionate
43
+ to the thing being bought, and this is the only place that number appears.
44
+
45
+ ### Step 3: Read the code
46
+
47
+ The repositories are on this machine. Use Glob, Grep and Read. Konductro never clones
48
+ anything and neither do you: if a repository named in the context is not present locally,
49
+ say so rather than guessing at it.
50
+
51
+ Start with the repositories you were pointed at, then follow the work wherever it goes.
52
+
53
+ What you are trying to establish, in this order:
54
+
55
+ 1. **What already exists.** Half of every demand turns out to be built. Say what is there
56
+ before you say what is needed.
57
+ 2. **What actually has to change**, per repository, concretely enough that somebody could
58
+ argue with it.
59
+ 3. **What is in the way.** Missing data, an integration nobody has written, a migration
60
+ with no way back.
61
+ 4. **What the estimate rests on.** Every assumption you make is a way the number could be
62
+ wrong, and the forum is told which one when it is.
63
+
64
+ ### Step 4: Propose the phases
65
+
66
+ This is the part the forum needs most, and the part it cannot do itself.
67
+
68
+ - **A phase belongs to ONE project.** Work spanning two projects is two phases. This is
69
+ not a formality: each phase becomes a real Phase in that project when the demand is
70
+ green lit.
71
+ - **Order them by what has to land first.** If phase two cannot start until phase one is
72
+ deployed, say so in its `why`.
73
+ - **Points per phase, never a total.** Konductro derives the total. Sending your own is
74
+ how the headline number and the breakdown behind it end up disagreeing.
75
+ - **A phase with no obvious home** is allowed: omit `projectId` and say why in the `why`.
76
+ A visible gap beats a phase filed in whichever project came first.
77
+
78
+ ### Step 5: Submit
79
+
80
+ Call `submit_demand_analysis` with:
81
+
82
+ - `summary` — what you found. Structure it as: what exists, what has to change, risks,
83
+ assumptions. Markdown.
84
+ - `foundRepos` — the repositories the change actually touches. Not the hint you were given.
85
+ - `proposedPhases` — the breakdown above.
86
+
87
+ The forum is notified and records the IT Eval from your proposal. They can change any of
88
+ it; you are advising, not deciding.
89
+
90
+ ## The bar
91
+
92
+ **Never estimate something you have not read.** An unfamiliar name is a reason to go and
93
+ look, never a reason to assume it is small. If a repository you need is not on this
94
+ machine, the honest output is a summary that says which one and what it blocks — not a
95
+ number with a shrug behind it.
96
+
97
+ **Say what you did not check.** The forum is about to commit money against this. A gap you
98
+ name costs an hour; a gap you paper over costs the quarter.
@@ -19,11 +19,20 @@ Once the user picks a task, call `get_task_context` with the phase ID. This load
19
19
  - The approved requirements document (what needs to be built)
20
20
  - Project and client context
21
21
  - Repository information
22
+ - A "Refresh Requested" section, when someone has asked for an existing analysis
23
+ to be redone. Read it first: it carries the requester's reason, and the job is
24
+ to revise the previous analysis rather than start from scratch.
22
25
 
23
26
  Share a summary of the requirements with the user and confirm you're ready to begin.
24
27
 
25
28
  ### Step 3: Explore the Codebase
26
29
 
30
+ **If the context carried a "Required Document Structure", that is your brief.** Every section in it is something you must be able to answer by the end of this step, and the ones marked "must cover" are not optional. Explore with those sections in mind rather than working through the generic list below and hoping it covers them — a workspace that asks for a Regulatory Impact section is telling you what to go and find out, and nothing in the generic list will lead you there.
31
+
32
+ Where the structure asks for something the generic list does not cover, go and look for it. Where it omits something, you do not need to chase it.
33
+
34
+ If no structure was supplied, use the list below as-is.
35
+
27
36
  Now analyse the local codebase. The user has the repository/repositories cloned in their current working directory. Use fast repository search and focused file reads to explore:
28
37
 
29
38
  - **Project structure** — folder layout, module organisation
@@ -40,6 +49,10 @@ Discuss your findings with the user as you go. Ask clarifying questions about de
40
49
 
41
50
  ### Step 4: Impact Analysis
42
51
 
52
+ **Before moving on, check yourself against the required structure.** Take each section, and each "must cover" section especially, and ask whether you could write it now from what you have found. Where you could not, that is a question for the user or another pass over the codebase — ask it now rather than discovering the gap while writing the document, when the honest options are guessing or going back.
53
+
54
+ This is the step that makes the structure mean something. Producing the right headings over content that does not answer them is worse than the default document, because it looks like compliance.
55
+
43
56
  Based on the requirements and your codebase exploration, assess:
44
57
 
45
58
  - **What needs to change** — which files, modules, or services need modification
@@ -50,7 +63,11 @@ Based on the requirements and your codebase exploration, assess:
50
63
 
51
64
  ### Step 5: Produce the Document
52
65
 
53
- When the user is satisfied with the analysis, produce a structured technical analysis document. The document must include:
66
+ **If the context carried a "Required Document Structure", follow it exactly** — those sections, in that order, under those headings. It replaces the default list below rather than supplementing it: do not add the default sections alongside it, and do not reorder it to something you find more natural. Where a section carries standing content, reproduce that text word for word; it is usually a clause the workspace is required to publish, and paraphrasing it defeats the point of it being there. Where a section asks for a diagram, draw one, as Mermaid, inside that section.
67
+
68
+ A document produced here must be indistinguishable from one produced for the same workspace in Konductro itself. That is the whole purpose of the structure being sent.
69
+
70
+ **If no structure was supplied**, use this default list:
54
71
 
55
72
  1. **Codebase Overview** — what exists today (structure, stack, patterns)
56
73
  2. **Technical Stack** — frameworks, versions, build tools, deployment
@@ -79,4 +96,5 @@ After submission, confirm success and let the user know the document is availabl
79
96
  - Be thorough but focused — analyse what's relevant to the requirements
80
97
  - Ask the user questions — they know the codebase context you don't
81
98
  - Produce a complete, standalone document that an architect can use without additional context
99
+ - When a required document structure is supplied, it wins over anything in this file. It is the workspace's own standard, and your job is to meet it, not to improve on it
82
100
  - The conversation summary should capture the "why" behind decisions, not just the findings
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: konductro-test-pack
3
+ description: Turn a story's acceptance criteria into Test Library cases, checked against the existing library, and add them straight into the library once the tester approves the plan. Use when asked to build a test pack or test cases for a story key such as KON-784.
4
+ ---
5
+
6
+ # Test Pack
7
+
8
+ Build manual regression test cases for one story and add them to the project's Test Library.
9
+ A test case is a checklist a person runs: a name, an optional description and ordered steps.
10
+ Nothing here is automated testing.
11
+
12
+ Cases you add go live in the library straight away, both new cases and extra steps on an
13
+ existing case. There is no review step in Konductro: the tester's approval of your plan in
14
+ Step 4 IS the review, so never add anything they have not approved.
15
+
16
+ ## Step 1: Load the story and the library
17
+
18
+ Call `get_story_test_context` with the story key from the request (ask for it if it is
19
+ missing). Summarise in a few lines:
20
+
21
+ - the story title and its acceptance criteria, numbered
22
+ - the project's functional areas, with how many cases each holds
23
+
24
+ If it says you cannot write to this Test Library, stop and say so: adding cases needs the
25
+ tester or SDM role on the project. Ask the project's SDM for the role.
26
+
27
+ ## Step 2: Look at the code, if it is here
28
+
29
+ If the current directory is the story's repository, read the code the story touches, enough
30
+ to know what changed and what it affects. If it is not, say the cases come from the
31
+ acceptance criteria alone. Do not guess at code you have not read.
32
+
33
+ ## Step 3: Plan the cases
34
+
35
+ For each acceptance criterion decide:
36
+
37
+ - **Which area.** Use an existing area. If none fits, say so and suggest one new area (a
38
+ short domain name and a one-line description) for the tester to agree. Check it is not a
39
+ near-duplicate of an existing area first.
40
+ - **New case or extend an existing one.** Compare with the existing cases. If one already
41
+ covers the same scenario, plan `extend_case` with only the missing steps. Never add a
42
+ duplicate. An extension changes a case other testers already run, so name the case it
43
+ changes and quote its current last step.
44
+ - **Whether it is worth keeping as regression.** A criterion about a one-off migration or
45
+ wording does not need a permanent test. Say which criteria you are leaving out and why.
46
+
47
+ Group criteria that are one scenario into one case. Write each step as an action followed by
48
+ "Expected:" and the result, for example "Submit a R100,00 card payment while the bank stub
49
+ delays 31 seconds. Expected: one retry is logged, then the payment completes." Use obviously
50
+ fake test data only: test card 4111 1111 1111 1111, "Test Merchant 001", example.com
51
+ addresses. Never realistic ID numbers, phone numbers or addresses.
52
+
53
+ ## Step 4: Show the plan and wait
54
+
55
+ Present the plan as a table (area, new or extend, case name, step count), then each case's
56
+ steps. Say plainly that approving adds them to the library straight away. Ask the tester to
57
+ approve, change or drop cases. Do not add anything before they approve.
58
+
59
+ ## Step 5: Add
60
+
61
+ 1. If the tester agreed a new area, call `create_test_area` and use the area id it returns.
62
+ If it answers AREA_EXISTS, use the existing area it names instead.
63
+ 2. Call `add_test_case` once per approved case, with `sourceStoryKey` set to the story key.
64
+ 3. Report what was written: how many cases were added and how many steps were added to
65
+ existing cases, by area. The tester finds them under Test Library, Cases in the project.
66
+
67
+ If a call is refused, show the refusal exactly as it came back (for example CASE_ARCHIVED, or
68
+ the message about the tester or SDM role) and carry on with the remaining approved cases.
69
+ Do not retry a refusal or work around it.