pi-spine 2.8.0 → 2.10.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.
@@ -1,6 +1,8 @@
1
1
  // @ts-nocheck
2
2
  import { parseSizeLineFromMarkdown } from "./size-line.mjs";
3
3
 
4
+ import { parseMatrixTable } from "../../planner/matrix.mjs";
5
+
4
6
  /** PRD §13.4 — em dash (U+2014) required between ID and title. */
5
7
  export const TASK_HEADING_RE = /^# Task: ([A-Z][A-Z0-9]*-\d+) — (.+)$/m;
6
8
 
@@ -13,7 +15,7 @@ const REQUIRED_SECTIONS = [
13
15
  "Do NOT",
14
16
  ];
15
17
 
16
- const OPTIONAL_SECTIONS = ["Testing", "Context to Read First", "Environment", "Documentation Requirements"];
18
+ const OPTIONAL_SECTIONS = ["Testing", "Context to Read First", "Environment", "Documentation Requirements", "Matrix"];
17
19
 
18
20
  const H2_SECTION_RE = /^## (.+)$/gm;
19
21
  const STEP_HEADING_RE = /^### Step (\d+): (.+)$/gm;
@@ -21,6 +23,7 @@ const STEP_HEADING_RE = /^### Step (\d+): (.+)$/gm;
21
23
  /** Normative contract table fields per handoff §4.1. */
22
24
  export const CONTRACT_FIELD_NAMES = Object.freeze([
23
25
  "testCommand",
26
+ "runCommand",
24
27
  "fileScopeMustChange",
25
28
  "fileScopeMustNotChange",
26
29
  "minLineCoverage",
@@ -65,11 +68,24 @@ export function parsePrompt(markdown) {
65
68
 
66
69
  const missingSections = REQUIRED_SECTIONS.filter((name) => !sections[name]);
67
70
  const size = parseSizeLineFromMarkdown(markdown);
71
+ const typeMatch = /^\*\*Type:\*\*\s*(llm|execute)\s*$/im.exec(markdown);
72
+ const type = typeMatch ? typeMatch[1].toLowerCase() : "llm";
73
+
74
+ let matrix = null;
75
+ let matrixColumns = null;
76
+ if (sections.Matrix) {
77
+ const parsedMatrix = parseMatrixTable(sections.Matrix);
78
+ if (parsedMatrix.rows.length > 0) {
79
+ matrix = parsedMatrix.rows;
80
+ matrixColumns = parsedMatrix.columns;
81
+ }
82
+ }
68
83
 
69
84
  return {
70
85
  taskId,
71
86
  title,
72
87
  size,
88
+ type,
73
89
  headingLine,
74
90
  sections,
75
91
  steps,
@@ -79,6 +95,7 @@ export function parsePrompt(markdown) {
79
95
  missingSections,
80
96
  requiredSections: REQUIRED_SECTIONS,
81
97
  optionalSections: OPTIONAL_SECTIONS,
98
+ ...(matrix ? { matrix, matrixColumns } : {})
82
99
  };
83
100
  }
84
101
 
@@ -113,6 +130,13 @@ export function validatePrompt(markdown) {
113
130
 
114
131
  errors.push(...collectDuplicateStepNumberErrors(prompt.steps));
115
132
 
133
+ if (prompt.type === "execute") {
134
+ const contract = parseContract(markdown);
135
+ if (!contract.testCommand && !contract.runCommand) {
136
+ errors.push("Type: execute tasks require a testCommand or runCommand in the ## Contract section");
137
+ }
138
+ }
139
+
116
140
  return { ok: errors.length === 0, errors, prompt };
117
141
  }
118
142
 
@@ -149,6 +173,7 @@ function collectDuplicateStepNumberErrors(steps) {
149
173
  * @param {string} markdown PROMPT.md contents
150
174
  * @returns {{
151
175
  * testCommand: string | null,
176
+ * runCommand: string | null,
152
177
  * fileScopeMustChange: string[],
153
178
  * fileScopeMustNotChange: string[],
154
179
  * minLineCoverage: number | null,
@@ -171,6 +196,7 @@ export function parseContract(markdown) {
171
196
  /** @type {ReturnType<typeof parseContract>} */
172
197
  const parsed = {
173
198
  testCommand: null,
199
+ runCommand: null,
174
200
  fileScopeMustChange: [],
175
201
  fileScopeMustNotChange: [],
176
202
  minLineCoverage: null,
@@ -297,6 +323,19 @@ function applyContractField(parsed, field, rawValue) {
297
323
  parsed.testCommand = command;
298
324
  return;
299
325
  }
326
+ case "runCommand": {
327
+ const command = parseContractScalar(value);
328
+ if (command.includes("\n")) {
329
+ parsed.errors.push("Contract runCommand must not contain newlines");
330
+ return;
331
+ }
332
+ if (command.length > TEST_COMMAND_MAX_LENGTH) {
333
+ parsed.errors.push(`Contract runCommand exceeds ${TEST_COMMAND_MAX_LENGTH} characters`);
334
+ return;
335
+ }
336
+ parsed.runCommand = command;
337
+ return;
338
+ }
300
339
  case "fileScopeMustChange":
301
340
  parsed.fileScopeMustChange = parseContractPathList(value);
302
341
  return;