@alauda/doom 2.5.4 → 2.6.1

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.
Files changed (94) hide show
  1. package/lib/cli/api.d.ts +2 -0
  2. package/lib/cli/api.js +147 -0
  3. package/lib/cli/helpers.d.ts +1 -7
  4. package/lib/cli/helpers.js +4 -41
  5. package/lib/cli/index.js +2 -0
  6. package/lib/cli/translate-agent.d.ts +81 -0
  7. package/lib/cli/translate-agent.js +450 -0
  8. package/lib/cli/translate-check.d.ts +17 -0
  9. package/lib/cli/translate-check.js +67 -0
  10. package/lib/cli/translate-checker.d.ts +58 -0
  11. package/lib/cli/translate-checker.js +112 -0
  12. package/lib/cli/translate-judge.d.ts +119 -0
  13. package/lib/cli/translate-judge.js +224 -0
  14. package/lib/cli/translate-limits.d.ts +43 -0
  15. package/lib/cli/translate-limits.js +55 -0
  16. package/lib/cli/translate-mask.d.ts +144 -0
  17. package/lib/cli/translate-mask.js +617 -0
  18. package/lib/cli/translate-models.d.ts +127 -0
  19. package/lib/cli/translate-models.js +189 -0
  20. package/lib/cli/translate-scratch.d.ts +142 -0
  21. package/lib/cli/translate-scratch.js +187 -0
  22. package/lib/cli/translate-terms.d.ts +22 -0
  23. package/lib/cli/translate-terms.js +33 -0
  24. package/lib/cli/translate.d.ts +15 -10
  25. package/lib/cli/translate.js +228 -185
  26. package/lib/eslint.js +22 -3
  27. package/lib/plugins/api/index.js +1 -1
  28. package/lib/plugins/api/types.d.ts +36 -1
  29. package/lib/plugins/global/components.d.ts +16 -0
  30. package/lib/plugins/global/components.js +16 -1
  31. package/lib/remark-lint/index.d.ts +20 -0
  32. package/lib/remark-lint/index.js +40 -0
  33. package/lib/remark-lint/no-unmatched-anchor.d.ts +10 -0
  34. package/lib/remark-lint/no-unmatched-anchor.js +19 -2
  35. package/lib/remark-lint/no-unopened-frontmatter.d.ts +2 -0
  36. package/lib/remark-lint/no-unopened-frontmatter.js +70 -0
  37. package/lib/remark-lint/no-unparsed-emphasis.d.ts +2 -0
  38. package/lib/remark-lint/no-unparsed-emphasis.js +53 -0
  39. package/lib/remark-lint/no-unresolved-api-ref.d.ts +40 -0
  40. package/lib/remark-lint/no-unresolved-api-ref.js +194 -0
  41. package/lib/remark-lint/rule-sets.d.ts +73 -0
  42. package/lib/remark-lint/rule-sets.js +114 -0
  43. package/lib/remark-lint/syntax-plugins.d.ts +32 -0
  44. package/lib/remark-lint/syntax-plugins.js +46 -0
  45. package/lib/remark-lint/translation-parity/component-multiset.d.ts +17 -0
  46. package/lib/remark-lint/translation-parity/component-multiset.js +35 -0
  47. package/lib/remark-lint/translation-parity/echoed-source.d.ts +2 -0
  48. package/lib/remark-lint/translation-parity/echoed-source.js +37 -0
  49. package/lib/remark-lint/translation-parity/frontmatter-preservation.d.ts +2 -0
  50. package/lib/remark-lint/translation-parity/frontmatter-preservation.js +36 -0
  51. package/lib/remark-lint/translation-parity/heading-sequence.d.ts +12 -0
  52. package/lib/remark-lint/translation-parity/heading-sequence.js +25 -0
  53. package/lib/remark-lint/translation-parity/index.d.ts +24 -0
  54. package/lib/remark-lint/translation-parity/index.js +24 -0
  55. package/lib/remark-lint/translation-parity/jsx-attribute-parity.d.ts +14 -0
  56. package/lib/remark-lint/translation-parity/jsx-attribute-parity.js +47 -0
  57. package/lib/remark-lint/translation-parity/length-ratio.d.ts +2 -0
  58. package/lib/remark-lint/translation-parity/length-ratio.js +49 -0
  59. package/lib/remark-lint/translation-parity/link-isomorphism.d.ts +34 -0
  60. package/lib/remark-lint/translation-parity/link-isomorphism.js +81 -0
  61. package/lib/remark-lint/translation-parity/shared.d.ts +110 -0
  62. package/lib/remark-lint/translation-parity/shared.js +286 -0
  63. package/lib/remark-lint/translation-parity/terminology-adherence.d.ts +2 -0
  64. package/lib/remark-lint/translation-parity/terminology-adherence.js +67 -0
  65. package/lib/remark-lint/translation-parity/up-to-date.d.ts +11 -0
  66. package/lib/remark-lint/translation-parity/up-to-date.js +21 -0
  67. package/lib/remark-lint/translation-parity/url-residue.d.ts +3 -0
  68. package/lib/remark-lint/translation-parity/url-residue.js +67 -0
  69. package/lib/remarkrc.d.ts +1 -1
  70. package/lib/remarkrc.js +7 -34
  71. package/lib/runtime/api-paths.d.ts +20 -0
  72. package/lib/runtime/api-paths.js +29 -0
  73. package/lib/runtime/components/K8sAPI.d.ts +14 -1
  74. package/lib/runtime/components/K8sAPI.js +49 -10
  75. package/lib/runtime/components/K8sCrd.d.ts +1 -1
  76. package/lib/runtime/components/K8sPermissionTable.js +10 -5
  77. package/lib/runtime/components/OpenAPIPath.js +19 -2
  78. package/lib/runtime/components/_HeadingTitle.js +24 -6
  79. package/lib/runtime/components/_K8sAPIEndpoints.d.ts +8 -1
  80. package/lib/runtime/components/_K8sAPIEndpoints.js +27 -9
  81. package/lib/runtime/components/_K8sAPISchema.d.ts +9 -1
  82. package/lib/runtime/components/_K8sAPISchema.js +24 -6
  83. package/lib/runtime/components/_translation-policy.d.ts +23 -0
  84. package/lib/runtime/components/_translation-policy.js +32 -0
  85. package/lib/runtime/hooks/useTranslation.d.ts +1 -1
  86. package/lib/runtime/translation.d.ts +68 -0
  87. package/lib/runtime/translation.js +51 -0
  88. package/lib/runtime/utils.d.ts +24 -2
  89. package/lib/runtime/utils.js +87 -5
  90. package/lib/shared/constants.d.ts +9 -0
  91. package/lib/shared/constants.js +14 -0
  92. package/lib/types.d.ts +70 -0
  93. package/lib/utils/helpers.js +8 -2
  94. package/package.json +3 -1
@@ -0,0 +1,144 @@
1
+ import type { Code, Link, Root } from 'mdast';
2
+ import type { MdxJsxAttributeValueExpression } from 'mdast-util-mdx';
3
+ /**
4
+ * Deterministic masking for `doom translate`.
5
+ *
6
+ * Everything a translation model must not author — link targets, identifiers,
7
+ * code, JSX attribute values — is replaced by an opaque placeholder before the
8
+ * document is sent, and put back afterwards. The model never sees the real
9
+ * value, so it cannot rewrite it; and because every placeholder is counted on
10
+ * the way back, deleting or duplicating one is detected instead of shipped.
11
+ *
12
+ * This generalises the code-block mechanism that has been in `helpers.ts` (and
13
+ * in production) all along; the prompt-level "do not touch links" instructions
14
+ * it replaces were detailed, and documents still came back with rewritten
15
+ * links.
16
+ */
17
+ export type MaskKind =
18
+ /** the trailing `{#custom-id}` of a heading */
19
+ 'ANCHOR'
20
+ /** a fenced code block, including its language and meta */
21
+ | 'CODE'
22
+ /** the url of a link reference definition */
23
+ | 'DEF'
24
+ /** an MDX expression, such as a `cspell` pragma comment */
25
+ | 'EXPR'
26
+ /** a footnote label, shared by its reference(s) and its definition */
27
+ | 'FNID'
28
+ /** an `href=` / `src=` value inside a raw HTML node */
29
+ | 'HTMLATTR'
30
+ /** inline code */
31
+ | 'ICODE'
32
+ /** the url of a markdown image */
33
+ | 'IMG'
34
+ /** an MDX JSX attribute value */
35
+ | 'JSXATTR'
36
+ /** the url of a markdown link */
37
+ | 'LINK'
38
+ /** a link/image reference label, shared by its uses and its definition */
39
+ | 'REFID'
40
+ /** a bare URL written in prose (a GFM autolink literal), masked whole */
41
+ | 'URL';
42
+ export interface MaskEntryBase {
43
+ kind: MaskKind;
44
+ placeholder: string;
45
+ /**
46
+ * How many times the placeholder must appear in the translated document.
47
+ * Always 1, except for reference/footnote labels: those are a linkage key
48
+ * shared between a definition and its use(s), so masking them to different
49
+ * tokens would break the link itself.
50
+ */
51
+ occurrences: number;
52
+ }
53
+ export interface UrlMaskEntry extends MaskEntryBase {
54
+ kind: 'DEF' | 'IMG' | 'LINK';
55
+ url: string;
56
+ }
57
+ export interface IdMaskEntry extends MaskEntryBase {
58
+ kind: 'FNID' | 'REFID';
59
+ identifier: string;
60
+ label?: string | null;
61
+ }
62
+ export interface JsxAttrMaskEntry extends MaskEntryBase {
63
+ kind: 'JSXATTR';
64
+ attrKind: 'expression' | 'spread' | 'string';
65
+ value: MdxJsxAttributeValueExpression | string;
66
+ }
67
+ export interface TextMaskEntry extends MaskEntryBase {
68
+ kind: 'ANCHOR' | 'EXPR' | 'HTMLATTR' | 'ICODE';
69
+ value: string;
70
+ }
71
+ export interface CodeMaskEntry extends MaskEntryBase {
72
+ kind: 'CODE';
73
+ node: Code;
74
+ }
75
+ export interface AutolinkMaskEntry extends MaskEntryBase {
76
+ kind: 'URL';
77
+ node: Link;
78
+ }
79
+ export type MaskEntry = AutolinkMaskEntry | CodeMaskEntry | IdMaskEntry | JsxAttrMaskEntry | TextMaskEntry | UrlMaskEntry;
80
+ export type MaskFindingCode =
81
+ /** the translated document lost a placeholder — a node was deleted */
82
+ 'missing-placeholder'
83
+ /** a placeholder came back more often than it went out — a node was copied */
84
+ | 'duplicate-placeholder'
85
+ /** the model invented a placeholder-shaped token */
86
+ | 'unregistered-placeholder'
87
+ /** a placeholder survived restoration — it landed somewhere unexpected */
88
+ | 'unrestored-placeholder'
89
+ /** the model's output, or the restored document, is not valid markdown/MDX */
90
+ | 'unparseable-output'
91
+ /** the source already contained a placeholder-shaped token */
92
+ | 'source-contains-placeholder';
93
+ export interface MaskFinding {
94
+ code: MaskFindingCode;
95
+ placeholder?: string;
96
+ kind?: MaskKind;
97
+ expected?: number;
98
+ actual?: number;
99
+ detail?: string;
100
+ }
101
+ /**
102
+ * Raised when the masked round trip does not hold. This is check `A1` of the
103
+ * translation gate: it is not advisory, and it must never be swallowed — a
104
+ * translation that fails it is structurally damaged.
105
+ */
106
+ export declare class MaskIntegrityError extends Error {
107
+ readonly findings: readonly MaskFinding[];
108
+ readonly file?: string | undefined;
109
+ constructor(findings: readonly MaskFinding[], file?: string | undefined);
110
+ }
111
+ /** Minimal structural view of the remark processors in `plugins/replace`. */
112
+ export interface MaskProcessor {
113
+ parse: (content: string) => Root;
114
+ stringify: (tree: Root) => string;
115
+ }
116
+ /**
117
+ * Replaces every value a translation model must not author with a placeholder,
118
+ * in place, and returns the table needed to put them back.
119
+ *
120
+ * Masking works on **AST nodes only**. It never pattern-matches inside a prose
121
+ * text node: that is the one way this could swallow content that should have
122
+ * been translated, and it is ruled out structurally rather than by care.
123
+ * Anything only recognisable as a text pattern (a bare domain with no scheme,
124
+ * say) is deliberately left alone and covered by a check instead — a check that
125
+ * misfires costs one finding to review, whereas a mask that misfires hides
126
+ * prose from the reader.
127
+ */
128
+ export declare const maskAst: (tree: Root) => MaskEntry[];
129
+ /**
130
+ * Puts the masked values back and proves the round trip held.
131
+ *
132
+ * Three assertions, all of them free:
133
+ *
134
+ * 1. every placeholder comes back exactly as often as it went out — fewer means
135
+ * the model deleted the node, more means it copied it;
136
+ * 2. no placeholder-shaped token appears that was never issued;
137
+ * 3. the restored document still parses.
138
+ *
139
+ * Any failure throws {@link MaskIntegrityError} with the offending placeholders
140
+ * named. There is deliberately no lenient path: a document that fails here is
141
+ * damaged, and shipping it is how the damage became invisible in the first
142
+ * place.
143
+ */
144
+ export declare const restoreMaskedContent: (translatedContent: string, entries: readonly MaskEntry[], processor: MaskProcessor) => string;