specdx 0.4.0-alpha.16 → 0.4.0-alpha.18
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/.claude-plugin/plugin.json +1 -1
- package/README.md +435 -0
- package/dist/{check-6ULNLONS.js → check-PQQGR4KP.js} +6 -6
- package/dist/check-PQQGR4KP.js.map +1 -0
- package/dist/chunk-33FELECG.js +179 -0
- package/dist/chunk-33FELECG.js.map +1 -0
- package/dist/{chunk-4HPWTWBL.js → chunk-AXCGMUU7.js} +11 -6
- package/dist/chunk-AXCGMUU7.js.map +1 -0
- package/dist/{chunk-V7JOVK6D.js → chunk-FX4NRQHE.js} +139 -32
- package/dist/chunk-FX4NRQHE.js.map +1 -0
- package/dist/{chunk-PEC5LAVE.js → chunk-RI2SFGMR.js} +13 -5
- package/dist/chunk-RI2SFGMR.js.map +1 -0
- package/dist/{chunk-SDDTD4R3.js → chunk-TF7WSPFV.js} +31 -11
- package/dist/chunk-TF7WSPFV.js.map +1 -0
- package/dist/{diff-AWFDXYX4.js → diff-IOBAJMKU.js} +4 -4
- package/dist/diff-IOBAJMKU.js.map +1 -0
- package/dist/{dist-2YMKBA6A.js → dist-HRY2V5MO.js} +12 -6
- package/dist/dist-HRY2V5MO.js.map +1 -0
- package/dist/{dist-SWJSMLIP.js → dist-WXT4UJ55.js} +2 -2
- package/dist/generate-NSTYQOAV.js +21 -0
- package/dist/generate-NSTYQOAV.js.map +1 -0
- package/dist/{generate-story-OV3PFJN6.js → generate-story-RFAPULQY.js} +32 -7
- package/dist/generate-story-RFAPULQY.js.map +1 -0
- package/dist/{generate-test-plan-OGWEIXR2.js → generate-test-plan-M22PCW73.js} +13 -3
- package/dist/generate-test-plan-M22PCW73.js.map +1 -0
- package/dist/{graph-KZDCVMLT.js → graph-OKUMHR3Q.js} +2 -2
- package/dist/graph-OKUMHR3Q.js.map +1 -0
- package/dist/index.js +170 -141
- package/dist/index.js.map +1 -1
- package/dist/{lint-A5AXYDSO.js → lint-ADR7L6AP.js} +4 -4
- package/dist/lint-ADR7L6AP.js.map +1 -0
- package/dist/main.js +19 -142
- package/dist/main.js.map +1 -1
- package/dist/{mcp-CWJKX27S.js → mcp-A6CCWSS2.js} +3 -3
- package/dist/mcp-A6CCWSS2.js.map +1 -0
- package/dist/{migrate-76BXVREF.js → migrate-LAMRDT3V.js} +3 -3
- package/dist/migrate-LAMRDT3V.js.map +1 -0
- package/dist/{pack-I5WFM6B6.js → pack-B3KYRKUR.js} +3 -3
- package/dist/pack-B3KYRKUR.js.map +1 -0
- package/dist/{ready-2M5HXTRZ.js → ready-GH4YKVOX.js} +14 -5
- package/dist/ready-GH4YKVOX.js.map +1 -0
- package/dist/skills/core/specdx-onboard/SKILL.md +3 -2
- package/dist/{skills-IKRQ3IZP.js → skills-LHFTTEJ7.js} +3 -3
- package/dist/skills-LHFTTEJ7.js.map +1 -0
- package/dist/{status-QLG3ZKS7.js → status-PQKPTDP5.js} +4 -4
- package/dist/status-PQKPTDP5.js.map +1 -0
- package/dist/{update-HGZVLKSL.js → update-VAC6XV5E.js} +4 -4
- package/dist/update-VAC6XV5E.js.map +1 -0
- package/dist/{validate-HMOCZJ2M.js → validate-WIB246IE.js} +2 -2
- package/dist/validate-WIB246IE.js.map +1 -0
- package/hooks/hooks.json +1 -1
- package/package.json +19 -6
- package/dist/check-6ULNLONS.js.map +0 -1
- package/dist/chunk-4HPWTWBL.js.map +0 -1
- package/dist/chunk-PEC5LAVE.js.map +0 -1
- package/dist/chunk-SDDTD4R3.js.map +0 -1
- package/dist/chunk-V7JOVK6D.js.map +0 -1
- package/dist/diff-AWFDXYX4.js.map +0 -1
- package/dist/dist-2YMKBA6A.js.map +0 -1
- package/dist/explain-M2VXXXGP.js +0 -113
- package/dist/explain-M2VXXXGP.js.map +0 -1
- package/dist/generate-XG52JCWH.js +0 -15
- package/dist/generate-XG52JCWH.js.map +0 -1
- package/dist/generate-story-OV3PFJN6.js.map +0 -1
- package/dist/generate-test-plan-OGWEIXR2.js.map +0 -1
- package/dist/graph-KZDCVMLT.js.map +0 -1
- package/dist/lint-A5AXYDSO.js.map +0 -1
- package/dist/mcp-CWJKX27S.js.map +0 -1
- package/dist/migrate-76BXVREF.js.map +0 -1
- package/dist/pack-I5WFM6B6.js.map +0 -1
- package/dist/ready-2M5HXTRZ.js.map +0 -1
- package/dist/skills-IKRQ3IZP.js.map +0 -1
- package/dist/status-QLG3ZKS7.js.map +0 -1
- package/dist/update-HGZVLKSL.js.map +0 -1
- package/dist/validate-HMOCZJ2M.js.map +0 -1
- /package/dist/{dist-SWJSMLIP.js.map → dist-WXT4UJ55.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1542,7 +1542,7 @@ var require_picomatch2 = __commonJS({
|
|
|
1542
1542
|
}
|
|
1543
1543
|
});
|
|
1544
1544
|
|
|
1545
|
-
// src/commands/init.ts
|
|
1545
|
+
// src/commands/core/init.ts
|
|
1546
1546
|
import { defineCommand } from "citty";
|
|
1547
1547
|
import { mkdir, writeFile } from "fs/promises";
|
|
1548
1548
|
import { join } from "path";
|
|
@@ -1976,7 +1976,7 @@ function validateConfig(data) {
|
|
|
1976
1976
|
return { valid: !!valid, errors: valid ? null : configValidator.errors ?? null };
|
|
1977
1977
|
}
|
|
1978
1978
|
|
|
1979
|
-
// src/commands/init.ts
|
|
1979
|
+
// src/commands/core/init.ts
|
|
1980
1980
|
var TEMPLATE_SPECS = {
|
|
1981
1981
|
lightweight: [
|
|
1982
1982
|
{ filename: "prd.md", type: "prd" },
|
|
@@ -2094,7 +2094,7 @@ var init_default = defineCommand({
|
|
|
2094
2094
|
}
|
|
2095
2095
|
});
|
|
2096
2096
|
|
|
2097
|
-
// src/commands/lint.ts
|
|
2097
|
+
// src/commands/core/lint.ts
|
|
2098
2098
|
import { defineCommand as defineCommand2 } from "citty";
|
|
2099
2099
|
|
|
2100
2100
|
// ../core/dist/config.js
|
|
@@ -2512,6 +2512,18 @@ function createLintEngine(options) {
|
|
|
2512
2512
|
}
|
|
2513
2513
|
|
|
2514
2514
|
// ../lint/dist/rules/valid-frontmatter.js
|
|
2515
|
+
function readablePath(instancePath) {
|
|
2516
|
+
return instancePath.split("/").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? `[${segment}]` : `.${segment}`).join("").replace(/^\./, "");
|
|
2517
|
+
}
|
|
2518
|
+
function describeValidationError(err) {
|
|
2519
|
+
const path = readablePath(err.instancePath ?? "");
|
|
2520
|
+
const allowed = err.params?.allowedValues;
|
|
2521
|
+
let detail = err.message ?? JSON.stringify(err);
|
|
2522
|
+
if (Array.isArray(allowed) && allowed.length > 0) {
|
|
2523
|
+
detail += `: ${allowed.map((v) => JSON.stringify(v)).join(", ")}`;
|
|
2524
|
+
}
|
|
2525
|
+
return path ? `${path} ${detail}` : detail;
|
|
2526
|
+
}
|
|
2515
2527
|
var validFrontmatterRule = {
|
|
2516
2528
|
id: "structure/valid-frontmatter",
|
|
2517
2529
|
description: "Frontmatter matches the schema for the declared spec type",
|
|
@@ -2523,7 +2535,7 @@ var validFrontmatterRule = {
|
|
|
2523
2535
|
return errors.map((err) => ({
|
|
2524
2536
|
ruleId: "structure/valid-frontmatter",
|
|
2525
2537
|
severity: "error",
|
|
2526
|
-
message: `Invalid frontmatter: ${
|
|
2538
|
+
message: `Invalid frontmatter: ${describeValidationError(err)}`,
|
|
2527
2539
|
filePath: context.spec.filePath
|
|
2528
2540
|
}));
|
|
2529
2541
|
}
|
|
@@ -2583,7 +2595,106 @@ var noCircularDepsRule = {
|
|
|
2583
2595
|
};
|
|
2584
2596
|
|
|
2585
2597
|
// ../lint/dist/rules/story-coverage.js
|
|
2586
|
-
var
|
|
2598
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
2599
|
+
"a",
|
|
2600
|
+
"an",
|
|
2601
|
+
"the",
|
|
2602
|
+
"and",
|
|
2603
|
+
"or",
|
|
2604
|
+
"of",
|
|
2605
|
+
"to",
|
|
2606
|
+
"for",
|
|
2607
|
+
"with",
|
|
2608
|
+
"its",
|
|
2609
|
+
"it",
|
|
2610
|
+
"in",
|
|
2611
|
+
"on",
|
|
2612
|
+
"at",
|
|
2613
|
+
"by",
|
|
2614
|
+
"from",
|
|
2615
|
+
"into",
|
|
2616
|
+
"every",
|
|
2617
|
+
"each",
|
|
2618
|
+
"that",
|
|
2619
|
+
"this",
|
|
2620
|
+
"be",
|
|
2621
|
+
"is",
|
|
2622
|
+
"are",
|
|
2623
|
+
"as",
|
|
2624
|
+
"can",
|
|
2625
|
+
"will",
|
|
2626
|
+
"must",
|
|
2627
|
+
"so",
|
|
2628
|
+
"their",
|
|
2629
|
+
"them",
|
|
2630
|
+
"when",
|
|
2631
|
+
"which",
|
|
2632
|
+
"who"
|
|
2633
|
+
]);
|
|
2634
|
+
var OVERLAP_THRESHOLD = 0.5;
|
|
2635
|
+
var REFERENCED_THRESHOLD = 0.34;
|
|
2636
|
+
function tokenise(text) {
|
|
2637
|
+
const words = text.toLowerCase().replace(/[^a-z0-9\s-]/g, " ").split(/\s+/).filter((w) => w.length > 2 && !STOPWORDS.has(w)).map((w) => w.length > 3 && w.endsWith("s") && !w.endsWith("ss") ? w.slice(0, -1) : w);
|
|
2638
|
+
return new Set(words);
|
|
2639
|
+
}
|
|
2640
|
+
function extractFeatureSection(content) {
|
|
2641
|
+
const lines = content.split("\n");
|
|
2642
|
+
const start = lines.findIndex((l) => /^##\s+Features\s*$/.test(l.trim()));
|
|
2643
|
+
if (start === -1)
|
|
2644
|
+
return null;
|
|
2645
|
+
const body = [];
|
|
2646
|
+
for (let i = start + 1; i < lines.length; i++) {
|
|
2647
|
+
if (/^##\s/.test(lines[i]))
|
|
2648
|
+
break;
|
|
2649
|
+
body.push(lines[i]);
|
|
2650
|
+
}
|
|
2651
|
+
return body.join("\n");
|
|
2652
|
+
}
|
|
2653
|
+
function parseFeatures(content) {
|
|
2654
|
+
const section = extractFeatureSection(content);
|
|
2655
|
+
if (section === null)
|
|
2656
|
+
return [];
|
|
2657
|
+
const ID_PREFIX = /^\*{0,2}F\d+\*{0,2}\s*[:.-]\s*/i;
|
|
2658
|
+
const features = [];
|
|
2659
|
+
for (const rawLine of section.split("\n")) {
|
|
2660
|
+
const line = rawLine.trim();
|
|
2661
|
+
if (!line)
|
|
2662
|
+
continue;
|
|
2663
|
+
const bullet = /^[-*]\s+(.*)$/.exec(line);
|
|
2664
|
+
const text = bullet ? (bullet[1] ?? "").trim() : ID_PREFIX.test(line) ? line : "";
|
|
2665
|
+
if (!text)
|
|
2666
|
+
continue;
|
|
2667
|
+
const stripped = text.replace(ID_PREFIX, "").trim();
|
|
2668
|
+
if (stripped)
|
|
2669
|
+
features.push(stripped);
|
|
2670
|
+
}
|
|
2671
|
+
return features;
|
|
2672
|
+
}
|
|
2673
|
+
function overlap(featureTokens, storyTokens) {
|
|
2674
|
+
if (featureTokens.size === 0)
|
|
2675
|
+
return 0;
|
|
2676
|
+
let shared = 0;
|
|
2677
|
+
for (const token of featureTokens)
|
|
2678
|
+
if (storyTokens.has(token))
|
|
2679
|
+
shared++;
|
|
2680
|
+
return shared / featureTokens.size;
|
|
2681
|
+
}
|
|
2682
|
+
function referencesSpec(story, specId) {
|
|
2683
|
+
const refs = story.frontmatter.references;
|
|
2684
|
+
if (!Array.isArray(refs))
|
|
2685
|
+
return false;
|
|
2686
|
+
return refs.some((r) => r?.id === specId);
|
|
2687
|
+
}
|
|
2688
|
+
function uncoveredFeatures(features, stories, prdId) {
|
|
2689
|
+
const scored = stories.map((story) => ({
|
|
2690
|
+
tokens: tokenise(`${String(story.frontmatter.title ?? "")} ${story.content}`),
|
|
2691
|
+
threshold: referencesSpec(story, prdId) ? REFERENCED_THRESHOLD : OVERLAP_THRESHOLD
|
|
2692
|
+
}));
|
|
2693
|
+
return features.filter((feature) => {
|
|
2694
|
+
const featureTokens = tokenise(feature);
|
|
2695
|
+
return !scored.some((s) => overlap(featureTokens, s.tokens) >= s.threshold);
|
|
2696
|
+
});
|
|
2697
|
+
}
|
|
2587
2698
|
var storyCoverageRule = {
|
|
2588
2699
|
id: "completeness/story-coverage",
|
|
2589
2700
|
description: "Every feature listed in a PRD has at least one corresponding user story",
|
|
@@ -2591,17 +2702,11 @@ var storyCoverageRule = {
|
|
|
2591
2702
|
run(context) {
|
|
2592
2703
|
if (context.spec.frontmatter.type !== "prd")
|
|
2593
2704
|
return [];
|
|
2594
|
-
const features =
|
|
2595
|
-
let match;
|
|
2596
|
-
const re = new RegExp(FEATURE_PATTERN.source, "g");
|
|
2597
|
-
while ((match = re.exec(context.spec.content)) !== null) {
|
|
2598
|
-
features.push(match[1].trim());
|
|
2599
|
-
}
|
|
2705
|
+
const features = parseFeatures(context.spec.content);
|
|
2600
2706
|
if (features.length === 0)
|
|
2601
2707
|
return [];
|
|
2602
2708
|
const stories = context.allSpecs.filter((s) => s.frontmatter.type === "user-story");
|
|
2603
|
-
|
|
2604
|
-
return features.filter((feature) => !storyContent.toLowerCase().includes(feature.toLowerCase())).map((feature) => ({
|
|
2709
|
+
return uncoveredFeatures(features, stories, context.spec.frontmatter.id).map((feature) => ({
|
|
2605
2710
|
ruleId: "completeness/story-coverage",
|
|
2606
2711
|
severity: "warn",
|
|
2607
2712
|
message: `Feature "${feature}" has no corresponding user story`,
|
|
@@ -2896,7 +3001,7 @@ var namingConventionsRule = {
|
|
|
2896
3001
|
};
|
|
2897
3002
|
|
|
2898
3003
|
// ../lint/dist/rules/threat-coverage.js
|
|
2899
|
-
var
|
|
3004
|
+
var STOPWORDS2 = /* @__PURE__ */ new Set(["the", "and", "for", "with", "from", "that", "this", "into", "via"]);
|
|
2900
3005
|
function extractThreats(content) {
|
|
2901
3006
|
const parts = content.split(/^(?=## )/m);
|
|
2902
3007
|
const threats = [];
|
|
@@ -2909,7 +3014,7 @@ function extractThreats(content) {
|
|
|
2909
3014
|
return threats;
|
|
2910
3015
|
}
|
|
2911
3016
|
function extractKeyTerms(text) {
|
|
2912
|
-
return text.toLowerCase().split(/\W+/).filter((w) => w.length > 3).filter((w) => !
|
|
3017
|
+
return text.toLowerCase().split(/\W+/).filter((w) => w.length > 3).filter((w) => !STOPWORDS2.has(w));
|
|
2913
3018
|
}
|
|
2914
3019
|
var threatCoverageRule = {
|
|
2915
3020
|
id: "security/threat-coverage",
|
|
@@ -3059,7 +3164,7 @@ function formatGithub(diagnostics) {
|
|
|
3059
3164
|
}).join("\n");
|
|
3060
3165
|
}
|
|
3061
3166
|
|
|
3062
|
-
// src/commands/lint.ts
|
|
3167
|
+
// src/commands/core/lint.ts
|
|
3063
3168
|
async function runLint(options) {
|
|
3064
3169
|
const config = await loadConfig(void 0, options.configDir);
|
|
3065
3170
|
const preset = options.preset ?? config.lint?.extends ?? "recommended";
|
|
@@ -3134,11 +3239,11 @@ var lint_default = defineCommand2({
|
|
|
3134
3239
|
}
|
|
3135
3240
|
});
|
|
3136
3241
|
|
|
3137
|
-
// src/commands/pack.ts
|
|
3242
|
+
// src/commands/core/pack.ts
|
|
3138
3243
|
import { defineCommand as defineCommand3 } from "citty";
|
|
3139
3244
|
|
|
3140
3245
|
// ../pack/dist/resolver.js
|
|
3141
|
-
var
|
|
3246
|
+
var STOPWORDS3 = /* @__PURE__ */ new Set([
|
|
3142
3247
|
"a",
|
|
3143
3248
|
"an",
|
|
3144
3249
|
"and",
|
|
@@ -3215,7 +3320,7 @@ var STOPWORDS2 = /* @__PURE__ */ new Set([
|
|
|
3215
3320
|
"your"
|
|
3216
3321
|
]);
|
|
3217
3322
|
function tokenize(task) {
|
|
3218
|
-
return task.split(/[\s\-_/.,;:!?()[\]{}'"]+/).map((t) => t.toLowerCase()).filter((t) => t.length > 1 && !
|
|
3323
|
+
return task.split(/[\s\-_/.,;:!?()[\]{}'"]+/).map((t) => t.toLowerCase()).filter((t) => t.length > 1 && !STOPWORDS3.has(t));
|
|
3219
3324
|
}
|
|
3220
3325
|
var WEIGHT_TAGS = 3;
|
|
3221
3326
|
var WEIGHT_TITLE = 3;
|
|
@@ -3495,12 +3600,18 @@ function allocate(specs, scores, options) {
|
|
|
3495
3600
|
for (const spec of specs) {
|
|
3496
3601
|
specMap.set(spec.frontmatter.id, spec);
|
|
3497
3602
|
}
|
|
3603
|
+
function tokensOf(compressed) {
|
|
3604
|
+
if (compressed.collapsed)
|
|
3605
|
+
return countTokens(compressed.collapsedSummary ?? "");
|
|
3606
|
+
return compressed.sections.reduce((sum, section) => sum + section.tokens, 0);
|
|
3607
|
+
}
|
|
3498
3608
|
const items = [];
|
|
3499
3609
|
for (const score of scores) {
|
|
3500
3610
|
const spec = specMap.get(score.specId);
|
|
3501
3611
|
if (!spec)
|
|
3502
3612
|
continue;
|
|
3503
3613
|
let compressed;
|
|
3614
|
+
let stale;
|
|
3504
3615
|
if (options.full) {
|
|
3505
3616
|
compressed = {
|
|
3506
3617
|
specId: score.specId,
|
|
@@ -3516,20 +3627,34 @@ function allocate(specs, scores, options) {
|
|
|
3516
3627
|
collapsed: false
|
|
3517
3628
|
};
|
|
3518
3629
|
} else {
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
tokens += section.tokens;
|
|
3630
|
+
const compress = (compression) => compressSpec(score.specId, String(spec.frontmatter.type), String(spec.frontmatter.title), spec.frontmatter.status, spec.frontmatter.updated, spec.parsedSections, compression);
|
|
3631
|
+
compressed = compress({ ...options.compression, stableDays: 0 });
|
|
3632
|
+
if (options.compression.stableDays > 0) {
|
|
3633
|
+
const collapsed = compress(options.compression);
|
|
3634
|
+
const collapsedTokens = tokensOf(collapsed);
|
|
3635
|
+
if (collapsedTokens < tokensOf(compressed)) {
|
|
3636
|
+
stale = { spec: collapsed, tokens: collapsedTokens };
|
|
3637
|
+
}
|
|
3528
3638
|
}
|
|
3529
3639
|
}
|
|
3530
|
-
items.push({
|
|
3640
|
+
items.push({
|
|
3641
|
+
compressed,
|
|
3642
|
+
relevance: score.score,
|
|
3643
|
+
tokens: tokensOf(compressed),
|
|
3644
|
+
idMatched: score.idMatched ?? false,
|
|
3645
|
+
stale
|
|
3646
|
+
});
|
|
3531
3647
|
}
|
|
3532
3648
|
items.sort((a, b) => b.relevance - a.relevance || Number(b.idMatched) - Number(a.idMatched));
|
|
3649
|
+
let projected = items.reduce((sum, item) => sum + item.tokens, 0);
|
|
3650
|
+
for (let i = items.length - 1; i >= 0 && projected > options.budget; i--) {
|
|
3651
|
+
const item = items[i];
|
|
3652
|
+
if (!item.stale)
|
|
3653
|
+
continue;
|
|
3654
|
+
projected -= item.tokens - item.stale.tokens;
|
|
3655
|
+
item.compressed = item.stale.spec;
|
|
3656
|
+
item.tokens = item.stale.tokens;
|
|
3657
|
+
}
|
|
3533
3658
|
const totalTokens = items.reduce((sum, item) => sum + item.tokens, 0);
|
|
3534
3659
|
const withinBudget = totalTokens <= options.budget;
|
|
3535
3660
|
const included = [];
|
|
@@ -3796,7 +3921,7 @@ function pack(specs, options, packConfig, graph) {
|
|
|
3796
3921
|
return { output, stats };
|
|
3797
3922
|
}
|
|
3798
3923
|
|
|
3799
|
-
// src/commands/pack.ts
|
|
3924
|
+
// src/commands/core/pack.ts
|
|
3800
3925
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
3801
3926
|
import { execSync } from "child_process";
|
|
3802
3927
|
function copyToClipboard(text) {
|
|
@@ -3966,7 +4091,7 @@ var pack_default = defineCommand3({
|
|
|
3966
4091
|
}
|
|
3967
4092
|
});
|
|
3968
4093
|
|
|
3969
|
-
// src/commands/diff.ts
|
|
4094
|
+
// src/commands/core/diff.ts
|
|
3970
4095
|
import { defineCommand as defineCommand4 } from "citty";
|
|
3971
4096
|
import { join as join5 } from "path";
|
|
3972
4097
|
|
|
@@ -4396,8 +4521,8 @@ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep
|
|
|
4396
4521
|
} else if (endKeep) {
|
|
4397
4522
|
var endKeepWsPrefix = endKeep.value.match(/^\s*/)[0];
|
|
4398
4523
|
var deletionWsSuffix = deletion.value.match(/\s*$/)[0];
|
|
4399
|
-
var
|
|
4400
|
-
deletion.value = removeSuffix(deletion.value,
|
|
4524
|
+
var overlap2 = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
|
|
4525
|
+
deletion.value = removeSuffix(deletion.value, overlap2);
|
|
4401
4526
|
} else if (startKeep) {
|
|
4402
4527
|
var startKeepWsSuffix = startKeep.value.match(/\s*$/)[0];
|
|
4403
4528
|
var deletionWsPrefix = deletion.value.match(/^\s*/)[0];
|
|
@@ -4976,11 +5101,16 @@ import { execSync as execSync2 } from "child_process";
|
|
|
4976
5101
|
import { readFileSync, realpathSync } from "fs";
|
|
4977
5102
|
import { dirname as dirname2, relative, resolve as resolve2, sep } from "path";
|
|
4978
5103
|
function getRepoRoot(cwd) {
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
5104
|
+
let root;
|
|
5105
|
+
try {
|
|
5106
|
+
root = execSync2("git rev-parse --show-toplevel", {
|
|
5107
|
+
cwd,
|
|
5108
|
+
encoding: "utf-8",
|
|
5109
|
+
stdio: "pipe"
|
|
5110
|
+
}).trim();
|
|
5111
|
+
} catch {
|
|
5112
|
+
throw new DiffError("diff compares specs across git history, and this directory is not inside a git repository. Run `git init` first, or run diff from a checked-out project.");
|
|
5113
|
+
}
|
|
4984
5114
|
return realpathSync(root);
|
|
4985
5115
|
}
|
|
4986
5116
|
function validateRef(ref, cwd) {
|
|
@@ -5324,7 +5454,7 @@ function formatChangelog(result, baseRef, headRef) {
|
|
|
5324
5454
|
return lines.join("\n");
|
|
5325
5455
|
}
|
|
5326
5456
|
|
|
5327
|
-
// src/commands/diff.ts
|
|
5457
|
+
// src/commands/core/diff.ts
|
|
5328
5458
|
async function runDiff(options) {
|
|
5329
5459
|
const configDir = process.cwd();
|
|
5330
5460
|
const config = await loadConfig(void 0, configDir);
|
|
@@ -5444,7 +5574,7 @@ var diff_default = defineCommand4({
|
|
|
5444
5574
|
}
|
|
5445
5575
|
});
|
|
5446
5576
|
|
|
5447
|
-
// src/commands/status.ts
|
|
5577
|
+
// src/commands/core/status.ts
|
|
5448
5578
|
import { defineCommand as defineCommand5 } from "citty";
|
|
5449
5579
|
async function runStatus(_options = {}) {
|
|
5450
5580
|
const configDir = process.cwd();
|
|
@@ -5584,109 +5714,8 @@ var status_default = defineCommand5({
|
|
|
5584
5714
|
}
|
|
5585
5715
|
}
|
|
5586
5716
|
});
|
|
5587
|
-
|
|
5588
|
-
// src/commands/explain.ts
|
|
5589
|
-
import { defineCommand as defineCommand6 } from "citty";
|
|
5590
|
-
async function runExplain(_options = {}) {
|
|
5591
|
-
const configDir = process.cwd();
|
|
5592
|
-
const config = await loadConfig(void 0, configDir);
|
|
5593
|
-
const specs = [];
|
|
5594
|
-
for (const [, entry] of Object.entries(config.specs)) {
|
|
5595
|
-
const paths = await resolveGlob(entry.path, configDir);
|
|
5596
|
-
for (const p of paths) {
|
|
5597
|
-
specs.push(await parseSpec(p));
|
|
5598
|
-
}
|
|
5599
|
-
}
|
|
5600
|
-
const byType = {};
|
|
5601
|
-
const byStatus = {};
|
|
5602
|
-
for (const spec of specs) {
|
|
5603
|
-
const type = spec.frontmatter.type || "unknown";
|
|
5604
|
-
const status = spec.frontmatter.status || "unknown";
|
|
5605
|
-
byType[type] = (byType[type] ?? 0) + 1;
|
|
5606
|
-
byStatus[status] = (byStatus[status] ?? 0) + 1;
|
|
5607
|
-
}
|
|
5608
|
-
const specSummaries = specs.map((spec) => {
|
|
5609
|
-
const firstSection = spec.parsedSections[0];
|
|
5610
|
-
const firstLine = firstSection?.content?.split("\n").find((l) => l.trim().length > 0)?.trim() ?? "";
|
|
5611
|
-
const truncated = firstLine.slice(0, 120) + (firstLine.length > 120 ? "..." : "");
|
|
5612
|
-
return {
|
|
5613
|
-
id: spec.frontmatter.id,
|
|
5614
|
-
type: spec.frontmatter.type,
|
|
5615
|
-
title: spec.frontmatter.title,
|
|
5616
|
-
status: spec.frontmatter.status,
|
|
5617
|
-
firstLine: truncated
|
|
5618
|
-
};
|
|
5619
|
-
});
|
|
5620
|
-
const graph = buildGraph(config);
|
|
5621
|
-
const graphLines = [];
|
|
5622
|
-
for (const node of graph.nodes) {
|
|
5623
|
-
const downstream = graph.edges.filter((e) => e.from === node).map((e) => e.to);
|
|
5624
|
-
if (downstream.length > 0) {
|
|
5625
|
-
graphLines.push(`${node} \u2192 ${downstream.join(", ")}`);
|
|
5626
|
-
} else {
|
|
5627
|
-
graphLines.push(node);
|
|
5628
|
-
}
|
|
5629
|
-
}
|
|
5630
|
-
return {
|
|
5631
|
-
project: config.project?.name ?? "unknown",
|
|
5632
|
-
description: config.project?.description,
|
|
5633
|
-
specCount: specs.length,
|
|
5634
|
-
byType,
|
|
5635
|
-
byStatus,
|
|
5636
|
-
specs: specSummaries,
|
|
5637
|
-
graph: graphLines
|
|
5638
|
-
};
|
|
5639
|
-
}
|
|
5640
|
-
var explain_default = defineCommand6({
|
|
5641
|
-
meta: {
|
|
5642
|
-
name: "explain",
|
|
5643
|
-
description: "[experimental] Explain the spec suite for onboarding"
|
|
5644
|
-
},
|
|
5645
|
-
args: {
|
|
5646
|
-
format: { type: "string", description: "Output format: pretty, json", default: "pretty" }
|
|
5647
|
-
},
|
|
5648
|
-
async run({ args }) {
|
|
5649
|
-
try {
|
|
5650
|
-
const result = await runExplain({ format: args.format });
|
|
5651
|
-
if (args.format === "json") {
|
|
5652
|
-
console.log(JSON.stringify(result, null, 2));
|
|
5653
|
-
return;
|
|
5654
|
-
}
|
|
5655
|
-
console.log(`
|
|
5656
|
-
${result.project}`);
|
|
5657
|
-
if (result.description) {
|
|
5658
|
-
console.log(` ${result.description}`);
|
|
5659
|
-
}
|
|
5660
|
-
console.log(
|
|
5661
|
-
`
|
|
5662
|
-
${result.specCount} specs: ${Object.entries(result.byType).map(([k, v]) => `${v} ${k}`).join(", ")}`
|
|
5663
|
-
);
|
|
5664
|
-
console.log(
|
|
5665
|
-
` Status: ${Object.entries(result.byStatus).map(([k, v]) => `${v} ${k}`).join(", ")}`
|
|
5666
|
-
);
|
|
5667
|
-
console.log("\n Specs:");
|
|
5668
|
-
for (const spec of result.specs) {
|
|
5669
|
-
console.log(` ${spec.id} (${spec.type}, ${spec.status}) \u2014 ${spec.title}`);
|
|
5670
|
-
if (spec.firstLine) {
|
|
5671
|
-
console.log(` ${spec.firstLine}`);
|
|
5672
|
-
}
|
|
5673
|
-
}
|
|
5674
|
-
console.log("\n Dependencies:");
|
|
5675
|
-
for (const line of result.graph) {
|
|
5676
|
-
console.log(` ${line}`);
|
|
5677
|
-
}
|
|
5678
|
-
console.log();
|
|
5679
|
-
} catch (err) {
|
|
5680
|
-
console.error(`
|
|
5681
|
-
\u2717 ${err.message}
|
|
5682
|
-
`);
|
|
5683
|
-
process.exit(1);
|
|
5684
|
-
}
|
|
5685
|
-
}
|
|
5686
|
-
});
|
|
5687
5717
|
export {
|
|
5688
5718
|
runDiff,
|
|
5689
|
-
runExplain,
|
|
5690
5719
|
runLint,
|
|
5691
5720
|
runPack,
|
|
5692
5721
|
runStatus,
|