@konductro/codex-plugin 2.2.0 → 2.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/README.md CHANGED
@@ -68,6 +68,7 @@ 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 |
71
72
 
72
73
  ## Tools
73
74
 
@@ -82,14 +83,94 @@ Tools are called automatically by Codex based on natural language. You do not in
82
83
  | `start_work` | Start work on a ticket: creates a branch, pushes the ticket spec, and sets `in_progress` |
83
84
  | `create_pr` | Create a pull request and move the ticket to `pr_open` |
84
85
 
86
+ ### Work Items
87
+
88
+ | Tool | What it does |
89
+ |---|---|
90
+ | `create_work_item` | Create a story, task or bug in the project this repo belongs to |
91
+ | `update_work_item` | Change the title, description or acceptance criteria of a work item you own |
92
+ | `delete_work_item` | Delete a task or bug that has not been started |
93
+
94
+ The project is resolved from the repository's git remote, so you are never asked for a
95
+ project identifier.
96
+
97
+ **Everything created lands in Draft** and still needs an SDM's approval before it can be
98
+ worked on.
99
+
100
+ **`update_work_item` can change three fields and no others.** Status, sprint, assignee and
101
+ everything else are deliberately not on the schema — change those in Konductro. Sending
102
+ `acceptanceCriteria` replaces the whole list rather than appending to it. The `changed`
103
+ list it reports back is the fields that were written, not the ones that turned out to
104
+ differ, so re-sending a value unchanged still shows up in it.
105
+
106
+ **A task is created in the repository you are standing in.** Its parent story is the only
107
+ thing you need to name. Set `repositoryId` yourself only for a task that will be built in a
108
+ different repository on the same project.
109
+
110
+ **Only a task may have a parent.** A story or a bug sent with a `parentKey` is refused and
111
+ nothing is created, rather than being filed top-level as though it had worked. A bug is
112
+ always standalone here — Konductro parents one to a story only when QA files it against a
113
+ failed test criterion — so name the story in the description instead. A story is top-level
114
+ by definition: the hierarchy is story → task, and work that belongs under a story is a task.
115
+
116
+ **`create_work_item` returns the new item's id.** Use it for the follow-up call. Ticket
117
+ keys are prefix plus number and the prefix is not returned, so a guessed key resolves to a
118
+ different project's item of the same number instead of failing.
119
+
120
+ #### Who can create and change stories
121
+
122
+ Each project has a story access setting, which an SDM controls under Settings → General:
123
+
124
+ | Setting | What a developer can do |
125
+ |---|---|
126
+ | **Planning roles only** | Cannot create or change stories. Filing bugs and editing tasks are unaffected. |
127
+ | **Developers can, with review** | Changes apply straight away, then wait for an SDM to approve or reject. |
128
+ | **Developers can, no review** | Creates and changes apply with nothing held for approval. |
129
+
130
+ A new project starts on **planning roles only**.
131
+
132
+ Under *with review*, a change to a story is applied and then held: the story will not move
133
+ to Ready for QA until an SDM resolves it, even once every task is done. If it is rejected,
134
+ the previous values are restored and you are notified.
135
+
136
+ #### What a refusal means
137
+
138
+ These are answers, not errors — none of them is worth retrying as-is.
139
+
140
+ | You will see | What to do |
141
+ |---|---|
142
+ | The project's story access is set to planning roles only | A project setting. Ask an SDM to make the change, or to open story access for developers. |
143
+ | You can only change work items assigned to you, that you are the developer on, or that you created | Ask whoever owns it, or ask an SDM. |
144
+ | Stories cannot be deleted from the CLI | Deleting a story removes its tasks with it. Archive it in Konductro instead. |
145
+ | QA filed this bug against a failed test criterion | It is QA's record of a failure, not yours to remove. |
146
+ | Only a task can be created under a parent | Nothing was created. For a bug, re-run without `parentKey` and name the story in the description. For a story, you probably wanted `kind: "task"`. |
147
+ | Work has already started on this item | It has a branch, or has moved past sprint planning. Only items still in draft, approved or in_sprint can be deleted. |
148
+ | Your seat is a viewer seat | Read-only across the whole platform, not a project setting. Ask an admin for a contributor seat. |
149
+ | Your role on this project is read-only | Ask an SDM for a writing role on the project. |
150
+ | You are not a member of this project | Ask an SDM to add you to the project team. |
151
+ | Konductro is not configured | A setup problem rather than a permissions one — run `konductro-codex-setup`, or your CLI token is expired or revoked. Create a new one in Konductro under your profile. |
152
+
85
153
  ### Technical Analysis
86
154
 
87
155
  | Tool | What it does |
88
156
  |---|---|
89
157
  | `list_tech_analysis_tasks` | List your pending technical analysis assignments |
90
- | `get_task_context` | Load requirements and project context for a technical analysis task |
158
+ | `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 |
91
159
  | `submit_tech_analysis` | Submit your analysis document back to Konductro |
92
160
 
161
+ ### Demand Analysis
162
+
163
+ A demand sits above projects: a business request that has passed the demand forum and now
164
+ needs sizing against the real code before the forum will commit to it. Unlike a phase's
165
+ analysis, the repositories are not known in advance — deciding which projects the work
166
+ lands in is part of the job.
167
+
168
+ | Tool | What it does |
169
+ |---|---|
170
+ | `list_demand_analyses` | List the demand analyses assigned to you |
171
+ | `get_demand_analysis_context` | Load the pitch as the requester answered it, what the forum asked, and every repository in the workspace |
172
+ | `submit_demand_analysis` | Submit the analysis, the repositories the change actually touches, and the phases you propose |
173
+
93
174
  ### Story Decomposition
94
175
 
95
176
  | Tool | What it does |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konductro/codex-plugin",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
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
@@ -52,13 +71,157 @@ async function konductroFetch(path, options = {}) {
52
71
  });
53
72
 
54
73
  if (!response.ok) {
55
- const body = await response.text().catch(() => '');
56
- throw new Error(`Konductro API error (${response.status}): ${body}`);
74
+ const raw = await response.text().catch(() => '');
75
+ // KON-519: keep the machine-readable code and status on the error. The backend
76
+ // answers { error, code, details? }, and every tool should branch on CODE rather than
77
+ // on message text so a wording change server-side cannot break the plugin.
78
+ //
79
+ // NOTE this CHANGED err.message. It used to be the whole envelope —
80
+ // `Konductro API error (404): {"error":"Bug not found","code":"BUG_NOT_FOUND"}` — and
81
+ // is now just the `error` sentence. Anything that used to sniff the message for a
82
+ // status or a code no longer matches, so those call sites were moved onto err.code /
83
+ // err.status (get_bug_for_enrichment and submit_bug_enrichment). If you add a tool,
84
+ // read the code; do not go back to matching text.
85
+ let parsed = null;
86
+ try { parsed = JSON.parse(raw); } catch { /* not JSON — fall through to the raw body */ }
87
+ const err = new Error(
88
+ parsed?.error ? parsed.error : `Konductro API error (${response.status}): ${raw}`,
89
+ );
90
+ err.status = response.status;
91
+ err.code = parsed?.code ?? null;
92
+ // Zod's flatten() on a validation failure. Kept so a refusal can name the offending
93
+ // field instead of saying "Validation failed" and leaving the agent to guess.
94
+ err.details = parsed?.details ?? null;
95
+ throw err;
57
96
  }
58
97
 
59
98
  return response.json();
60
99
  }
61
100
 
101
+ // ─── KON-519: work-item tools ────────────────────────────────────────────────
102
+
103
+ /**
104
+ * Turn a backend refusal into a sentence a developer can act on.
105
+ *
106
+ * A bare 403 makes an agent retry or guess. Each of these says what to do instead, and
107
+ * the setting-related one NAMES the setting, because the developer's next move is to ask
108
+ * their SDM rather than to try again.
109
+ *
110
+ * Keyed on code, never on message text.
111
+ */
112
+ function refusalText(err) {
113
+ switch (err.code) {
114
+ case 'STORY_ACCESS_DENIED':
115
+ return "Refused: this project's story access is set to planning roles only, so stories here can only be created or edited by an SDM, architect or UX lead. This is a project setting, not something to retry — ask an SDM to make the change, or to open story access for developers. Filing bugs and editing tasks are unaffected.";
116
+ case 'NOT_YOUR_WORK_ITEM':
117
+ return 'Refused: you can only change work items assigned to you, that you are the developer on, or that you created. Ask whoever owns it, or ask an SDM to make the change.';
118
+ case 'STORIES_NOT_DELETABLE':
119
+ return 'Refused: stories cannot be deleted from the CLI — deleting one removes its tasks with it and cannot be undone. Archive it in Konductro instead.';
120
+ case 'QA_FILED_BUG':
121
+ return "Refused: QA filed this bug against a failed test criterion, so it is their record of what went wrong and is not yours to remove. Fix it, or ask QA if it was raised in error.";
122
+ case 'WORK_ALREADY_STARTED':
123
+ // Mirrors DELETABLE_STATUSES in work-item-access.service.ts: draft, approved and
124
+ // in_sprint are all still deletable. Anything past those, or anything with a
125
+ // branch, is not.
126
+ return 'Refused: work has already started on this item — it has a branch, or has moved past sprint planning (only items still in draft, approved or in_sprint can be deleted). Deleting it would orphan the branch. Close it out in Konductro instead.';
127
+ case 'INSUFFICIENT_ROLE':
128
+ return 'Refused: your Konductro seat is a viewer seat, which is read-only across the whole platform. This is not a project setting — ask an admin to move you to a contributor seat.';
129
+ case 'READ_ONLY_ROLE':
130
+ 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.';
131
+ case 'NOT_PROJECT_MEMBER':
132
+ 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.';
133
+ // KON-608: the demand-analysis refusals. A demand is assigned to ONE person, and
134
+ // the stage moves on without them, so both of these are ordinary outcomes rather
135
+ // than faults — they need to read as "here is where it went", not as an error.
136
+ case 'NOT_ASSIGNED':
137
+ 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.';
138
+ case 'WRONG_STAGE':
139
+ 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.';
140
+ case 'PROJECT_NOT_FOUND':
141
+ 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.';
142
+ default:
143
+ return null;
144
+ }
145
+ }
146
+
147
+ /**
148
+ * A missing token is a setup problem, not a permission problem — say so differently.
149
+ *
150
+ * Uses this plugin's own NOT_CONFIGURED_MESSAGE, which names `konductro-codex-setup`, so
151
+ * the sentence matches what every other tool here already says. The `setup` flag is what
152
+ * workItemCall branches on: the reference implementation matched the message prefix
153
+ * instead, and matching our own wording is the very habit this change removes elsewhere.
154
+ */
155
+ function assertAuthConfigured() {
156
+ if (!KONDUCTRO_URL || !CLI_TOKEN) {
157
+ const err = new Error(NOT_CONFIGURED_MESSAGE);
158
+ err.setup = true;
159
+ throw err;
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Name the field a validation failure is actually about.
165
+ *
166
+ * The backend answers INVALID_BODY with Zod's flatten() attached. Dropping it leaves the
167
+ * agent holding "Validation failed" with nothing to correct, which it can only respond to
168
+ * by guessing — so the whole point of validating is lost on the way back.
169
+ */
170
+ function validationText(err) {
171
+ const f = err.details?.fieldErrors ?? {};
172
+ const fields = Object.entries(f)
173
+ .map(([name, msgs]) => `${name} (${(msgs ?? []).join('; ')})`)
174
+ .join(', ');
175
+ const form = (err.details?.formErrors ?? []).join('; ');
176
+ const parts = [fields, form].filter(Boolean).join(' — ');
177
+ if (!parts) return err.message;
178
+ // The backend's sentence for this code is sometimes unpunctuated ('Validation failed'),
179
+ // so close it before appending rather than running the two together.
180
+ const lead = /[.!?]$/.test(err.message) ? err.message : `${err.message}.`;
181
+ return `${lead} Problem with: ${parts}.`;
182
+ }
183
+
184
+ /**
185
+ * Every work-item tool answers refusals the same way, so the cases read alike.
186
+ *
187
+ * ON isError. A REFUSAL is not an error — it is a correct, final answer to a question the
188
+ * developer was entitled to ask, and flagging it as an error is what makes an agent retry
189
+ * it or escalate around it. A genuine FAILURE (bad token, unreachable server, a 500, a
190
+ * shape the backend rejected) is an error, and is flagged, because the agent should stop
191
+ * and surface it rather than carry on as if the write landed.
192
+ *
193
+ * This is deliberately NOT "whatever the rest of the file does": most tools here flag
194
+ * nothing at all and report failures as ordinary prose, which is the weaker half of the
195
+ * convention. The two bug-enrichment tools already make the distinction this follows.
196
+ */
197
+ async function workItemCall(fn) {
198
+ try {
199
+ assertAuthConfigured();
200
+ return { content: [{ type: 'text', text: await fn() }] };
201
+ } catch (err) {
202
+ if (err.status === 401) {
203
+ return {
204
+ 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, then re-run `konductro-codex-setup --url <URL> --token <TOKEN>` or update KONDUCTRO_CLI_TOKEN. This is a setup problem, not a permissions one.' }],
205
+ isError: true,
206
+ };
207
+ }
208
+ const refusal = refusalText(err);
209
+ if (refusal) return { content: [{ type: 'text', text: refusal }] };
210
+
211
+ // Setup errors already read as full sentences; only wrap the ones that do not.
212
+ const text = err.setup
213
+ ? err.message
214
+ : `Failed: ${err.code === 'INVALID_BODY' ? validationText(err) : err.message}`;
215
+ return { content: [{ type: 'text', text }], isError: true };
216
+ }
217
+ }
218
+
219
+ /** Resolve the project from the repo's git remote, so no project id is ever asked for. */
220
+ async function projectFromRepo(repoUrl) {
221
+ const repo = await konductroFetch(`/api/cli/repo-by-url?url=${encodeURIComponent(repoUrl)}`);
222
+ return repo;
223
+ }
224
+
62
225
  const server = new McpServer({
63
226
  name: 'konductro',
64
227
  version: '1.0.0',
@@ -91,7 +254,7 @@ server.tool(
91
254
  }
92
255
 
93
256
  const taskList = tasks.map((t, i) =>
94
- `${i + 1}. **${t.projectName}** — ${t.phaseName}\n Client: ${t.clientName}\n Phase ID: ${t.phaseId}\n ${t.hasExistingDraft ? '(has existing draft)' : '(new analysis)'}`
257
+ `${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)'}`
95
258
  ).join('\n\n');
96
259
 
97
260
  return {
@@ -121,6 +284,25 @@ server.tool(
121
284
  if (context.phase.description) contextText += `**Description:** ${context.phase.description}\n`;
122
285
  contextText += `\n`;
123
286
 
287
+ // KON-320: a refresh was requested, so this is a revision of an approved
288
+ // analysis rather than a first pass. Sits above the repositories and the
289
+ // previous document deliberately — it changes what is being asked for, so
290
+ // it has to be read before the material it applies to. Absent on a normal
291
+ // task, in which case the output is exactly what it was before.
292
+ if (context.refreshContext) {
293
+ const { requestedBy, message } = context.refreshContext;
294
+ contextText += `### Refresh Requested\n\n`;
295
+ contextText += `A refresh of this technical analysis was requested`;
296
+ if (requestedBy) contextText += ` by ${requestedBy}`;
297
+ contextText += `.\n\n`;
298
+ if (message) {
299
+ contextText += `**Context from the requester:**\n\n${message}\n\n`;
300
+ } else {
301
+ contextText += `No further context was given.\n\n`;
302
+ }
303
+ contextText += `Revise the existing analysis below rather than starting over.\n\n`;
304
+ }
305
+
124
306
  if (context.repositories.length > 0) {
125
307
  contextText += `### Repositories\n\n`;
126
308
  for (const repo of context.repositories) {
@@ -147,6 +329,8 @@ server.tool(
147
329
  }
148
330
  }
149
331
 
332
+ contextText += renderDocumentTemplate(context.documentTemplate);
333
+
150
334
  return {
151
335
  content: [{
152
336
  type: 'text',
@@ -156,6 +340,51 @@ server.tool(
156
340
  }
157
341
  );
158
342
 
343
+ /**
344
+ * The document structure this workspace requires, as the agent must read it.
345
+ *
346
+ * APPENDED, never woven into the blob above. Four plugins share that server response and
347
+ * the agent's prompt is sensitive to its shape, so everything before this point is
348
+ * byte-identical to what it has always been. A workspace with no template gets an empty
349
+ * string here and therefore exactly today's context.
350
+ *
351
+ * THE WORDING IS IDENTICAL IN ALL FOUR PLUGINS, deliberately. The story this belongs to
352
+ * requires the same behaviour from Claude, Amazon Q, Codex and Cursor, and four separately
353
+ * worded prompts is precisely how that stops being true. Change it here and copy it, do
354
+ * not improve it in one place.
355
+ *
356
+ * Standing content is reproduced WORD FOR WORD rather than summarised. It is usually a
357
+ * compliance clause the workspace requires verbatim, which is the whole reason the field
358
+ * exists.
359
+ */
360
+ function renderDocumentTemplate(template) {
361
+ if (!template) return '';
362
+
363
+ let text = `### Required Document Structure\n\n`;
364
+ text += `This workspace requires technical analysis documents to follow **${template.name}** `;
365
+ text += `(v${template.version}). Produce these sections, in this order, using these exact headings.\n\n`;
366
+
367
+ for (const [index, section] of template.sections.entries()) {
368
+ text += `${index + 1}. **${section.title}**`;
369
+ if (section.intent) text += ` — ${section.intent}`;
370
+ if (section.mustCover) text += ` _(must cover: do not produce the document until you can answer this)_`;
371
+ text += `\n`;
372
+ if (section.diagram && section.diagram !== 'none') {
373
+ const kind = section.diagram === 'any' ? 'a Mermaid diagram of whichever type fits' : `a Mermaid ${section.diagram} diagram`;
374
+ text += ` Include ${kind} inside this section.\n`;
375
+ }
376
+ if (section.standingContent) {
377
+ text += ` Reproduce this text inside the section, word for word:\n`;
378
+ text += ` > ${section.standingContent.split('\n').join('\n > ')}\n`;
379
+ }
380
+ }
381
+
382
+ text += `\nThis structure replaces any default you would otherwise use. `;
383
+ text += `The sections marked "must cover" are what your exploration and your questions `;
384
+ text += `must be able to answer before you produce the document.\n\n`;
385
+ return text;
386
+ }
387
+
159
388
  // Tool: Submit tech analysis
160
389
  server.tool(
161
390
  'submit_tech_analysis',
@@ -180,6 +409,151 @@ server.tool(
180
409
  }
181
410
  );
182
411
 
412
+ // ══ DEMAND ANALYSIS ════════════════════════════════════════════════════════
413
+ //
414
+ // The demand-level counterpart of the three tools above. A DEMAND has no project yet —
415
+ // which projects it lands in is decided at IT Eval, from what this analysis finds — so
416
+ // the context carries the whole workspace's repositories and the submission reports
417
+ // which of them the change actually touches.
418
+ //
419
+ // All three go through workItemCall, like the KON-519 tools: it asserts the token is
420
+ // configured, turns a refusal into a sentence via refusalText, and keeps 401 separate
421
+ // because an expired token is a setup problem rather than a permission one. Written
422
+ // bare, a 403 from an analysis assigned to somebody else surfaced as an unhandled
423
+ // error rather than an answer.
424
+
425
+ /** A demand question and its answer, or a plain note that it was left blank. */
426
+ function answerLine(q) {
427
+ const answer = q.answer && String(q.answer).trim() ? q.answer : '_Not answered._';
428
+ return [`**${q.question}**`, q.help ? `_${q.help}_` : null, '', answer].filter((l) => l !== null).join('\n');
429
+ }
430
+
431
+ // Tool: List pending demand analyses
432
+ server.tool(
433
+ 'list_demand_analyses',
434
+ '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.',
435
+ {},
436
+ async () => workItemCall(async () => {
437
+ const { tasks } = await konductroFetch('/api/cli/demand-analyses');
438
+
439
+ if (!tasks || tasks.length === 0) {
440
+ return 'No demand analyses assigned to you.';
441
+ }
442
+
443
+ const lines = tasks.map((t) => {
444
+ const parts = [`### ${t.key} — ${t.title}`];
445
+ if (t.businessUnit) parts.push(`**Business unit:** ${t.businessUnit}`);
446
+ if (t.nextSitting) parts.push(`**Back at the forum:** ${new Date(t.nextSitting).toISOString().slice(0, 10)}`);
447
+ if (t.startWith && t.startWith.length) parts.push(`**Start with:** ${t.startWith.join(', ')}`);
448
+ if (t.askedFor) parts.push(`**They asked:** ${t.askedFor}`);
449
+ parts.push(`\`get_demand_analysis_context\` with demandId ${t.key} to load it.`);
450
+ return parts.join('\n');
451
+ });
452
+
453
+ return `## Demand analyses assigned to you (${tasks.length})\n\n${lines.join('\n\n')}`;
454
+ })
455
+ );
456
+
457
+ // Tool: Load one demand's analysis context
458
+ server.tool(
459
+ 'get_demand_analysis_context',
460
+ "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.",
461
+ {
462
+ demandId: z.string().describe('The demand key (e.g. DEM-4) or its UUID, from list_demand_analyses'),
463
+ },
464
+ async ({ demandId }) => workItemCall(async () => {
465
+ const ctx = await konductroFetch(`/api/cli/demand-analyses/${demandId}/context`);
466
+ const d = ctx && ctx.demand;
467
+ if (!d) {
468
+ return `No demand context came back for ${demandId}. Check the key, and that the analysis is assigned to you.`;
469
+ }
470
+
471
+ const repos = (ctx.repositories || [])
472
+ .map((r) => `- \`${r.name}\` (${r.projectName}${r.type ? `, ${r.type}` : ''}) — ${r.url}\n projectId: \`${r.projectId}\``)
473
+ .join('\n') || '- None linked to any project yet';
474
+
475
+ const conversation = (ctx.conversation || [])
476
+ .map((c) => `- **${c.by}**${c.kind === 'amendment' ? ' (amendment)' : ''}: ${c.body}`)
477
+ .join('\n');
478
+
479
+ // THE PITCH AS THE WORKSPACE ACTUALLY ASKED IT.
480
+ //
481
+ // This renders ctx.template, not the demand's own columns. Every workspace writes
482
+ // its own pitch template — questions it added, questions it deleted, its own
483
+ // wording — and the demand is answered against the version it was RAISED on. The
484
+ // backend maps the nine shipped answers into that same template (KON-604), so this
485
+ // one shape carries both, in the order the requester saw.
486
+ //
487
+ // Reading the columns instead would have dropped every question the workspace added
488
+ // — "Which regulator requires this?" would be invisible to the analysis — which is
489
+ // the whole point of the templating feature. The backend had exactly this bug and it
490
+ // was caught in review; the same mistake is available here.
491
+ const pitch = ctx.template
492
+ ? [
493
+ `_Answered against **${ctx.template.name}** v${ctx.template.version}._`,
494
+ ...(ctx.template.sections || []).map((section) => [
495
+ `## ${section.name}`,
496
+ section.help ? `_${section.help}_` : null,
497
+ '',
498
+ (section.questions || []).map(answerLine).join('\n\n'),
499
+ ].filter((l) => l !== null).join('\n')),
500
+ ].join('\n\n')
501
+ // A demand raised before templates existed has none pinned. Fall back to the
502
+ // columns rather than showing the analyst nothing.
503
+ : [
504
+ '## What they need', d.need || 'Not given',
505
+ '', '## What happens today', d.currentState || 'Not given',
506
+ '', '## Who it affects', [d.affects, d.affectsWho].filter(Boolean).join(' — ') || 'Not given',
507
+ '', '## How they would know it worked', d.successLooksLike || 'Not given',
508
+ ].join('\n');
509
+
510
+ return [
511
+ `# ${d.key} — ${d.title}`,
512
+ '',
513
+ `**Raised by:** ${d.raisedBy}${d.businessUnit ? ` (${d.businessUnit})` : ''}`,
514
+ '',
515
+ pitch,
516
+ '',
517
+ '## What the forum asked you to answer',
518
+ ctx.askedFor || 'Nothing specific. Answer the pitch.',
519
+ '',
520
+ '## Where to start looking',
521
+ (ctx.startWith && ctx.startWith.length) ? ctx.startWith.map((r) => `\`${r}\``).join(', ') : 'Nothing named — use your judgement.',
522
+ '',
523
+ '## Every repository in this workspace',
524
+ 'The starting point above is a hint, not a boundary. Report what the change ACTUALLY touches.',
525
+ '',
526
+ repos,
527
+ conversation ? `\n## Conversation on the demand\n${conversation}` : '',
528
+ ].join('\n');
529
+ })
530
+ );
531
+
532
+ // Tool: Submit a demand analysis
533
+ server.tool(
534
+ 'submit_demand_analysis',
535
+ '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.',
536
+ {
537
+ demandId: z.string().describe('The demand key (e.g. DEM-4) or its UUID'),
538
+ 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.'),
539
+ foundRepos: z.array(z.string()).optional().describe('The repositories the change actually touches, by name. Not the ones you were told to start with.'),
540
+ proposedPhases: z.array(z.object({
541
+ name: z.string().describe('What this phase delivers'),
542
+ projectId: z.string().uuid().optional().describe('The project it lands in, from the context. Omit if it genuinely belongs nowhere yet.'),
543
+ points: z.number().int().min(0).max(1000).describe('Story points for this phase alone. Never send a total; Konductro derives it.'),
544
+ why: z.string().optional().describe('Why it is its own phase rather than part of another'),
545
+ })).optional().describe('The phases you propose. A phase belongs to ONE project; work spanning two projects is two phases.'),
546
+ },
547
+ async ({ demandId, summary, foundRepos, proposedPhases }) => workItemCall(async () => {
548
+ const result = await konductroFetch(`/api/cli/demand-analyses/${demandId}/submit`, {
549
+ method: 'POST',
550
+ body: JSON.stringify({ summary, foundRepos, proposedPhases }),
551
+ });
552
+
553
+ 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.`;
554
+ })
555
+ );
556
+
183
557
  // Tool: List pending decomposition tasks
184
558
  server.tool(
185
559
  'list_decomposition_tasks',
@@ -505,6 +879,12 @@ server.tool(
505
879
  text += `### Context Pack\n\n${ctx.ticket.contextPack}\n\n`;
506
880
  }
507
881
 
882
+ // Developer Notes — present when context is fetched on a story itself. For a
883
+ // task, the notes that matter are the parent story's, rendered below.
884
+ if (ctx.ticket.developerNotes) {
885
+ text += `### Developer Notes\n\n${ctx.ticket.developerNotes}\n\n`;
886
+ }
887
+
508
888
  // Parent Story
509
889
  if (ctx.parent) {
510
890
  text += `### Parent Story: ${ctx.parent.ticketKey} — ${ctx.parent.title}\n\n`;
@@ -517,6 +897,10 @@ server.tool(
517
897
  if (ctx.parent.contextPack) {
518
898
  text += `**Story Context Pack:**\n${ctx.parent.contextPack}\n\n`;
519
899
  }
900
+ // Story-level context accumulated by whoever worked the story's other tasks.
901
+ if (ctx.parent.developerNotes) {
902
+ text += `**Parent Story, Developer Notes:**\n${ctx.parent.developerNotes}\n\n`;
903
+ }
520
904
  }
521
905
 
522
906
  // Children tasks
@@ -562,6 +946,153 @@ server.tool(
562
946
  }
563
947
  );
564
948
 
949
+ // Tool: Append a developer note to a story (KON-313)
950
+ server.tool(
951
+ 'append_story_developer_note',
952
+ "Append a note to a story's developer notes in Konductro, so context you worked out on one task is there for whoever picks up the next task on the same story. Notes live on the STORY, not the task: pass the parent story's key, which get_ticket_context prints in its Parent Story heading. Pass the current task's key as taskKey so the entry is attributable. Send only your new note — the endpoint appends it, and Konductro stamps the author, timestamp and task itself, so do not include a heading, a timestamp, a separator, or any notes you read earlier.",
953
+ {
954
+ storyId: z.string().describe('The story to append to — key (e.g. KON-283) or UUID. Not a task.'),
955
+ note: z.string().describe('The new note only, as markdown. No heading, timestamp or separator.'),
956
+ taskKey: z.string().optional().describe("The key of the task this note came from (e.g. KON-313), when there is one"),
957
+ },
958
+ async ({ storyId, note, taskKey }) => {
959
+ const result = await konductroFetch(`/api/cli/tickets/${storyId}/developer-notes`, {
960
+ method: 'POST',
961
+ body: JSON.stringify({ note, taskKey }),
962
+ });
963
+
964
+ // Not echoing result.developerNotes: it is the whole accumulated blob, and
965
+ // repeating it here invites a later call to send it back as a "new" note.
966
+ return {
967
+ content: [{
968
+ type: 'text',
969
+ text: `Note appended to ${result.ticketKey}'s developer notes.`,
970
+ }],
971
+ };
972
+ }
973
+ );
974
+
975
+ // Tool: Create a work item
976
+ server.tool(
977
+ 'create_work_item',
978
+ "Create a story, task or bug in the Konductro project this repository belongs to. Anything created this way lands in DRAFT and still needs an SDM's approval before it can be worked — say so when you report back, so nobody thinks it is ready to start. A task needs a parent story, and is created in the repository repoUrl resolves to; a bug needs no parent and is filed standalone. Creating STORIES is governed by the project's story access setting and may be refused; filing bugs and creating tasks are not affected by it. Pass the repository's git remote (git remote get-url origin) — the project is resolved from it, never asked for.",
979
+ {
980
+ repoUrl: z.string().describe('The git remote URL of this repository (run: git remote get-url origin)'),
981
+ kind: z.enum(['story', 'task', 'bug']).describe('What to create'),
982
+ title: z.string().describe('A short title, as a person would write it'),
983
+ description: z.string().describe('What this is and why, in markdown'),
984
+ acceptanceCriteria: z.array(z.string()).optional().describe('Observable behaviour, one per item. Omit for a bug unless you have them.'),
985
+ parentKey: z.string().optional().describe('For a TASK, the parent story key (e.g. KON-451). ONLY a task may have a parent. A story or a bug sent with a parentKey is REFUSED and nothing is created, rather than being filed top-level as though it had worked.'),
986
+ repositoryId: z.string().optional().describe('For a TASK, the repository UUID it will be built in. Leave this out — it defaults to the repository repoUrl resolves to, which is the one you are standing in. Only set it for a task that will be built in a DIFFERENT repository on the same project, and then you need that repo\'s UUID from Konductro.'),
987
+ },
988
+ async ({ repoUrl, kind, title, description, acceptanceCriteria, parentKey, repositoryId }) => workItemCall(async () => {
989
+ // The backend's body schema DECLARES parentKey, so .strict() does not reject it — it
990
+ // is accepted and then dropped for anything that is not a task, because the route
991
+ // reads it only inside the task branch and calls createBug / createStory without it
992
+ // (routes/cli.ts). The item lands top-level and the 201 reports success, so asking for
993
+ // it under a story and being told it worked is exactly what happens. Refuse instead: a
994
+ // refusal is recoverable in the next turn, a misfiled item is found later by someone
995
+ // else, if at all.
996
+ //
997
+ // The two cases are dropped by the same code path but for different reasons, so the
998
+ // remedy differs and the message branches. A bug COULD have a parent — QA files bugs
999
+ // against the tested story that way — this endpoint just does not wire it through. A
1000
+ // story could not: the hierarchy is story → task, so nothing sits above a story ever,
1001
+ // and an agent sending one almost certainly meant to create a task.
1002
+ if (kind !== 'task' && parentKey) {
1003
+ const why = kind === 'bug'
1004
+ ? `Konductro only parents a bug to a story when QA files it against a failed test criterion; a bug created from the CLI is always standalone in the project's Bugs phase. Re-run without parentKey, and name ${parentKey} in the description so the link to it is not lost.`
1005
+ : `A story is top-level by definition — the hierarchy is story → task, so nothing sits above a story. If you meant to add work under ${parentKey}, re-run with kind "task". If you meant a new story, re-run without parentKey.`;
1006
+ return `Refused: only a task can be created under a parent, and NOTHING WAS CREATED. ${why}`;
1007
+ }
1008
+
1009
+ const repo = await projectFromRepo(repoUrl);
1010
+
1011
+ // Creating a task would otherwise be a dead end. The backend requires repositoryId as
1012
+ // a UUID, and nothing a developer can reach hands one out — get_decomposition_context
1013
+ // is the only tool that returns one, and that needs an assigned decomposition task you
1014
+ // do not have. So the agent was asked for a value it could not obtain, and a guess
1015
+ // came back as a bare "Validation failed".
1016
+ //
1017
+ // It was in hand the whole time: repo-by-url returns the repository row (id, name,
1018
+ // repoUrl, repoType, stacks, projectId, project) and the id was being discarded.
1019
+ // Defaulting to it is also the right answer rather than merely an available one — the
1020
+ // task is being written from inside the repo it will be built in.
1021
+ //
1022
+ // Tasks only. createStory ignores it, and defaulting it on a bug would silently start
1023
+ // attributing bugs to a repository they were not attributed to before.
1024
+ const resolvedRepositoryId = kind === 'task' ? (repositoryId ?? repo.id) : repositoryId;
1025
+
1026
+ const created = await konductroFetch(`/api/cli/projects/${repo.projectId}/work-items`, {
1027
+ method: 'POST',
1028
+ body: JSON.stringify({ kind, title, description, acceptanceCriteria, parentKey, repositoryId: resolvedRepositoryId }),
1029
+ });
1030
+ // Report the id, not just the number. A key is PREFIX-NUMBER, the prefix is nowhere in
1031
+ // this tool's reach (repo-by-url does not return ticketPrefix), so printing the number
1032
+ // alone invites the agent to guess one. resolveTicketId matches prefix+number across
1033
+ // the whole TENANT, not within the project, so a guessed prefix does not 404 — it
1034
+ // resolves to another project's ticket of the same number, and the next
1035
+ // update_work_item edits that one instead. The id closes it off: the UUID branch of
1036
+ // resolveTicketId short-circuits with no lookup at all, so it can only be this row.
1037
+ return `Created #${created.ticketNumber} — "${created.title}" (${created.kind}) in ${repo.project?.name ?? 'the project'}.\n\nid: ${created.id}\n\nIt is in ${created.status.toUpperCase()} and needs an SDM to approve it before it can be worked on. Use THAT id with get_ticket_context, update_work_item or delete_work_item. Do not build a key from #${created.ticketNumber} — the project's ticket prefix is not returned here, and a guessed prefix silently resolves to a different project's item of the same number rather than failing.`;
1038
+ })
1039
+ );
1040
+
1041
+ // Tool: Update a work item
1042
+ server.tool(
1043
+ 'update_work_item',
1044
+ "Change the title, description or acceptance criteria of a work item you own in Konductro — one assigned to you, that you are the developer on, or that you created. THESE THREE FIELDS ARE ALL YOU CAN CHANGE: status, sprint, assignee and everything else are deliberately not available here and must be changed in Konductro. Editing a STORY is governed by the project's story access setting and may be refused, or may be applied and then held for an SDM to review; editing a task is not affected by it. Send only the fields you are actually changing.",
1045
+ {
1046
+ key: z.string().describe('The work item key (e.g. KON-451) or UUID'),
1047
+ title: z.string().optional().describe('The new title'),
1048
+ description: z.string().optional().describe('The new description, in markdown'),
1049
+ acceptanceCriteria: z.array(z.string()).optional().describe('The FULL new list, not just the additions — it replaces what is there'),
1050
+ },
1051
+ async ({ key, title, description, acceptanceCriteria }) => workItemCall(async () => {
1052
+ const body = {};
1053
+ if (title !== undefined) body.title = title;
1054
+ if (description !== undefined) body.description = description;
1055
+ if (acceptanceCriteria !== undefined) body.acceptanceCriteria = acceptanceCriteria;
1056
+ if (Object.keys(body).length === 0) {
1057
+ return 'Nothing to change — pass at least one of title, description or acceptanceCriteria.';
1058
+ }
1059
+
1060
+ const result = await konductroFetch(`/api/cli/tickets/${encodeURIComponent(key)}/work-item`, {
1061
+ method: 'PATCH',
1062
+ body: JSON.stringify(body),
1063
+ });
1064
+
1065
+ // Deliberately NOT echoing the updated values back. Returning the item invites the
1066
+ // next call to send them again as "new" values, re-submitting fields nobody changed
1067
+ // and raising a review for a no-op. Same reason append_story_developer_note does not
1068
+ // return the notes blob.
1069
+ // `changed` echoes the fields that were WRITTEN, not the ones that turned out to
1070
+ // differ — the server returns Object.keys of what it applied (routes/cli.ts). So
1071
+ // re-sending a title with its existing value still reports "changed: title". Do not
1072
+ // read it as a diff.
1073
+ const changed = (result.changed ?? Object.keys(body)).join(', ');
1074
+ let text = `Updated ${key} (#${result.ticketNumber}) — changed: ${changed}.`;
1075
+ if (result.awaitingReview) {
1076
+ text += '\n\nThis change is APPLIED but now waiting for an SDM to approve or reject it, because this project reviews story changes. Until it is resolved the story will not move to Ready for QA, even if every task is done. If it is rejected the previous values come back and you will be notified.';
1077
+ }
1078
+ return text;
1079
+ })
1080
+ );
1081
+
1082
+ // Tool: Delete a work item
1083
+ server.tool(
1084
+ 'delete_work_item',
1085
+ "Delete a task or a bug from Konductro that has not been started. Bugs count: Konductro stores a bug as a task, so a developer's own unstarted bug can be deleted here. Stories cannot — deleting one takes its tasks with it and there is no restore, so archive a story in Konductro instead. Neither can a bug QA filed against a failed test criterion, which is part of that test record rather than yours. Nothing that has started can be deleted by anyone: that means anything carrying a branch, or anything past sprint planning, since only draft, approved and in_sprint items still qualify. Close those out in Konductro instead. Beyond that you may delete an item you are assigned to, are the developer on, or created; an SDM, architect or UX lead on the project may delete any item that qualifies. This is permanent and there is no undo, so be sure the developer asked for it.",
1086
+ {
1087
+ key: z.string().describe('The task or bug key (e.g. KON-452) or UUID'),
1088
+ },
1089
+ async ({ key }) => workItemCall(async () => {
1090
+ const result = await konductroFetch(`/api/cli/tickets/${encodeURIComponent(key)}/work-item`, { method: 'DELETE' });
1091
+ const extra = result.deleted > 1 ? ` (${result.deleted} rows, including its linked records)` : '';
1092
+ return `Deleted ${key}${extra}. This cannot be undone.`;
1093
+ })
1094
+ );
1095
+
565
1096
  // Tool: Start work on a ticket
566
1097
  server.tool(
567
1098
  'start_work',
@@ -958,7 +1489,13 @@ server.tool(
958
1489
 
959
1490
  return { content: [{ type: 'text', text }] };
960
1491
  } catch (err) {
961
- const msg = err.message?.includes('BUG_NOT_FOUND') || err.message?.includes('404')
1492
+ // KON-519: these used to sniff err.message for 'BUG_NOT_FOUND' / '404', which
1493
+ // worked only because the message was the whole raw envelope. konductroFetch now
1494
+ // sets message to the backend's `error` sentence, so that match silently stopped
1495
+ // firing and a missing bug reported as a generic failure. Read the code and the
1496
+ // status instead — both are on the error and neither depends on wording.
1497
+ const notABug = err.code === 'BUG_NOT_FOUND' || err.status === 404;
1498
+ const msg = notABug
962
1499
  ? `Ticket ${ticketId} not found or is not a bug.`
963
1500
  : `Failed to load bug context: ${err.message}`;
964
1501
  return { content: [{ type: 'text', text: msg }], isError: true };
@@ -994,9 +1531,11 @@ server.tool(
994
1531
  : 'No new enrichment applied (fields may already exist on the ticket).';
995
1532
  return { content: [{ type: 'text', text: applied }] };
996
1533
  } catch (err) {
997
- const msg = err.message?.includes('BUG_NOT_FOUND') || err.message?.includes('404')
1534
+ // Same fix as get_bug_for_enrichment above — match on err.code / err.status, not
1535
+ // on message text, which konductroFetch no longer formats the way this expected.
1536
+ const msg = (err.code === 'BUG_NOT_FOUND' || err.status === 404)
998
1537
  ? `Ticket ${ticketId} not found or is not a bug.`
999
- : err.message?.includes('INVALID_ENRICHMENT')
1538
+ : err.code === 'INVALID_ENRICHMENT'
1000
1539
  ? 'At least one enrichment field must be provided.'
1001
1540
  : `Failed to submit enrichment: ${err.message}`;
1002
1541
  return { content: [{ type: 'text', text: msg }], isError: true };
@@ -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