@sublang/spex 0.2.3 → 1.0.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/README.md +70 -17
- package/dist/append-agent-specs.d.ts +7 -1
- package/dist/append-agent-specs.js +7 -2
- package/dist/cli.js +8 -2
- package/dist/copy-templates.d.ts +28 -3
- package/dist/copy-templates.js +172 -54
- package/dist/create-specs-structure.js +2 -4
- package/dist/lint.d.ts +15 -0
- package/dist/lint.js +967 -0
- package/dist/markdown.d.ts +46 -0
- package/dist/markdown.js +130 -0
- package/dist/scaffold.js +171 -31
- package/package.json +15 -7
- package/scaffold/.file-history.json +32 -24
- package/scaffold/.legacy-file-history.json +48 -0
- package/scaffold/LICENSE +202 -0
- package/scaffold/agent-specs.txt +10 -2
- package/scaffold/i18n/zh/specs/map.md +44 -0
- package/scaffold/i18n/zh/specs/meta.md +208 -0
- package/scaffold/specs/decisions/000-spec-structure-format.md +40 -42
- package/scaffold/specs/intents/000-spdx-headers.md +39 -0
- package/scaffold/specs/map.md +14 -24
- package/scaffold/specs/meta.md +110 -72
- package/scaffold/specs/packages/git.md +46 -0
- package/scaffold/specs/packages/licensing.md +56 -0
- package/scaffold/update-merge-prompt.md +8 -1
- package/scaffold/specs/dev/git.md +0 -28
- package/scaffold/specs/dev/licensing.md +0 -44
- package/scaffold/specs/iterations/000-spdx-headers.md +0 -35
- package/scaffold/specs/test/licensing.md +0 -20
- package/scaffold/specs/user/.gitkeep +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Heading, Node, Root } from "mdast";
|
|
2
|
+
/** Parse markdown into an mdast tree with position offsets. */
|
|
3
|
+
export declare function parseMarkdown(text: string): Root;
|
|
4
|
+
/**
|
|
5
|
+
* Per-line flag: the line lies inside a code block — a GFM fence of
|
|
6
|
+
* any delimiter length (including its delimiter lines) or indented
|
|
7
|
+
* code — per the parsed tree, so a literal fence inside a longer
|
|
8
|
+
* fence is not mistaken for a closer.
|
|
9
|
+
*/
|
|
10
|
+
export declare function codeLineMap(tree: Root, lineCount: number): boolean[];
|
|
11
|
+
/** Start offset of a node, throwing when position data is absent. */
|
|
12
|
+
export declare function startOffset(node: Node): number;
|
|
13
|
+
/** End offset of a node, throwing when position data is absent. */
|
|
14
|
+
export declare function endOffset(node: Node): number;
|
|
15
|
+
/** Raw source text covered by a node. */
|
|
16
|
+
export declare function sliceNode(text: string, node: Node): string;
|
|
17
|
+
/**
|
|
18
|
+
* The inline source text of a heading (without ATX markers or a
|
|
19
|
+
* setext underline), preserving inline markup verbatim.
|
|
20
|
+
*/
|
|
21
|
+
export declare function headingText(text: string, heading: Heading): string;
|
|
22
|
+
export type TextEdit = {
|
|
23
|
+
start: number;
|
|
24
|
+
end: number;
|
|
25
|
+
replacement: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Apply non-overlapping offset edits to text. Edits are sorted and
|
|
29
|
+
* applied back-to-front so recorded offsets stay valid.
|
|
30
|
+
*/
|
|
31
|
+
export declare function applyEdits(text: string, edits: TextEdit[]): string;
|
|
32
|
+
/** Walk every node in an mdast tree, depth first. */
|
|
33
|
+
export declare function visit(node: Node, fn: (node: Node) => void): void;
|
|
34
|
+
/**
|
|
35
|
+
* GitHub-style anchor slugs for every heading in a document, in
|
|
36
|
+
* order, with `-N` suffixes for repeats (matching GitHub rendering).
|
|
37
|
+
*/
|
|
38
|
+
export declare function headingSlugs(text: string, tree?: Root): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Base slugs of every heading, each computed with a fresh slugger so
|
|
41
|
+
* no `-N` dedupe counters are applied. Collisions show up as
|
|
42
|
+
* repeated values.
|
|
43
|
+
*/
|
|
44
|
+
export declare function baseHeadingSlugs(text: string, tree?: Root): string[];
|
|
45
|
+
/** Heading text with inline markdown markers stripped for slugging. */
|
|
46
|
+
export declare function plainHeadingText(text: string, heading: Heading): string;
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
import GithubSlugger from "github-slugger";
|
|
4
|
+
import remarkGfm from "remark-gfm";
|
|
5
|
+
import remarkParse from "remark-parse";
|
|
6
|
+
import { unified } from "unified";
|
|
7
|
+
const processor = unified().use(remarkParse).use(remarkGfm);
|
|
8
|
+
/** Parse markdown into an mdast tree with position offsets. */
|
|
9
|
+
export function parseMarkdown(text) {
|
|
10
|
+
return processor.parse(text);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Per-line flag: the line lies inside a code block — a GFM fence of
|
|
14
|
+
* any delimiter length (including its delimiter lines) or indented
|
|
15
|
+
* code — per the parsed tree, so a literal fence inside a longer
|
|
16
|
+
* fence is not mistaken for a closer.
|
|
17
|
+
*/
|
|
18
|
+
export function codeLineMap(tree, lineCount) {
|
|
19
|
+
const inCode = new Array(lineCount).fill(false);
|
|
20
|
+
visit(tree, (node) => {
|
|
21
|
+
if (node.type !== "code")
|
|
22
|
+
return;
|
|
23
|
+
const start = node.position?.start.line;
|
|
24
|
+
const end = node.position?.end.line;
|
|
25
|
+
if (start === undefined || end === undefined)
|
|
26
|
+
return;
|
|
27
|
+
for (let line = start; line <= end && line <= lineCount; line += 1) {
|
|
28
|
+
inCode[line - 1] = true;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return inCode;
|
|
32
|
+
}
|
|
33
|
+
/** Start offset of a node, throwing when position data is absent. */
|
|
34
|
+
export function startOffset(node) {
|
|
35
|
+
const offset = node.position?.start.offset;
|
|
36
|
+
if (offset === undefined)
|
|
37
|
+
throw new Error(`node has no position: ${node.type}`);
|
|
38
|
+
return offset;
|
|
39
|
+
}
|
|
40
|
+
/** End offset of a node, throwing when position data is absent. */
|
|
41
|
+
export function endOffset(node) {
|
|
42
|
+
const offset = node.position?.end.offset;
|
|
43
|
+
if (offset === undefined)
|
|
44
|
+
throw new Error(`node has no position: ${node.type}`);
|
|
45
|
+
return offset;
|
|
46
|
+
}
|
|
47
|
+
/** Raw source text covered by a node. */
|
|
48
|
+
export function sliceNode(text, node) {
|
|
49
|
+
return text.slice(startOffset(node), endOffset(node));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The inline source text of a heading (without ATX markers or a
|
|
53
|
+
* setext underline), preserving inline markup verbatim.
|
|
54
|
+
*/
|
|
55
|
+
export function headingText(text, heading) {
|
|
56
|
+
const children = heading.children;
|
|
57
|
+
if (children.length === 0)
|
|
58
|
+
return "";
|
|
59
|
+
return text
|
|
60
|
+
.slice(startOffset(children[0]), endOffset(children[children.length - 1]))
|
|
61
|
+
.trim();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Apply non-overlapping offset edits to text. Edits are sorted and
|
|
65
|
+
* applied back-to-front so recorded offsets stay valid.
|
|
66
|
+
*/
|
|
67
|
+
export function applyEdits(text, edits) {
|
|
68
|
+
const sorted = [...edits].sort((a, b) => a.start - b.start || a.end - b.end);
|
|
69
|
+
for (let i = 1; i < sorted.length; i += 1) {
|
|
70
|
+
if (sorted[i].start < sorted[i - 1].end) {
|
|
71
|
+
throw new Error(`overlapping markdown edits at offsets ${sorted[i - 1].start}..${sorted[i - 1].end} and ${sorted[i].start}..${sorted[i].end}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
let result = text;
|
|
75
|
+
for (let i = sorted.length - 1; i >= 0; i -= 1) {
|
|
76
|
+
const { start, end, replacement } = sorted[i];
|
|
77
|
+
result = result.slice(0, start) + replacement + result.slice(end);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
/** Walk every node in an mdast tree, depth first. */
|
|
82
|
+
export function visit(node, fn) {
|
|
83
|
+
fn(node);
|
|
84
|
+
const children = node.children;
|
|
85
|
+
if (children === undefined)
|
|
86
|
+
return;
|
|
87
|
+
for (const child of children)
|
|
88
|
+
visit(child, fn);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* GitHub-style anchor slugs for every heading in a document, in
|
|
92
|
+
* order, with `-N` suffixes for repeats (matching GitHub rendering).
|
|
93
|
+
*/
|
|
94
|
+
export function headingSlugs(text, tree = parseMarkdown(text)) {
|
|
95
|
+
const slugger = new GithubSlugger();
|
|
96
|
+
const slugs = [];
|
|
97
|
+
visit(tree, (node) => {
|
|
98
|
+
if (node.type !== "heading")
|
|
99
|
+
return;
|
|
100
|
+
slugs.push(slugger.slug(plainHeadingText(text, node)));
|
|
101
|
+
});
|
|
102
|
+
return slugs;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Base slugs of every heading, each computed with a fresh slugger so
|
|
106
|
+
* no `-N` dedupe counters are applied. Collisions show up as
|
|
107
|
+
* repeated values.
|
|
108
|
+
*/
|
|
109
|
+
export function baseHeadingSlugs(text, tree = parseMarkdown(text)) {
|
|
110
|
+
const slugs = [];
|
|
111
|
+
visit(tree, (node) => {
|
|
112
|
+
if (node.type !== "heading")
|
|
113
|
+
return;
|
|
114
|
+
slugs.push(new GithubSlugger().slug(plainHeadingText(text, node)));
|
|
115
|
+
});
|
|
116
|
+
return slugs;
|
|
117
|
+
}
|
|
118
|
+
/** Heading text with inline markdown markers stripped for slugging. */
|
|
119
|
+
export function plainHeadingText(text, heading) {
|
|
120
|
+
let plain = "";
|
|
121
|
+
visit(heading, (node) => {
|
|
122
|
+
if (node.type === "text" || node.type === "inlineCode") {
|
|
123
|
+
plain += node.value;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
if (plain !== "")
|
|
127
|
+
return plain;
|
|
128
|
+
return headingText(text, heading);
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=markdown.js.map
|
package/dist/scaffold.js
CHANGED
|
@@ -1,23 +1,79 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
3
|
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
4
6
|
import { appendAgentSpecs } from "./append-agent-specs.js";
|
|
5
|
-
import { readBundledMarkdown } from "./bundled-scaffold.js";
|
|
6
|
-
import { copyTemplates,
|
|
7
|
+
import { getScaffoldDir, readBundledMarkdown } from "./bundled-scaffold.js";
|
|
8
|
+
import { copyRootLicense, copyTemplates, formatSupportedLanguages, isLegacyPristine, isPristine, isSupportedLanguage, overwriteFrameworkSpecFiles, refreshPristineSeeds, } from "./copy-templates.js";
|
|
7
9
|
import { createSpecsStructure } from "./create-specs-structure.js";
|
|
8
10
|
import { resolveBase } from "./resolve-base.js";
|
|
11
|
+
const AUTHORING_LANGUAGE_RE = /^Authoring language:\s*([A-Za-z0-9-]+)\s*$/m;
|
|
12
|
+
// SCAF-26 / SCAF-52: directories that mark a legacy spec generation.
|
|
13
|
+
// Structural migration of a legacy generation is agent-skill work, not
|
|
14
|
+
// CLI code (DR-021), so the CLI only detects these and points at the
|
|
15
|
+
// spec-structure-migration skill.
|
|
16
|
+
const LEGACY_GENERATION_DIRS = [
|
|
17
|
+
"user",
|
|
18
|
+
"dev",
|
|
19
|
+
"test",
|
|
20
|
+
"items",
|
|
21
|
+
"interactions",
|
|
22
|
+
"compositions",
|
|
23
|
+
"iterations",
|
|
24
|
+
];
|
|
25
|
+
function parseLanguage(code) {
|
|
26
|
+
if (isSupportedLanguage(code))
|
|
27
|
+
return code;
|
|
28
|
+
throw new Error(`Unsupported language code: ${code}. Supported codes: ${formatSupportedLanguages()}`);
|
|
29
|
+
}
|
|
9
30
|
function parseArgs(args) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
31
|
+
let update = false;
|
|
32
|
+
let language;
|
|
33
|
+
const pathArgs = [];
|
|
34
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
35
|
+
const arg = args[i];
|
|
36
|
+
if (arg === "--update") {
|
|
37
|
+
update = true;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (arg === "--lang") {
|
|
41
|
+
const code = args[i + 1];
|
|
42
|
+
if (code === undefined) {
|
|
43
|
+
throw new Error("--lang requires a language code");
|
|
44
|
+
}
|
|
45
|
+
if (language !== undefined) {
|
|
46
|
+
throw new Error("--lang may only be specified once");
|
|
47
|
+
}
|
|
48
|
+
language = parseLanguage(code);
|
|
49
|
+
i += 1;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (arg.startsWith("--lang=")) {
|
|
53
|
+
if (language !== undefined) {
|
|
54
|
+
throw new Error("--lang may only be specified once");
|
|
55
|
+
}
|
|
56
|
+
language = parseLanguage(arg.slice("--lang=".length));
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (arg.startsWith("-")) {
|
|
60
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
61
|
+
}
|
|
62
|
+
pathArgs.push(arg);
|
|
63
|
+
}
|
|
64
|
+
if (update) {
|
|
65
|
+
if (language !== undefined) {
|
|
66
|
+
throw new Error("--update does not accept --lang");
|
|
67
|
+
}
|
|
68
|
+
if (pathArgs.length !== 0) {
|
|
13
69
|
throw new Error("--update does not accept a <path> argument");
|
|
14
70
|
}
|
|
15
71
|
return { mode: "update" };
|
|
16
72
|
}
|
|
17
|
-
if (
|
|
18
|
-
throw new Error(`Unexpected arguments: ${
|
|
73
|
+
if (pathArgs.length > 1) {
|
|
74
|
+
throw new Error(`Unexpected arguments: ${pathArgs.slice(1).join(" ")}`);
|
|
19
75
|
}
|
|
20
|
-
return { mode: "create", pathArg:
|
|
76
|
+
return { mode: "create", pathArg: pathArgs[0], language };
|
|
21
77
|
}
|
|
22
78
|
function getGitRoot() {
|
|
23
79
|
try {
|
|
@@ -40,38 +96,119 @@ function assertCleanSpecsTree(basePath) {
|
|
|
40
96
|
throw new Error("--update requires a clean specs/ working tree");
|
|
41
97
|
}
|
|
42
98
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
99
|
+
function readActiveLanguage(basePath) {
|
|
100
|
+
const metaPath = join(basePath, "specs", "meta.md");
|
|
101
|
+
if (!existsSync(metaPath))
|
|
102
|
+
return "en";
|
|
103
|
+
const match = readFileSync(metaPath, "utf-8").match(AUTHORING_LANGUAGE_RE);
|
|
104
|
+
if (match === null)
|
|
105
|
+
return "en";
|
|
106
|
+
return parseLanguage(match[1]);
|
|
107
|
+
}
|
|
108
|
+
function resolveCreateLanguage(basePath, requestedLanguage) {
|
|
109
|
+
const metaPath = join(basePath, "specs", "meta.md");
|
|
110
|
+
if (!existsSync(metaPath))
|
|
111
|
+
return requestedLanguage ?? "en";
|
|
112
|
+
const activeLanguage = readActiveLanguage(basePath);
|
|
113
|
+
if (requestedLanguage !== undefined &&
|
|
114
|
+
requestedLanguage !== activeLanguage) {
|
|
115
|
+
throw new Error(`--lang ${requestedLanguage} does not match existing authoring language ${activeLanguage}`);
|
|
116
|
+
}
|
|
117
|
+
return activeLanguage;
|
|
118
|
+
}
|
|
119
|
+
function warnReplacedFrameworkFiles(replaced) {
|
|
120
|
+
if (replaced.length === 0)
|
|
121
|
+
return;
|
|
122
|
+
console.warn("");
|
|
123
|
+
console.warn("WARNING: --update replaced framework file(s) that contained local modifications:");
|
|
124
|
+
for (const relPath of replaced) {
|
|
125
|
+
console.warn(` - ${relPath}`);
|
|
126
|
+
}
|
|
127
|
+
console.warn("These files are maintained by spex and were refreshed to the bundled version.");
|
|
128
|
+
console.warn("Your previous content remains in git history; review what changed with");
|
|
129
|
+
console.warn("`git diff -- specs` and reapply any local additions on top of the refreshed file.");
|
|
130
|
+
}
|
|
131
|
+
function hasLegacyGenerationDir(basePath) {
|
|
132
|
+
return LEGACY_GENERATION_DIRS.some((dir) => {
|
|
133
|
+
const abs = join(basePath, "specs", dir);
|
|
134
|
+
return existsSync(abs) && statSync(abs).isDirectory();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
// SCAF-26: a specs/meta.md matching a pre-packages bundled version in
|
|
138
|
+
// its chronological history is an old-generation marker. Every
|
|
139
|
+
// pre-packages bundled meta.md carried uppercase META-* item IDs, so a
|
|
140
|
+
// recognized bundled version with an uppercase item heading predates
|
|
141
|
+
// the packages generation.
|
|
142
|
+
function isOldGenerationMeta(basePath, language) {
|
|
143
|
+
const relPath = "specs/meta.md";
|
|
144
|
+
if (isPristine(basePath, relPath, language) !== "pristine")
|
|
145
|
+
return false;
|
|
146
|
+
const content = readFileSync(join(basePath, relPath), "utf-8");
|
|
147
|
+
return /^#{1,6} META-\d+/m.test(content);
|
|
148
|
+
}
|
|
149
|
+
// SCAF-26 / SCAF-47: target content matching a retired bundled seed in
|
|
150
|
+
// the legacy manifest is an old-generation marker.
|
|
151
|
+
function matchesRetiredBundledSeed(basePath) {
|
|
152
|
+
const manifestPath = join(getScaffoldDir(), ".legacy-file-history.json");
|
|
153
|
+
if (!existsSync(manifestPath))
|
|
154
|
+
return false;
|
|
155
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
156
|
+
return Object.keys(manifest).some((relPath) => isLegacyPristine(basePath, relPath) === "pristine");
|
|
45
157
|
}
|
|
158
|
+
/** SCAF-26 legacy-generation detection, sampled before the refresh. */
|
|
159
|
+
function detectLegacyGeneration(basePath, language) {
|
|
160
|
+
return (hasLegacyGenerationDir(basePath) ||
|
|
161
|
+
isOldGenerationMeta(basePath, language) ||
|
|
162
|
+
matchesRetiredBundledSeed(basePath));
|
|
163
|
+
}
|
|
164
|
+
// SCAF-26: the guidance names the migration skill, its guide, and the
|
|
165
|
+
// lint gate. No path-level summary lines here — the per-file indicators
|
|
166
|
+
// above are the run's only path summary (SCAF-11).
|
|
167
|
+
function printMigrationGuidance() {
|
|
168
|
+
console.log("");
|
|
169
|
+
console.log("This specs tree carries a legacy spec generation (spex 0.x). The template refresh");
|
|
170
|
+
console.log("above left all legacy content untouched: structural migration is");
|
|
171
|
+
console.log("agent-skill work, not CLI code.");
|
|
172
|
+
console.log("To migrate, run the spec-structure-migration skill bundled with spex");
|
|
173
|
+
console.log("(skills/spec-structure-migration/ in the spex repo); its guide is");
|
|
174
|
+
console.log("docs/spec-migration.md.");
|
|
175
|
+
console.log("The migrated tree must pass `spex lint` — the mechanical gate.");
|
|
176
|
+
}
|
|
177
|
+
// SCAF-18: the four-step --update pipeline — framework overwrite, seed
|
|
178
|
+
// refresh, agent-file refresh, then the completion output.
|
|
46
179
|
function updateScaffoldTemplates() {
|
|
47
180
|
const basePath = getGitRoot();
|
|
48
181
|
assertCleanSpecsTree(basePath);
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
for (const result of legacyResults) {
|
|
58
|
-
if (result.status === "conflict") {
|
|
59
|
-
console.log(` ${result.legacyRelPath} (kept — target exists at ${result.targetRelPath})`);
|
|
60
|
-
}
|
|
61
|
-
else if (!seedPaths.has(result.targetRelPath)) {
|
|
62
|
-
console.log(` ${result.targetRelPath} (migrated from ${result.legacyRelPath})`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
overwriteFrameworkSpecFiles(basePath);
|
|
66
|
-
refreshPristineSeeds(basePath, { migratedFrom: migratedSeedSources });
|
|
182
|
+
const language = readActiveLanguage(basePath);
|
|
183
|
+
// Sample legacy-generation markers before the framework overwrite
|
|
184
|
+
// replaces specs/meta.md (SCAF-26).
|
|
185
|
+
const legacyGeneration = detectLegacyGeneration(basePath, language);
|
|
186
|
+
const replacedFramework = overwriteFrameworkSpecFiles(basePath, language);
|
|
187
|
+
refreshPristineSeeds(basePath, { language });
|
|
188
|
+
appendAgentSpecs(basePath, { createMissing: false });
|
|
189
|
+
warnReplacedFrameworkFiles(replacedFramework);
|
|
67
190
|
console.log("");
|
|
68
191
|
console.log("spex scaffold --update completed.");
|
|
69
|
-
console.log("Review the file indicators above and inspect changes (e.g., `git diff -- specs`)
|
|
192
|
+
console.log("Review the file indicators above and inspect changes (e.g., `git diff -- specs`),");
|
|
193
|
+
console.log("then run `spex lint` to check the specs tree.");
|
|
70
194
|
console.log("Optionally, share this prompt with your AI agent to reconcile citations and local extensions:");
|
|
71
195
|
console.log("");
|
|
72
196
|
console.log("```");
|
|
73
|
-
console.log(
|
|
197
|
+
console.log(readBundledMarkdown("update-merge-prompt.md"));
|
|
74
198
|
console.log("```");
|
|
199
|
+
if (legacyGeneration)
|
|
200
|
+
printMigrationGuidance();
|
|
201
|
+
}
|
|
202
|
+
// SCAF-52: a legacy tree gets guidance, not a re-scaffold — creating
|
|
203
|
+
// current seed targets beside legacy files would entangle two spec
|
|
204
|
+
// generations before the migration skill has run.
|
|
205
|
+
function assertNoLegacyLayout(basePath) {
|
|
206
|
+
for (const dir of LEGACY_GENERATION_DIRS) {
|
|
207
|
+
const abs = join(basePath, "specs", dir);
|
|
208
|
+
if (existsSync(abs) && statSync(abs).isDirectory()) {
|
|
209
|
+
throw new Error(`specs/${dir}/ marks a legacy spec generation (spex 0.x); run \`spex scaffold --update\` to refresh templates and get migration guidance before scaffolding`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
75
212
|
}
|
|
76
213
|
/**
|
|
77
214
|
* Entry point for the scaffold subcommand.
|
|
@@ -85,8 +222,11 @@ export function scaffold(args = []) {
|
|
|
85
222
|
return;
|
|
86
223
|
}
|
|
87
224
|
const basePath = resolveBase(options.pathArg);
|
|
225
|
+
const language = resolveCreateLanguage(basePath, options.language);
|
|
226
|
+
assertNoLegacyLayout(basePath);
|
|
88
227
|
createSpecsStructure(basePath);
|
|
89
|
-
copyTemplates(basePath);
|
|
228
|
+
copyTemplates(basePath, language);
|
|
229
|
+
copyRootLicense(basePath);
|
|
90
230
|
appendAgentSpecs(basePath);
|
|
91
231
|
}
|
|
92
232
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sublang/spex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "The essential spec layer AI agents need to build software reliably",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/sublang-ai/spex.git"
|
|
9
|
+
"url": "https://github.com/sublang-ai/spex.git",
|
|
10
|
+
"directory": "packages/cli"
|
|
10
11
|
},
|
|
11
12
|
"keywords": [
|
|
12
13
|
"spex",
|
|
@@ -28,16 +29,23 @@
|
|
|
28
29
|
"scaffold/"
|
|
29
30
|
],
|
|
30
31
|
"scripts": {
|
|
31
|
-
"build": "tsc",
|
|
32
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc && node scripts/stage-scaffold.mjs",
|
|
32
33
|
"prepublishOnly": "npm run build && npm test",
|
|
33
|
-
"test": "node scripts/run-tests.cjs",
|
|
34
|
-
"test:integration": "node scripts/run-tests.cjs \"\\.integration\\.test\\.js$\""
|
|
34
|
+
"test": "node scripts/stage-scaffold.mjs && node scripts/run-tests.cjs",
|
|
35
|
+
"test:integration": "node scripts/stage-scaffold.mjs && node scripts/run-tests.cjs \"\\.integration\\.test\\.js$\""
|
|
35
36
|
},
|
|
36
37
|
"engines": {
|
|
37
38
|
"node": ">=20"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"
|
|
41
|
-
"@types/node": "^22.0.0"
|
|
41
|
+
"@types/mdast": "^4.0.4",
|
|
42
|
+
"@types/node": "^22.0.0",
|
|
43
|
+
"typescript": "^5.8.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"github-slugger": "^2.0.0",
|
|
47
|
+
"remark-gfm": "^4.0.1",
|
|
48
|
+
"remark-parse": "^11.0.0",
|
|
49
|
+
"unified": "^11.0.5"
|
|
42
50
|
}
|
|
43
51
|
}
|
|
@@ -1,37 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
"specs/
|
|
3
|
-
"sha256-
|
|
4
|
-
"sha256-
|
|
2
|
+
"i18n/zh/specs/map.md": [
|
|
3
|
+
"sha256-f1bcf636c567b830c5d6f625e10c8e4fe2c56b71fa7787106cd7b8701ad20efe",
|
|
4
|
+
"sha256-5da224028a738e3f8c50adbeb1f2bc9006beafe47050594a9a30b207d8ff0386"
|
|
5
5
|
],
|
|
6
|
-
"specs/
|
|
7
|
-
"sha256-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"sha256-
|
|
11
|
-
"sha256-f0690fbe5613097f3d0d1196fec5323a21a6b62bc3875068c38d09c74c5658c4"
|
|
6
|
+
"i18n/zh/specs/meta.md": [
|
|
7
|
+
"sha256-ce07160cf8af1fb67f4f86c572aa182e92dff24a72b313a89914e058de894b56",
|
|
8
|
+
"sha256-78a34b62546391e16f27265399c62568882563cad97def3520d9f675a7b75cab",
|
|
9
|
+
"sha256-1d8a2507d30ef54b5d935a53b448ec74ea8a8556df5cae24e81dcfbd94f9b648",
|
|
10
|
+
"sha256-3c75823810863849ae302255d477749fc57e8e367a499240cde0dd47c479219a"
|
|
12
11
|
],
|
|
13
|
-
"specs/
|
|
14
|
-
"sha256-
|
|
15
|
-
"sha256-
|
|
16
|
-
"sha256-
|
|
17
|
-
"sha256-
|
|
12
|
+
"specs/decisions/000-spec-structure-format.md": [
|
|
13
|
+
"sha256-28d0705311a8ede97c487a944efe99bed20863e246da0aa1a33286dd4f8864ca",
|
|
14
|
+
"sha256-a06e1b102d96c91f6ba36fd317426aae9c6a384a76c2dd5996275405d02d1883",
|
|
15
|
+
"sha256-e492c52ea2ff89ab7b5b87d151a1755fac094233524eb8e6718be43111321227",
|
|
16
|
+
"sha256-97041a244e1f1bef6c14b44a2805c214931c649faa523e49489ae7c42c9c11b5"
|
|
18
17
|
],
|
|
19
18
|
"specs/map.md": [
|
|
20
19
|
"sha256-a1d6bc4a23fa58d8ccdcf7cd0570fc05face0aae8b6947367298dad3cde0af75",
|
|
21
|
-
"sha256-
|
|
22
|
-
"sha256-
|
|
20
|
+
"sha256-4f2772c2d268972c1d5b1e2f4efb604b304c285ef3d91def9c1bad59666b303d",
|
|
21
|
+
"sha256-aa12c658e84b8925b2981807a72edc9dbd274a78bd87f7186bb558afc42d8bc6"
|
|
23
22
|
],
|
|
24
23
|
"specs/meta.md": [
|
|
25
24
|
"sha256-ce07160cf8af1fb67f4f86c572aa182e92dff24a72b313a89914e058de894b56",
|
|
26
|
-
"sha256-
|
|
27
|
-
"sha256-
|
|
28
|
-
"sha256-
|
|
25
|
+
"sha256-78a34b62546391e16f27265399c62568882563cad97def3520d9f675a7b75cab",
|
|
26
|
+
"sha256-6a23f014ccbbe871e811f2ef9bd39119b50f0ce65a10bd75045d5735cf5b70b3",
|
|
27
|
+
"sha256-ca67a077cfaecb51a85e98ec8f8508ce9d8a43dcb7355b9e16de611c38cdabfc"
|
|
28
|
+
],
|
|
29
|
+
"specs/packages/git.md": [
|
|
30
|
+
"sha256-1b194304866d05580de8b2d0caa3454aa772e876fb3dee1f6c5d637c9e9a42b2",
|
|
31
|
+
"sha256-77625a315ac14eb6fd5f3c0697f121646ba8c0d976a98c3b51f27f3422cd1afb"
|
|
29
32
|
],
|
|
30
|
-
"specs/
|
|
31
|
-
"sha256-
|
|
33
|
+
"specs/packages/licensing.md": [
|
|
34
|
+
"sha256-ff6ce317bf51fb2f4a20dde8790a79f2a1237f6b5835c74e619f6e3d1647ab50",
|
|
35
|
+
"sha256-f0690fbe5613097f3d0d1196fec5323a21a6b62bc3875068c38d09c74c5658c4",
|
|
36
|
+
"sha256-3ea1ba444666c05895c05d7f33056137b5dab8f6cdbdb80eb057a338fdf8eb4b",
|
|
37
|
+
"sha256-7a08e109f0314e9b3297d2d791b635afb183c0815775690690497a9ac720a95b"
|
|
32
38
|
],
|
|
33
|
-
"specs/
|
|
34
|
-
"sha256-
|
|
35
|
-
"sha256-
|
|
39
|
+
"specs/intents/000-spdx-headers.md": [
|
|
40
|
+
"sha256-a5ae7e8e31e4292a9364ba7947b2fbf27836e9f88dc80436557191550fe1bd34",
|
|
41
|
+
"sha256-f9914497c46f9bfa05d12dfa9190c2d53d20cffd1af3eb3e44f0f0a4b20830f2",
|
|
42
|
+
"sha256-4fac8c7fee1fec71297c50ee605f0417c3ae2b27e8aa37b03e409f08db976516",
|
|
43
|
+
"sha256-0bf92bee3c73d1f34da7039480d56b290e6e5a40a1314bc23a4be81507c80d3e"
|
|
36
44
|
]
|
|
37
45
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"specs/dev/git.md": [
|
|
3
|
+
"sha256-1b194304866d05580de8b2d0caa3454aa772e876fb3dee1f6c5d637c9e9a42b2"
|
|
4
|
+
],
|
|
5
|
+
"specs/dev/licensing.md": [
|
|
6
|
+
"sha256-ff6ce317bf51fb2f4a20dde8790a79f2a1237f6b5835c74e619f6e3d1647ab50",
|
|
7
|
+
"sha256-f0690fbe5613097f3d0d1196fec5323a21a6b62bc3875068c38d09c74c5658c4",
|
|
8
|
+
"sha256-3ea1ba444666c05895c05d7f33056137b5dab8f6cdbdb80eb057a338fdf8eb4b"
|
|
9
|
+
],
|
|
10
|
+
"specs/test/licensing.md": [
|
|
11
|
+
"sha256-075e5782e80c7068deb55c21bfc43a1214a85945ed535d95f6ceadbbc9fa187f"
|
|
12
|
+
],
|
|
13
|
+
"specs/interactions/.gitkeep": [
|
|
14
|
+
"sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
|
15
|
+
],
|
|
16
|
+
"specs/compositions/.gitkeep": [
|
|
17
|
+
"sha256-01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
|
|
18
|
+
"sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
|
19
|
+
],
|
|
20
|
+
"specs/user/.gitkeep": [
|
|
21
|
+
"sha256-01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
|
|
22
|
+
"sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
|
23
|
+
],
|
|
24
|
+
"specs/iterations/000-spdx-headers.md": [
|
|
25
|
+
"sha256-a5ae7e8e31e4292a9364ba7947b2fbf27836e9f88dc80436557191550fe1bd34",
|
|
26
|
+
"sha256-3b7d95e80a9ca42b81510d4fac5515fdeeb80d842f7aeb91fef76bafccc01b1a",
|
|
27
|
+
"sha256-f9914497c46f9bfa05d12dfa9190c2d53d20cffd1af3eb3e44f0f0a4b20830f2",
|
|
28
|
+
"sha256-4fac8c7fee1fec71297c50ee605f0417c3ae2b27e8aa37b03e409f08db976516",
|
|
29
|
+
"sha256-71d24c93749439ca306302e341667963f71031c06d1dd62cca5ec5d6ab33e49c",
|
|
30
|
+
"sha256-cdf1eccbfbc1f77190b9401e4a8b20da38b3789cc4f27ef96ab4b3dbfff6691b",
|
|
31
|
+
"sha256-6df63e92bcdbc6a9feb26fd07a01e45a9cb8c22cb7b29cf46cf31edbe04aa1e3",
|
|
32
|
+
"sha256-159a955adf974ee733c2ca7d740a9530c20d5ef1153c6788884ce70c5651ef14",
|
|
33
|
+
"sha256-fb100492ac46ae412f05c0ebd6d243d886a901fcd655bd647241dfd534d37224"
|
|
34
|
+
],
|
|
35
|
+
"specs/items/dev/git.md": [
|
|
36
|
+
"sha256-1b194304866d05580de8b2d0caa3454aa772e876fb3dee1f6c5d637c9e9a42b2"
|
|
37
|
+
],
|
|
38
|
+
"specs/items/dev/licensing.md": [
|
|
39
|
+
"sha256-ff6ce317bf51fb2f4a20dde8790a79f2a1237f6b5835c74e619f6e3d1647ab50"
|
|
40
|
+
],
|
|
41
|
+
"specs/items/test/licensing.md": [
|
|
42
|
+
"sha256-075e5782e80c7068deb55c21bfc43a1214a85945ed535d95f6ceadbbc9fa187f"
|
|
43
|
+
],
|
|
44
|
+
"specs/items/user/.gitkeep": [
|
|
45
|
+
"sha256-01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
|
|
46
|
+
"sha256-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
|
47
|
+
]
|
|
48
|
+
}
|