@sublang/spex 1.0.0 → 2.1.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/dist/lint.js CHANGED
@@ -58,7 +58,7 @@ const HAS_CITATION_RE = /\[[^\]]*\]\([^)]*\)/;
58
58
  const CITATION_SCAN_RE = /\[[^\]]*\]\([^)]*\)/g;
59
59
  const DETACHED_VERIFIES_RE = /^Verifies\b(?:[\s,.;]|and\b)*$/;
60
60
  // Legacy directories of retired spec generations (lint-4); their
61
- // structural migration is agent-skill work, not CLI code (DR-021).
61
+ // structural migration is agent judgment, not CLI code (DR-022).
62
62
  const LEGACY_DIRS = [
63
63
  "user",
64
64
  "dev",
@@ -228,7 +228,7 @@ function lintStructure(ctx) {
228
228
  const specsDir = join(ctx.basePath, "specs");
229
229
  for (const dir of LEGACY_DIRS) {
230
230
  if (existsSync(join(specsDir, dir))) {
231
- report(ctx, `specs/${dir}`, 1, "error", "structure/legacy-layout", `legacy directory specs/${dir}/ found; run the spec-structure-migration skill to migrate to the current layout (DR-021)`);
231
+ report(ctx, `specs/${dir}`, 1, "error", "structure/legacy-layout", `legacy directory specs/${dir}/ found; run \`spex scaffold --update\` to refresh the spec law and get the migration prompt`);
232
232
  }
233
233
  }
234
234
  for (const entry of readdirSync(specsDir).sort()) {
@@ -319,7 +319,7 @@ function lintPackageFile(ctx, file) {
319
319
  }
320
320
  }
321
321
  if (!present.includes("Verification")) {
322
- report(ctx, file.relPath, 1, "warning", "package/verification", 'missing "## Verification" section; verification is required unless irrelevant (meta-33)');
322
+ report(ctx, file.relPath, 1, "error", "package/verification", 'missing required "## Verification" section (meta-30)');
323
323
  }
324
324
  }
325
325
  function collectItems(ctx) {
@@ -396,22 +396,22 @@ function lintItems(ctx, items) {
396
396
  report(ctx, item.file.relPath, item.heading.line, "error", "id/duplicate", `item ID ${item.id} is defined ${list.length} times across specs/ (meta-11)`);
397
397
  }
398
398
  }
399
- // A package's identity is its basename (meta-10); one basename
400
- // used by two files collides even across subdirectories.
399
+ // An item-bearing file's identity is its basename (meta-10),
400
+ // which is unique across the specs tree.
401
+ const itemFiles = new Set(items.map((item) => item.file.relPath));
401
402
  const byBasename = new Map();
402
403
  for (const file of ctx.files.values()) {
403
- if (!isUnder(file.relPath, "packages"))
404
- continue;
405
404
  const basename = basenameOf(file.relPath);
406
405
  const list = byBasename.get(basename) ?? [];
407
406
  list.push(file);
408
407
  byBasename.set(basename, list);
409
408
  }
410
409
  for (const [basename, list] of byBasename) {
411
- if (list.length < 2)
410
+ if (list.length < 2 || !list.some((file) => itemFiles.has(file.relPath))) {
412
411
  continue;
413
- for (const file of list) {
414
- report(ctx, file.relPath, 1, "error", "id/basename", `package basename "${basename}" is used by ${list
412
+ }
413
+ for (const file of list.filter((candidate) => itemFiles.has(candidate.relPath))) {
414
+ report(ctx, file.relPath, 1, "error", "id/basename", `item-bearing basename "${basename}" conflicts with ${list
415
415
  .map((other) => other.relPath)
416
416
  .join(", ")} (meta-10)`);
417
417
  }
@@ -508,11 +508,9 @@ function lintItemRelationships(ctx, items) {
508
508
  report(ctx, item.file.relPath, item.heading.line, "error", "verify/uncited", `Verification item ${item.id} cites no same-file behavior item; cite each behavior it verifies inline at the assertion (meta-20)`);
509
509
  }
510
510
  }
511
- // Peer citations resolve against the peer's sections: a
512
- // behavior item may rely on External Behavior alone (lint-7,
513
- // meta-14); a Verification item cites behavior items (meta-20),
514
- // and the law is silent on it reaching a peer's Internal
515
- // Behavior, so lint tolerates that reach (lint-13).
511
+ // A behavior reaches peers through External Behavior alone
512
+ // (meta-14). Verification behavior citations stay within their
513
+ // own package (meta-20), where Internal Behavior remains valid.
516
514
  const isBehavior = item.section !== null && BEHAVIOR_SECTIONS.has(item.section);
517
515
  const isVerification = item.section === "Verification";
518
516
  if (isBehavior || isVerification) {
@@ -530,21 +528,18 @@ function lintItemRelationships(ctx, items) {
530
528
  report(ctx, item.file.relPath, link.line, "error", "cite/internal", `item ${item.id} cites ${cited.id} in ${target.relPath}'s ${cited.section ?? "front matter"}; a peer behavior is relied on through External Behavior alone (meta-14)`);
531
529
  }
532
530
  }
533
- else if (target.fragment !== "") {
534
- // Verification: the cited peer anchor must be an External
535
- // or Internal Behavior item.
536
- if (cited === undefined ||
537
- cited.section === null ||
538
- !BEHAVIOR_SECTIONS.has(cited.section)) {
539
- report(ctx, item.file.relPath, link.line, "error", "cite/internal", `Verification item ${item.id} cites ${target.relPath}#${target.fragment} outside the peer's External and Internal Behavior items (meta-20)`);
540
- }
531
+ else if (target.fragment !== "" &&
532
+ cited?.section !== null &&
533
+ cited?.section !== undefined &&
534
+ BEHAVIOR_SECTIONS.has(cited.section)) {
535
+ report(ctx, item.file.relPath, link.line, "error", "verify/peer", `Verification item ${item.id} cites peer behavior ${cited.id}; behavior citations stay within the containing package (meta-20)`);
541
536
  }
542
537
  }
543
538
  }
544
539
  }
545
- // One governing statement per item (meta-29), sentence count as
540
+ // One requirement per item (meta-29), sentence count as
546
541
  // its advisory proxy (lint-14) — a conformant item may carry
547
- // several sentences of one contract's cases, so this only
542
+ // several sentences of one requirement's cases, so this only
548
543
  // prompts a read: prose outside fenced blocks, lists, tables,
549
544
  // blockquotes, and headings carries at most one sentence.
550
545
  // Terminators: ASCII before whitespace or line end, fullwidth
@@ -573,7 +568,7 @@ function lintItemRelationships(ctx, items) {
573
568
  terminators += found;
574
569
  }
575
570
  if (terminators > 1) {
576
- report(ctx, item.file.relPath, extraLine, "warning", "item/sentence", `item ${item.id} carries more than one sentence; review it for a second governing statement (meta-29)`);
571
+ report(ctx, item.file.relPath, extraLine, "warning", "item/sentence", `item ${item.id} carries more than one sentence; review it for a second requirement (meta-29)`);
577
572
  }
578
573
  }
579
574
  }
@@ -581,8 +576,8 @@ function lintCitationDiscipline(ctx, items) {
581
576
  for (const file of ctx.files.values()) {
582
577
  if (!isUnder(file.relPath, "packages"))
583
578
  continue;
584
- // A package Intent is self-contained prose (meta-15): no
585
- // citation links, no reference markers (lint-13).
579
+ // Intent may carry supporting citations, but it is not an item
580
+ // relationship source, so exclude its links from cite/prose.
586
581
  const h2s = file.headings.filter((heading) => heading.depth === 2 && heading.root);
587
582
  const intentRanges = [];
588
583
  for (const [index, heading] of h2s.entries()) {
@@ -593,24 +588,10 @@ function lintCitationDiscipline(ctx, items) {
593
588
  end: h2s[index + 1]?.line ?? file.lines.length + 1,
594
589
  });
595
590
  }
596
- for (const range of intentRanges) {
597
- for (const link of file.links) {
598
- if (link.kind !== "link")
599
- continue;
600
- if (link.line > range.start && link.line < range.end) {
601
- report(ctx, file.relPath, link.line, "error", "intent/cited", "the Intent section carries a citation; a package reads standalone (meta-15)");
602
- }
603
- }
604
- for (const use of file.referenceUses) {
605
- if (use.line > range.start && use.line < range.end) {
606
- report(ctx, file.relPath, use.line, "error", "intent/cited", "the Intent section carries a reference marker; a package reads standalone (meta-15)");
607
- }
608
- }
609
- }
610
591
  // Item statements are the single relationship source (meta-14):
611
592
  // a peer-package link from section prose outside every item
612
593
  // body declares no dependency (lint-13). Intent links are
613
- // skipped here — they carry intent/cited already.
594
+ // supporting context rather than behavior relationships.
614
595
  const itemRanges = items
615
596
  .filter((item) => item.file === file)
616
597
  .map((item) => ({ start: item.heading.line, end: item.bodyEnd }));
@@ -696,6 +677,7 @@ function lintCitations(ctx, items) {
696
677
  report(ctx, file.relPath, link.line, "error", "cite/broken-link", `link target ${resolved} does not exist`);
697
678
  continue;
698
679
  }
680
+ lintRecordCitationForm(ctx, file, link, resolved, fragment);
699
681
  if (fragment !== "" && resolved.endsWith(".md")) {
700
682
  const target = ctx.files.get(resolved);
701
683
  if (target !== undefined && !target.slugs.has(fragment)) {
@@ -707,6 +689,16 @@ function lintCitations(ctx, items) {
707
689
  }
708
690
  }
709
691
  }
692
+ /** Record citations are plain links to the file, labeled by record ID. */
693
+ function lintRecordCitationForm(ctx, file, link, targetPath, fragment) {
694
+ const match = targetPath.match(/^specs\/(decisions|intents|iterations)\/(\d+)-[^/]+\.md$/);
695
+ if (match === null)
696
+ return;
697
+ const expected = `${match[1] === "decisions" ? "DR" : "IR"}-${match[2]}`;
698
+ if (!link.enclosed && link.text === expected && fragment === "")
699
+ return;
700
+ report(ctx, file.relPath, link.line, "error", "cite/record-link", `citation of ${expected} must be a plain relative link to its file with ${expected} as the link text (meta-16)`);
701
+ }
710
702
  /**
711
703
  * An item citation is an enclosed inline link whose link text is
712
704
  * the target item ID — `[[<pack>-<N>](<path>#<pack>-<N>)]`
package/dist/scaffold.js CHANGED
@@ -3,16 +3,15 @@
3
3
  import { execFileSync } from "node:child_process";
4
4
  import { existsSync, readFileSync, statSync } from "node:fs";
5
5
  import { join } from "node:path";
6
- import { appendAgentSpecs } from "./append-agent-specs.js";
6
+ import { parseAgentNames, reconcileAgentSpecs, resolveAgentTargets, } from "./append-agent-specs.js";
7
7
  import { getScaffoldDir, readBundledMarkdown } from "./bundled-scaffold.js";
8
- import { copyRootLicense, copyTemplates, formatSupportedLanguages, isLegacyPristine, isPristine, isSupportedLanguage, overwriteFrameworkSpecFiles, refreshPristineSeeds, } from "./copy-templates.js";
8
+ import { canonicalContentHash, copyRootLicense, copyTemplates, formatSupportedLanguages, getFileHistory, SUPPORTED_LANGUAGES, isLegacyPristine, isPristine, isSupportedLanguage, overwriteFrameworkSpecFiles, refreshPristineSeeds, } from "./copy-templates.js";
9
9
  import { createSpecsStructure } from "./create-specs-structure.js";
10
10
  import { resolveBase } from "./resolve-base.js";
11
11
  const AUTHORING_LANGUAGE_RE = /^Authoring language:\s*([A-Za-z0-9-]+)\s*$/m;
12
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.
13
+ // Structural migration is agent judgment, not CLI code (DR-022), so
14
+ // the CLI detects these and prints the bundled migration prompt.
16
15
  const LEGACY_GENERATION_DIRS = [
17
16
  "user",
18
17
  "dev",
@@ -30,6 +29,7 @@ function parseLanguage(code) {
30
29
  function parseArgs(args) {
31
30
  let update = false;
32
31
  let language;
32
+ let agents;
33
33
  const pathArgs = [];
34
34
  for (let i = 0; i < args.length; i += 1) {
35
35
  const arg = args[i];
@@ -56,24 +56,40 @@ function parseArgs(args) {
56
56
  language = parseLanguage(arg.slice("--lang=".length));
57
57
  continue;
58
58
  }
59
+ if (arg === "--agents") {
60
+ const value = args[i + 1];
61
+ if (value === undefined) {
62
+ throw new Error("--agents requires a comma-separated agent list");
63
+ }
64
+ if (agents !== undefined) {
65
+ throw new Error("--agents may only be specified once");
66
+ }
67
+ agents = parseAgentNames(value);
68
+ i += 1;
69
+ continue;
70
+ }
71
+ if (arg.startsWith("--agents=")) {
72
+ if (agents !== undefined) {
73
+ throw new Error("--agents may only be specified once");
74
+ }
75
+ agents = parseAgentNames(arg.slice("--agents=".length));
76
+ continue;
77
+ }
59
78
  if (arg.startsWith("-")) {
60
79
  throw new Error(`Unknown option: ${arg}`);
61
80
  }
62
81
  pathArgs.push(arg);
63
82
  }
64
83
  if (update) {
65
- if (language !== undefined) {
66
- throw new Error("--update does not accept --lang");
67
- }
68
84
  if (pathArgs.length !== 0) {
69
85
  throw new Error("--update does not accept a <path> argument");
70
86
  }
71
- return { mode: "update" };
87
+ return { mode: "update", language, agents };
72
88
  }
73
89
  if (pathArgs.length > 1) {
74
90
  throw new Error(`Unexpected arguments: ${pathArgs.slice(1).join(" ")}`);
75
91
  }
76
- return { mode: "create", pathArg: pathArgs[0], language };
92
+ return { mode: "create", pathArg: pathArgs[0], language, agents };
77
93
  }
78
94
  function getGitRoot() {
79
95
  try {
@@ -97,13 +113,35 @@ function assertCleanSpecsTree(basePath) {
97
113
  }
98
114
  }
99
115
  function readActiveLanguage(basePath) {
116
+ const resolved = resolveActiveLanguage(basePath);
117
+ return resolved.kind === "undeterminable" ? "en" : resolved.language;
118
+ }
119
+ /**
120
+ * Resolve the tree's authoring language and how confidently.
121
+ *
122
+ * A declaration is definitive. Absent one, `specs/meta.md` matching a
123
+ * version this CLI shipped is still definitive — every bundled base
124
+ * `meta.md` is English — which keeps pre-marker trees updating
125
+ * silently. What remains is genuinely undeterminable: a file we never
126
+ * shipped that declares nothing (a localized tree whose marker line
127
+ * was lost reads exactly like this), or no file at all. Guessing `en`
128
+ * there replaces a localized tree's framework files with English, so
129
+ * the caller stops instead.
130
+ */
131
+ function resolveActiveLanguage(basePath) {
100
132
  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]);
133
+ if (!existsSync(metaPath)) {
134
+ return { kind: "undeterminable", reason: "absent" };
135
+ }
136
+ const content = readFileSync(metaPath);
137
+ const match = content.toString("utf-8").match(AUTHORING_LANGUAGE_RE);
138
+ if (match !== null) {
139
+ return { kind: "declared", language: parseLanguage(match[1]) };
140
+ }
141
+ if (getFileHistory("specs/meta.md").includes(canonicalContentHash(content))) {
142
+ return { kind: "bundled-english", language: "en" };
143
+ }
144
+ return { kind: "undeterminable", reason: "unrecognized" };
107
145
  }
108
146
  function resolveCreateLanguage(basePath, requestedLanguage) {
109
147
  const metaPath = join(basePath, "specs", "meta.md");
@@ -161,52 +199,99 @@ function detectLegacyGeneration(basePath, language) {
161
199
  isOldGenerationMeta(basePath, language) ||
162
200
  matchesRetiredBundledSeed(basePath));
163
201
  }
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
202
  // SCAF-18: the four-step --update pipeline — framework overwrite, seed
178
203
  // refresh, agent-file refresh, then the completion output.
179
- function updateScaffoldTemplates() {
204
+ function updateScaffoldTemplates(agents, requested) {
180
205
  const basePath = getGitRoot();
181
206
  assertCleanSpecsTree(basePath);
182
- const language = readActiveLanguage(basePath);
207
+ const active = resolveActiveLanguage(basePath);
208
+ // An explicit --lang settles the language outright, so neither the
209
+ // undeterminable stop nor its warning applies.
210
+ if (active.kind === "undeterminable" && requested === undefined) {
211
+ if (active.reason === "unrecognized") {
212
+ throw new Error("specs/meta.md declares no authoring language and matches no bundled " +
213
+ "version, so the language cannot be determined and updating would " +
214
+ "replace the framework files with English. Restore its " +
215
+ "`Authoring language: <code>` line (`en` or `zh`), commit the " +
216
+ "specs/ change, and run again — --update needs a clean specs/ tree.");
217
+ }
218
+ // Absent: an older tree being repaired, since --update creates
219
+ // missing framework files. English is the only available answer,
220
+ // but a localized tree lands mixed, so it is never silent.
221
+ console.warn(" warning: no specs/meta.md, so the authoring language is unknown; " +
222
+ "creating framework files as en. On a localized tree, set the new " +
223
+ "`Authoring language:` line to that language, commit the specs/ " +
224
+ "changes, and run `spex scaffold --update` again to refresh them " +
225
+ "from its overlay.");
226
+ }
227
+ // The declaration, not the fallback: an undeclared tree must not
228
+ // look like an English one, or --lang en reads as "same language"
229
+ // and the switch never runs.
230
+ const declared = active.kind === "undeterminable" ? undefined : active.language;
231
+ const language = requested ?? declared ?? "en";
232
+ // A switch reads a tree written in one language and writes another,
233
+ // so both languages' bundled versions count as pristine: without
234
+ // that, the old language's files read as user customizations and
235
+ // seeds would be kept rather than converted.
236
+ // A switch reads a tree written in one language and writes another.
237
+ // When the tree still declares its language, that one language is
238
+ // enough; when it declares none, any bundled language could be in
239
+ // the tree, so all of them count — otherwise the undeclared tree's
240
+ // seeds read as customizations and are kept in the old language.
241
+ const switchingFrom = requested === undefined
242
+ ? undefined
243
+ : declared === undefined
244
+ ? "unknown"
245
+ : requested === declared
246
+ ? undefined
247
+ : declared;
248
+ const alsoRecognize = switchingFrom === undefined
249
+ ? []
250
+ : switchingFrom === "unknown"
251
+ ? SUPPORTED_LANGUAGES
252
+ : [switchingFrom];
183
253
  // Sample legacy-generation markers before the framework overwrite
184
254
  // replaces specs/meta.md (SCAF-26).
185
255
  const legacyGeneration = detectLegacyGeneration(basePath, language);
186
- const replacedFramework = overwriteFrameworkSpecFiles(basePath, language);
187
- refreshPristineSeeds(basePath, { language });
188
- appendAgentSpecs(basePath, { createMissing: false });
256
+ const agentTargets = resolveAgentTargets(basePath, agents);
257
+ const replacedFramework = overwriteFrameworkSpecFiles(basePath, language, alsoRecognize);
258
+ refreshPristineSeeds(basePath, { language, alsoRecognize });
259
+ reconcileAgentSpecs(basePath, agentTargets);
189
260
  warnReplacedFrameworkFiles(replacedFramework);
190
261
  console.log("");
191
262
  console.log("spex scaffold --update completed.");
192
263
  console.log("Review the file indicators above and inspect changes (e.g., `git diff -- specs`),");
193
264
  console.log("then run `spex lint` to check the specs tree.");
194
- console.log("Optionally, share this prompt with your AI agent to reconcile citations and local extensions:");
265
+ console.log(legacyGeneration
266
+ ? "Share this prompt with your AI agent to migrate the untouched legacy content:"
267
+ : "Optionally, share this prompt with your AI agent to reconcile citations and local extensions:");
195
268
  console.log("");
196
269
  console.log("```");
197
- console.log(readBundledMarkdown("update-merge-prompt.md"));
270
+ console.log(readBundledMarkdown(legacyGeneration
271
+ ? "spec-migration-prompt.md"
272
+ : "update-merge-prompt.md"));
198
273
  console.log("```");
199
- if (legacyGeneration)
200
- printMigrationGuidance();
274
+ if (switchingFrom !== undefined) {
275
+ console.log("");
276
+ console.log(switchingFrom === "unknown"
277
+ ? `Authoring language set to ${language}: bundled specs are now ${language}.`
278
+ : `Authoring language switched from ${switchingFrom} to ${language}: bundled specs are now ${language}.`);
279
+ console.log("Existing project specs stay in their original language — translating them is agent work.");
280
+ console.log("Share this prompt with your AI agent to translate them:");
281
+ console.log("");
282
+ console.log("```");
283
+ console.log(readBundledMarkdown("language-switch-prompt.md"));
284
+ console.log("```");
285
+ }
201
286
  }
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.
287
+ // SCAF-52: a legacy tree gets the migration prompt, not a re-scaffold —
288
+ // creating current seed targets beside legacy files would entangle two
289
+ // spec generations before migration.
205
290
  function assertNoLegacyLayout(basePath) {
206
291
  for (const dir of LEGACY_GENERATION_DIRS) {
207
292
  const abs = join(basePath, "specs", dir);
208
293
  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`);
294
+ throw new Error(`specs/${dir}/ marks a legacy spec generation (spex 0.x); run \`spex scaffold --update\` to refresh templates and get the migration prompt before scaffolding`);
210
295
  }
211
296
  }
212
297
  }
@@ -218,16 +303,17 @@ export function scaffold(args = []) {
218
303
  try {
219
304
  const options = parseArgs(args);
220
305
  if (options.mode === "update") {
221
- updateScaffoldTemplates();
306
+ updateScaffoldTemplates(options.agents, options.language);
222
307
  return;
223
308
  }
224
309
  const basePath = resolveBase(options.pathArg);
225
310
  const language = resolveCreateLanguage(basePath, options.language);
226
311
  assertNoLegacyLayout(basePath);
312
+ const agentTargets = resolveAgentTargets(basePath, options.agents);
227
313
  createSpecsStructure(basePath);
228
314
  copyTemplates(basePath, language);
229
315
  copyRootLicense(basePath);
230
- appendAgentSpecs(basePath);
316
+ reconcileAgentSpecs(basePath, agentTargets);
231
317
  }
232
318
  catch (err) {
233
319
  const msg = err instanceof Error ? err.message : String(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sublang/spex",
3
- "version": "1.0.0",
3
+ "version": "2.1.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",
@@ -1,34 +1,40 @@
1
1
  {
2
2
  "i18n/zh/specs/map.md": [
3
3
  "sha256-f1bcf636c567b830c5d6f625e10c8e4fe2c56b71fa7787106cd7b8701ad20efe",
4
- "sha256-5da224028a738e3f8c50adbeb1f2bc9006beafe47050594a9a30b207d8ff0386"
4
+ "sha256-5da224028a738e3f8c50adbeb1f2bc9006beafe47050594a9a30b207d8ff0386",
5
+ "sha256-390e4beb58f88ffcdb63c9518634d31c07d61f71e09a3bfab0495a5da0c56244"
5
6
  ],
6
7
  "i18n/zh/specs/meta.md": [
7
8
  "sha256-ce07160cf8af1fb67f4f86c572aa182e92dff24a72b313a89914e058de894b56",
8
9
  "sha256-78a34b62546391e16f27265399c62568882563cad97def3520d9f675a7b75cab",
9
10
  "sha256-1d8a2507d30ef54b5d935a53b448ec74ea8a8556df5cae24e81dcfbd94f9b648",
10
- "sha256-3c75823810863849ae302255d477749fc57e8e367a499240cde0dd47c479219a"
11
+ "sha256-3c75823810863849ae302255d477749fc57e8e367a499240cde0dd47c479219a",
12
+ "sha256-b4feb754ffd405050d50efe9da527c9a81e7dec48f58a7ed29db3bd28617bbbb"
11
13
  ],
12
14
  "specs/decisions/000-spec-structure-format.md": [
13
15
  "sha256-28d0705311a8ede97c487a944efe99bed20863e246da0aa1a33286dd4f8864ca",
14
16
  "sha256-a06e1b102d96c91f6ba36fd317426aae9c6a384a76c2dd5996275405d02d1883",
15
17
  "sha256-e492c52ea2ff89ab7b5b87d151a1755fac094233524eb8e6718be43111321227",
16
- "sha256-97041a244e1f1bef6c14b44a2805c214931c649faa523e49489ae7c42c9c11b5"
18
+ "sha256-97041a244e1f1bef6c14b44a2805c214931c649faa523e49489ae7c42c9c11b5",
19
+ "sha256-456de62399db3a9d5d4ee9cfc722930112d677ee50660b4702d04837c9f5b1ea"
17
20
  ],
18
21
  "specs/map.md": [
19
22
  "sha256-a1d6bc4a23fa58d8ccdcf7cd0570fc05face0aae8b6947367298dad3cde0af75",
20
23
  "sha256-4f2772c2d268972c1d5b1e2f4efb604b304c285ef3d91def9c1bad59666b303d",
21
- "sha256-aa12c658e84b8925b2981807a72edc9dbd274a78bd87f7186bb558afc42d8bc6"
24
+ "sha256-aa12c658e84b8925b2981807a72edc9dbd274a78bd87f7186bb558afc42d8bc6",
25
+ "sha256-6d93bd3c2c2fc35e0806229f45c751429ae4ef7ae86ff9e9089b76b0edbf7461"
22
26
  ],
23
27
  "specs/meta.md": [
24
28
  "sha256-ce07160cf8af1fb67f4f86c572aa182e92dff24a72b313a89914e058de894b56",
25
29
  "sha256-78a34b62546391e16f27265399c62568882563cad97def3520d9f675a7b75cab",
26
30
  "sha256-6a23f014ccbbe871e811f2ef9bd39119b50f0ce65a10bd75045d5735cf5b70b3",
27
- "sha256-ca67a077cfaecb51a85e98ec8f8508ce9d8a43dcb7355b9e16de611c38cdabfc"
31
+ "sha256-ca67a077cfaecb51a85e98ec8f8508ce9d8a43dcb7355b9e16de611c38cdabfc",
32
+ "sha256-ba58b39de3537f06fbe4f13c9b1443a8a64cf090c9ba202a67263dfc054b78c8"
28
33
  ],
29
34
  "specs/packages/git.md": [
30
35
  "sha256-1b194304866d05580de8b2d0caa3454aa772e876fb3dee1f6c5d637c9e9a42b2",
31
- "sha256-77625a315ac14eb6fd5f3c0697f121646ba8c0d976a98c3b51f27f3422cd1afb"
36
+ "sha256-77625a315ac14eb6fd5f3c0697f121646ba8c0d976a98c3b51f27f3422cd1afb",
37
+ "sha256-648eb12f6dd2dd5b9c9cebc14708de1a6d2184b698dfeacce93102995878e14a"
32
38
  ],
33
39
  "specs/packages/licensing.md": [
34
40
  "sha256-ff6ce317bf51fb2f4a20dde8790a79f2a1237f6b5835c74e619f6e3d1647ab50",
@@ -1,13 +1,9 @@
1
1
  ## Specs (Source of Truth)
2
2
 
3
3
  - Canonical specs live in @specs/.
4
- Start with @specs/map.md for a quick-reference index of all spec files and @specs/meta.md for the spec format.
4
+ Start with @specs/map.md for a quick-reference index of all spec files and @specs/meta.md for the spec format; spec packages live in @specs/packages.
5
5
  - Before making changes or suggestions in an area that has a spec, read the relevant spec file(s) first and follow them.
6
6
  - Whenever your changes involve any spec, or you make a decision worth recording, keep the specs in sync — don't let them drift.
7
- - Keep specs:
8
- - Complete & coherent: sufficient for you to reimplement code.
9
- - Right level: each package file in @specs/packages holds its shared intent (## Intent), behavior its users may rely on (## External Behavior), optional implementation hidden from them (## Internal Behavior), and tests of its own claims (## Verification); behavior that emerges from several packages working together is itself a spec package citing the peers' External Behavior — there is no @specs/compositions. Specify integration/system testing, not unit testing, and prefer tests that execute the real behavior of cited packages over substitutes.
10
- - Minimal: essential and concise; also check against other spec items to avoid overlap.
11
- - Well organized: spec packages are finely scoped, with high cohesion and low coupling.
12
- - Single-source: item citations are enclosed relative links like `[[pack-3](pack.md#pack-3)]`, written inline at the phrase that relies on them; items carry no metadata lines (`Verifies:`, `Binds:`, `Composes:`, `Clients:`, `Suppliers:`, `Scope:`).
7
+ - Resolve conflicts spec-first, then iterate freely: an intended change that conflicts with existing spec items is resolved in the specs — or dropped — before coding against it; implementing first to explore an approach is fine, and implementation lessons update this intent's specs, but no intent completes until its specs and code agree.
8
+ - Keep specs lawful per @specs/meta.md — the law itself, not this summary: complete and exact (meta-34), minimal (meta-23), one requirement per item (meta-29), cohesive packages for a shared intent (meta-13), sections per meta-30, relationships and test evidence only as inline citations (meta-14, meta-16, meta-20), integration/system tests only (meta-21, meta-32).
13
9
  - Run `spex lint` to check structure, item IDs, and citations after editing specs; never add trace lines to satisfy an older checker.
@@ -1,5 +1,6 @@
1
1
  <!-- SPDX-License-Identifier: Apache-2.0 -->
2
2
  <!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
3
+ <!-- spex-i18n-source: map.md sha256-6d93bd3c2c2fc35e0806229f45c751429ae4ef7ae86ff9e9089b76b0edbf7461 -->
3
4
 
4
5
  # 规约地图
5
6
 
@@ -11,9 +12,6 @@
11
12
 
12
13
  在编写、修改或审阅 DR、IR 或条目前,先了解 [`meta.md`](meta.md) 中的规则。
13
14
 
14
- - DR 和 IR:见 [Overall](meta.md#overall)、[Record format](meta.md#record-format) 和 [Citation](meta.md#citation)。
15
- - 条目:见 [Overall](meta.md#overall)、[Item syntax](meta.md#item-syntax)、[Spec packages](meta.md#spec-packages)、[Testing](meta.md#testing) 和 [Citation](meta.md#citation)。
16
-
17
15
  ## 目录结构
18
16
 
19
17
  ```text
@@ -28,15 +26,15 @@ meta.md 规约的规约
28
26
 
29
27
  | ID | 文件 | 摘要 |
30
28
  | --- | --- | --- |
31
- | DR-000 | [000-spec-structure-format.md](decisions/000-spec-structure-format.md) | 规约结构、格式和命名约定 |
29
+ | [DR-000](decisions/000-spec-structure-format.md) | 000-spec-structure-format.md | 规约结构、格式和命名约定 |
32
30
 
33
31
  ## 意图
34
32
 
35
33
  | ID | 文件 | 意图 |
36
34
  | --- | --- | --- |
37
- | IR-000 | [000-spdx-headers.md](intents/000-spdx-headers.md) | 为适用文件添加 SPDX 头 |
35
+ | [IR-000](intents/000-spdx-headers.md) | 000-spdx-headers.md | 为适用文件添加 SPDX 头 |
38
36
 
39
- ## 包
37
+ ## 规约包
40
38
 
41
39
  | 文件 | 摘要 |
42
40
  | --- | --- |