lee-spec-kit 0.6.36 → 0.6.37

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/dist/index.js CHANGED
@@ -12038,9 +12038,49 @@ function extractMarkdownByHeadings(content, headings, levels) {
12038
12038
  }
12039
12039
  return lines.slice(start, end).join("\n");
12040
12040
  }
12041
+ function removeMarkdownByHeadings(content, headings, levels) {
12042
+ const targets = new Set(headings.map((heading) => normalizeHeading(heading)));
12043
+ const lines = content.split("\n");
12044
+ const levelSet = new Set(levels);
12045
+ let start = -1;
12046
+ let startLevel = 0;
12047
+ for (let i = 0; i < lines.length; i++) {
12048
+ const match = lines[i].match(/^\s*(#{2,6})\s+(.+?)\s*$/);
12049
+ if (!match) continue;
12050
+ const level = match[1].length;
12051
+ if (!levelSet.has(level)) continue;
12052
+ if (!targets.has(normalizeHeading(match[2]))) continue;
12053
+ start = i;
12054
+ startLevel = level;
12055
+ break;
12056
+ }
12057
+ if (start < 0) return content;
12058
+ let end = lines.length;
12059
+ for (let i = start + 1; i < lines.length; i++) {
12060
+ const heading = lines[i].match(/^\s*(#{2,6})\s+(.+?)\s*$/);
12061
+ if (!heading) continue;
12062
+ const level = heading[1].length;
12063
+ if (level <= startLevel) {
12064
+ end = i;
12065
+ break;
12066
+ }
12067
+ }
12068
+ const next = [...lines.slice(0, start), ...lines.slice(end)].join("\n");
12069
+ const hasTrailingNewline = /\n$/.test(content);
12070
+ const normalized = next.replace(/\n{3,}/g, "\n\n").trimEnd();
12071
+ if (!normalized) return "";
12072
+ return hasTrailingNewline ? `${normalized}
12073
+ ` : normalized;
12074
+ }
12041
12075
  function extractMarkdownSection(content, headings) {
12042
12076
  return extractMarkdownByHeadings(content, headings, [2]);
12043
12077
  }
12078
+ function stripIssueDraftMetadataSection(content) {
12079
+ return stripWorkflowDraftMetadataSection(content);
12080
+ }
12081
+ function stripWorkflowDraftMetadataSection(content) {
12082
+ return removeMarkdownByHeadings(content, ["Metadata", "\uBA54\uD0C0\uB370\uC774\uD130"], [2]);
12083
+ }
12044
12084
  function isTemplateLine(line) {
12045
12085
  const trimmed = line.trim();
12046
12086
  if (!trimmed) return true;
@@ -13047,8 +13087,20 @@ function githubCommand(program2) {
13047
13087
  kindLabel: tg(config.lang, "kindIssue"),
13048
13088
  lang: config.lang
13049
13089
  });
13050
- const body = preparedBody.body;
13051
- const bodyFile = preparedBody.bodyFile;
13090
+ const body = stripIssueDraftMetadataSection(preparedBody.body);
13091
+ let bodyFile = preparedBody.bodyFile;
13092
+ if (options.create && body !== preparedBody.body) {
13093
+ const sanitizedBodyFile = toBodyFilePath(
13094
+ void 0,
13095
+ "issue",
13096
+ config.docsDir,
13097
+ `${feature.type}-issue-sanitized`,
13098
+ config.lang
13099
+ );
13100
+ await fs.ensureDir(path12.dirname(sanitizedBodyFile));
13101
+ await fs.writeFile(sanitizedBodyFile, body, "utf-8");
13102
+ bodyFile = sanitizedBodyFile;
13103
+ }
13052
13104
  const title = options.title?.trim() || (preparedBody.source === "workflow-ready" ? preparedBody.draftMetadata?.title : void 0) || defaultTitle;
13053
13105
  const labels = parseLabels(
13054
13106
  optionLabels || (preparedBody.source === "workflow-ready" ? preparedBody.draftMetadata?.labels : void 0),
@@ -13255,8 +13307,22 @@ function githubCommand(program2) {
13255
13307
  kindLabel: tg(config.lang, "kindPr"),
13256
13308
  lang: config.lang
13257
13309
  });
13258
- let body = preparedBody.body;
13310
+ let body = stripWorkflowDraftMetadataSection(
13311
+ preparedBody.body
13312
+ );
13259
13313
  let bodyFile = preparedBody.bodyFile;
13314
+ if (options.create && body !== preparedBody.body) {
13315
+ const sanitizedBodyFile = toBodyFilePath(
13316
+ void 0,
13317
+ "pr",
13318
+ config.docsDir,
13319
+ `${feature.type}-pr-sanitized`,
13320
+ config.lang
13321
+ );
13322
+ await fs.ensureDir(path12.dirname(sanitizedBodyFile));
13323
+ await fs.writeFile(sanitizedBodyFile, body, "utf-8");
13324
+ bodyFile = sanitizedBodyFile;
13325
+ }
13260
13326
  const title = options.title?.trim() || (preparedBody.source === "workflow-ready" ? preparedBody.draftMetadata?.title : void 0) || defaultTitle;
13261
13327
  const labels = parseLabels(
13262
13328
  optionLabels || (preparedBody.source === "workflow-ready" ? preparedBody.draftMetadata?.labels : void 0),