@vypdev/copilot 3.10.4 → 3.10.5

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.
@@ -61163,7 +61163,7 @@ async function draftSddMarkdown(agent, configuration, plan, prompt, validate) {
61163
61163
  try {
61164
61164
  value = await agent.query({
61165
61165
  configuration, agentId: 'pre-branch-sdd-draft',
61166
- prompt: `${attempt === 0 ? contractPrompt : `${contractPrompt}\n\n${problem === 'size' ? `The previous response exceeded the ${maximum}-character draft limit.` : `The previous response failed the required SDD ${formatReason} contract.`} Regenerate a concise complete draft for this same owner and plan. Use the exact numbered canonical headings from the supplied template. Preserve all resolved requirements, architecture, documentation and acceptance. Do not change ownership or truncate a requirement.`}\n\n${sdd_draft_consistency_1.SDD_CONSISTENCY_PROMPT}`,
61166
+ prompt: `${attempt === 0 ? contractPrompt : `${contractPrompt}\n\n${problem === 'size' ? `The previous response exceeded the ${maximum}-character draft limit.` : `The previous response failed the required SDD ${formatReason} contract.`} Regenerate a concise complete draft for this same owner and plan. Use the exact numbered canonical headings from the supplied template. Preserve all resolved requirements, architecture, documentation and acceptance. Do not change ownership or truncate a requirement.`}\n\n${sdd_draft_consistency_1.SDD_CONSISTENCY_PROMPT}\n\n${sdd_draft_consistency_1.SDD_DERIVED_TABLES_PROMPT}`,
61167
61167
  options: { expectJson: true, schemaName: 'pre_branch_sdd_draft', schema },
61168
61168
  });
61169
61169
  }
@@ -61185,8 +61185,13 @@ async function draftSddMarkdown(agent, configuration, plan, prompt, validate) {
61185
61185
  continue;
61186
61186
  }
61187
61187
  try {
61188
- await validate?.(markdown);
61189
- return markdown;
61188
+ const assembled = (0, sdd_draft_consistency_1.renderSddDerivedTables)(markdown);
61189
+ if (assembled.length > maximum) {
61190
+ problem = 'size';
61191
+ continue;
61192
+ }
61193
+ await validate?.(assembled);
61194
+ return assembled;
61190
61195
  }
61191
61196
  catch (error) {
61192
61197
  if (!(error instanceof pre_branch_sdd_1.SddDraftFormatFailure))
@@ -93609,7 +93614,8 @@ function replyRequestBodyDigest(body) {
93609
93614
  "use strict";
93610
93615
 
93611
93616
  Object.defineProperty(exports, "__esModule", ({ value: true }));
93612
- exports.SDD_CONSISTENCY_PROMPT = void 0;
93617
+ exports.SDD_DERIVED_TABLES_PROMPT = exports.SDD_CONSISTENCY_PROMPT = void 0;
93618
+ exports.renderSddDerivedTables = renderSddDerivedTables;
93613
93619
  exports.reservedSddCaseIds = reservedSddCaseIds;
93614
93620
  exports.validateSddDraftConsistency = validateSddDraftConsistency;
93615
93621
  const pre_branch_sdd_1 = __nccwpck_require__(34730);
@@ -93624,6 +93630,10 @@ Also in section 14 include one inventory table: Case ID | Area | Requirements |
93624
93630
  Each row is one distinct executable case with a fully qualified ID such as capability-change-C01, one exact budget area, comma-separated requirement IDs and an observable scenario. Never use shorthand C01, ranges or redefine an ID found in any owning SDD. Reference retained baseline cases in prose using their full IDs; count only the new inventory.
93625
93631
  In section 17 include one table: Requirement | Cases. List comma-separated full case IDs for every requirement. Its links must exactly match the case inventory in both directions, with no undefined or generic documentation checks.
93626
93632
  In section 15 include one table: Path | Change. Change is update, reference or create. Include the selected SDD path itself with update for an existing SDD or create for a new/companion SDD. Use existing immutable-base files for update/reference. Only explicitly proposed new files may use create; never mark a missing current document as an existing artifact. Cite repository files as full repository-relative paths in backticks, or relative Markdown file links. Put every planned new file in this table. These tables are publication consistency checks, not runtime/security acceptance.`;
93633
+ const BUDGET_SLOT = '{{SDD_CASE_BUDGET}}';
93634
+ const TRACEABILITY_SLOT = '{{SDD_REQUIREMENT_CASES}}';
93635
+ /** The provider writes definitions once; trusted code renders their two redundant projections. */
93636
+ exports.SDD_DERIVED_TABLES_PROMPT = `Draft assembly: the consistency contract above describes the final document. In your raw Markdown, write the complete Requirement | Behavior table in section 4 and Case ID | Area | Requirements | Scenario inventory in section 14. Preserve every resolved minimum, per-area allocation and observable case as actual inventory rows, never ranges or summaries. Instead of independently writing the budget table, put ${BUDGET_SLOT} once on its own visible line in section 14. Instead of writing the reverse Requirement | Cases table, put ${TRACEABILITY_SLOT} once on its own visible line in section 17. Do not include either derived table yourself or put these slots in examples, fences or comments. Trusted code derives exact counts, Total and reciprocal links from your unchanged definitions, then runs every publication check. The compact character target is advisory: use more space when required to preserve the full resolved inventory and scope. The hard limit applies after assembly too.`;
93627
93637
  function fail(reason) {
93628
93638
  // Closed diagnostics: rejected Markdown and repository text never become repair instructions.
93629
93639
  throw new pre_branch_sdd_1.SddDraftFormatFailure(reason, `The SDD draft violates its ${reason} consistency contract.`);
@@ -93661,14 +93671,17 @@ function visible(source) {
93661
93671
  }).join('\n');
93662
93672
  }
93663
93673
  function clean(value) { return value.trim().replace(/^(?:\*\*|__|`)(.*?)(?:\*\*|__|`)$/u, '$1').trim(); }
93664
- function table(source, section, headers, reason) {
93674
+ function section(source, number, reason) {
93665
93675
  const sections = [...source.matchAll(/^## (\d+)\. [^\n]*$/gmu)];
93666
- const matches = sections.filter(heading => Number(heading[1]) === section);
93676
+ const matches = sections.filter(heading => Number(heading[1]) === number);
93667
93677
  if (matches.length !== 1)
93668
93678
  return fail(reason);
93669
93679
  const start = matches[0];
93670
93680
  const end = sections.find(heading => heading.index > start.index)?.index ?? source.length;
93671
- const lines = source.slice(start.index + start[0].length, end).split('\n');
93681
+ return source.slice(start.index + start[0].length, end);
93682
+ }
93683
+ function table(source, number, headers, reason) {
93684
+ const lines = section(source, number, reason).split('\n');
93672
93685
  const found = [];
93673
93686
  for (let index = 0; index < lines.length; index++) {
93674
93687
  if (!/^\s*\|/u.test(lines[index]))
@@ -93699,6 +93712,47 @@ function ids(value, pattern, reason) {
93699
93712
  return fail(reason);
93700
93713
  return values;
93701
93714
  }
93715
+ /** Never repairs definitions or contradictory supplied tables; the writer independently revalidates. */
93716
+ function renderSddDerivedTables(markdown) {
93717
+ if (!markdown.includes(BUDGET_SLOT) && !markdown.includes(TRACEABILITY_SLOT))
93718
+ return markdown;
93719
+ const source = visible(markdown);
93720
+ for (const [slot, number, reason] of [
93721
+ [BUDGET_SLOT, 14, 'case-budget'], [TRACEABILITY_SLOT, 17, 'requirement-mapping'],
93722
+ ]) {
93723
+ if (markdown.split(slot).length !== 2
93724
+ || section(source, number, reason).split('\n').filter(line => line.trim() === slot).length !== 1)
93725
+ fail(reason);
93726
+ }
93727
+ const requirements = table(source, 4, ['Requirement', 'Behavior'], 'requirement-mapping').map(row => row[0]);
93728
+ if (new Set(requirements).size !== requirements.length || requirements.some(id => !REQUIREMENT_ID.test(id)))
93729
+ fail('requirement-mapping');
93730
+ const cases = table(source, 14, ['Case ID', 'Area', 'Requirements', 'Scenario'], 'case-identity');
93731
+ const caseIds = cases.map(row => row[0]);
93732
+ if (new Set(caseIds).size !== caseIds.length || caseIds.some(id => !CASE_ID.test(id)))
93733
+ fail('case-identity');
93734
+ const counts = new Map();
93735
+ const edges = new Map(requirements.map(id => [id, []]));
93736
+ for (const [id, area, links] of cases) {
93737
+ if (area === 'Total')
93738
+ fail('case-budget');
93739
+ counts.set(area, (counts.get(area) ?? 0) + 1);
93740
+ for (const requirement of ids(links, REQUIREMENT_ID, 'requirement-mapping')) {
93741
+ const linked = edges.get(requirement);
93742
+ if (!linked)
93743
+ fail('requirement-mapping');
93744
+ linked.push(id);
93745
+ }
93746
+ }
93747
+ if ([...edges.values()].some(links => links.length === 0))
93748
+ fail('requirement-mapping');
93749
+ const budget = ['| Area | Minimum distinct cases | Behaviors/risks covered |', '|---|---:|---|',
93750
+ ...[...counts].map(([area, count]) => `| ${area} | ${count} | Observable scenarios in the case inventory. |`),
93751
+ `| Total | ${cases.length} | Distinct inventory cases; repeated executions do not add cases. |`].join('\n');
93752
+ const traceability = ['| Requirement | Cases |', '|---|---|',
93753
+ ...[...edges].map(([requirement, links]) => `| ${requirement} | ${links.join(', ')} |`)].join('\n');
93754
+ return markdown.replace(BUDGET_SLOT, () => budget).replace(TRACEABILITY_SLOT, () => traceability);
93755
+ }
93702
93756
  function reservedSddCaseIds(documents) {
93703
93757
  const reserved = new Set();
93704
93758
  for (const document of documents) {
@@ -59163,7 +59163,7 @@ async function draftSddMarkdown(agent, configuration, plan, prompt, validate) {
59163
59163
  try {
59164
59164
  value = await agent.query({
59165
59165
  configuration, agentId: 'pre-branch-sdd-draft',
59166
- prompt: `${attempt === 0 ? contractPrompt : `${contractPrompt}\n\n${problem === 'size' ? `The previous response exceeded the ${maximum}-character draft limit.` : `The previous response failed the required SDD ${formatReason} contract.`} Regenerate a concise complete draft for this same owner and plan. Use the exact numbered canonical headings from the supplied template. Preserve all resolved requirements, architecture, documentation and acceptance. Do not change ownership or truncate a requirement.`}\n\n${sdd_draft_consistency_1.SDD_CONSISTENCY_PROMPT}`,
59166
+ prompt: `${attempt === 0 ? contractPrompt : `${contractPrompt}\n\n${problem === 'size' ? `The previous response exceeded the ${maximum}-character draft limit.` : `The previous response failed the required SDD ${formatReason} contract.`} Regenerate a concise complete draft for this same owner and plan. Use the exact numbered canonical headings from the supplied template. Preserve all resolved requirements, architecture, documentation and acceptance. Do not change ownership or truncate a requirement.`}\n\n${sdd_draft_consistency_1.SDD_CONSISTENCY_PROMPT}\n\n${sdd_draft_consistency_1.SDD_DERIVED_TABLES_PROMPT}`,
59167
59167
  options: { expectJson: true, schemaName: 'pre_branch_sdd_draft', schema },
59168
59168
  });
59169
59169
  }
@@ -59185,8 +59185,13 @@ async function draftSddMarkdown(agent, configuration, plan, prompt, validate) {
59185
59185
  continue;
59186
59186
  }
59187
59187
  try {
59188
- await validate?.(markdown);
59189
- return markdown;
59188
+ const assembled = (0, sdd_draft_consistency_1.renderSddDerivedTables)(markdown);
59189
+ if (assembled.length > maximum) {
59190
+ problem = 'size';
59191
+ continue;
59192
+ }
59193
+ await validate?.(assembled);
59194
+ return assembled;
59190
59195
  }
59191
59196
  catch (error) {
59192
59197
  if (!(error instanceof pre_branch_sdd_1.SddDraftFormatFailure))
@@ -84053,7 +84058,8 @@ function replyRequestBodyDigest(body) {
84053
84058
  "use strict";
84054
84059
 
84055
84060
  Object.defineProperty(exports, "__esModule", ({ value: true }));
84056
- exports.SDD_CONSISTENCY_PROMPT = void 0;
84061
+ exports.SDD_DERIVED_TABLES_PROMPT = exports.SDD_CONSISTENCY_PROMPT = void 0;
84062
+ exports.renderSddDerivedTables = renderSddDerivedTables;
84057
84063
  exports.reservedSddCaseIds = reservedSddCaseIds;
84058
84064
  exports.validateSddDraftConsistency = validateSddDraftConsistency;
84059
84065
  const pre_branch_sdd_1 = __nccwpck_require__(34730);
@@ -84068,6 +84074,10 @@ Also in section 14 include one inventory table: Case ID | Area | Requirements |
84068
84074
  Each row is one distinct executable case with a fully qualified ID such as capability-change-C01, one exact budget area, comma-separated requirement IDs and an observable scenario. Never use shorthand C01, ranges or redefine an ID found in any owning SDD. Reference retained baseline cases in prose using their full IDs; count only the new inventory.
84069
84075
  In section 17 include one table: Requirement | Cases. List comma-separated full case IDs for every requirement. Its links must exactly match the case inventory in both directions, with no undefined or generic documentation checks.
84070
84076
  In section 15 include one table: Path | Change. Change is update, reference or create. Include the selected SDD path itself with update for an existing SDD or create for a new/companion SDD. Use existing immutable-base files for update/reference. Only explicitly proposed new files may use create; never mark a missing current document as an existing artifact. Cite repository files as full repository-relative paths in backticks, or relative Markdown file links. Put every planned new file in this table. These tables are publication consistency checks, not runtime/security acceptance.`;
84077
+ const BUDGET_SLOT = '{{SDD_CASE_BUDGET}}';
84078
+ const TRACEABILITY_SLOT = '{{SDD_REQUIREMENT_CASES}}';
84079
+ /** The provider writes definitions once; trusted code renders their two redundant projections. */
84080
+ exports.SDD_DERIVED_TABLES_PROMPT = `Draft assembly: the consistency contract above describes the final document. In your raw Markdown, write the complete Requirement | Behavior table in section 4 and Case ID | Area | Requirements | Scenario inventory in section 14. Preserve every resolved minimum, per-area allocation and observable case as actual inventory rows, never ranges or summaries. Instead of independently writing the budget table, put ${BUDGET_SLOT} once on its own visible line in section 14. Instead of writing the reverse Requirement | Cases table, put ${TRACEABILITY_SLOT} once on its own visible line in section 17. Do not include either derived table yourself or put these slots in examples, fences or comments. Trusted code derives exact counts, Total and reciprocal links from your unchanged definitions, then runs every publication check. The compact character target is advisory: use more space when required to preserve the full resolved inventory and scope. The hard limit applies after assembly too.`;
84071
84081
  function fail(reason) {
84072
84082
  // Closed diagnostics: rejected Markdown and repository text never become repair instructions.
84073
84083
  throw new pre_branch_sdd_1.SddDraftFormatFailure(reason, `The SDD draft violates its ${reason} consistency contract.`);
@@ -84105,14 +84115,17 @@ function visible(source) {
84105
84115
  }).join('\n');
84106
84116
  }
84107
84117
  function clean(value) { return value.trim().replace(/^(?:\*\*|__|`)(.*?)(?:\*\*|__|`)$/u, '$1').trim(); }
84108
- function table(source, section, headers, reason) {
84118
+ function section(source, number, reason) {
84109
84119
  const sections = [...source.matchAll(/^## (\d+)\. [^\n]*$/gmu)];
84110
- const matches = sections.filter(heading => Number(heading[1]) === section);
84120
+ const matches = sections.filter(heading => Number(heading[1]) === number);
84111
84121
  if (matches.length !== 1)
84112
84122
  return fail(reason);
84113
84123
  const start = matches[0];
84114
84124
  const end = sections.find(heading => heading.index > start.index)?.index ?? source.length;
84115
- const lines = source.slice(start.index + start[0].length, end).split('\n');
84125
+ return source.slice(start.index + start[0].length, end);
84126
+ }
84127
+ function table(source, number, headers, reason) {
84128
+ const lines = section(source, number, reason).split('\n');
84116
84129
  const found = [];
84117
84130
  for (let index = 0; index < lines.length; index++) {
84118
84131
  if (!/^\s*\|/u.test(lines[index]))
@@ -84143,6 +84156,47 @@ function ids(value, pattern, reason) {
84143
84156
  return fail(reason);
84144
84157
  return values;
84145
84158
  }
84159
+ /** Never repairs definitions or contradictory supplied tables; the writer independently revalidates. */
84160
+ function renderSddDerivedTables(markdown) {
84161
+ if (!markdown.includes(BUDGET_SLOT) && !markdown.includes(TRACEABILITY_SLOT))
84162
+ return markdown;
84163
+ const source = visible(markdown);
84164
+ for (const [slot, number, reason] of [
84165
+ [BUDGET_SLOT, 14, 'case-budget'], [TRACEABILITY_SLOT, 17, 'requirement-mapping'],
84166
+ ]) {
84167
+ if (markdown.split(slot).length !== 2
84168
+ || section(source, number, reason).split('\n').filter(line => line.trim() === slot).length !== 1)
84169
+ fail(reason);
84170
+ }
84171
+ const requirements = table(source, 4, ['Requirement', 'Behavior'], 'requirement-mapping').map(row => row[0]);
84172
+ if (new Set(requirements).size !== requirements.length || requirements.some(id => !REQUIREMENT_ID.test(id)))
84173
+ fail('requirement-mapping');
84174
+ const cases = table(source, 14, ['Case ID', 'Area', 'Requirements', 'Scenario'], 'case-identity');
84175
+ const caseIds = cases.map(row => row[0]);
84176
+ if (new Set(caseIds).size !== caseIds.length || caseIds.some(id => !CASE_ID.test(id)))
84177
+ fail('case-identity');
84178
+ const counts = new Map();
84179
+ const edges = new Map(requirements.map(id => [id, []]));
84180
+ for (const [id, area, links] of cases) {
84181
+ if (area === 'Total')
84182
+ fail('case-budget');
84183
+ counts.set(area, (counts.get(area) ?? 0) + 1);
84184
+ for (const requirement of ids(links, REQUIREMENT_ID, 'requirement-mapping')) {
84185
+ const linked = edges.get(requirement);
84186
+ if (!linked)
84187
+ fail('requirement-mapping');
84188
+ linked.push(id);
84189
+ }
84190
+ }
84191
+ if ([...edges.values()].some(links => links.length === 0))
84192
+ fail('requirement-mapping');
84193
+ const budget = ['| Area | Minimum distinct cases | Behaviors/risks covered |', '|---|---:|---|',
84194
+ ...[...counts].map(([area, count]) => `| ${area} | ${count} | Observable scenarios in the case inventory. |`),
84195
+ `| Total | ${cases.length} | Distinct inventory cases; repeated executions do not add cases. |`].join('\n');
84196
+ const traceability = ['| Requirement | Cases |', '|---|---|',
84197
+ ...[...edges].map(([requirement, links]) => `| ${requirement} | ${links.join(', ')} |`)].join('\n');
84198
+ return markdown.replace(BUDGET_SLOT, () => budget).replace(TRACEABILITY_SLOT, () => traceability);
84199
+ }
84146
84200
  function reservedSddCaseIds(documents) {
84147
84201
  const reserved = new Set();
84148
84202
  for (const document of documents) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vypdev/copilot",
3
- "version": "3.10.4",
3
+ "version": "3.10.5",
4
4
  "packageManager": "pnpm@10.12.4",
5
5
  "pnpm": {
6
6
  "overrides": {