@seanmars/tospec 0.17.0 → 0.19.0-beta.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.
- package/CHANGELOG.md +54 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +33 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/show.js +1 -1
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/validate.d.ts +9 -0
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +29 -5
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/workflow/index.d.ts +1 -1
- package/dist/commands/workflow/index.d.ts.map +1 -1
- package/dist/commands/workflow/index.js +1 -1
- package/dist/commands/workflow/index.js.map +1 -1
- package/dist/commands/workflow/status.d.ts +7 -0
- package/dist/commands/workflow/status.d.ts.map +1 -1
- package/dist/commands/workflow/status.js +71 -9
- package/dist/commands/workflow/status.js.map +1 -1
- package/dist/core/change-presenter.d.ts +26 -0
- package/dist/core/change-presenter.d.ts.map +1 -1
- package/dist/core/change-presenter.js +195 -0
- package/dist/core/change-presenter.js.map +1 -1
- package/dist/core/init.d.ts +8 -0
- package/dist/core/init.d.ts.map +1 -1
- package/dist/core/init.js +18 -19
- package/dist/core/init.js.map +1 -1
- package/dist/core/parsers/requirement-blocks.d.ts +6 -0
- package/dist/core/parsers/requirement-blocks.d.ts.map +1 -1
- package/dist/core/parsers/requirement-blocks.js +2 -0
- package/dist/core/parsers/requirement-blocks.js.map +1 -1
- package/dist/core/project-layout.d.ts +29 -0
- package/dist/core/project-layout.d.ts.map +1 -0
- package/dist/core/project-layout.js +62 -0
- package/dist/core/project-layout.js.map +1 -0
- package/dist/core/specs-apply.d.ts +2 -1
- package/dist/core/specs-apply.d.ts.map +1 -1
- package/dist/core/specs-apply.js +72 -34
- package/dist/core/specs-apply.js.map +1 -1
- package/dist/core/templates/workflows/propose.d.ts.map +1 -1
- package/dist/core/templates/workflows/propose.js +6 -0
- package/dist/core/templates/workflows/propose.js.map +1 -1
- package/dist/core/validation/constants.d.ts +3 -0
- package/dist/core/validation/constants.d.ts.map +1 -1
- package/dist/core/validation/constants.js +12 -0
- package/dist/core/validation/constants.js.map +1 -1
- package/dist/core/validation/purpose-placeholder.d.ts +37 -0
- package/dist/core/validation/purpose-placeholder.d.ts.map +1 -0
- package/dist/core/validation/purpose-placeholder.js +126 -0
- package/dist/core/validation/purpose-placeholder.js.map +1 -0
- package/dist/core/validation/validator.d.ts +20 -6
- package/dist/core/validation/validator.d.ts.map +1 -1
- package/dist/core/validation/validator.js +118 -10
- package/dist/core/validation/validator.js.map +1 -1
- package/dist/utils/file-system.d.ts +25 -0
- package/dist/utils/file-system.d.ts.map +1 -1
- package/dist/utils/file-system.js +30 -0
- package/dist/utils/file-system.js.map +1 -1
- package/dist/utils/requirement-diff.d.ts +50 -0
- package/dist/utils/requirement-diff.d.ts.map +1 -0
- package/dist/utils/requirement-diff.js +69 -0
- package/dist/utils/requirement-diff.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Requirement-level diffing for `tospec show <change> --diff`.
|
|
3
|
+
*
|
|
4
|
+
* A delta spec says what changes but not what it changes *from*: a MODIFIED
|
|
5
|
+
* block restates the whole requirement, so reading one tells you nothing about
|
|
6
|
+
* which line moved. Pairing each block with its main-spec counterpart is the
|
|
7
|
+
* only way to review a delta without opening two files side by side.
|
|
8
|
+
*/
|
|
9
|
+
import { formatPatch, OMIT_HEADERS, structuredPatch } from 'diff';
|
|
10
|
+
import { extractRequirementsSection, foldRequirementName, normalizeRequirementName, } from '../core/parsers/requirement-blocks.js';
|
|
11
|
+
/**
|
|
12
|
+
* The raw markdown block for a requirement in a main spec, or null when no
|
|
13
|
+
* header matches either way.
|
|
14
|
+
*
|
|
15
|
+
* Delegates to extractRequirementsSection(), which already handles code fences,
|
|
16
|
+
* section boundaries and header parsing. Lookup is exact first, then the shared
|
|
17
|
+
* case/whitespace fold, so a header that differs only in spelling still shows
|
|
18
|
+
* its diff — flagged inexact rather than silently treated as a match.
|
|
19
|
+
*/
|
|
20
|
+
export function extractRequirementBlock(specContent, requirementName) {
|
|
21
|
+
const parts = extractRequirementsSection(specContent);
|
|
22
|
+
const targetName = normalizeRequirementName(requirementName);
|
|
23
|
+
const foldedTarget = foldRequirementName(targetName);
|
|
24
|
+
let folded = null;
|
|
25
|
+
for (const block of parts.bodyBlocks) {
|
|
26
|
+
const name = normalizeRequirementName(block.name);
|
|
27
|
+
if (name === targetName) {
|
|
28
|
+
return { raw: block.raw, name, exact: true };
|
|
29
|
+
}
|
|
30
|
+
if (!folded && foldRequirementName(name) === foldedTarget) {
|
|
31
|
+
folded = { raw: block.raw, name, exact: false };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return folded;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A unified diff between a main-spec requirement block and the delta block that
|
|
38
|
+
* replaces it. A null main block diffs against the empty string, so every line
|
|
39
|
+
* reads as an addition.
|
|
40
|
+
*
|
|
41
|
+
* structuredPatch keeps the unified hunk ranges; the synthetic file headers are
|
|
42
|
+
* omitted because the caller labels the block itself.
|
|
43
|
+
*/
|
|
44
|
+
export function diffRequirementBlock(baseBlock, deltaBlock, label) {
|
|
45
|
+
const base = ensureTrailingNewline(baseBlock ?? '');
|
|
46
|
+
const delta = ensureTrailingNewline(deltaBlock);
|
|
47
|
+
const patch = structuredPatch(label, label, base, delta);
|
|
48
|
+
return formatPatch(patch, OMIT_HEADERS).trimEnd();
|
|
49
|
+
}
|
|
50
|
+
function ensureTrailingNewline(s) {
|
|
51
|
+
return s.endsWith('\n') ? s : s + '\n';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Maps a RENAMED TO name (folded) back to the original main-spec name.
|
|
55
|
+
*
|
|
56
|
+
* Renames apply in source order, so a chain A -> B -> C maps C back to A — the
|
|
57
|
+
* block a later MODIFIED C actually replaces in the main spec.
|
|
58
|
+
*/
|
|
59
|
+
export function buildRenameMap(renames) {
|
|
60
|
+
const map = new Map();
|
|
61
|
+
for (const r of renames) {
|
|
62
|
+
const from = foldRequirementName(r.from);
|
|
63
|
+
const original = map.get(from) ?? normalizeRequirementName(r.from);
|
|
64
|
+
map.delete(from);
|
|
65
|
+
map.set(foldRequirementName(r.to), original);
|
|
66
|
+
}
|
|
67
|
+
return map;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=requirement-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirement-diff.js","sourceRoot":"","sources":["../../src/utils/requirement-diff.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,uCAAuC,CAAC;AAe/C;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CACrC,WAAmB,EACnB,eAAuB;IAEvB,MAAM,KAAK,GAAG,0BAA0B,CAAC,WAAW,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,wBAAwB,CAAC,eAAe,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACrD,IAAI,MAAM,GAAmC,IAAI,CAAC;IAElD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YACxB,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC/C,CAAC;QACD,IAAI,CAAC,MAAM,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,YAAY,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seanmars/tospec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0-beta.0",
|
|
4
4
|
"description": "Spec-driven development CLI for structured requirements and issue workflows",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.npmjs.com/package/@seanmars/tospec",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@inquirer/core": "^11.2.1",
|
|
43
43
|
"@inquirer/prompts": "^8.5.2",
|
|
44
44
|
"commander": "^15.0.0",
|
|
45
|
+
"diff": "^9.0.0",
|
|
45
46
|
"fast-glob": "^3.3.3",
|
|
46
47
|
"marked": "^18.0.6",
|
|
47
48
|
"yaml": "^2.9.0",
|