specdx 0.2.0-alpha.3 → 0.3.0-alpha.2

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.
Files changed (54) hide show
  1. package/.claude-plugin/plugin.json +6 -0
  2. package/dist/changelog-URU2TFNM.js +86 -0
  3. package/dist/changelog-URU2TFNM.js.map +1 -0
  4. package/dist/{chunk-JLK2NNAF.js → chunk-276J7LR6.js} +12 -16
  5. package/dist/chunk-276J7LR6.js.map +1 -0
  6. package/dist/{lint-V42NAO3U.js → chunk-ATLVRGHI.js} +6 -102
  7. package/dist/chunk-ATLVRGHI.js.map +1 -0
  8. package/dist/chunk-GAM4MXPC.js +15 -0
  9. package/dist/chunk-GAM4MXPC.js.map +1 -0
  10. package/dist/chunk-LU6M5O63.js +1147 -0
  11. package/dist/chunk-LU6M5O63.js.map +1 -0
  12. package/dist/{chunk-CV2CHFFG.js → chunk-XLEN6ZYM.js} +29 -5
  13. package/dist/chunk-XLEN6ZYM.js.map +1 -0
  14. package/dist/diff-55PTEVB3.js +100 -0
  15. package/dist/diff-55PTEVB3.js.map +1 -0
  16. package/dist/explain-YXUILNEA.js +102 -0
  17. package/dist/explain-YXUILNEA.js.map +1 -0
  18. package/dist/{graph-G3ILOAV6.js → graph-OWQJWVSN.js} +7 -5
  19. package/dist/{graph-G3ILOAV6.js.map → graph-OWQJWVSN.js.map} +1 -1
  20. package/dist/index.js +1552 -6
  21. package/dist/index.js.map +1 -1
  22. package/dist/lint-U7VLGS75.js +111 -0
  23. package/dist/lint-U7VLGS75.js.map +1 -0
  24. package/dist/main.js +11 -6
  25. package/dist/main.js.map +1 -1
  26. package/dist/{pack-RWWFJSPV.js → pack-OJAC7JF2.js} +7 -5
  27. package/dist/{pack-RWWFJSPV.js.map → pack-OJAC7JF2.js.map} +1 -1
  28. package/dist/ready-3OIF4QHM.js +159 -0
  29. package/dist/ready-3OIF4QHM.js.map +1 -0
  30. package/dist/skills/spec-type-reference.md +57 -0
  31. package/dist/skills/specdx-author-spec/step-01-frontmatter.md +66 -0
  32. package/dist/skills/specdx-author-spec/step-02-sections.md +70 -0
  33. package/dist/skills/specdx-author-spec/step-03-finalize.md +48 -0
  34. package/dist/skills/specdx-author-spec.md +29 -0
  35. package/dist/skills/specdx-onboard.md +49 -0
  36. package/dist/skills/specdx-plan-from-spec.md +72 -0
  37. package/dist/skills/specdx-pre-commit.md +56 -0
  38. package/dist/skills/specdx-sprint-review.md +69 -0
  39. package/dist/skills/{specdx-start-task/SKILL.md → specdx-start-task.md} +1 -1
  40. package/dist/{skills-5XHJEKA2.js → skills-XJYTWGDK.js} +15 -9
  41. package/dist/skills-XJYTWGDK.js.map +1 -0
  42. package/dist/status-LYZUO6AJ.js +145 -0
  43. package/dist/status-LYZUO6AJ.js.map +1 -0
  44. package/dist/{validate-XZWUCAWU.js → validate-DOZZEZFC.js} +7 -5
  45. package/dist/{validate-XZWUCAWU.js.map → validate-DOZZEZFC.js.map} +1 -1
  46. package/hooks/hooks.json +8 -0
  47. package/hooks/run-hook.cmd +46 -0
  48. package/hooks/session-start +77 -0
  49. package/package.json +5 -2
  50. package/dist/chunk-CV2CHFFG.js.map +0 -1
  51. package/dist/chunk-JLK2NNAF.js.map +0 -1
  52. package/dist/lint-V42NAO3U.js.map +0 -1
  53. package/dist/skills/specdx-author-spec/SKILL.md +0 -115
  54. package/dist/skills-5XHJEKA2.js.map +0 -1
package/dist/index.js CHANGED
@@ -80,7 +80,8 @@ var config_default = {
80
80
  path: { type: "string" },
81
81
  type: { type: "string", enum: ["prd", "technical-design", "user-story", "test-plan", "adr", "api-contract"] },
82
82
  required: { type: "boolean", default: false },
83
- requires: { type: "array", items: { type: "string" } }
83
+ requires: { type: "array", items: { type: "string" } },
84
+ owner: { type: "string" }
84
85
  },
85
86
  required: ["path", "type"],
86
87
  additionalProperties: false
@@ -89,7 +90,7 @@ var config_default = {
89
90
  lint: {
90
91
  type: "object",
91
92
  properties: {
92
- extends: { type: "string", enum: ["minimal", "recommended", "strict"] },
93
+ extends: { type: "string" },
93
94
  rules: { type: "object" },
94
95
  ignore: { type: "array", items: { type: "string" } }
95
96
  },
@@ -116,8 +117,31 @@ var config_default = {
116
117
  },
117
118
  additionalProperties: false
118
119
  },
119
- diff: { type: "object" },
120
- ci: { type: "object" }
120
+ diff: {
121
+ type: "object",
122
+ properties: {
123
+ baseline_ref: { type: "string", default: "main" },
124
+ staleness_threshold_days: { type: "integer", minimum: 1, default: 14 },
125
+ ignore_paths: { type: "array", items: { type: "string" } }
126
+ },
127
+ additionalProperties: false
128
+ },
129
+ ci: {
130
+ type: "object",
131
+ properties: {
132
+ block_on: {
133
+ type: "array",
134
+ items: { type: "string", enum: ["error", "warn", "info"] }
135
+ },
136
+ post_comment: { type: "boolean", default: true },
137
+ update_badge: { type: "boolean", default: true },
138
+ trigger_paths: {
139
+ type: "array",
140
+ items: { type: "string" }
141
+ }
142
+ },
143
+ additionalProperties: false
144
+ }
121
145
  },
122
146
  required: ["version", "specs"],
123
147
  additionalProperties: false
@@ -427,11 +451,14 @@ async function parseSpec(filePath) {
427
451
  } catch {
428
452
  throw new ParseError(`Cannot read spec file: ${filePath}`);
429
453
  }
454
+ return parseSpecFromString(raw, filePath);
455
+ }
456
+ function parseSpecFromString(content, filePath) {
430
457
  const ext = extname(filePath).toLowerCase();
431
458
  if (ext === ".yaml" || ext === ".yml") {
432
- return parseYamlSpec(filePath, raw);
459
+ return Promise.resolve(parseYamlSpec(filePath, content));
433
460
  }
434
- return parseMarkdownSpec(filePath, raw);
461
+ return Promise.resolve(parseMarkdownSpec(filePath, content));
435
462
  }
436
463
  function parseMarkdownSpec(filePath, raw) {
437
464
  const { data, content } = matter(raw);
@@ -613,6 +640,10 @@ function createLogger(options) {
613
640
  return createConsola({ level });
614
641
  }
615
642
 
643
+ // ../core/dist/preset.js
644
+ import { readFile as readFile3 } from "fs/promises";
645
+ import { resolve, isAbsolute as isAbsolute2 } from "path";
646
+
616
647
  // ../lint/dist/engine.js
617
648
  function createLintEngine(options) {
618
649
  return {
@@ -833,6 +864,8 @@ function getPreset(name) {
833
864
  return allBuiltinRules;
834
865
  case "strict":
835
866
  return allBuiltinRules.map((rule) => ({ ...rule, severity: "error" }));
867
+ default:
868
+ throw new Error(`Unknown preset: "${name}". Use "minimal", "recommended", or "strict", or resolve external presets via resolvePreset() from @specdx/core.`);
836
869
  }
837
870
  }
838
871
 
@@ -1618,9 +1651,1522 @@ var pack_default = defineCommand3({
1618
1651
  }
1619
1652
  }
1620
1653
  });
1654
+
1655
+ // src/commands/diff.ts
1656
+ import { defineCommand as defineCommand4 } from "citty";
1657
+ import { join as join5 } from "path";
1658
+
1659
+ // ../diff/dist/types.js
1660
+ var DEFAULT_DIFF_CONFIG = {
1661
+ baseline_ref: "main",
1662
+ staleness_threshold_days: 14
1663
+ };
1664
+ var DiffError = class extends Error {
1665
+ constructor(message) {
1666
+ super(message);
1667
+ this.name = "DiffError";
1668
+ }
1669
+ };
1670
+
1671
+ // ../../node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.mjs
1672
+ function Diff() {
1673
+ }
1674
+ Diff.prototype = {
1675
+ diff: function diff(oldString, newString) {
1676
+ var _options$timeout;
1677
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1678
+ var callback = options.callback;
1679
+ if (typeof options === "function") {
1680
+ callback = options;
1681
+ options = {};
1682
+ }
1683
+ var self = this;
1684
+ function done(value) {
1685
+ value = self.postProcess(value, options);
1686
+ if (callback) {
1687
+ setTimeout(function() {
1688
+ callback(value);
1689
+ }, 0);
1690
+ return true;
1691
+ } else {
1692
+ return value;
1693
+ }
1694
+ }
1695
+ oldString = this.castInput(oldString, options);
1696
+ newString = this.castInput(newString, options);
1697
+ oldString = this.removeEmpty(this.tokenize(oldString, options));
1698
+ newString = this.removeEmpty(this.tokenize(newString, options));
1699
+ var newLen = newString.length, oldLen = oldString.length;
1700
+ var editLength = 1;
1701
+ var maxEditLength = newLen + oldLen;
1702
+ if (options.maxEditLength != null) {
1703
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
1704
+ }
1705
+ var maxExecutionTime = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : Infinity;
1706
+ var abortAfterTimestamp = Date.now() + maxExecutionTime;
1707
+ var bestPath = [{
1708
+ oldPos: -1,
1709
+ lastComponent: void 0
1710
+ }];
1711
+ var newPos = this.extractCommon(bestPath[0], newString, oldString, 0, options);
1712
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
1713
+ return done(buildValues(self, bestPath[0].lastComponent, newString, oldString, self.useLongestToken));
1714
+ }
1715
+ var minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
1716
+ function execEditLength() {
1717
+ for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
1718
+ var basePath = void 0;
1719
+ var removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
1720
+ if (removePath) {
1721
+ bestPath[diagonalPath - 1] = void 0;
1722
+ }
1723
+ var canAdd = false;
1724
+ if (addPath) {
1725
+ var addPathNewPos = addPath.oldPos - diagonalPath;
1726
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
1727
+ }
1728
+ var canRemove = removePath && removePath.oldPos + 1 < oldLen;
1729
+ if (!canAdd && !canRemove) {
1730
+ bestPath[diagonalPath] = void 0;
1731
+ continue;
1732
+ }
1733
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
1734
+ basePath = self.addToPath(addPath, true, false, 0, options);
1735
+ } else {
1736
+ basePath = self.addToPath(removePath, false, true, 1, options);
1737
+ }
1738
+ newPos = self.extractCommon(basePath, newString, oldString, diagonalPath, options);
1739
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
1740
+ return done(buildValues(self, basePath.lastComponent, newString, oldString, self.useLongestToken));
1741
+ } else {
1742
+ bestPath[diagonalPath] = basePath;
1743
+ if (basePath.oldPos + 1 >= oldLen) {
1744
+ maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
1745
+ }
1746
+ if (newPos + 1 >= newLen) {
1747
+ minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
1748
+ }
1749
+ }
1750
+ }
1751
+ editLength++;
1752
+ }
1753
+ if (callback) {
1754
+ (function exec() {
1755
+ setTimeout(function() {
1756
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
1757
+ return callback();
1758
+ }
1759
+ if (!execEditLength()) {
1760
+ exec();
1761
+ }
1762
+ }, 0);
1763
+ })();
1764
+ } else {
1765
+ while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
1766
+ var ret = execEditLength();
1767
+ if (ret) {
1768
+ return ret;
1769
+ }
1770
+ }
1771
+ }
1772
+ },
1773
+ addToPath: function addToPath(path, added, removed, oldPosInc, options) {
1774
+ var last = path.lastComponent;
1775
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
1776
+ return {
1777
+ oldPos: path.oldPos + oldPosInc,
1778
+ lastComponent: {
1779
+ count: last.count + 1,
1780
+ added,
1781
+ removed,
1782
+ previousComponent: last.previousComponent
1783
+ }
1784
+ };
1785
+ } else {
1786
+ return {
1787
+ oldPos: path.oldPos + oldPosInc,
1788
+ lastComponent: {
1789
+ count: 1,
1790
+ added,
1791
+ removed,
1792
+ previousComponent: last
1793
+ }
1794
+ };
1795
+ }
1796
+ },
1797
+ extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath, options) {
1798
+ var newLen = newString.length, oldLen = oldString.length, oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
1799
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldString[oldPos + 1], newString[newPos + 1], options)) {
1800
+ newPos++;
1801
+ oldPos++;
1802
+ commonCount++;
1803
+ if (options.oneChangePerToken) {
1804
+ basePath.lastComponent = {
1805
+ count: 1,
1806
+ previousComponent: basePath.lastComponent,
1807
+ added: false,
1808
+ removed: false
1809
+ };
1810
+ }
1811
+ }
1812
+ if (commonCount && !options.oneChangePerToken) {
1813
+ basePath.lastComponent = {
1814
+ count: commonCount,
1815
+ previousComponent: basePath.lastComponent,
1816
+ added: false,
1817
+ removed: false
1818
+ };
1819
+ }
1820
+ basePath.oldPos = oldPos;
1821
+ return newPos;
1822
+ },
1823
+ equals: function equals(left, right, options) {
1824
+ if (options.comparator) {
1825
+ return options.comparator(left, right);
1826
+ } else {
1827
+ return left === right || options.ignoreCase && left.toLowerCase() === right.toLowerCase();
1828
+ }
1829
+ },
1830
+ removeEmpty: function removeEmpty(array) {
1831
+ var ret = [];
1832
+ for (var i = 0; i < array.length; i++) {
1833
+ if (array[i]) {
1834
+ ret.push(array[i]);
1835
+ }
1836
+ }
1837
+ return ret;
1838
+ },
1839
+ castInput: function castInput(value) {
1840
+ return value;
1841
+ },
1842
+ tokenize: function tokenize2(value) {
1843
+ return Array.from(value);
1844
+ },
1845
+ join: function join4(chars) {
1846
+ return chars.join("");
1847
+ },
1848
+ postProcess: function postProcess(changeObjects) {
1849
+ return changeObjects;
1850
+ }
1851
+ };
1852
+ function buildValues(diff2, lastComponent, newString, oldString, useLongestToken) {
1853
+ var components = [];
1854
+ var nextComponent;
1855
+ while (lastComponent) {
1856
+ components.push(lastComponent);
1857
+ nextComponent = lastComponent.previousComponent;
1858
+ delete lastComponent.previousComponent;
1859
+ lastComponent = nextComponent;
1860
+ }
1861
+ components.reverse();
1862
+ var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
1863
+ for (; componentPos < componentLen; componentPos++) {
1864
+ var component = components[componentPos];
1865
+ if (!component.removed) {
1866
+ if (!component.added && useLongestToken) {
1867
+ var value = newString.slice(newPos, newPos + component.count);
1868
+ value = value.map(function(value2, i) {
1869
+ var oldValue = oldString[oldPos + i];
1870
+ return oldValue.length > value2.length ? oldValue : value2;
1871
+ });
1872
+ component.value = diff2.join(value);
1873
+ } else {
1874
+ component.value = diff2.join(newString.slice(newPos, newPos + component.count));
1875
+ }
1876
+ newPos += component.count;
1877
+ if (!component.added) {
1878
+ oldPos += component.count;
1879
+ }
1880
+ } else {
1881
+ component.value = diff2.join(oldString.slice(oldPos, oldPos + component.count));
1882
+ oldPos += component.count;
1883
+ }
1884
+ }
1885
+ return components;
1886
+ }
1887
+ var characterDiff = new Diff();
1888
+ function longestCommonPrefix(str1, str2) {
1889
+ var i;
1890
+ for (i = 0; i < str1.length && i < str2.length; i++) {
1891
+ if (str1[i] != str2[i]) {
1892
+ return str1.slice(0, i);
1893
+ }
1894
+ }
1895
+ return str1.slice(0, i);
1896
+ }
1897
+ function longestCommonSuffix(str1, str2) {
1898
+ var i;
1899
+ if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
1900
+ return "";
1901
+ }
1902
+ for (i = 0; i < str1.length && i < str2.length; i++) {
1903
+ if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
1904
+ return str1.slice(-i);
1905
+ }
1906
+ }
1907
+ return str1.slice(-i);
1908
+ }
1909
+ function replacePrefix(string, oldPrefix, newPrefix) {
1910
+ if (string.slice(0, oldPrefix.length) != oldPrefix) {
1911
+ throw Error("string ".concat(JSON.stringify(string), " doesn't start with prefix ").concat(JSON.stringify(oldPrefix), "; this is a bug"));
1912
+ }
1913
+ return newPrefix + string.slice(oldPrefix.length);
1914
+ }
1915
+ function replaceSuffix(string, oldSuffix, newSuffix) {
1916
+ if (!oldSuffix) {
1917
+ return string + newSuffix;
1918
+ }
1919
+ if (string.slice(-oldSuffix.length) != oldSuffix) {
1920
+ throw Error("string ".concat(JSON.stringify(string), " doesn't end with suffix ").concat(JSON.stringify(oldSuffix), "; this is a bug"));
1921
+ }
1922
+ return string.slice(0, -oldSuffix.length) + newSuffix;
1923
+ }
1924
+ function removePrefix(string, oldPrefix) {
1925
+ return replacePrefix(string, oldPrefix, "");
1926
+ }
1927
+ function removeSuffix(string, oldSuffix) {
1928
+ return replaceSuffix(string, oldSuffix, "");
1929
+ }
1930
+ function maximumOverlap(string1, string2) {
1931
+ return string2.slice(0, overlapCount(string1, string2));
1932
+ }
1933
+ function overlapCount(a, b) {
1934
+ var startA = 0;
1935
+ if (a.length > b.length) {
1936
+ startA = a.length - b.length;
1937
+ }
1938
+ var endB = b.length;
1939
+ if (a.length < b.length) {
1940
+ endB = a.length;
1941
+ }
1942
+ var map = Array(endB);
1943
+ var k = 0;
1944
+ map[0] = 0;
1945
+ for (var j = 1; j < endB; j++) {
1946
+ if (b[j] == b[k]) {
1947
+ map[j] = map[k];
1948
+ } else {
1949
+ map[j] = k;
1950
+ }
1951
+ while (k > 0 && b[j] != b[k]) {
1952
+ k = map[k];
1953
+ }
1954
+ if (b[j] == b[k]) {
1955
+ k++;
1956
+ }
1957
+ }
1958
+ k = 0;
1959
+ for (var i = startA; i < a.length; i++) {
1960
+ while (k > 0 && a[i] != b[k]) {
1961
+ k = map[k];
1962
+ }
1963
+ if (a[i] == b[k]) {
1964
+ k++;
1965
+ }
1966
+ }
1967
+ return k;
1968
+ }
1969
+ var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
1970
+ var tokenizeIncludingWhitespace = new RegExp("[".concat(extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), "ug");
1971
+ var wordDiff = new Diff();
1972
+ wordDiff.equals = function(left, right, options) {
1973
+ if (options.ignoreCase) {
1974
+ left = left.toLowerCase();
1975
+ right = right.toLowerCase();
1976
+ }
1977
+ return left.trim() === right.trim();
1978
+ };
1979
+ wordDiff.tokenize = function(value) {
1980
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1981
+ var parts;
1982
+ if (options.intlSegmenter) {
1983
+ if (options.intlSegmenter.resolvedOptions().granularity != "word") {
1984
+ throw new Error('The segmenter passed must have a granularity of "word"');
1985
+ }
1986
+ parts = Array.from(options.intlSegmenter.segment(value), function(segment) {
1987
+ return segment.segment;
1988
+ });
1989
+ } else {
1990
+ parts = value.match(tokenizeIncludingWhitespace) || [];
1991
+ }
1992
+ var tokens = [];
1993
+ var prevPart = null;
1994
+ parts.forEach(function(part) {
1995
+ if (/\s/.test(part)) {
1996
+ if (prevPart == null) {
1997
+ tokens.push(part);
1998
+ } else {
1999
+ tokens.push(tokens.pop() + part);
2000
+ }
2001
+ } else if (/\s/.test(prevPart)) {
2002
+ if (tokens[tokens.length - 1] == prevPart) {
2003
+ tokens.push(tokens.pop() + part);
2004
+ } else {
2005
+ tokens.push(prevPart + part);
2006
+ }
2007
+ } else {
2008
+ tokens.push(part);
2009
+ }
2010
+ prevPart = part;
2011
+ });
2012
+ return tokens;
2013
+ };
2014
+ wordDiff.join = function(tokens) {
2015
+ return tokens.map(function(token, i) {
2016
+ if (i == 0) {
2017
+ return token;
2018
+ } else {
2019
+ return token.replace(/^\s+/, "");
2020
+ }
2021
+ }).join("");
2022
+ };
2023
+ wordDiff.postProcess = function(changes, options) {
2024
+ if (!changes || options.oneChangePerToken) {
2025
+ return changes;
2026
+ }
2027
+ var lastKeep = null;
2028
+ var insertion = null;
2029
+ var deletion = null;
2030
+ changes.forEach(function(change) {
2031
+ if (change.added) {
2032
+ insertion = change;
2033
+ } else if (change.removed) {
2034
+ deletion = change;
2035
+ } else {
2036
+ if (insertion || deletion) {
2037
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
2038
+ }
2039
+ lastKeep = change;
2040
+ insertion = null;
2041
+ deletion = null;
2042
+ }
2043
+ });
2044
+ if (insertion || deletion) {
2045
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
2046
+ }
2047
+ return changes;
2048
+ };
2049
+ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
2050
+ if (deletion && insertion) {
2051
+ var oldWsPrefix = deletion.value.match(/^\s*/)[0];
2052
+ var oldWsSuffix = deletion.value.match(/\s*$/)[0];
2053
+ var newWsPrefix = insertion.value.match(/^\s*/)[0];
2054
+ var newWsSuffix = insertion.value.match(/\s*$/)[0];
2055
+ if (startKeep) {
2056
+ var commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
2057
+ startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
2058
+ deletion.value = removePrefix(deletion.value, commonWsPrefix);
2059
+ insertion.value = removePrefix(insertion.value, commonWsPrefix);
2060
+ }
2061
+ if (endKeep) {
2062
+ var commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
2063
+ endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
2064
+ deletion.value = removeSuffix(deletion.value, commonWsSuffix);
2065
+ insertion.value = removeSuffix(insertion.value, commonWsSuffix);
2066
+ }
2067
+ } else if (insertion) {
2068
+ if (startKeep) {
2069
+ insertion.value = insertion.value.replace(/^\s*/, "");
2070
+ }
2071
+ if (endKeep) {
2072
+ endKeep.value = endKeep.value.replace(/^\s*/, "");
2073
+ }
2074
+ } else if (startKeep && endKeep) {
2075
+ var newWsFull = endKeep.value.match(/^\s*/)[0], delWsStart = deletion.value.match(/^\s*/)[0], delWsEnd = deletion.value.match(/\s*$/)[0];
2076
+ var newWsStart = longestCommonPrefix(newWsFull, delWsStart);
2077
+ deletion.value = removePrefix(deletion.value, newWsStart);
2078
+ var newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
2079
+ deletion.value = removeSuffix(deletion.value, newWsEnd);
2080
+ endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
2081
+ startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
2082
+ } else if (endKeep) {
2083
+ var endKeepWsPrefix = endKeep.value.match(/^\s*/)[0];
2084
+ var deletionWsSuffix = deletion.value.match(/\s*$/)[0];
2085
+ var overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
2086
+ deletion.value = removeSuffix(deletion.value, overlap);
2087
+ } else if (startKeep) {
2088
+ var startKeepWsSuffix = startKeep.value.match(/\s*$/)[0];
2089
+ var deletionWsPrefix = deletion.value.match(/^\s*/)[0];
2090
+ var _overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
2091
+ deletion.value = removePrefix(deletion.value, _overlap);
2092
+ }
2093
+ }
2094
+ var wordWithSpaceDiff = new Diff();
2095
+ wordWithSpaceDiff.tokenize = function(value) {
2096
+ var regex = new RegExp("(\\r?\\n)|[".concat(extendedWordChars, "]+|[^\\S\\n\\r]+|[^").concat(extendedWordChars, "]"), "ug");
2097
+ return value.match(regex) || [];
2098
+ };
2099
+ var lineDiff = new Diff();
2100
+ lineDiff.tokenize = function(value, options) {
2101
+ if (options.stripTrailingCr) {
2102
+ value = value.replace(/\r\n/g, "\n");
2103
+ }
2104
+ var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
2105
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
2106
+ linesAndNewlines.pop();
2107
+ }
2108
+ for (var i = 0; i < linesAndNewlines.length; i++) {
2109
+ var line = linesAndNewlines[i];
2110
+ if (i % 2 && !options.newlineIsToken) {
2111
+ retLines[retLines.length - 1] += line;
2112
+ } else {
2113
+ retLines.push(line);
2114
+ }
2115
+ }
2116
+ return retLines;
2117
+ };
2118
+ lineDiff.equals = function(left, right, options) {
2119
+ if (options.ignoreWhitespace) {
2120
+ if (!options.newlineIsToken || !left.includes("\n")) {
2121
+ left = left.trim();
2122
+ }
2123
+ if (!options.newlineIsToken || !right.includes("\n")) {
2124
+ right = right.trim();
2125
+ }
2126
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
2127
+ if (left.endsWith("\n")) {
2128
+ left = left.slice(0, -1);
2129
+ }
2130
+ if (right.endsWith("\n")) {
2131
+ right = right.slice(0, -1);
2132
+ }
2133
+ }
2134
+ return Diff.prototype.equals.call(this, left, right, options);
2135
+ };
2136
+ function diffLines(oldStr, newStr, callback) {
2137
+ return lineDiff.diff(oldStr, newStr, callback);
2138
+ }
2139
+ var sentenceDiff = new Diff();
2140
+ sentenceDiff.tokenize = function(value) {
2141
+ return value.split(/(\S.+?[.!?])(?=\s+|$)/);
2142
+ };
2143
+ var cssDiff = new Diff();
2144
+ cssDiff.tokenize = function(value) {
2145
+ return value.split(/([{}:;,]|\s+)/);
2146
+ };
2147
+ function ownKeys(e, r) {
2148
+ var t = Object.keys(e);
2149
+ if (Object.getOwnPropertySymbols) {
2150
+ var o = Object.getOwnPropertySymbols(e);
2151
+ r && (o = o.filter(function(r2) {
2152
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
2153
+ })), t.push.apply(t, o);
2154
+ }
2155
+ return t;
2156
+ }
2157
+ function _objectSpread2(e) {
2158
+ for (var r = 1; r < arguments.length; r++) {
2159
+ var t = null != arguments[r] ? arguments[r] : {};
2160
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
2161
+ _defineProperty(e, r2, t[r2]);
2162
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
2163
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
2164
+ });
2165
+ }
2166
+ return e;
2167
+ }
2168
+ function _toPrimitive(t, r) {
2169
+ if ("object" != typeof t || !t) return t;
2170
+ var e = t[Symbol.toPrimitive];
2171
+ if (void 0 !== e) {
2172
+ var i = e.call(t, r || "default");
2173
+ if ("object" != typeof i) return i;
2174
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2175
+ }
2176
+ return ("string" === r ? String : Number)(t);
2177
+ }
2178
+ function _toPropertyKey(t) {
2179
+ var i = _toPrimitive(t, "string");
2180
+ return "symbol" == typeof i ? i : i + "";
2181
+ }
2182
+ function _typeof(o) {
2183
+ "@babel/helpers - typeof";
2184
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
2185
+ return typeof o2;
2186
+ } : function(o2) {
2187
+ return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
2188
+ }, _typeof(o);
2189
+ }
2190
+ function _defineProperty(obj, key, value) {
2191
+ key = _toPropertyKey(key);
2192
+ if (key in obj) {
2193
+ Object.defineProperty(obj, key, {
2194
+ value,
2195
+ enumerable: true,
2196
+ configurable: true,
2197
+ writable: true
2198
+ });
2199
+ } else {
2200
+ obj[key] = value;
2201
+ }
2202
+ return obj;
2203
+ }
2204
+ function _toConsumableArray(arr) {
2205
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
2206
+ }
2207
+ function _arrayWithoutHoles(arr) {
2208
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
2209
+ }
2210
+ function _iterableToArray(iter) {
2211
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
2212
+ }
2213
+ function _unsupportedIterableToArray(o, minLen) {
2214
+ if (!o) return;
2215
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
2216
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2217
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2218
+ if (n === "Map" || n === "Set") return Array.from(o);
2219
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
2220
+ }
2221
+ function _arrayLikeToArray(arr, len) {
2222
+ if (len == null || len > arr.length) len = arr.length;
2223
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
2224
+ return arr2;
2225
+ }
2226
+ function _nonIterableSpread() {
2227
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2228
+ }
2229
+ var jsonDiff = new Diff();
2230
+ jsonDiff.useLongestToken = true;
2231
+ jsonDiff.tokenize = lineDiff.tokenize;
2232
+ jsonDiff.castInput = function(value, options) {
2233
+ var undefinedReplacement = options.undefinedReplacement, _options$stringifyRep = options.stringifyReplacer, stringifyReplacer = _options$stringifyRep === void 0 ? function(k, v) {
2234
+ return typeof v === "undefined" ? undefinedReplacement : v;
2235
+ } : _options$stringifyRep;
2236
+ return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, " ");
2237
+ };
2238
+ jsonDiff.equals = function(left, right, options) {
2239
+ return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
2240
+ };
2241
+ function canonicalize(obj, stack, replacementStack, replacer, key) {
2242
+ stack = stack || [];
2243
+ replacementStack = replacementStack || [];
2244
+ if (replacer) {
2245
+ obj = replacer(key, obj);
2246
+ }
2247
+ var i;
2248
+ for (i = 0; i < stack.length; i += 1) {
2249
+ if (stack[i] === obj) {
2250
+ return replacementStack[i];
2251
+ }
2252
+ }
2253
+ var canonicalizedObj;
2254
+ if ("[object Array]" === Object.prototype.toString.call(obj)) {
2255
+ stack.push(obj);
2256
+ canonicalizedObj = new Array(obj.length);
2257
+ replacementStack.push(canonicalizedObj);
2258
+ for (i = 0; i < obj.length; i += 1) {
2259
+ canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
2260
+ }
2261
+ stack.pop();
2262
+ replacementStack.pop();
2263
+ return canonicalizedObj;
2264
+ }
2265
+ if (obj && obj.toJSON) {
2266
+ obj = obj.toJSON();
2267
+ }
2268
+ if (_typeof(obj) === "object" && obj !== null) {
2269
+ stack.push(obj);
2270
+ canonicalizedObj = {};
2271
+ replacementStack.push(canonicalizedObj);
2272
+ var sortedKeys = [], _key;
2273
+ for (_key in obj) {
2274
+ if (Object.prototype.hasOwnProperty.call(obj, _key)) {
2275
+ sortedKeys.push(_key);
2276
+ }
2277
+ }
2278
+ sortedKeys.sort();
2279
+ for (i = 0; i < sortedKeys.length; i += 1) {
2280
+ _key = sortedKeys[i];
2281
+ canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
2282
+ }
2283
+ stack.pop();
2284
+ replacementStack.pop();
2285
+ } else {
2286
+ canonicalizedObj = obj;
2287
+ }
2288
+ return canonicalizedObj;
2289
+ }
2290
+ var arrayDiff = new Diff();
2291
+ arrayDiff.tokenize = function(value) {
2292
+ return value.slice();
2293
+ };
2294
+ arrayDiff.join = arrayDiff.removeEmpty = function(value) {
2295
+ return value;
2296
+ };
2297
+ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
2298
+ if (!options) {
2299
+ options = {};
2300
+ }
2301
+ if (typeof options === "function") {
2302
+ options = {
2303
+ callback: options
2304
+ };
2305
+ }
2306
+ if (typeof options.context === "undefined") {
2307
+ options.context = 4;
2308
+ }
2309
+ if (options.newlineIsToken) {
2310
+ throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
2311
+ }
2312
+ if (!options.callback) {
2313
+ return diffLinesResultToPatch(diffLines(oldStr, newStr, options));
2314
+ } else {
2315
+ var _options = options, _callback = _options.callback;
2316
+ diffLines(oldStr, newStr, _objectSpread2(_objectSpread2({}, options), {}, {
2317
+ callback: function callback(diff2) {
2318
+ var patch = diffLinesResultToPatch(diff2);
2319
+ _callback(patch);
2320
+ }
2321
+ }));
2322
+ }
2323
+ function diffLinesResultToPatch(diff2) {
2324
+ if (!diff2) {
2325
+ return;
2326
+ }
2327
+ diff2.push({
2328
+ value: "",
2329
+ lines: []
2330
+ });
2331
+ function contextLines(lines) {
2332
+ return lines.map(function(entry) {
2333
+ return " " + entry;
2334
+ });
2335
+ }
2336
+ var hunks = [];
2337
+ var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
2338
+ var _loop = function _loop2() {
2339
+ var current = diff2[i], lines = current.lines || splitLines(current.value);
2340
+ current.lines = lines;
2341
+ if (current.added || current.removed) {
2342
+ var _curRange;
2343
+ if (!oldRangeStart) {
2344
+ var prev = diff2[i - 1];
2345
+ oldRangeStart = oldLine;
2346
+ newRangeStart = newLine;
2347
+ if (prev) {
2348
+ curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
2349
+ oldRangeStart -= curRange.length;
2350
+ newRangeStart -= curRange.length;
2351
+ }
2352
+ }
2353
+ (_curRange = curRange).push.apply(_curRange, _toConsumableArray(lines.map(function(entry) {
2354
+ return (current.added ? "+" : "-") + entry;
2355
+ })));
2356
+ if (current.added) {
2357
+ newLine += lines.length;
2358
+ } else {
2359
+ oldLine += lines.length;
2360
+ }
2361
+ } else {
2362
+ if (oldRangeStart) {
2363
+ if (lines.length <= options.context * 2 && i < diff2.length - 2) {
2364
+ var _curRange2;
2365
+ (_curRange2 = curRange).push.apply(_curRange2, _toConsumableArray(contextLines(lines)));
2366
+ } else {
2367
+ var _curRange3;
2368
+ var contextSize = Math.min(lines.length, options.context);
2369
+ (_curRange3 = curRange).push.apply(_curRange3, _toConsumableArray(contextLines(lines.slice(0, contextSize))));
2370
+ var _hunk = {
2371
+ oldStart: oldRangeStart,
2372
+ oldLines: oldLine - oldRangeStart + contextSize,
2373
+ newStart: newRangeStart,
2374
+ newLines: newLine - newRangeStart + contextSize,
2375
+ lines: curRange
2376
+ };
2377
+ hunks.push(_hunk);
2378
+ oldRangeStart = 0;
2379
+ newRangeStart = 0;
2380
+ curRange = [];
2381
+ }
2382
+ }
2383
+ oldLine += lines.length;
2384
+ newLine += lines.length;
2385
+ }
2386
+ };
2387
+ for (var i = 0; i < diff2.length; i++) {
2388
+ _loop();
2389
+ }
2390
+ for (var _i = 0, _hunks = hunks; _i < _hunks.length; _i++) {
2391
+ var hunk = _hunks[_i];
2392
+ for (var _i2 = 0; _i2 < hunk.lines.length; _i2++) {
2393
+ if (hunk.lines[_i2].endsWith("\n")) {
2394
+ hunk.lines[_i2] = hunk.lines[_i2].slice(0, -1);
2395
+ } else {
2396
+ hunk.lines.splice(_i2 + 1, 0, "\");
2397
+ _i2++;
2398
+ }
2399
+ }
2400
+ }
2401
+ return {
2402
+ oldFileName,
2403
+ newFileName,
2404
+ oldHeader,
2405
+ newHeader,
2406
+ hunks
2407
+ };
2408
+ }
2409
+ }
2410
+ function formatPatch(diff2) {
2411
+ if (Array.isArray(diff2)) {
2412
+ return diff2.map(formatPatch).join("\n");
2413
+ }
2414
+ var ret = [];
2415
+ if (diff2.oldFileName == diff2.newFileName) {
2416
+ ret.push("Index: " + diff2.oldFileName);
2417
+ }
2418
+ ret.push("===================================================================");
2419
+ ret.push("--- " + diff2.oldFileName + (typeof diff2.oldHeader === "undefined" ? "" : " " + diff2.oldHeader));
2420
+ ret.push("+++ " + diff2.newFileName + (typeof diff2.newHeader === "undefined" ? "" : " " + diff2.newHeader));
2421
+ for (var i = 0; i < diff2.hunks.length; i++) {
2422
+ var hunk = diff2.hunks[i];
2423
+ if (hunk.oldLines === 0) {
2424
+ hunk.oldStart -= 1;
2425
+ }
2426
+ if (hunk.newLines === 0) {
2427
+ hunk.newStart -= 1;
2428
+ }
2429
+ ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
2430
+ ret.push.apply(ret, hunk.lines);
2431
+ }
2432
+ return ret.join("\n") + "\n";
2433
+ }
2434
+ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
2435
+ var _options2;
2436
+ if (typeof options === "function") {
2437
+ options = {
2438
+ callback: options
2439
+ };
2440
+ }
2441
+ if (!((_options2 = options) !== null && _options2 !== void 0 && _options2.callback)) {
2442
+ var patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
2443
+ if (!patchObj) {
2444
+ return;
2445
+ }
2446
+ return formatPatch(patchObj);
2447
+ } else {
2448
+ var _options3 = options, _callback2 = _options3.callback;
2449
+ structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, _objectSpread2(_objectSpread2({}, options), {}, {
2450
+ callback: function callback(patchObj2) {
2451
+ if (!patchObj2) {
2452
+ _callback2();
2453
+ } else {
2454
+ _callback2(formatPatch(patchObj2));
2455
+ }
2456
+ }
2457
+ }));
2458
+ }
2459
+ }
2460
+ function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
2461
+ return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
2462
+ }
2463
+ function splitLines(text) {
2464
+ var hasTrailingNl = text.endsWith("\n");
2465
+ var result = text.split("\n").map(function(line) {
2466
+ return line + "\n";
2467
+ });
2468
+ if (hasTrailingNl) {
2469
+ result.pop();
2470
+ } else {
2471
+ result.push(result.pop().slice(0, -1));
2472
+ }
2473
+ return result;
2474
+ }
2475
+
2476
+ // ../diff/dist/diff-specs.js
2477
+ function diffSpecs(before, after) {
2478
+ const frontmatter = diffFrontmatter(before.frontmatter, after.frontmatter);
2479
+ const sections = diffSections(before.parsedSections, after.parsedSections);
2480
+ const specId = after.frontmatter.id;
2481
+ const parts = [];
2482
+ if (frontmatter.length > 0)
2483
+ parts.push(`${frontmatter.length} field(s) changed`);
2484
+ if (sections.length > 0)
2485
+ parts.push(`${sections.length} section(s) changed`);
2486
+ const summary = parts.length > 0 ? `${specId}: ${parts.join(", ")}` : `${specId}: no changes`;
2487
+ return { specId, filePath: after.filePath, frontmatter, sections, summary };
2488
+ }
2489
+ function diffFrontmatter(before, after) {
2490
+ const changes = [];
2491
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)]);
2492
+ for (const key of allKeys) {
2493
+ const inBefore = Object.prototype.hasOwnProperty.call(before, key);
2494
+ const inAfter = Object.prototype.hasOwnProperty.call(after, key);
2495
+ if (inBefore && !inAfter) {
2496
+ changes.push({ field: key, type: "removed", before: before[key] });
2497
+ } else if (!inBefore && inAfter) {
2498
+ changes.push({ field: key, type: "added", after: after[key] });
2499
+ } else if (inBefore && inAfter) {
2500
+ const bVal = before[key];
2501
+ const aVal = after[key];
2502
+ if (JSON.stringify(bVal) !== JSON.stringify(aVal)) {
2503
+ changes.push({ field: key, type: "modified", before: bVal, after: aVal });
2504
+ }
2505
+ }
2506
+ }
2507
+ return changes;
2508
+ }
2509
+ function diffSections(before, after) {
2510
+ const changes = [];
2511
+ const beforeMap = /* @__PURE__ */ new Map();
2512
+ for (const section of before) {
2513
+ beforeMap.set(section.heading, section);
2514
+ }
2515
+ const afterMap = /* @__PURE__ */ new Map();
2516
+ for (const section of after) {
2517
+ afterMap.set(section.heading, section);
2518
+ }
2519
+ for (const [heading] of beforeMap) {
2520
+ if (!afterMap.has(heading)) {
2521
+ changes.push({ heading, type: "removed" });
2522
+ }
2523
+ }
2524
+ for (const [heading, afterSection] of afterMap) {
2525
+ const beforeSection = beforeMap.get(heading);
2526
+ if (!beforeSection) {
2527
+ changes.push({ heading, type: "added" });
2528
+ } else if (beforeSection.content !== afterSection.content) {
2529
+ const contentDiff = createPatch(heading, beforeSection.content, afterSection.content, "before", "after");
2530
+ changes.push({ heading, type: "modified", contentDiff });
2531
+ }
2532
+ }
2533
+ return changes;
2534
+ }
2535
+
2536
+ // ../diff/dist/impact.js
2537
+ var STRUCTURAL_SECTIONS = /* @__PURE__ */ new Set([
2538
+ "Goals",
2539
+ "Architecture",
2540
+ "Features",
2541
+ "Endpoints",
2542
+ "Data Model",
2543
+ "API Design",
2544
+ "Problem Statement"
2545
+ ]);
2546
+ function bfsDistances(startId, graph) {
2547
+ const distances = /* @__PURE__ */ new Map();
2548
+ const queue = [];
2549
+ for (const edge of graph.edges) {
2550
+ if (edge.from === startId) {
2551
+ if (!distances.has(edge.to)) {
2552
+ distances.set(edge.to, 1);
2553
+ queue.push({ id: edge.to, distance: 1 });
2554
+ }
2555
+ }
2556
+ }
2557
+ while (queue.length > 0) {
2558
+ const item = queue.shift();
2559
+ const currentDist = item.distance;
2560
+ for (const edge of graph.edges) {
2561
+ if (edge.from === item.id && !distances.has(edge.to)) {
2562
+ distances.set(edge.to, currentDist + 1);
2563
+ queue.push({ id: edge.to, distance: currentDist + 1 });
2564
+ }
2565
+ }
2566
+ }
2567
+ return distances;
2568
+ }
2569
+ function daysBetween(dateStr) {
2570
+ const then = new Date(dateStr).getTime();
2571
+ const now = Date.now();
2572
+ return Math.max(0, (now - then) / (1e3 * 60 * 60 * 24));
2573
+ }
2574
+ function clamp(min, max, value) {
2575
+ return Math.min(max, Math.max(min, value));
2576
+ }
2577
+ function analyzeImpact(changedSpecId, diff2, graph, allSpecs, thresholdDays = 14) {
2578
+ const distanceMap = bfsDistances(changedSpecId, graph);
2579
+ if (distanceMap.size === 0) {
2580
+ return {
2581
+ changedSpec: changedSpecId,
2582
+ downstream: [],
2583
+ totalAffected: 0
2584
+ };
2585
+ }
2586
+ const totalSections = Math.max(1, diff2.sections.length);
2587
+ const structuralSectionsChanged = diff2.sections.filter((s) => STRUCTURAL_SECTIONS.has(s.heading)).length;
2588
+ const specById = /* @__PURE__ */ new Map();
2589
+ for (const spec of allSpecs) {
2590
+ const id = spec.frontmatter.id;
2591
+ if (id)
2592
+ specById.set(id, spec);
2593
+ }
2594
+ const downstream = [];
2595
+ for (const [specId, distance] of distanceMap) {
2596
+ const spec = specById.get(specId);
2597
+ const lastUpdated = spec?.frontmatter.updated ?? spec?.frontmatter.created ?? null;
2598
+ const filePath = spec?.filePath ?? `specs/${specId}.md`;
2599
+ let staleness;
2600
+ if (lastUpdated) {
2601
+ const daysSinceUpdate = daysBetween(lastUpdated);
2602
+ staleness = clamp(0, 1, daysSinceUpdate / thresholdDays * 0.5 + structuralSectionsChanged / totalSections * 0.3 + 1 / distance * 0.2);
2603
+ } else {
2604
+ staleness = clamp(0, 1, structuralSectionsChanged / totalSections * 0.3 + 1 / distance * 0.2);
2605
+ }
2606
+ const parts = [];
2607
+ parts.push(`depends on ${changedSpecId} (distance ${distance})`);
2608
+ if (structuralSectionsChanged > 0) {
2609
+ parts.push(`${structuralSectionsChanged} structural section(s) changed`);
2610
+ }
2611
+ if (lastUpdated) {
2612
+ const days = Math.round(daysBetween(lastUpdated));
2613
+ parts.push(`last updated ${days} day(s) ago`);
2614
+ }
2615
+ const reason = parts.join("; ");
2616
+ downstream.push({
2617
+ specId,
2618
+ filePath,
2619
+ distance,
2620
+ lastUpdated,
2621
+ staleness,
2622
+ reason
2623
+ });
2624
+ }
2625
+ downstream.sort((a, b) => a.distance - b.distance || b.staleness - a.staleness);
2626
+ return {
2627
+ changedSpec: changedSpecId,
2628
+ downstream,
2629
+ totalAffected: downstream.length
2630
+ };
2631
+ }
2632
+
2633
+ // ../diff/dist/cross-refs.js
2634
+ function checkCrossReferences(allSpecs, removedIds) {
2635
+ const validIds = new Set(allSpecs.map((s) => s.frontmatter.id));
2636
+ for (const id of removedIds) {
2637
+ validIds.delete(id);
2638
+ }
2639
+ const broken = [];
2640
+ for (const spec of allSpecs) {
2641
+ const references = spec.frontmatter.references;
2642
+ if (!references || references.length === 0) {
2643
+ continue;
2644
+ }
2645
+ for (const ref of references) {
2646
+ if (!validIds.has(ref.id)) {
2647
+ broken.push({
2648
+ specId: spec.frontmatter.id,
2649
+ field: "references",
2650
+ type: "broken-reference",
2651
+ referencedId: ref.id
2652
+ });
2653
+ }
2654
+ }
2655
+ }
2656
+ return broken;
2657
+ }
2658
+
2659
+ // ../diff/dist/git.js
2660
+ import { execSync as execSync2 } from "child_process";
2661
+ import { realpathSync } from "fs";
2662
+ import { dirname as dirname2, relative, resolve as resolve2 } from "path";
2663
+ function getRepoRoot(cwd) {
2664
+ const root = execSync2("git rev-parse --show-toplevel", {
2665
+ cwd,
2666
+ encoding: "utf-8",
2667
+ stdio: "pipe"
2668
+ }).trim();
2669
+ return realpathSync(root);
2670
+ }
2671
+ function validateRef(ref, cwd) {
2672
+ try {
2673
+ execSync2(`git rev-parse --verify ${ref}`, { cwd, encoding: "utf-8", stdio: "pipe" });
2674
+ } catch {
2675
+ throw new DiffError(`Invalid git ref: "${ref}"`);
2676
+ }
2677
+ }
2678
+ function gitShow(ref, filePath, projectRoot, repoRoot) {
2679
+ const relPath = relative(repoRoot, resolve2(projectRoot, filePath));
2680
+ try {
2681
+ return execSync2(`git show ${ref}:${relPath}`, {
2682
+ cwd: repoRoot,
2683
+ encoding: "utf-8",
2684
+ stdio: "pipe"
2685
+ });
2686
+ } catch {
2687
+ throw new DiffError(`Cannot read "${filePath}" at ref "${ref}"`);
2688
+ }
2689
+ }
2690
+ function getChangedSpecFiles(baseRef, headRef, specPaths, projectRoot, repoRoot) {
2691
+ const repoRelToProjectRel = /* @__PURE__ */ new Map();
2692
+ for (const p of specPaths) {
2693
+ const repoRel = relative(repoRoot, resolve2(projectRoot, p));
2694
+ repoRelToProjectRel.set(repoRel, p);
2695
+ }
2696
+ let diffOutput;
2697
+ try {
2698
+ diffOutput = execSync2(`git diff --name-status ${baseRef} ${headRef}`, {
2699
+ cwd: repoRoot,
2700
+ encoding: "utf-8",
2701
+ stdio: "pipe"
2702
+ });
2703
+ } catch {
2704
+ throw new DiffError(`Failed to run git diff between "${baseRef}" and "${headRef}"`);
2705
+ }
2706
+ const result = { modified: [], added: [], deleted: [] };
2707
+ for (const line of diffOutput.trim().split("\n")) {
2708
+ if (!line)
2709
+ continue;
2710
+ const parts = line.split(" ");
2711
+ const status = parts[0];
2712
+ const filePath = parts[1];
2713
+ if (!status || !filePath)
2714
+ continue;
2715
+ const projectRelPath = repoRelToProjectRel.get(filePath);
2716
+ if (projectRelPath === void 0)
2717
+ continue;
2718
+ if (status === "M") {
2719
+ result.modified.push(projectRelPath);
2720
+ } else if (status === "A") {
2721
+ result.added.push(projectRelPath);
2722
+ } else if (status === "D") {
2723
+ result.deleted.push(projectRelPath);
2724
+ }
2725
+ }
2726
+ return result;
2727
+ }
2728
+ async function diffBetweenRefs(configPath, baseRef, headRef) {
2729
+ const projectRoot = realpathSync(dirname2(resolve2(configPath)));
2730
+ const repoRoot = getRepoRoot(projectRoot);
2731
+ validateRef(baseRef, projectRoot);
2732
+ validateRef(headRef, projectRoot);
2733
+ const config = await loadConfig(configPath);
2734
+ const specPaths = [];
2735
+ const specIdByPath = /* @__PURE__ */ new Map();
2736
+ for (const [specId, entry] of Object.entries(config.specs)) {
2737
+ specPaths.push(entry.path);
2738
+ specIdByPath.set(entry.path, specId);
2739
+ }
2740
+ const changed = getChangedSpecFiles(baseRef, headRef, specPaths, projectRoot, repoRoot);
2741
+ const diffs = [];
2742
+ for (const filePath of changed.modified) {
2743
+ const beforeContent = gitShow(baseRef, filePath, projectRoot, repoRoot);
2744
+ const afterContent = gitShow(headRef, filePath, projectRoot, repoRoot);
2745
+ const beforeSpec = await parseSpecFromString(beforeContent, filePath);
2746
+ const afterSpec = await parseSpecFromString(afterContent, filePath);
2747
+ const diff2 = diffSpecs(beforeSpec, afterSpec);
2748
+ diffs.push(diff2);
2749
+ }
2750
+ const added = changed.added.map((p) => specIdByPath.get(p)).filter((id) => id !== void 0);
2751
+ const removed = changed.deleted.map((p) => specIdByPath.get(p)).filter((id) => id !== void 0);
2752
+ const graph = buildGraph(config);
2753
+ const impact = [];
2754
+ const allSpecs = [];
2755
+ for (const entry of Object.values(config.specs)) {
2756
+ try {
2757
+ const content = gitShow(headRef, entry.path, projectRoot, repoRoot);
2758
+ const parsed = await parseSpecFromString(content, entry.path);
2759
+ allSpecs.push(parsed);
2760
+ } catch {
2761
+ }
2762
+ }
2763
+ const thresholdDays = config.diff?.staleness_threshold_days ?? 14;
2764
+ for (const diff2 of diffs) {
2765
+ const analysis = analyzeImpact(diff2.specId, diff2, graph, allSpecs, thresholdDays);
2766
+ if (analysis.totalAffected > 0) {
2767
+ impact.push(analysis);
2768
+ }
2769
+ }
2770
+ const _brokenRefs = checkCrossReferences(allSpecs, removed);
2771
+ const summaryParts = [];
2772
+ if (diffs.length > 0) {
2773
+ summaryParts.push(`${diffs.length} spec(s) modified`);
2774
+ }
2775
+ if (added.length > 0) {
2776
+ summaryParts.push(`${added.length} spec(s) added`);
2777
+ }
2778
+ if (removed.length > 0) {
2779
+ summaryParts.push(`${removed.length} spec(s) removed`);
2780
+ }
2781
+ if (impact.length > 0) {
2782
+ const totalDownstream = impact.reduce((sum, i) => sum + i.totalAffected, 0);
2783
+ summaryParts.push(`${totalDownstream} downstream spec(s) potentially affected`);
2784
+ }
2785
+ if (_brokenRefs.length > 0) {
2786
+ summaryParts.push(`${_brokenRefs.length} broken reference(s)`);
2787
+ }
2788
+ const summary = summaryParts.length > 0 ? summaryParts.join("; ") : "No changes detected";
2789
+ return { diffs, added, removed, impact, summary };
2790
+ }
2791
+
2792
+ // src/commands/diff.ts
2793
+ async function runDiff(options) {
2794
+ const configDir = process.cwd();
2795
+ const config = await loadConfig(void 0, configDir);
2796
+ const baseRef = options.base ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;
2797
+ const headRef = options.head ?? "HEAD";
2798
+ const configPath = join5(configDir, "spec.config.yaml");
2799
+ const result = await diffBetweenRefs(configPath, baseRef, headRef);
2800
+ if (options.spec) {
2801
+ result.diffs = result.diffs.filter((d) => d.specId === options.spec);
2802
+ result.impact = result.impact.filter((i) => i.changedSpec === options.spec);
2803
+ }
2804
+ return result;
2805
+ }
2806
+ var diff_default = defineCommand4({
2807
+ meta: { name: "diff", description: "Show spec changes and downstream impact" },
2808
+ args: {
2809
+ base: { type: "string", description: "Base git ref (default: from config or 'main')" },
2810
+ head: { type: "string", description: "Head git ref (default: HEAD)" },
2811
+ spec: { type: "string", description: "Scope to a single spec ID" },
2812
+ format: {
2813
+ type: "string",
2814
+ description: "Output format: pretty, json",
2815
+ default: "pretty"
2816
+ }
2817
+ },
2818
+ async run({ args }) {
2819
+ try {
2820
+ const result = await runDiff({
2821
+ base: args.base,
2822
+ head: args.head,
2823
+ spec: args.spec,
2824
+ format: args.format
2825
+ });
2826
+ if (args.format === "json") {
2827
+ console.log(JSON.stringify(result, null, 2));
2828
+ return;
2829
+ }
2830
+ if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
2831
+ console.log(" \u2713 No spec changes detected.");
2832
+ return;
2833
+ }
2834
+ console.log(result.summary);
2835
+ console.log();
2836
+ for (const diff2 of result.diffs) {
2837
+ console.log(` ${diff2.specId}:`);
2838
+ for (const fc of diff2.frontmatter) {
2839
+ const detail = fc.before !== void 0 || fc.after !== void 0 ? ` (${String(fc.before)} \u2192 ${String(fc.after)})` : "";
2840
+ console.log(` ${fc.type}: ${fc.field}${detail}`);
2841
+ }
2842
+ for (const sc of diff2.sections) {
2843
+ console.log(` ${sc.type}: ${sc.heading}`);
2844
+ }
2845
+ }
2846
+ if (result.added.length > 0) {
2847
+ console.log(`
2848
+ Added: ${result.added.join(", ")}`);
2849
+ }
2850
+ if (result.removed.length > 0) {
2851
+ console.log(`
2852
+ Removed: ${result.removed.join(", ")}`);
2853
+ }
2854
+ if (result.impact.length > 0) {
2855
+ console.log("\n Downstream Impact:");
2856
+ for (const impact of result.impact) {
2857
+ for (const d of impact.downstream) {
2858
+ console.log(
2859
+ ` ${d.specId} \u2014 staleness: ${d.staleness.toFixed(2)} \u2014 ${d.reason}`
2860
+ );
2861
+ }
2862
+ }
2863
+ }
2864
+ } catch (err) {
2865
+ if (err instanceof DiffError) {
2866
+ console.error(`
2867
+ \u2717 ${err.message}
2868
+ `);
2869
+ process.exit(1);
2870
+ }
2871
+ throw err;
2872
+ }
2873
+ }
2874
+ });
2875
+
2876
+ // src/commands/status.ts
2877
+ import { defineCommand as defineCommand5 } from "citty";
2878
+ async function runStatus(_options = {}) {
2879
+ const configDir = process.cwd();
2880
+ const config = await loadConfig(void 0, configDir);
2881
+ const specs = [];
2882
+ for (const [, entry] of Object.entries(config.specs)) {
2883
+ const paths = await resolveGlob(entry.path, configDir);
2884
+ for (const p of paths) {
2885
+ const spec = await parseSpec(p);
2886
+ specs.push({ spec, entry });
2887
+ }
2888
+ }
2889
+ const byStatus = {};
2890
+ for (const { spec } of specs) {
2891
+ const status = spec.frontmatter.status || "unknown";
2892
+ byStatus[status] = (byStatus[status] ?? 0) + 1;
2893
+ }
2894
+ const presetName = config.lint?.extends ?? "recommended";
2895
+ const rules = getPreset(presetName);
2896
+ let graph;
2897
+ let graphError;
2898
+ try {
2899
+ graph = buildGraph(config);
2900
+ } catch (err) {
2901
+ graphError = err.message;
2902
+ }
2903
+ const engine = createLintEngine({ rules, config, graph });
2904
+ const lintResults = engine.lint(specs.map((s) => s.spec));
2905
+ if (graphError) {
2906
+ lintResults.diagnostics.push({
2907
+ ruleId: "structure/no-circular-deps",
2908
+ severity: "error",
2909
+ message: graphError,
2910
+ filePath: "spec.config.yaml"
2911
+ });
2912
+ lintResults.hasErrors = true;
2913
+ }
2914
+ const errors = lintResults.diagnostics.filter((d) => d.severity === "error").length;
2915
+ const warnings = lintResults.diagnostics.filter((d) => d.severity === "warn").length;
2916
+ const thresholdDays = config.diff?.staleness_threshold_days ?? DEFAULT_DIFF_CONFIG.staleness_threshold_days;
2917
+ const now = Date.now();
2918
+ const staleSpecs = [];
2919
+ for (const { spec, entry } of specs) {
2920
+ const dateStr = spec.frontmatter.updated || spec.frontmatter.created;
2921
+ if (dateStr) {
2922
+ const daysSinceUpdate = Math.floor(
2923
+ (now - new Date(dateStr).getTime()) / (1e3 * 60 * 60 * 24)
2924
+ );
2925
+ if (daysSinceUpdate > thresholdDays) {
2926
+ staleSpecs.push({
2927
+ specId: spec.frontmatter.id,
2928
+ daysSinceUpdate,
2929
+ owner: entry.owner
2930
+ });
2931
+ }
2932
+ }
2933
+ }
2934
+ const integrityIssues = [];
2935
+ if (graphError) {
2936
+ integrityIssues.push(graphError);
2937
+ }
2938
+ const refErrors = lintResults.diagnostics.filter(
2939
+ (d) => d.ruleId === "structure/valid-references"
2940
+ );
2941
+ for (const d of refErrors) {
2942
+ integrityIssues.push(d.message);
2943
+ }
2944
+ let verdict = "healthy";
2945
+ if (errors > 0) verdict = "errors";
2946
+ else if (warnings > 0 || staleSpecs.length > 0) verdict = "warnings";
2947
+ return {
2948
+ project: config.project?.name ?? "unknown",
2949
+ specCount: specs.length,
2950
+ byStatus,
2951
+ lintHealth: { errors, warnings, passing: specs.length - errors },
2952
+ staleSpecs,
2953
+ integrityIssues,
2954
+ verdict
2955
+ };
2956
+ }
2957
+ var status_default = defineCommand5({
2958
+ meta: { name: "status", description: "Show spec suite health overview" },
2959
+ args: {
2960
+ format: {
2961
+ type: "string",
2962
+ description: "Output format: pretty, json, github",
2963
+ default: "pretty"
2964
+ }
2965
+ },
2966
+ async run({ args }) {
2967
+ const result = await runStatus({ format: args.format });
2968
+ if (args.format === "json") {
2969
+ console.log(JSON.stringify(result, null, 2));
2970
+ return;
2971
+ }
2972
+ if (args.format === "github") {
2973
+ for (const s of result.staleSpecs) {
2974
+ console.log(
2975
+ `::warning::Spec "${s.specId}" is stale (${s.daysSinceUpdate} days since update)`
2976
+ );
2977
+ }
2978
+ for (const issue of result.integrityIssues) {
2979
+ console.log(`::error::${issue}`);
2980
+ }
2981
+ return;
2982
+ }
2983
+ const icon = result.verdict === "healthy" ? "\u2713" : result.verdict === "warnings" ? "\u26A0" : "\u2717";
2984
+ console.log(`
2985
+ ${icon} ${result.project} \u2014 ${result.verdict}`);
2986
+ console.log(
2987
+ ` ${result.specCount} specs: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
2988
+ );
2989
+ console.log(` Lint: ${result.lintHealth.errors} errors, ${result.lintHealth.warnings} warnings`);
2990
+ if (result.staleSpecs.length > 0) {
2991
+ console.log(
2992
+ ` Stale: ${result.staleSpecs.map((s) => `${s.specId} (${s.daysSinceUpdate}d)`).join(", ")}`
2993
+ );
2994
+ }
2995
+ if (result.integrityIssues.length > 0) {
2996
+ console.log(` Issues: ${result.integrityIssues.join("; ")}`);
2997
+ }
2998
+ console.log();
2999
+ }
3000
+ });
3001
+
3002
+ // src/commands/changelog.ts
3003
+ import { defineCommand as defineCommand6 } from "citty";
3004
+ import { join as join6 } from "path";
3005
+ async function runChangelog(options) {
3006
+ const configDir = process.cwd();
3007
+ const config = await loadConfig(void 0, configDir);
3008
+ const fromRef = options.from ?? config.diff?.baseline_ref ?? DEFAULT_DIFF_CONFIG.baseline_ref;
3009
+ const toRef = options.to ?? "HEAD";
3010
+ const configPath = join6(configDir, "spec.config.yaml");
3011
+ const result = await diffBetweenRefs(configPath, fromRef, toRef);
3012
+ const lines = [];
3013
+ lines.push(`## Spec Changes (${fromRef}..${toRef})
3014
+ `);
3015
+ if (result.diffs.length > 0) {
3016
+ lines.push("### Modified");
3017
+ for (const diff2 of result.diffs) {
3018
+ const sections = diff2.sections.map((s) => s.heading).join(", ");
3019
+ const versionChange = diff2.frontmatter.find((f) => f.field === "version");
3020
+ const versionStr = versionChange ? ` (${String(versionChange.before)} \u2192 ${String(versionChange.after)})` : "";
3021
+ lines.push(`- **${diff2.specId}**${versionStr} \u2014 ${sections || "frontmatter only"}`);
3022
+ }
3023
+ lines.push("");
3024
+ }
3025
+ if (result.added.length > 0) {
3026
+ lines.push("### Added");
3027
+ for (const id of result.added) {
3028
+ lines.push(`- **${id}**`);
3029
+ }
3030
+ lines.push("");
3031
+ }
3032
+ if (result.removed.length > 0) {
3033
+ lines.push("### Removed");
3034
+ for (const id of result.removed) {
3035
+ lines.push(`- **${id}**`);
3036
+ }
3037
+ lines.push("");
3038
+ }
3039
+ const allDownstream = result.impact.flatMap((i) => i.downstream);
3040
+ if (allDownstream.length > 0) {
3041
+ lines.push("### Downstream Impact");
3042
+ for (const d of allDownstream) {
3043
+ lines.push(`- ${d.specId} may be stale (${d.reason})`);
3044
+ }
3045
+ lines.push("");
3046
+ }
3047
+ if (result.diffs.length === 0 && result.added.length === 0 && result.removed.length === 0) {
3048
+ lines.push("No spec changes detected.\n");
3049
+ }
3050
+ return lines.join("\n");
3051
+ }
3052
+ var changelog_default = defineCommand6({
3053
+ meta: { name: "changelog", description: "Generate changelog of spec changes between git refs" },
3054
+ args: {
3055
+ from: { type: "string", description: "Start git ref (default: from config or 'main')" },
3056
+ to: { type: "string", description: "End git ref (default: HEAD)" }
3057
+ },
3058
+ async run({ args }) {
3059
+ try {
3060
+ const output = await runChangelog(args);
3061
+ console.log(output);
3062
+ } catch (err) {
3063
+ if (err instanceof DiffError) {
3064
+ console.error(`
3065
+ \u2717 ${err.message}
3066
+ `);
3067
+ process.exit(1);
3068
+ }
3069
+ throw err;
3070
+ }
3071
+ }
3072
+ });
3073
+
3074
+ // src/commands/explain.ts
3075
+ import { defineCommand as defineCommand7 } from "citty";
3076
+ async function runExplain(_options = {}) {
3077
+ const configDir = process.cwd();
3078
+ const config = await loadConfig(void 0, configDir);
3079
+ const specs = [];
3080
+ for (const [, entry] of Object.entries(config.specs)) {
3081
+ const paths = await resolveGlob(entry.path, configDir);
3082
+ for (const p of paths) {
3083
+ specs.push(await parseSpec(p));
3084
+ }
3085
+ }
3086
+ const byType = {};
3087
+ const byStatus = {};
3088
+ for (const spec of specs) {
3089
+ const type = spec.frontmatter.type || "unknown";
3090
+ const status = spec.frontmatter.status || "unknown";
3091
+ byType[type] = (byType[type] ?? 0) + 1;
3092
+ byStatus[status] = (byStatus[status] ?? 0) + 1;
3093
+ }
3094
+ const specSummaries = specs.map((spec) => {
3095
+ const firstSection = spec.parsedSections[0];
3096
+ const firstLine = firstSection?.content?.split("\n").find((l) => l.trim().length > 0)?.trim() ?? "";
3097
+ const truncated = firstLine.slice(0, 120) + (firstLine.length > 120 ? "..." : "");
3098
+ return {
3099
+ id: spec.frontmatter.id,
3100
+ type: spec.frontmatter.type,
3101
+ title: spec.frontmatter.title,
3102
+ status: spec.frontmatter.status,
3103
+ firstLine: truncated
3104
+ };
3105
+ });
3106
+ const graph = buildGraph(config);
3107
+ const graphLines = [];
3108
+ for (const node of graph.nodes) {
3109
+ const downstream = graph.edges.filter((e) => e.from === node).map((e) => e.to);
3110
+ if (downstream.length > 0) {
3111
+ graphLines.push(`${node} \u2192 ${downstream.join(", ")}`);
3112
+ } else {
3113
+ graphLines.push(node);
3114
+ }
3115
+ }
3116
+ return {
3117
+ project: config.project?.name ?? "unknown",
3118
+ description: config.project?.description,
3119
+ specCount: specs.length,
3120
+ byType,
3121
+ byStatus,
3122
+ specs: specSummaries,
3123
+ graph: graphLines
3124
+ };
3125
+ }
3126
+ var explain_default = defineCommand7({
3127
+ meta: { name: "explain", description: "Explain the spec suite for onboarding" },
3128
+ args: {
3129
+ format: { type: "string", description: "Output format: pretty, json", default: "pretty" }
3130
+ },
3131
+ async run({ args }) {
3132
+ const result = await runExplain({ format: args.format });
3133
+ if (args.format === "json") {
3134
+ console.log(JSON.stringify(result, null, 2));
3135
+ return;
3136
+ }
3137
+ console.log(`
3138
+ ${result.project}`);
3139
+ if (result.description) {
3140
+ console.log(` ${result.description}`);
3141
+ }
3142
+ console.log(
3143
+ `
3144
+ ${result.specCount} specs: ${Object.entries(result.byType).map(([k, v]) => `${v} ${k}`).join(", ")}`
3145
+ );
3146
+ console.log(
3147
+ ` Status: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
3148
+ );
3149
+ console.log("\n Specs:");
3150
+ for (const spec of result.specs) {
3151
+ console.log(` ${spec.id} (${spec.type}, ${spec.status}) \u2014 ${spec.title}`);
3152
+ if (spec.firstLine) {
3153
+ console.log(` ${spec.firstLine}`);
3154
+ }
3155
+ }
3156
+ console.log("\n Dependencies:");
3157
+ for (const line of result.graph) {
3158
+ console.log(` ${line}`);
3159
+ }
3160
+ console.log();
3161
+ }
3162
+ });
1621
3163
  export {
3164
+ runChangelog,
3165
+ runDiff,
3166
+ runExplain,
1622
3167
  runLint,
1623
3168
  runPack,
3169
+ runStatus,
1624
3170
  scaffoldProject
1625
3171
  };
1626
3172
  //# sourceMappingURL=index.js.map