@synopackageland/cli 0.50.1 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.51.0
4
+
5
+ - Add declarative `i18n.dsm_texts`: per-locale DSM strings files become native DSM text sections (for example `[notify]`) in the package, validated against English with matching keys and placeholders; `[synopkgland]` stays reserved
6
+ - Show archived native text sections in `inspect`
7
+
3
8
  ## 0.50.0
4
9
 
5
10
  - Preserve headless Compose STOP failures and stop before restart; missing Container Manager profiles remain normal lifecycle state
package/README.md CHANGED
@@ -708,3 +708,12 @@ executes HTTP bindings without forwarding DSM cookies. Authentication failures
708
708
  offer explicit renewal without replaying the command. Uploads and downloads
709
709
  stream with declared byte/MIME limits and secure local file handling. Read
710
710
  `synopkgland skill show ctl` for configuration, auth commands and transfer rules.
711
+
712
+ ### Native DSM text sections
713
+
714
+ Declare `i18n.dsm_texts: i18n/dsm-texts` to merge package-owned `[notify]` or
715
+ other native sections into `ui/texts/<DSM language>/strings`. `check` validates
716
+ all declared locales, keys and placeholder parity; `build` adds the keys to
717
+ `ui/config` preload lists. `inspect --json <SPK>` reports archived `nativeTexts`
718
+ sections and keys per DSM language. See `synopkgland skill show dsm-texts` and
719
+ [the format and evidence notes](skills/reference/dsm-texts.md).
@@ -1,9 +1,11 @@
1
+ import { type NativeTexts } from "../standalone/dsm-texts.js";
1
2
  import { type InfoTranslations } from "../standalone/i18n.js";
2
3
  /** The English INFO text and its translations, which also name the app in DSM. */
3
4
  export interface AppTitle {
4
5
  displayname: string;
5
6
  description: string;
6
7
  info?: InfoTranslations;
8
+ nativeTexts?: NativeTexts;
7
9
  }
8
10
  /**
9
11
  * `ui/config` title fields. With translations they are `section:key`
@@ -26,7 +28,7 @@ export declare function consoleTitle(displayname: string, console: {
26
28
  export declare function uiConsoleTitleFields(app: AppTitle, console: {
27
29
  title?: string;
28
30
  }): ReturnType<typeof uiTitleFields>;
29
- /** `ui/texts/<dsm lang>/strings` for English and every translated language; none without translations. */
31
+ /** Merge validated native sections after the reserved section, in fixed locale/section/key order. */
30
32
  export declare function renderUiTexts(app: AppTitle, console?: {
31
33
  title?: string;
32
34
  }): Map<string, string>;
@@ -1,3 +1,4 @@
1
+ import { nativeTextRefs } from "../standalone/dsm-texts.js";
1
2
  import { chmodSync, mkdirSync, writeFileSync } from "node:fs";
2
3
  import { join } from "node:path";
3
4
  import { DSM_LANGS, LOCALES } from "../standalone/i18n.js";
@@ -7,6 +8,10 @@ const DESC = `${SECTION}:app_desc`;
7
8
  const CONSOLE_TITLE = `${SECTION}:console_title`;
8
9
  /** `ui/` subdirectory with the strings; a `ui/config` entry's `texts` names it relative to `ui/`. */
9
10
  const TEXTS_DIR = "texts";
11
+ function nativeTextFields(app) {
12
+ const refs = nativeTextRefs(app.nativeTexts);
13
+ return refs.length ? { texts: TEXTS_DIR, preloadTexts: refs } : {};
14
+ }
10
15
  function translated(app) {
11
16
  return Object.values(app.info ?? {}).some((text) => text?.displayname || text?.description);
12
17
  }
@@ -19,8 +24,8 @@ function translated(app) {
19
24
  */
20
25
  export function uiTitleFields(app) {
21
26
  return translated(app)
22
- ? { title: TITLE, desc: DESC, texts: TEXTS_DIR, preloadTexts: [TITLE, DESC] }
23
- : { title: app.displayname, desc: app.description };
27
+ ? { title: TITLE, desc: DESC, texts: TEXTS_DIR, preloadTexts: [TITLE, DESC, ...nativeTextRefs(app.nativeTexts)] }
28
+ : { title: app.displayname, desc: app.description, ...nativeTextFields(app) };
24
29
  }
25
30
  /** The console's name: the declared title in every language, else "<displayname> for DSM". */
26
31
  export function consoleTitle(displayname, console) {
@@ -29,22 +34,26 @@ export function consoleTitle(displayname, console) {
29
34
  /** {@link uiTitleFields} for the console window, which shares the App's description. */
30
35
  export function uiConsoleTitleFields(app, console) {
31
36
  return translated(app)
32
- ? { title: CONSOLE_TITLE, desc: DESC, texts: TEXTS_DIR, preloadTexts: [CONSOLE_TITLE, DESC] }
33
- : { title: consoleTitle(app.displayname, console), desc: app.description };
37
+ ? { title: CONSOLE_TITLE, desc: DESC, texts: TEXTS_DIR, preloadTexts: [CONSOLE_TITLE, DESC, ...nativeTextRefs(app.nativeTexts)] }
38
+ : { title: consoleTitle(app.displayname, console), desc: app.description, ...nativeTextFields(app) };
34
39
  }
35
- /** `ui/texts/<dsm lang>/strings` for English and every translated language; none without translations. */
40
+ /** Merge validated native sections after the reserved section, in fixed locale/section/key order. */
36
41
  export function renderUiTexts(app, console) {
37
42
  const files = new Map();
38
- if (!translated(app))
43
+ if (!translated(app) && !app.nativeTexts)
39
44
  return files;
40
45
  for (const locale of LOCALES) {
41
46
  const text = locale === "en" ? undefined : app.info?.[locale];
42
- if (locale !== "en" && !text)
47
+ const native = app.nativeTexts?.[locale];
48
+ if (!translated(app) && !native)
49
+ continue;
50
+ if (locale !== "en" && !text && !native)
43
51
  continue;
44
52
  const title = text?.displayname ?? app.displayname;
45
53
  const desc = text?.description ?? app.description;
46
54
  const consoleLine = console ? `console_title="${consoleTitle(title, console)}"\n` : "";
47
- files.set(DSM_LANGS[locale], `[${SECTION}]\napp_title="${title}"\napp_desc="${desc}"\n${consoleLine}`);
55
+ const own = translated(app) ? `[${SECTION}]\napp_title="${title}"\napp_desc="${desc}"\n${consoleLine}` : "";
56
+ files.set(DSM_LANGS[locale], own + (own && native ? "\n" : "") + (native ?? ""));
48
57
  }
49
58
  return files;
50
59
  }
@@ -716,7 +716,12 @@ export const ERROR_REGISTRY = {
716
716
  STANDALONE_I18N_INVALID: {
717
717
  code: "STANDALONE_I18N_INVALID",
718
718
  description: "The i18n configuration in dsm-package.yaml is invalid.",
719
- suggestion: "i18n accepts only messages, glossary and info; info is keyed by a supported language such as zh-TW or ja (English goes at the top level).",
719
+ suggestion: "i18n accepts only messages, glossary, info and dsm_texts; info is keyed by a supported language such as zh-TW or ja (English goes at the top level).",
720
+ },
721
+ STANDALONE_DSM_TEXTS_INVALID: {
722
+ code: "STANDALONE_DSM_TEXTS_INVALID",
723
+ description: "A DSM native strings source is invalid or differs across locales.",
724
+ suggestion: "Use dsm_texts/<locale>/strings with non-empty [section] key=\"text\" entries, identical keys and placeholders in every declared locale; synopkgland is reserved.",
720
725
  },
721
726
  STANDALONE_I18N_MESSAGES_MISSING: {
722
727
  code: "STANDALONE_I18N_MESSAGES_MISSING",
package/dist/skill.js CHANGED
@@ -32,6 +32,7 @@ const SKILL_CATALOG = [
32
32
  file: "reference/identity.md",
33
33
  when: "Needs a DSM sign-in",
34
34
  },
35
+ { id: "dsm-texts", file: "reference/dsm-texts.md", when: "Ship native DSM sections and fixed desktop notification strings" },
35
36
  { id: "mobile", file: "reference/mobile.md", when: "Register an App for the mobile shell and generate its SDK entry page" },
36
37
  { id: "files", file: "reference/files.md", when: "Needs NAS files" },
37
38
  {
@@ -0,0 +1,17 @@
1
+ import { type Locale } from "./i18n.js";
2
+ import type { StandaloneError } from "./manifest.js";
3
+ /** Validated, canonical DSM strings bytes, keyed by package locale (not DSM code). */
4
+ export type NativeTexts = Partial<Record<Locale, string>>;
5
+ export type NativeSections = Map<string, Map<string, string>>;
6
+ /** Deliberately accepts only the evidenced single-line, quoted strings subset. */
7
+ export declare function parseDsmStrings(text: string, allowReserved?: boolean): NativeSections;
8
+ export declare function renderDsmStrings(sections: NativeSections): string;
9
+ export declare function nativeTextRefs(texts?: NativeTexts): string[];
10
+ /** English plus every locale declared by messages / INFO is mandatory; no fallback hides omissions. */
11
+ export declare function loadNativeTexts(dir: string, required: string[], root: string): {
12
+ ok: true;
13
+ texts: NativeTexts;
14
+ } | {
15
+ ok: false;
16
+ errors: StandaloneError[];
17
+ };
@@ -0,0 +1,102 @@
1
+ import { lstatSync, readdirSync, readFileSync, realpathSync } from "node:fs";
2
+ import { isAbsolute, join, relative } from "node:path";
3
+ import { TextDecoder } from "node:util";
4
+ import { isLocale } from "./i18n.js";
5
+ const NAME = "[A-Za-z][A-Za-z0-9_]*";
6
+ const SECTION = new RegExp(`^\\[(${NAME})\\]$`);
7
+ const ENTRY = new RegExp(`^(${NAME})\\s*=\\s*\"([^\"\\\\\\x00-\\x1f\\x7f]*)\"$`);
8
+ /** Deliberately accepts only the evidenced single-line, quoted strings subset. */
9
+ export function parseDsmStrings(text, allowReserved = false) {
10
+ const sections = new Map();
11
+ let entries;
12
+ for (const [index, raw] of text.split(/\r?\n/).entries()) {
13
+ const line = raw.trim();
14
+ if (!line || line.startsWith("#") || line.startsWith(";"))
15
+ continue;
16
+ const section = SECTION.exec(line);
17
+ if (section) {
18
+ const name = section[1];
19
+ if (!allowReserved && name.toLowerCase() === "synopkgland")
20
+ throw new Error(`line ${index + 1}: [synopkgland] is reserved for the packager`);
21
+ if (sections.has(name))
22
+ throw new Error(`line ${index + 1}: duplicate section [${name}]`);
23
+ entries = new Map();
24
+ sections.set(name, entries);
25
+ continue;
26
+ }
27
+ const entry = ENTRY.exec(line);
28
+ if (!entries || !entry || !entry[2].trim())
29
+ throw new Error(`line ${index + 1}: expected [section] or key="non-empty single-line text"; names use letters, digits and underscores, starting with a letter; quotes, backslashes and controls in values are unsupported`);
30
+ if (entries.has(entry[1]))
31
+ throw new Error(`line ${index + 1}: duplicate key ${entry[1]}`);
32
+ entries.set(entry[1], entry[2]);
33
+ }
34
+ if (!sections.size || [...sections.values()].some((entries) => !entries.size))
35
+ throw new Error("each strings file needs at least one section, and every section needs a key");
36
+ return sections;
37
+ }
38
+ export function renderDsmStrings(sections) {
39
+ return [...sections.keys()].sort().map((section) => `[${section}]\n` + [...sections.get(section).keys()].sort().map((key) => `${key}="${sections.get(section).get(key)}"\n`).join("")).join("\n");
40
+ }
41
+ export function nativeTextRefs(texts) {
42
+ if (!texts?.en)
43
+ return [];
44
+ return [...parseDsmStrings(texts.en)].flatMap(([section, entries]) => [...entries.keys()].map((key) => `${section}:${key}`)).sort();
45
+ }
46
+ // Lint parity only: desktop key mode does not interpolate these tokens.
47
+ function placeholders(text) {
48
+ return (text.match(/\{[A-Za-z0-9_]+\}|%[A-Za-z_][A-Za-z0-9_]*%|%%|%(?:\d+\$)?[-+#0 ]*(?:\d+|\*)?(?:\.(?:\d+|\*))?[sdifuxXocgeEG]/g) ?? []).sort().join("\0");
49
+ }
50
+ function flattened(sections) {
51
+ return new Map([...sections].flatMap(([section, entries]) => [...entries].map(([key, text]) => [`${section}:${key}`, text])));
52
+ }
53
+ /** English plus every locale declared by messages / INFO is mandatory; no fallback hides omissions. */
54
+ export function loadNativeTexts(dir, required, root) {
55
+ const errors = [];
56
+ const texts = {};
57
+ const invalid = (message) => errors.push({ code: "STANDALONE_DSM_TEXTS_INVALID", message: `i18n.dsm_texts ${message}` });
58
+ try {
59
+ const rel = relative(realpathSync(root), realpathSync(dir));
60
+ if (rel.startsWith("..") || isAbsolute(rel) || !lstatSync(dir).isDirectory())
61
+ throw new Error("source must be a directory inside the project, not a symlink");
62
+ for (const locale of readdirSync(dir).sort()) {
63
+ try {
64
+ if (!isLocale(locale))
65
+ throw new Error("unsupported locale; use en, zh-TW, zh-CN, ja, ko, de, fr, es, it");
66
+ const folder = join(dir, locale);
67
+ if (!lstatSync(folder).isDirectory())
68
+ throw new Error("locale must be a directory, not a symlink");
69
+ const files = readdirSync(folder);
70
+ if (files.length !== 1 || files[0] !== "strings" || !lstatSync(join(folder, "strings")).isFile())
71
+ throw new Error('locale must contain exactly one regular file named "strings" (no symlinks)');
72
+ const source = new TextDecoder("utf-8", { fatal: true }).decode(readFileSync(join(folder, "strings")));
73
+ texts[locale] = renderDsmStrings(parseDsmStrings(source));
74
+ }
75
+ catch (error) {
76
+ invalid(`${locale}/strings: ${error instanceof Error ? error.message : String(error)}`);
77
+ }
78
+ }
79
+ }
80
+ catch (error) {
81
+ invalid(`${dir}: ${error instanceof Error ? error.message : String(error)}`);
82
+ }
83
+ for (const locale of [...new Set(["en", ...required])].sort()) {
84
+ if (!texts[locale])
85
+ invalid(`missing valid ${locale}/strings; required by English fallback, messages or INFO`);
86
+ }
87
+ if (texts.en) {
88
+ const en = flattened(parseDsmStrings(texts.en));
89
+ for (const [locale, text] of Object.entries(texts)) {
90
+ const current = flattened(parseDsmStrings(text));
91
+ const missing = [...en.keys()].filter((key) => !current.has(key));
92
+ const extra = [...current.keys()].filter((key) => !en.has(key));
93
+ if (missing.length || extra.length)
94
+ invalid(`${locale}/strings differs from en/strings: missing [${missing.join(", ")}]; extra [${extra.join(", ")}]`);
95
+ for (const [key, value] of current) {
96
+ if (en.has(key) && placeholders(value) !== placeholders(en.get(key)))
97
+ invalid(`${locale}/strings ${key}: placeholders differ from en/strings`);
98
+ }
99
+ }
100
+ }
101
+ return errors.length ? { ok: false, errors } : { ok: true, texts };
102
+ }
@@ -90,6 +90,7 @@ export function appTitle(manifest) {
90
90
  displayname: manifest.displayname,
91
91
  description: manifest.description,
92
92
  info: manifest.i18n?.info,
93
+ nativeTexts: manifest.i18n?.nativeTexts,
93
94
  };
94
95
  }
95
96
  /**
@@ -172,6 +173,7 @@ export function renderUiConfig(manifest, icons = packageIcons(manifest.icon), lo
172
173
  type: "lib",
173
174
  title: consoleFields.title,
174
175
  texts: consoleFields.texts,
176
+ ...(manifest.i18n?.nativeTexts ? { preloadTexts: consoleFields.preloadTexts } : {}),
175
177
  icon,
176
178
  depend: [],
177
179
  },
@@ -195,6 +197,7 @@ export function renderUiConfig(manifest, icons = packageIcons(manifest.icon), lo
195
197
  type: "lib",
196
198
  title: titleFields.title,
197
199
  texts: titleFields.texts,
200
+ ...(manifest.i18n?.nativeTexts ? { preloadTexts: titleFields.preloadTexts } : {}),
198
201
  icon,
199
202
  depend: [],
200
203
  },
@@ -11,6 +11,8 @@ import type { EntryMode } from "./manifest.js";
11
11
  import { type UninstallCleanupItem } from "../runtime/uninstall-cleanup.js";
12
12
  export type SpkKind = "native-go" | "native-python" | "native-node" | "native-rust" | "binary" | "container" | "native-layout";
13
13
  export interface SpkInspection {
14
+ /** Archived DSM language -> native section -> sorted keys (no text values). */
15
+ nativeTexts?: Record<string, Record<string, string[]>>;
14
16
  dependencies?: PackageDependencies;
15
17
  installSettings?: InstallSettings;
16
18
  /** Hyper Backup application backup, as sdk-package.json records it. */
@@ -1,3 +1,4 @@
1
+ import { parseDsmStrings } from "./dsm-texts.js";
1
2
  import { inspectMobileFiles, mobileRecordProblem } from './mobile.js';
2
3
  import { DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM, readNoFile, daemonSystemUnitName, renderDaemonSystemUnit, daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM } from "./daemon-nofile.js";
3
4
  import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
@@ -182,6 +183,7 @@ export async function inspectSpk(spkPath, expectedKind) {
182
183
  }
183
184
  return root;
184
185
  }, payload, metadata.hyperBackup, /^package="([^"]*)"$/m.exec(readOptional(join(dir, "INFO")) ?? "")?.[1] ?? "", familyOfArchToken(/^arch="([^"]*)"$/m.exec(readOptional(join(dir, "INFO")) ?? "")?.[1]?.split(/\s+/)[0] ?? "") ?? "x86_64", findings);
186
+ const nativeTexts = await inspectNativeTexts(dir, paths, findings);
185
187
  const integrations = metadata.integrations ?? [];
186
188
  await inspectCtlArtifacts(dir, paths, metadata.ctl, metadata.entry, findings);
187
189
  if (metadata.compose !== undefined) {
@@ -197,6 +199,8 @@ export async function inspectSpk(spkPath, expectedKind) {
197
199
  result.identityGateway = identityGateway;
198
200
  if (gateway)
199
201
  result.gateway = gateway;
202
+ if (nativeTexts)
203
+ result.nativeTexts = nativeTexts;
200
204
  result.icon = inspectPackageIcons(dir, findings);
201
205
  return result;
202
206
  }
@@ -342,6 +346,7 @@ export async function inspectSpk(spkPath, expectedKind) {
342
346
  return {
343
347
  ...(dependencies ? { dependencies } : {}),
344
348
  kind,
349
+ ...(nativeTexts ? { nativeTexts } : {}),
345
350
  ...(identityGateway ? { identityGateway } : {}),
346
351
  ...(gateway ? { gateway } : {}),
347
352
  ...(installSettings ? { installSettings } : {}),
@@ -390,6 +395,26 @@ export async function inspectSpk(spkPath, expectedKind) {
390
395
  rmSync(dir, { recursive: true, force: true });
391
396
  }
392
397
  }
398
+ /** Read the archived bytes so inspect proves sections shipped, without consulting source files. */
399
+ async function inspectNativeTexts(dir, paths, findings) {
400
+ const files = [...paths].filter((path) => /^ui\/texts\/[^/]+\/strings$/.test(path)).sort();
401
+ if (!files.length)
402
+ return undefined;
403
+ const root = join(dir, "native-texts-inspection");
404
+ mkdirSync(root);
405
+ await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: (path) => files.includes(path.replace(/^\.\//, "")) });
406
+ const result = {};
407
+ for (const file of files) {
408
+ try {
409
+ const sections = parseDsmStrings(readFileSync(join(root, file), "utf8"), true);
410
+ result[file.split("/")[2]] = Object.fromEntries([...sections].map(([section, entries]) => [section, [...entries.keys()].sort()]));
411
+ }
412
+ catch (error) {
413
+ findings.push(`STANDALONE_DSM_TEXTS_INVALID ${file}: ${error instanceof Error ? error.message : String(error)}`);
414
+ }
415
+ }
416
+ return result;
417
+ }
393
418
  async function inspectModuleUi(dir, paths, version, findings, mobile) {
394
419
  if (version === undefined) {
395
420
  if ([...paths].some(path => /^ui\/app\/[a-f0-9]{64}\/app\.module\.js$/.test(path)))
@@ -1,3 +1,4 @@
1
+ import { type NativeTexts } from "./dsm-texts.js";
1
2
  import { type MobileDeclaration } from './mobile.js';
2
3
  import { type PackageDependencies } from "./package-dependencies.js";
3
4
  import { type InstallSettings } from './install-settings.js';
@@ -42,6 +43,8 @@ export type StandaloneBackend = {
42
43
  export interface StandaloneI18n {
43
44
  /** UI messages per locale, embedded into the DSM window. */
44
45
  catalogs?: Catalogs;
46
+ /** Additional validated DSM native sections, merged with the packager texts. */
47
+ nativeTexts?: NativeTexts;
45
48
  /** INFO `displayname_<dsm lang>` / `description_<dsm lang>`. */
46
49
  info: InfoTranslations;
47
50
  }
@@ -1,3 +1,4 @@
1
+ import { loadNativeTexts } from "./dsm-texts.js";
1
2
  import { validateNativeManifest } from './native-http.js';
2
3
  import { readMobile, mobileIconPath } from './mobile.js';
3
4
  import { daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM, DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM } from './daemon-nofile.js';
@@ -82,7 +83,7 @@ export const KNOWN_FIELDS = new Set([
82
83
  "root",
83
84
  "login_style",
84
85
  ]);
85
- const I18N_FIELDS = new Set(["messages", "glossary", "info"]);
86
+ const I18N_FIELDS = new Set(["messages", "glossary", "info", "dsm_texts"]);
86
87
  const PACKAGE_ID = /^[A-Za-z][A-Za-z0-9]{1,63}$/;
87
88
  const VERSION = /^\d+(\.\d+){0,3}$/;
88
89
  const OS_MIN_VER = /^\d+\.\d+(\.\d+)?-\d+$/;
@@ -1031,34 +1032,46 @@ function readI18n(value, c) {
1031
1032
  const invalid = (why) => c.fail("STANDALONE_I18N_INVALID", `i18n ${why}`);
1032
1033
  if (!isRecord(value) ||
1033
1034
  Object.keys(value).some((key) => !I18N_FIELDS.has(key))) {
1034
- return invalid("Only messages (the message directory), glossary (the terminology table) and info (per-language INFO text) are accepted.");
1035
+ return invalid("Only messages (the message directory), glossary (the terminology table), info (per-language INFO text) and dsm_texts (native sections directory) are accepted.");
1035
1036
  }
1036
1037
  const info = readInfoTranslations(value.info, {
1037
1038
  invalid: (why) => c.fail("STANDALONE_I18N_INVALID", `i18n.info ${why}`),
1038
1039
  text: (text, field) => c.text(text, field),
1039
1040
  });
1041
+ let catalogs;
1040
1042
  if (value.messages === undefined) {
1041
- return value.glossary === undefined
1042
- ? info && { info }
1043
- : invalid("glossary needs messages.");
1043
+ if (value.glossary !== undefined)
1044
+ return invalid("glossary needs messages.");
1044
1045
  }
1045
- const dir = c.path(value.messages, "i18n.messages");
1046
- const glossary = value.glossary === undefined
1047
- ? undefined
1048
- : c.path(value.glossary, "i18n.glossary");
1049
- if (!dir || (value.glossary !== undefined && !glossary)) {
1050
- return undefined;
1046
+ else {
1047
+ const dir = c.path(value.messages, "i18n.messages");
1048
+ const glossary = value.glossary === undefined ? undefined : c.path(value.glossary, "i18n.glossary");
1049
+ if (!dir || (value.glossary !== undefined && !glossary))
1050
+ return undefined;
1051
+ const loaded = loadCatalogs(dir);
1052
+ if (!loaded.ok) {
1053
+ loaded.errors.forEach((e) => c.fail(e.code, e.message));
1054
+ return undefined;
1055
+ }
1056
+ catalogs = loaded.catalogs;
1057
+ const drift = glossary ? checkGlossary(glossary, catalogs) : [];
1058
+ drift.forEach((e) => c.fail(e.code, e.message));
1059
+ if (drift.length)
1060
+ return undefined;
1051
1061
  }
1052
- const loaded = loadCatalogs(dir);
1053
- if (!loaded.ok) {
1054
- loaded.errors.forEach((e) => c.fail(e.code, e.message));
1055
- return undefined;
1062
+ let nativeTexts;
1063
+ if (value.dsm_texts !== undefined) {
1064
+ const dir = c.path(value.dsm_texts, "i18n.dsm_texts");
1065
+ if (!dir)
1066
+ return undefined;
1067
+ const loaded = loadNativeTexts(dir, [...Object.keys(catalogs ?? {}), ...Object.keys(info ?? {})], c.root);
1068
+ if (!loaded.ok) {
1069
+ loaded.errors.forEach((e) => c.fail(e.code, e.message));
1070
+ return undefined;
1071
+ }
1072
+ nativeTexts = loaded.texts;
1056
1073
  }
1057
- const drift = glossary ? checkGlossary(glossary, loaded.catalogs) : [];
1058
- drift.forEach((e) => c.fail(e.code, e.message));
1059
- return info && drift.length === 0
1060
- ? { catalogs: loaded.catalogs, info }
1061
- : undefined;
1074
+ return info ? { info, ...(catalogs ? { catalogs } : {}), ...(nativeTexts ? { nativeTexts } : {}) } : undefined;
1062
1075
  }
1063
1076
  /**
1064
1077
  * The nearest directory at or above `start` that holds dsm-package.yaml,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.50.1",
3
+ "version": "0.51.0",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,18 @@
17
17
  }
18
18
  },
19
19
  "identity_gateway": {"$ref": "identity-gateway.v1.schema.json"},
20
- "mobile": {"$ref": "mobile.v1.schema.json"}
20
+ "mobile": {"$ref": "mobile.v1.schema.json"},
21
+ "i18n": {
22
+ "type": "object",
23
+ "properties": {
24
+ "dsm_texts": {
25
+ "type": "string",
26
+ "minLength": 1,
27
+ "description": "Project-relative <locale>/strings directory. English and every messages/INFO locale are required; synopkgland is reserved. See synopkgland skill show dsm-texts."
28
+ }
29
+ },
30
+ "additionalProperties": true
31
+ }
21
32
  },
22
33
  "additionalProperties": true
23
34
  }
package/skills/SKILL.md CHANGED
@@ -5,6 +5,9 @@ description: Initialize, extend, check, build, inspect, and deploy Synology appl
5
5
 
6
6
  # Independent Synology SPKs
7
7
 
8
+ For native DSM strings and fixed desktop notifications, read
9
+ [reference/dsm-texts.md](reference/dsm-texts.md) (`synopkgland skill show dsm-texts`).
10
+
8
11
  For mobile registration, entry pages and native-shell capabilities, read
9
12
  [reference/mobile.md](reference/mobile.md).
10
13
 
@@ -0,0 +1,95 @@
1
+ # Native DSM text sections and desktop notifications
2
+
3
+ Use this for schema 2 (`dsm-package.yaml`), independently of browser JSON message
4
+ keys. Add an explicit directory; no source is copied by convention alone:
5
+
6
+ ```yaml
7
+ i18n:
8
+ messages: i18n/messages # optional existing browser catalogs
9
+ dsm_texts: i18n/dsm-texts
10
+ info:
11
+ zh-TW: {description: NAS 健康助理}
12
+ ```
13
+
14
+ `i18n/dsm-texts/en/strings`:
15
+
16
+ ```ini
17
+ [notify]
18
+ title="NAS assistant"
19
+ new_warning="A new warning needs your attention; open the app for details"
20
+ ```
21
+
22
+ Provide the same sections and keys in `zh-TW/strings` and in every other locale
23
+ present in `i18n.messages` or declared under `i18n.info`. English is mandatory.
24
+ Native-only locales are also accepted and checked against English. The nine
25
+ supported source locales map to DSM directories as follows:
26
+
27
+ | Source | DSM |
28
+ | --- | --- |
29
+ | en | enu |
30
+ | zh-TW | cht |
31
+ | zh-CN | chs |
32
+ | ja | jpn |
33
+ | ko | krn |
34
+ | de | ger |
35
+ | fr | fre |
36
+ | es | spn |
37
+ | it | ita |
38
+
39
+ Each locale directory must contain exactly one regular UTF-8 `strings` file.
40
+ Symlinks and sources outside the project are refused. Blank lines and full-line
41
+ `#` / `;` comments are allowed. Section and key names start with an ASCII letter,
42
+ then contain only ASCII letters, digits and underscores. Each section needs at
43
+ least one key; duplicate sections/keys and empty values fail. Values must be
44
+ single-line double-quoted text without embedded double quotes, backslashes or
45
+ control characters. Escaping and multiline syntax are deliberately unsupported
46
+ until DSM parsing evidence is available. `[synopkgland]` is reserved (case
47
+ insensitive) and cannot be supplied by packages.
48
+
49
+ `check` reports `STANDALONE_DSM_TEXTS_INVALID` with file/line or locale/key context.
50
+ Every locale must have exactly the English section/key set. Placeholder tokens
51
+ `{name}`, `%NAME%` and printf conversions (including positional forms like `%1$s`)
52
+ must match English, including repeated occurrences. This is a translation lint;
53
+ it does not implement or promise substitution in DSM desktop key mode. Use fixed
54
+ text for desktop notifications and put variable details in the package UI.
55
+
56
+ `build` sorts sections and keys and writes LF-terminated files to
57
+ `ui/texts/<DSM language>/strings`, preserving the packager's title/description
58
+ section. It adds `texts: texts` and every native `section:key` to each generated
59
+ launcher/window's `preloadTexts`, including apps without INFO translations.
60
+ `inspect <SPK> --json` reads the archive and returns `nativeTexts`, mapping DSM
61
+ language to section to sorted key names. It reports malformed strings as a
62
+ finding. Inspect does not prove delivery, language selection or fallback on DSM.
63
+
64
+ A sender can invoke, with a validated recipient and fixed keys as argv:
65
+
66
+ ```text
67
+ /usr/syno/bin/synodsmnotify -c SYNO.SDS.MyPackage.Instance \
68
+ <user|@group> MyPackage:notify:title MyPackage:notify:new_warning
69
+ ```
70
+
71
+ `MyPackage` is `INFO.package`; use the actual app ID from `ui/config` (`.Console`
72
+ for packages whose SDK window is a separate console). The packager adds resources;
73
+ it grants no runtime privileges and provides no sender. Never shell-concatenate
74
+ recipients or accept arbitrary package/section/key references from callers.
75
+
76
+ ## Evidence and limits
77
+
78
+ The Home Keeper t-1442 research (2026-11-06, SA3400 DSM 7.3.2-86009 Update 3)
79
+ recorded one fixed-key desktop send as a non-root package user, with an existing
80
+ installed package's preloaded title/description keys. Its source index references
81
+ `developer-guide` commit `eeeffb04af21f14a5928e93c03b1f9e71a0bb15d`,
82
+ `synology_package/show_massage.md` L88-101 and `integrate_dsm/i18n.md` L7-43:
83
+ UI texts are `texts/<DSM language>/strings`, using `[section]` and `key="value"`;
84
+ config declares `texts` and `preloadTexts`. `libsynosysnotify/lib/utils/string.c`
85
+ DSM7-3 commit `99131ab07c4fc7c9c5980db475bd46c61e25316a` L362-390 validates
86
+ `package:section:key`. These are research references, not bundled internal source.
87
+
88
+ Home Keeper t-1448 (2026-11-07) separately recorded an unsigned SPK rejected with
89
+ 4539 for the Synology-only `sysnotify` worker. This extension adds no `sysnotify`
90
+ resource, `mails` event definitions, JSON-variable mode or email/push/webhook
91
+ forwarding. Those are different mechanisms. Exact `[notify]` resources generated
92
+ here, all nine runtime language selections, missing-language fallback, escaped
93
+ text syntax and cross-model/DSM-version behavior have not been tested on a NAS
94
+ in this change. The evidence establishes the native format and existing-key
95
+ mechanism; local archive inspection establishes packaging, not device acceptance.