@synopackageland/cli 0.53.10 → 0.53.11

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.53.11 (2026-11-11)
4
+
5
+ - `check`, `build` and `inspect` accept `--catalog <catalog.yaml>` (or `SYNOPKGLAND_CATALOG`, also from `.env`): a schema 4 catalog entry, selected by its `pins` package name and the exact SPK version, supplies the store text. Before packaging, the build projects it in memory: INFO `description` and the eight `description_<language>` from the long description (paragraph breaks as spaces, not shortened), INFO `changelog` from that version's English notes joined with ` · `, and nine-language `description`, `long_description` and that version's notes in `spk_land_metadata`. The DSM main menu tooltip keeps the short description. `build` writes `release-notes.md` next to the SPKs and reports the catalog SHA-256 as `catalogText`.
6
+ - With a catalog, the build fails when the entry or the exact version's notes are missing, any of the nine languages is missing, text ends with a period, or `dsm-package.yaml` still writes `description`, `i18n.info.<language>.description` or `metadata.description/long_description/changelog`.
7
+ - `inspect <spk> --catalog` and `check <spk> --catalog` fail with `CATALOG_TEXT_DRIFT` when the SPK's INFO or metadata differ from the catalog's projection.
8
+ - SPK metadata accepts a short `description` (plain or per language, up to 1,000 characters). Without a catalog, manifests and built SPKs are unchanged.
9
+
3
10
  ## 0.53.10 (2026-11-11)
4
11
 
5
12
  - `entry: admin-only` no longer turns `integration` routes (`api.HandleIntegration` callbacks, which have no DSM session) into `administrators`. Every admin-only App with an integration callback in its v2 `ctl.registry` failed `ctl generate`, `check` and `build` with `CTL_ROUTE_MISMATCH: missing spec or permission mismatch` for the callback. The registry keeps `integration` for these operations, and the generated permissions keep `integration`. Other App routes are still raised to `administrators`, so a registry that declares them below `administrators` is still refused. The v1 description path is unchanged.
@@ -0,0 +1,60 @@
1
+ import { type Locale } from "./standalone/i18n.js";
2
+ import type { PackageMetadata } from "./package-metadata.js";
3
+ /**
4
+ * Store text from a catalog file (schema 4): the one place a package's short
5
+ * and long description and per-version release notes are written. `--catalog`
6
+ * or SYNOPKGLAND_CATALOG projects it into the manifest in memory, before any
7
+ * packaging, so INFO, SPK metadata and release notes all come from it.
8
+ */
9
+ export declare const CATALOG_ENV = "SYNOPKGLAND_CATALOG";
10
+ export declare const CATALOG_SCHEMA = 4;
11
+ /** INFO changelog separator, the same the package feed uses. */
12
+ export declare const NOTE_SEPARATOR = " \u00B7 ";
13
+ /** The hand-written manifest fields the catalog replaces. */
14
+ export declare const CATALOG_OWNED_FIELDS: readonly ["description", "i18n.info.<language>.description", "metadata.description", "metadata.long_description", "metadata.changelog"];
15
+ export type LocalizedMap = Record<Locale, string>;
16
+ export interface CatalogText {
17
+ /** Absolute catalog file path and SHA-256 of its bytes, for release evidence. */
18
+ source: {
19
+ path: string;
20
+ sha256: string;
21
+ };
22
+ package: string;
23
+ version: string;
24
+ description: LocalizedMap;
25
+ long_description: LocalizedMap;
26
+ notes: Record<Locale, string[]>;
27
+ }
28
+ /** What a build or drift check reports for release evidence. */
29
+ export interface CatalogEvidence {
30
+ path: string;
31
+ sha256: string;
32
+ package: string;
33
+ version: string;
34
+ releaseNotes?: string;
35
+ }
36
+ export declare class CatalogTextError extends Error {
37
+ readonly code: string;
38
+ constructor(code: string, message: string);
39
+ }
40
+ /** `--catalog` wins over SYNOPKGLAND_CATALOG; both are paths to catalog.yaml. */
41
+ export declare function setCatalogPath(path: string | undefined): void;
42
+ export declare function activeCatalogPath(): string | undefined;
43
+ /** The entry whose pins name this package, and that exact SPK version's notes. */
44
+ export declare function readCatalogText(path: string, pkg: string, version: string): CatalogText;
45
+ /** INFO description: paragraph breaks become spaces; nothing is cut. */
46
+ export declare function infoDescription(text: string): string;
47
+ export declare function infoChangelog(notes: string[]): string;
48
+ /** The SPK metadata fields the catalog owns; the rest of the manifest metadata stays. */
49
+ export declare function catalogMetadata(text: CatalogText, metadata?: PackageMetadata): PackageMetadata;
50
+ /** The INFO fields the catalog sets: English description/changelog and eight description_<lang>. */
51
+ export declare function catalogInfoFields(text: CatalogText): Record<string, string>;
52
+ /** release-notes.md for this version: English first, then each translation. */
53
+ export declare function releaseNotesMarkdown(text: CatalogText): string;
54
+ /** Fields of a built SPK that differ from the catalog projection; empty when they match. */
55
+ export declare function catalogDrift(text: CatalogText, info: Map<string, string>): string[];
56
+ /** Reads a built SPK's INFO and compares it with the catalog's projection for its package and version. */
57
+ export declare function spkCatalogDrift(spk: string, catalogPath: string): Promise<{
58
+ text: CatalogText;
59
+ drift: string[];
60
+ }>;
@@ -0,0 +1,211 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFileSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import { parse } from "yaml";
5
+ import { DSM_LANGS, LOCALES } from "./standalone/i18n.js";
6
+ /**
7
+ * Store text from a catalog file (schema 4): the one place a package's short
8
+ * and long description and per-version release notes are written. `--catalog`
9
+ * or SYNOPKGLAND_CATALOG projects it into the manifest in memory, before any
10
+ * packaging, so INFO, SPK metadata and release notes all come from it.
11
+ */
12
+ export const CATALOG_ENV = "SYNOPKGLAND_CATALOG";
13
+ export const CATALOG_SCHEMA = 4;
14
+ /** INFO changelog separator, the same the package feed uses. */
15
+ export const NOTE_SEPARATOR = " · ";
16
+ /** The hand-written manifest fields the catalog replaces. */
17
+ export const CATALOG_OWNED_FIELDS = [
18
+ "description",
19
+ "i18n.info.<language>.description",
20
+ "metadata.description",
21
+ "metadata.long_description",
22
+ "metadata.changelog",
23
+ ];
24
+ export class CatalogTextError extends Error {
25
+ code;
26
+ constructor(code, message) {
27
+ super(message);
28
+ this.code = code;
29
+ }
30
+ }
31
+ let explicitPath;
32
+ /** `--catalog` wins over SYNOPKGLAND_CATALOG; both are paths to catalog.yaml. */
33
+ export function setCatalogPath(path) {
34
+ explicitPath = path === undefined ? undefined : resolve(path);
35
+ }
36
+ export function activeCatalogPath() {
37
+ if (explicitPath)
38
+ return explicitPath;
39
+ const env = process.env[CATALOG_ENV]?.trim();
40
+ return env ? resolve(env) : undefined;
41
+ }
42
+ const TRAILING_PERIOD = /[.。.。]$/;
43
+ // Control characters other than a line feed; INFO lines and DSM strings can't carry them.
44
+ const CONTROL = /[\x00-\x09\x0b-\x1f\x7f]/;
45
+ function isRecord(value) {
46
+ return typeof value === "object" && value !== null && !Array.isArray(value);
47
+ }
48
+ function fail(code, message) {
49
+ throw new CatalogTextError(code, message);
50
+ }
51
+ const REFUSED = {
52
+ short: [/[\n"\\]/, "one line without control characters, \" or \\"],
53
+ line: [/\n/, "one line without control characters"],
54
+ long: [/(?!)/, "text without control characters"],
55
+ };
56
+ function checkedText(value, where, kind) {
57
+ if (typeof value !== "string" || !value.trim())
58
+ fail("CATALOG_TEXT_LANGUAGE_MISSING", `${where} is missing or empty.`);
59
+ const [refused, rule] = REFUSED[kind];
60
+ if (CONTROL.test(value) || refused.test(value))
61
+ fail("CATALOG_TEXT_INVALID", `${where} must be ${rule}.`);
62
+ if (TRAILING_PERIOD.test(value.trimEnd()))
63
+ fail("CATALOG_TEXT_TRAILING_PERIOD", `${where} ends with a period; store text has no trailing period.`);
64
+ return value;
65
+ }
66
+ function localized(value, where, kind) {
67
+ if (!isRecord(value))
68
+ fail("CATALOG_TEXT_LANGUAGE_MISSING", `${where} must map each of ${LOCALES.join(", ")} to text.`);
69
+ return Object.fromEntries(LOCALES.map((locale) => [locale, checkedText(value[locale], `${where}.${locale}`, kind)]));
70
+ }
71
+ function noteLists(value, where) {
72
+ if (!isRecord(value))
73
+ fail("CATALOG_NOTES_MISSING", `${where} is missing.`);
74
+ return Object.fromEntries(LOCALES.map((locale) => {
75
+ const list = value[locale];
76
+ if (!Array.isArray(list) || list.length === 0)
77
+ fail("CATALOG_TEXT_LANGUAGE_MISSING", `${where}.${locale} must be a nonempty list of notes.`);
78
+ return [locale, list.map((note, i) => checkedText(note, `${where}.${locale}[${i}]`, "line"))];
79
+ }));
80
+ }
81
+ /** The entry whose pins name this package, and that exact SPK version's notes. */
82
+ export function readCatalogText(path, pkg, version) {
83
+ let bytes;
84
+ try {
85
+ bytes = readFileSync(path);
86
+ }
87
+ catch {
88
+ fail("CATALOG_FILE_UNREADABLE", `The catalog file cannot be read: ${path}`);
89
+ }
90
+ let doc;
91
+ try {
92
+ doc = parse(bytes.toString("utf8"));
93
+ }
94
+ catch (error) {
95
+ fail("CATALOG_FILE_UNREADABLE", `The catalog file is not valid YAML: ${error.message}`);
96
+ }
97
+ if (!isRecord(doc) || doc.schema !== CATALOG_SCHEMA || !Array.isArray(doc.packages))
98
+ fail("CATALOG_SCHEMA_UNSUPPORTED", `The catalog file must be schema ${CATALOG_SCHEMA} with a packages list.`);
99
+ const entries = doc.packages.filter((entry) => isRecord(entry) && Array.isArray(entry.pins) && entry.pins.some((pin) => isRecord(pin) && pin.package === pkg));
100
+ if (entries.length !== 1)
101
+ fail("CATALOG_ENTRY_MISSING", entries.length
102
+ ? `The catalog has ${entries.length} entries for ${pkg}; it must have exactly one.`
103
+ : `The catalog has no entry whose pins name ${pkg}.`);
104
+ const metadata = entries[0].metadata;
105
+ if (!isRecord(metadata))
106
+ fail("CATALOG_ENTRY_MISSING", `The catalog entry for ${pkg} has no metadata.`);
107
+ const where = `catalog ${pkg} metadata`;
108
+ const description = localized(metadata.description, `${where}.description`, "short");
109
+ const long_description = metadata.long_description === undefined
110
+ ? description
111
+ : localized(metadata.long_description, `${where}.long_description`, "long");
112
+ const releases = isRecord(metadata.changelog) ? metadata.changelog.releases : undefined;
113
+ if (!isRecord(releases) || !Object.hasOwn(releases, version))
114
+ fail("CATALOG_NOTES_MISSING", `The catalog has no notes for ${pkg} ${version}; add metadata.changelog.releases.${version} in all nine languages.`);
115
+ const notes = noteLists(releases[version], `${where}.changelog.releases.${version}`);
116
+ return {
117
+ source: { path, sha256: createHash("sha256").update(bytes).digest("hex") },
118
+ package: pkg,
119
+ version,
120
+ description,
121
+ long_description,
122
+ notes,
123
+ };
124
+ }
125
+ /** INFO description: paragraph breaks become spaces; nothing is cut. */
126
+ export function infoDescription(text) {
127
+ return text.trim().replace(/[ \t]*\n\s*/g, " ");
128
+ }
129
+ export function infoChangelog(notes) {
130
+ return notes.join(NOTE_SEPARATOR);
131
+ }
132
+ /** The SPK metadata fields the catalog owns; the rest of the manifest metadata stays. */
133
+ export function catalogMetadata(text, metadata) {
134
+ return {
135
+ ...metadata,
136
+ description: { ...text.description },
137
+ long_description: { ...text.long_description },
138
+ changelog: Object.fromEntries(LOCALES.map((locale) => [locale, text.notes[locale].join("\n")])),
139
+ };
140
+ }
141
+ /** The INFO fields the catalog sets: English description/changelog and eight description_<lang>. */
142
+ export function catalogInfoFields(text) {
143
+ const fields = {
144
+ description: infoDescription(text.long_description.en),
145
+ changelog: infoChangelog(text.notes.en),
146
+ };
147
+ for (const locale of LOCALES)
148
+ if (locale !== "en")
149
+ fields[`description_${DSM_LANGS[locale]}`] = infoDescription(text.long_description[locale]);
150
+ return fields;
151
+ }
152
+ const LANGUAGE_NAMES = {
153
+ en: "English",
154
+ "zh-TW": "繁體中文",
155
+ "zh-CN": "简体中文",
156
+ ja: "日本語",
157
+ ko: "한국어",
158
+ de: "Deutsch",
159
+ fr: "Français",
160
+ es: "Español",
161
+ it: "Italiano",
162
+ };
163
+ /** release-notes.md for this version: English first, then each translation. */
164
+ export function releaseNotesMarkdown(text) {
165
+ const list = (notes) => notes.map((note) => `- ${note}`).join("\n");
166
+ return [
167
+ list(text.notes.en),
168
+ ...LOCALES.filter((locale) => locale !== "en").map((locale) => `### ${LANGUAGE_NAMES[locale]}\n\n${list(text.notes[locale])}`),
169
+ ].join("\n\n") + "\n";
170
+ }
171
+ /** Fields of a built SPK that differ from the catalog projection; empty when they match. */
172
+ export function catalogDrift(text, info) {
173
+ const drift = [];
174
+ for (const [key, expected] of Object.entries(catalogInfoFields(text)))
175
+ if (info.get(key) !== expected)
176
+ drift.push(`INFO ${key}`);
177
+ let metadata;
178
+ try {
179
+ metadata = JSON.parse(info.get("spk_land_metadata") ?? "");
180
+ }
181
+ catch {
182
+ metadata = undefined;
183
+ }
184
+ if (!isRecord(metadata))
185
+ return [...drift, "INFO spk_land_metadata"];
186
+ const expected = catalogMetadata(text);
187
+ for (const key of ["description", "long_description", "changelog"])
188
+ if (JSON.stringify(metadata[key]) !== JSON.stringify(expected[key]))
189
+ drift.push(`spk_land_metadata.${key}`);
190
+ return drift;
191
+ }
192
+ /** Reads a built SPK's INFO and compares it with the catalog's projection for its package and version. */
193
+ export async function spkCatalogDrift(spk, catalogPath) {
194
+ const [{ mkdtempSync, rmSync }, { tmpdir }, { join }, { extractSpk }, { parseInfo }] = await Promise.all([
195
+ import("node:fs"),
196
+ import("node:os"),
197
+ import("node:path"),
198
+ import("./build-spk/generator.js"),
199
+ import("./spk/check-info.js"),
200
+ ]);
201
+ const dir = mkdtempSync(join(tmpdir(), "synopkgland-catalog-"));
202
+ try {
203
+ await extractSpk(spk, dir);
204
+ const info = parseInfo(readFileSync(join(dir, "INFO"), "utf8"));
205
+ const text = readCatalogText(catalogPath, info.get("package") ?? "", info.get("version") ?? "");
206
+ return { text, drift: catalogDrift(text, info) };
207
+ }
208
+ finally {
209
+ rmSync(dir, { recursive: true, force: true });
210
+ }
211
+ }
package/dist/cli.js CHANGED
@@ -41,6 +41,7 @@ import { checkJobs, commitOutputs, forEachArch, } from "./standalone/arch-jobs.j
41
41
  import { checkReproducible } from "./reproducible.js";
42
42
  import { spkApprovalDiff, formatApprovalDiff } from "./runtime/approval-diff.js";
43
43
  import { inspectAnySpk } from "./spk/inspect.js";
44
+ import { activeCatalogPath, CATALOG_ENV, CatalogTextError, setCatalogPath, spkCatalogDrift } from "./catalog-text.js";
44
45
  import { validateSpk } from "./spk/validate-spk.js";
45
46
  import { backupRecord } from "./standalone/hyper-backup.js";
46
47
  import { terminalSafe } from "./terminal-text.js";
@@ -199,6 +200,33 @@ function formatSpkReport(spk, report) {
199
200
  ...formatSpkChecks(report),
200
201
  ].join("\n");
201
202
  }
203
+ const CATALOG_OPTION = "Catalog file (schema 4) whose entry supplies the store text; also " + CATALOG_ENV;
204
+ /** The catalog projection covers dsm-package.yaml Apps only, not native layouts or synology-app.yaml. */
205
+ function requireCatalogSupport(standalone) {
206
+ const catalog = activeCatalogPath();
207
+ if (catalog && (!standalone || isNativeLayout(standalone)))
208
+ throw failure("CATALOG_TEXT_UNSUPPORTED", `${catalog}: store text from a catalog needs a dsm-package.yaml App without a native layout.`, `Remove --catalog and ${CATALOG_ENV}, and keep the text in the manifest.`);
209
+ }
210
+ /** Fails when a built SPK's INFO or metadata no longer match the catalog entry. */
211
+ async function checkCatalogDrift(spk) {
212
+ const catalog = activeCatalogPath();
213
+ if (!catalog)
214
+ return undefined;
215
+ let result;
216
+ try {
217
+ result = await spkCatalogDrift(spk, catalog);
218
+ }
219
+ catch (error) {
220
+ if (error instanceof CatalogTextError)
221
+ throw failure(error.code, error.message);
222
+ throw error;
223
+ }
224
+ if (result.drift.length)
225
+ throw failure("CATALOG_TEXT_DRIFT", `${spk} differs from ${catalog} for ${result.text.package} ${result.text.version}: ${result.drift.join(", ")}.`, "Rebuild the SPK with the same --catalog file; never edit SPK bytes after the build.");
226
+ return { ...result.text.source, package: result.text.package, version: result.text.version };
227
+ }
228
+ /** The catalog evidence of the last standalone build; the build command reports it. */
229
+ let lastCatalogText;
202
230
  async function standaloneBuild(root, arches, options) {
203
231
  if (options.output && arches?.length !== 1)
204
232
  throw failure("CLI_OUTPUT_ARCH_REQUIRED", "-o requires a single --arch; use --out-dir for multiple architectures.");
@@ -223,6 +251,7 @@ async function standaloneBuild(root, arches, options) {
223
251
  jobs: options.jobs,
224
252
  });
225
253
  result.warnings?.forEach((warning) => console.error(warning));
254
+ lastCatalogText = result.catalogText;
226
255
  return result.outputs.map((output) => {
227
256
  if (!options.output)
228
257
  return output;
@@ -313,6 +342,8 @@ async function containerBuild(project, arches, options) {
313
342
  /** Resolves after dispatch; commands may set process.exitCode. Rejections are failures. */
314
343
  export async function runCli(argv) {
315
344
  installOutputGuards();
345
+ setCatalogPath(undefined);
346
+ lastCatalogText = undefined;
316
347
  if (argv[2] === 'ctl' && argv[3] === 'external') {
317
348
  const { runCtl } = await import('./ctl/cli.js');
318
349
  return runCtl(argv.slice(3));
@@ -407,19 +438,24 @@ async function runCliWithin(argv) {
407
438
  program
408
439
  .command("check [spk]")
409
440
  .description("Validate the project, or check a built SPK including its final public UI payload")
441
+ .option("--catalog <file>", CATALOG_OPTION)
410
442
  .option("--json", "Print a single JSON object")
411
- .action(async (input, _options, command) => {
443
+ .action(async (input, options, command) => {
444
+ if (options.catalog)
445
+ setCatalogPath(options.catalog);
412
446
  if (input) {
413
447
  const spk = resolve(input);
414
448
  const report = await validateSpk(spk);
415
449
  if (!report.ok)
416
450
  throw Object.assign(failure("SPK_CHECK_FAILED", formatFindings(report.errors).join("\n"), "Remove public UI credentials and source maps, correct the package and rebuild."), { report: { spk, ...report } });
417
- emit("check", { spk, ...report }, [
451
+ const catalogText = await checkCatalogDrift(spk);
452
+ emit("check", { spk, ...report, ...(catalogText ? { catalogText } : {}) }, [
418
453
  `SPK check passed: ${spk}`,
419
454
  ...formatFindings(report.warnings),
420
455
  ].join("\n"));
421
456
  return;
422
457
  }
458
+ requireCatalogSupport(standaloneRoot(rootOf(command)) ?? undefined);
423
459
  const validation = validateProject(requireProject(rootOf(command)), {
424
460
  profile: "personal",
425
461
  });
@@ -529,6 +565,7 @@ async function runCliWithin(argv) {
529
565
  program
530
566
  .command("inspect <spk>")
531
567
  .option("--baseline <spk>", "Compare approval requirements with the previous SPK")
568
+ .option("--catalog <file>", "Catalog file (schema 4): fail when INFO or metadata differ from its entry; also " + CATALOG_ENV)
532
569
  .description("Inspect any SPK against the DSM 7 package format without installing; for a synopkgland-built SPK also check the build contract and root privilege requirements")
533
570
  .option("--json", "Print a single JSON object")
534
571
  .action(async (input, options) => {
@@ -538,8 +575,11 @@ async function runCliWithin(argv) {
538
575
  const report = await inspectAnySpk(spk);
539
576
  if (!report.dsm.ok || report.findings.length)
540
577
  throw Object.assign(failure("SPK_INSPECTION_FAILED", formatSpkChecks(report).join("\n"), "Fix the SPK by error code and repackage; see reference/errors for the codes; do not install an SPK that fails inspection."), { report: { spk, ...report } });
578
+ if (options.catalog)
579
+ setCatalogPath(options.catalog);
580
+ const catalogText = await checkCatalogDrift(spk);
541
581
  const approval = await spkApprovalDiff(spk, options.baseline && resolve(options.baseline), report);
542
- emit("inspect", { spk, ...report, approval }, formatSpkReport(spk, report) + "\n" + formatApprovalDiff(approval));
582
+ emit("inspect", { spk, ...report, approval, ...(catalogText ? { catalogText } : {}) }, formatSpkReport(spk, report) + "\n" + formatApprovalDiff(approval));
543
583
  });
544
584
  const images = program.command("images").description("Container image tools");
545
585
  images
@@ -786,6 +826,7 @@ async function runCliWithin(argv) {
786
826
  .description("Build an SPK from synology-app.yaml or dsm-package.yaml")
787
827
  .option("--json", "Print a single JSON object")
788
828
  .option("-o, --output <path>", "Output SPK; use with a single --arch")
829
+ .option("--catalog <file>", CATALOG_OPTION + "; writes release-notes.md next to the SPKs")
789
830
  .option("--out-dir <dir>", "Output directory; native projects default to dist/")
790
831
  .option("--arch <families>", `Architectures, comma-separated or repeated: ${NATIVE_ARCH_FAMILIES.join(",")} (armv7 is for native-go and binary, not for Container Manager Apps); native layout also supports armv8`, (value, previous) => [
791
832
  ...(previous ?? []),
@@ -797,6 +838,9 @@ async function runCliWithin(argv) {
797
838
  .action(async (options, command) => {
798
839
  const root = rootOf(command);
799
840
  const standalone = standaloneRoot(root);
841
+ if (options.catalog)
842
+ setCatalogPath(options.catalog);
843
+ requireCatalogSupport(standalone ?? undefined);
800
844
  const verify = options.verifyReproducible === true
801
845
  ? "changed"
802
846
  : options.verifyReproducible;
@@ -829,6 +873,7 @@ async function runCliWithin(argv) {
829
873
  ...overrides,
830
874
  });
831
875
  const outputs = await build();
876
+ const catalogText = lastCatalogText;
832
877
  const reproducible = verify === undefined
833
878
  ? undefined
834
879
  : await checkReproducible({
@@ -853,12 +898,13 @@ async function runCliWithin(argv) {
853
898
  ...(identityGateway ? [identityGateway.notice] : []),
854
899
  ...approval.map(item => item.output + "\n" + formatApprovalDiff(item)),
855
900
  ...outputs.map((output) => `Built ${output}`),
901
+ ...(catalogText ? [`Release notes ${catalogText.releaseNotes} (catalog sha256 ${catalogText.sha256})`] : []),
856
902
  ...(devices?.gpu ? [`GPU: ${devices.gpu.paths}; GID source: ${devices.gpu.gid_source}; fallback: ${devices.gpu.fallback}`] : []),
857
903
  ...(reproducible ? reproducibleLines(reproducible) : []),
858
904
  ];
859
905
  if (reproducible && !reproducible.identical)
860
906
  throw Object.assign(failure("BUILD_NOT_REPRODUCIBLE", lines.join("\n"), "Find the payload files that differ between builds (timestamps, random paths, unpinned dependencies) and retry after fixing them."), { report: { outputs, reproducible } });
861
- emit("build", { outputs, approval, ...(installSettings ? { installSettings } : {}), ...(identityGateway ? { identityGateway } : {}), ...(devices ? { compose: { devices } } : {}), ...(reproducible ? { reproducible } : {}) }, lines.join("\n"));
907
+ emit("build", { outputs, approval, ...(catalogText ? { catalogText } : {}), ...(installSettings ? { installSettings } : {}), ...(identityGateway ? { identityGateway } : {}), ...(devices ? { compose: { devices } } : {}), ...(reproducible ? { reproducible } : {}) }, lines.join("\n"));
862
908
  });
863
909
  if (json)
864
910
  console.log = (...args) => console.error(...args);
@@ -269,6 +269,56 @@ export const ERROR_REGISTRY = {
269
269
  description: "The deploy pre-install check found the Compose published TCP port already taken by another service or container.",
270
270
  suggestion: "Change the published host port in synology-app.yaml/compose.yaml; existing containers of the same Package Identity are allowed during upgrade or reinstall.",
271
271
  },
272
+ CATALOG_FILE_UNREADABLE: {
273
+ code: "CATALOG_FILE_UNREADABLE",
274
+ description: "The --catalog / SYNOPKGLAND_CATALOG file cannot be read or is not YAML.",
275
+ suggestion: "Pass the path of a catalog.yaml checkout at a fixed commit.",
276
+ },
277
+ CATALOG_SCHEMA_UNSUPPORTED: {
278
+ code: "CATALOG_SCHEMA_UNSUPPORTED",
279
+ description: "The catalog file is not schema 4.",
280
+ suggestion: "Use a schema 4 catalog.yaml, or build without --catalog and keep the text in the manifest.",
281
+ },
282
+ CATALOG_ENTRY_MISSING: {
283
+ code: "CATALOG_ENTRY_MISSING",
284
+ description: "The catalog has no single entry whose pins name this package.",
285
+ suggestion: "Add the package’s entry to the catalog, or check the package name.",
286
+ },
287
+ CATALOG_NOTES_MISSING: {
288
+ code: "CATALOG_NOTES_MISSING",
289
+ description: "The catalog entry has no release notes for this exact SPK version.",
290
+ suggestion: "Add metadata.changelog.releases.<SPK version> in all nine languages; older records are not used.",
291
+ },
292
+ CATALOG_TEXT_LANGUAGE_MISSING: {
293
+ code: "CATALOG_TEXT_LANGUAGE_MISSING",
294
+ description: "A catalog description or note list lacks one of the nine languages.",
295
+ suggestion: "Add en, zh-TW, zh-CN, ja, ko, de, fr, es and it.",
296
+ },
297
+ CATALOG_TEXT_INVALID: {
298
+ code: "CATALOG_TEXT_INVALID",
299
+ description: "Catalog store text has a control character, a line break in a note or short text, or a quote or backslash in the short text.",
300
+ suggestion: "Edit the catalog text; short descriptions are one line without a double quote or backslash.",
301
+ },
302
+ CATALOG_TEXT_TRAILING_PERIOD: {
303
+ code: "CATALOG_TEXT_TRAILING_PERIOD",
304
+ description: "Catalog store text ends with a period.",
305
+ suggestion: "Remove the trailing period (., 。, ., 。) from the description or note.",
306
+ },
307
+ CATALOG_TEXT_DUPLICATED: {
308
+ code: "CATALOG_TEXT_DUPLICATED",
309
+ description: "The manifest still hand-writes store text the catalog owns.",
310
+ suggestion: "Remove description, i18n.info.<language>.description and metadata.description/long_description/changelog from dsm-package.yaml.",
311
+ },
312
+ CATALOG_TEXT_DRIFT: {
313
+ code: "CATALOG_TEXT_DRIFT",
314
+ description: "A built SPK’s INFO or metadata differ from the catalog entry.",
315
+ suggestion: "Rebuild with the same --catalog file; never edit SPK bytes after the build.",
316
+ },
317
+ CATALOG_TEXT_UNSUPPORTED: {
318
+ code: "CATALOG_TEXT_UNSUPPORTED",
319
+ description: "Catalog store text needs a dsm-package.yaml App without a native layout.",
320
+ suggestion: "Remove --catalog and SYNOPKGLAND_CATALOG and keep the text in the manifest.",
321
+ },
272
322
  CATALOG_INSTALL_FAILED: {
273
323
  code: "CATALOG_INSTALL_FAILED",
274
324
  description: "NAS Package Center failed to install the package.",
@@ -8,6 +8,8 @@ export interface UpstreamMetadata {
8
8
  /** Normalize the URL shorthand to the catalog's existing structured contract. */
9
9
  export declare function upstreamMetadata(raw: unknown): UpstreamMetadata;
10
10
  export interface PackageMetadata {
11
+ /** Short store description, up to 1,000 characters. */
12
+ description?: LocalizedText;
11
13
  long_description?: LocalizedText;
12
14
  changelog?: LocalizedText;
13
15
  contact_email?: string;
@@ -44,6 +44,7 @@ export function validateMetadata(raw) {
44
44
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
45
45
  throw new Error("invalid metadata");
46
46
  const allowed = [
47
+ "description",
47
48
  "long_description",
48
49
  "changelog",
49
50
  "contact_email",
@@ -73,19 +74,19 @@ export function validateMetadata(raw) {
73
74
  !v.every(safeScreenshotUrl))
74
75
  throw new Error("invalid screenshots");
75
76
  }
76
- else if ((k === "long_description" || k === "changelog") &&
77
+ else if ((k === "description" || k === "long_description" || k === "changelog") &&
77
78
  typeof v === "object" &&
78
79
  v &&
79
80
  !Array.isArray(v)) {
80
81
  if (Object.entries(v).length > 32 ||
81
82
  !Object.entries(v).every(([lang, t]) => /^[a-z]{2}(?:-[A-Za-z]{2})?$/.test(lang) &&
82
83
  typeof t === "string" &&
83
- t.length <= 16000 &&
84
+ t.length <= (k === "description" ? 1000 : 16000) &&
84
85
  !/[\x00-\x08\x0b\x0c\x0e-\x1f]/.test(t)))
85
86
  throw new Error("invalid localized description");
86
87
  }
87
88
  else if (typeof v !== "string" ||
88
- v.length > 16000 ||
89
+ v.length > (k === "description" ? 1000 : 16000) ||
89
90
  /[\x00-\x08\x0b\x0c\x0e-\x1f]/.test(v))
90
91
  throw new Error("invalid text");
91
92
  if (k.endsWith("_email") &&
@@ -1,3 +1,4 @@
1
+ import { type CatalogEvidence } from "../catalog-text.js";
1
2
  import { type NativeArchFamily } from "../build-spk/dsm-arch.js";
2
3
  export interface CommandResult {
3
4
  status: number | null;
@@ -37,4 +38,6 @@ export declare function runnerFor(run: CommandRunner | undefined, jobs: number,
37
38
  export declare function buildStandalone(options: StandaloneBuildOptions): Promise<{
38
39
  outputs: string[];
39
40
  warnings: string[];
41
+ releaseNotes?: string;
42
+ catalogText?: CatalogEvidence;
40
43
  }>;
@@ -10,7 +10,8 @@ import { goChildEnv } from "../runtime/go-env.js";
10
10
  import { spawn } from "node:child_process";
11
11
  import { installCommand, packageManager } from "../package-manager.js";
12
12
  import { goModulePath, privateSdkHint, SDK_MODULE, sdkSource, } from "../runtime/sdk-source.js";
13
- import { existsSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
13
+ import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
14
+ import { releaseNotesMarkdown } from "../catalog-text.js";
14
15
  import { tmpdir } from "node:os";
15
16
  import { join } from "node:path";
16
17
  import { goBuildEnv } from "../build-spk/dsm-arch.js";
@@ -192,7 +193,13 @@ export async function buildStandalone(options) {
192
193
  });
193
194
  return outputPath;
194
195
  }));
195
- return { outputs, warnings: [...warnings] };
196
+ // The GitHub release text for this exact version, from the same catalog entry as INFO.
197
+ if (!manifest.catalogText)
198
+ return { outputs, warnings: [...warnings] };
199
+ const releaseNotes = join(outDir, "release-notes.md");
200
+ writeFileSync(releaseNotes, releaseNotesMarkdown(manifest.catalogText));
201
+ const { source, package: pkg, version } = manifest.catalogText;
202
+ return { outputs, warnings: [...warnings], releaseNotes, catalogText: { ...source, package: pkg, version, releaseNotes } };
196
203
  }
197
204
  finally {
198
205
  rmSync(work, { recursive: true, force: true });
@@ -88,10 +88,14 @@ export function entryLauncherAccess(entry) {
88
88
  : { allUsers: true, grantPrivilege: "all", advanceGrantPrivilege: true };
89
89
  }
90
90
  export function appTitle(manifest) {
91
+ // The main menu's tooltip keeps the catalog's short text; INFO carries the long one.
92
+ const short = manifest.catalogText?.description;
91
93
  return {
92
94
  displayname: manifest.displayname,
93
- description: manifest.description,
94
- info: manifest.i18n?.info,
95
+ description: short?.en ?? manifest.description,
96
+ info: short
97
+ ? Object.fromEntries(Object.entries(manifest.i18n?.info ?? {}).map(([locale, text]) => [locale, { ...text, description: short[locale] }]))
98
+ : manifest.i18n?.info,
95
99
  nativeTexts: manifest.i18n?.nativeTexts,
96
100
  };
97
101
  }
@@ -7,6 +7,7 @@ import { type InstallSettings } from './install-settings.js';
7
7
  import { type WebLaunchMode } from "../contract/web-launch.js";
8
8
  import { type WebAPIProfiles } from "../runtime/webapi-profile.js";
9
9
  import { type PackageMetadata } from "../package-metadata.js";
10
+ import { type CatalogText } from "../catalog-text.js";
10
11
  import { type DelegateCapability } from "../runtime/executor-policy.js";
11
12
  import type { ExecutorPins, ExecutorTask } from "../runtime/executor-tasks.js";
12
13
  import { type NativeArchFamily } from "../build-spk/dsm-arch.js";
@@ -66,6 +67,8 @@ export interface StandaloneManifest {
66
67
  external?: import("../ctl/descriptor.js").ApiPayload['external'];
67
68
  };
68
69
  metadata?: PackageMetadata;
70
+ /** Store text projected from `--catalog` / SYNOPKGLAND_CATALOG; absent on the manifest path. */
71
+ catalogText?: CatalogText;
69
72
  dependencies?: PackageDependencies;
70
73
  root: string;
71
74
  package: string;
@@ -17,12 +17,13 @@ import { BACKGROUND_WORKER_MAIN } from './background.js';
17
17
  import { isWebLaunchMode } from "../contract/web-launch.js";
18
18
  import { validWebAPIProfiles, } from "../runtime/webapi-profile.js";
19
19
  import { validateMetadata } from "../package-metadata.js";
20
+ import { activeCatalogPath, catalogMetadata, CatalogTextError, infoDescription, readCatalogText } from "../catalog-text.js";
20
21
  import { validDelegate, } from "../runtime/executor-policy.js";
21
22
  import { existsSync, readFileSync } from "node:fs";
22
23
  import { isAbsolute, join, relative, resolve } from "node:path";
23
24
  import { parse } from "yaml";
24
25
  import { isNativeArchFamily, } from "../build-spk/dsm-arch.js";
25
- import { checkGlossary, loadCatalogs, readInfoTranslations, } from "./i18n.js";
26
+ import { checkGlossary, loadCatalogs, LOCALES, readInfoTranslations, } from "./i18n.js";
26
27
  import { loadRootOps, readRootSettings, rootBinaryProblem, ROOT_OPS_DIR, } from "./root-ops.js";
27
28
  import { composeManifestContext, readComposeApp } from "./compose.js";
28
29
  import { daemonSdkVersion, readDaemon, readLifecycleTimeouts } from "./daemon.js";
@@ -224,7 +225,11 @@ function readManifest(raw, c) {
224
225
  c.fail("STANDALONE_OS_MIN_VER_INVALID", `root templates require DSM ${DEFAULT_MIN_DSM} or later.`);
225
226
  }
226
227
  const displayname = c.text(raw.displayname, "displayname");
227
- const description = c.text(raw.description, "description");
228
+ const catalogPath = activeCatalogPath();
229
+ // With a catalog, its entry is the only source of store text; the manifest must not repeat it.
230
+ const description = catalogPath
231
+ ? catalogOwnedFields(raw, c, catalogPath)
232
+ : c.text(raw.description, "description");
228
233
  const maintainer = c.text(raw.maintainer, "maintainer");
229
234
  let metadata;
230
235
  if (raw.metadata !== undefined)
@@ -708,6 +713,8 @@ function readManifest(raw, c) {
708
713
  ...(loginStyle ? { loginStyle } : {}),
709
714
  ...(appScripts ? { appScripts } : {}),
710
715
  };
716
+ if (catalogPath && !applyCatalogText(manifest, catalogPath, c))
717
+ return undefined;
711
718
  if (manifest.ctl?.transport === 'native-http') {
712
719
  try {
713
720
  validateNativeManifest(manifest);
@@ -719,6 +726,51 @@ function readManifest(raw, c) {
719
726
  }
720
727
  return manifest;
721
728
  }
729
+ /** Reports hand-written store text next to a catalog; returns the placeholder the catalog replaces. */
730
+ function catalogOwnedFields(raw, c, catalogPath) {
731
+ const found = [];
732
+ if (raw.description !== undefined)
733
+ found.push("description");
734
+ const info = isRecord(raw.i18n) && isRecord(raw.i18n.info) ? raw.i18n.info : {};
735
+ for (const [locale, text] of Object.entries(info))
736
+ if (isRecord(text) && text.description !== undefined)
737
+ found.push(`i18n.info.${locale}.description`);
738
+ if (isRecord(raw.metadata))
739
+ for (const key of ["description", "long_description", "changelog"])
740
+ if (raw.metadata[key] !== undefined)
741
+ found.push(`metadata.${key}`);
742
+ if (found.length)
743
+ return c.fail("CATALOG_TEXT_DUPLICATED", `${catalogPath} is the only source of store text; remove ${found.join(", ")} from ${STANDALONE_MANIFEST}.`);
744
+ return "(catalog)";
745
+ }
746
+ /** Projects the catalog entry's text for this exact SPK version into the manifest, in memory. */
747
+ function applyCatalogText(manifest, catalogPath, c) {
748
+ let text;
749
+ try {
750
+ text = readCatalogText(catalogPath, manifest.package, manifest.spkVersion);
751
+ }
752
+ catch (error) {
753
+ if (!(error instanceof CatalogTextError))
754
+ throw error;
755
+ c.fail(error.code, error.message);
756
+ return false;
757
+ }
758
+ try {
759
+ manifest.metadata = validateMetadata(catalogMetadata(text, manifest.metadata));
760
+ }
761
+ catch (error) {
762
+ c.fail("CATALOG_TEXT_INVALID", `The catalog text does not fit the SPK metadata: ${error.message}.`);
763
+ return false;
764
+ }
765
+ manifest.catalogText = text;
766
+ manifest.description = infoDescription(text.long_description.en);
767
+ const info = { ...manifest.i18n?.info };
768
+ for (const locale of LOCALES)
769
+ if (locale !== "en")
770
+ info[locale] = { ...info[locale], description: infoDescription(text.long_description[locale]) };
771
+ manifest.i18n = { ...manifest.i18n, info };
772
+ return true;
773
+ }
722
774
  function checkBridgeMethods(backend, permissions, c) {
723
775
  for (const problem of bridgeMethodProblems(backend.methods, permissions, `${relative(c.root, backend.dir)}/permissions.json`))
724
776
  c.fail("STANDALONE_BRIDGE_METHODS_MISMATCH", problem);
@@ -0,0 +1,67 @@
1
+ # Store text from a catalog
2
+
3
+ A package's store text can come from one catalog entry instead of the App
4
+ manifest: the short and long description and each version's release notes, in
5
+ nine languages (`en`, `zh-TW`, `zh-CN`, `ja`, `ko`, `de`, `fr`, `es`, `it`).
6
+ The catalog file is schema 4:
7
+
8
+ ```yaml
9
+ schema: 4
10
+ packages:
11
+ - metadata:
12
+ description: {en: Keep your notes in one place, ...} # all nine
13
+ long_description: {en: "Write and organize notes...", ...} # all nine
14
+ changelog:
15
+ releases:
16
+ 1.0.0-0002: # exact SPK version (INFO version)
17
+ en: [Faster search]
18
+ # ...the other eight lists
19
+ pins:
20
+ - package: MyApp # selects the entry
21
+ ```
22
+
23
+ Pass the file to `check`, `build` and `inspect` with `--catalog <catalog.yaml>`,
24
+ or set `SYNOPKGLAND_CATALOG` (also in the project `.env`; a relative path is
25
+ resolved from the current directory). Without either, the manifest's own text is
26
+ used as before.
27
+
28
+ ## What the build writes
29
+
30
+ The CLI selects the entry whose `pins` name the manifest's `package` and the
31
+ notes for the exact SPK version (`<version>-<build>`), and projects them in
32
+ memory before packaging, checksums and signing:
33
+
34
+ | Output | Value |
35
+ | --- | --- |
36
+ | INFO `description` | English long description, paragraph breaks as spaces, not shortened (the short one when there is no long one) |
37
+ | INFO `description_<DSM language>` | The same for the other eight languages |
38
+ | INFO `changelog` | That version's English notes joined with ` · ` (Package Center shows no line breaks or markup) |
39
+ | `spk_land_metadata` | Nine-language `description`, `long_description` and that version's notes as `changelog`; not the older history |
40
+ | DSM main menu tooltip | The short description |
41
+ | `release-notes.md` next to the SPKs | That version's notes, English first, then each translation |
42
+
43
+ `build --json` reports the catalog file's SHA-256, package, version and the
44
+ release notes path as `catalogText`, for release evidence.
45
+
46
+ ## Failures
47
+
48
+ With a catalog, the build stops when:
49
+
50
+ - no single entry's `pins` name the package, or the exact version has no notes
51
+ (an older release record is never used instead);
52
+ - any of the nine languages is missing or empty;
53
+ - a description or note ends with a period (`.`, `。`, `.`, `。`);
54
+ - a note or short description spans lines, or a short description contains `"` or `\`;
55
+ - `dsm-package.yaml` still writes `description`, `i18n.info.<language>.description`
56
+ or `metadata.description` / `long_description` / `changelog`: the catalog is the
57
+ only source. `displayname` and its translations stay in the manifest.
58
+
59
+ Catalog text applies to `dsm-package.yaml` Apps; native layouts and
60
+ `synology-app.yaml` projects keep their text in the manifest.
61
+
62
+ ## Drift check
63
+
64
+ `inspect <spk> --catalog <catalog.yaml>` (and `check <spk> --catalog`) reads the
65
+ built SPK's INFO and metadata and fails with `CATALOG_TEXT_DRIFT` when any of
66
+ them differ from the projection of the same file. Pass the same catalog file,
67
+ at the same commit, to `build` and `inspect`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.53.10",
3
+ "version": "0.53.11",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,7 +23,8 @@
23
23
  "docs/shared-folders.md",
24
24
  "docs/daemon-nofile.md",
25
25
  "docs/compose-admin.md",
26
- "docs/install-memory.md"
26
+ "docs/install-memory.md",
27
+ "docs/catalog-text.md"
27
28
  ],
28
29
  "scripts": {
29
30
  "check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
@@ -3,6 +3,22 @@
3
3
  "type": "object",
4
4
  "additionalProperties": false,
5
5
  "properties": {
6
+ "description": {
7
+ "oneOf": [
8
+ {
9
+ "type": "string",
10
+ "maxLength": 1000
11
+ },
12
+ {
13
+ "type": "object",
14
+ "maxProperties": 32,
15
+ "additionalProperties": {
16
+ "type": "string",
17
+ "maxLength": 1000
18
+ }
19
+ }
20
+ ]
21
+ },
6
22
  "changelog": {
7
23
  "oneOf": [
8
24
  {
package/skills/SKILL.md CHANGED
@@ -147,6 +147,12 @@ own Apps use your publisher as maintainer. Pass upstream and publisher attributi
147
147
  to `init --upstream-fork`; resolve TODOs and review `check` warnings before release.
148
148
  See the scaffold steps and release checklist in [reference/upstream-fork.md](reference/upstream-fork.md).
149
149
 
150
+ When a schema 4 catalog entry owns the store text, build, check and inspect with
151
+ `--catalog <catalog.yaml>` (or `SYNOPKGLAND_CATALOG`) and keep `description`,
152
+ `i18n.info.*.description` and `metadata.description/long_description/changelog`
153
+ out of `dsm-package.yaml`; the build writes INFO, SPK metadata and
154
+ `release-notes.md` from that entry. See [catalog text](../docs/catalog-text.md).
155
+
150
156
  For upstream OSS packaging, leave `ctl` absent from the manifest by default. Ask whether the user wants AI control; implement it only when explicitly requested. Read [reference/ctl.md](reference/ctl.md) for the required `ctl-plan`, UI/API coverage checklist and asynchronous-operation rules. Own Apps retain the native template's ctl defaults, with commands covering their main features; status-only coverage is incomplete.
151
157
 
152
158
  Start with `synopkgland init -t native-go`, `synopkgland init -t binary`, or `synopkgland init -t compose`. Read reference/create.md or reference/wrap.md, then reference/deploy.md. Native CGI session checks belong to the package. For wrapping upstream OSS with DSM accounts, read [reference/identity-gateway.md](reference/identity-gateway.md) first. For all Compose work, read [reference/compose.md](reference/compose.md): schema-2 upstream files, generated override, SDK planner, fixed package identity and current DSM blockers. Container temporary files go to disk (`compose.services.<service>.scratch`, with `TMPDIR`); a memory tmpfs needs an explicit `compose.services.<service>.tmpfs` declaration and is always size-bounded. Containers do not inherit a signed-in user's File Station ACL. Existing Shared Folder mounts are blocked until official protected ACL/project control is verified.