@terra-symposium/standards-quality 0.0.0-stage → 0.5.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.
Files changed (67) hide show
  1. package/README.md +89 -2
  2. package/dist/collapse.d.ts +13 -0
  3. package/dist/collapse.d.ts.map +1 -0
  4. package/dist/collapse.js +151 -0
  5. package/dist/collapse.js.map +1 -0
  6. package/dist/documentation.d.ts +84 -0
  7. package/dist/documentation.d.ts.map +1 -0
  8. package/dist/documentation.js +1244 -0
  9. package/dist/documentation.js.map +1 -0
  10. package/dist/files.d.ts +39 -0
  11. package/dist/files.d.ts.map +1 -0
  12. package/dist/files.js +90 -0
  13. package/dist/files.js.map +1 -0
  14. package/dist/github-report.d.ts +89 -0
  15. package/dist/github-report.d.ts.map +1 -0
  16. package/dist/github-report.js +469 -0
  17. package/dist/github-report.js.map +1 -0
  18. package/dist/history-report.d.ts +52 -0
  19. package/dist/history-report.d.ts.map +1 -0
  20. package/dist/history-report.js +317 -0
  21. package/dist/history-report.js.map +1 -0
  22. package/dist/imports.d.ts +19 -0
  23. package/dist/imports.d.ts.map +1 -0
  24. package/dist/imports.js +90 -0
  25. package/dist/imports.js.map +1 -0
  26. package/dist/index.d.ts +19 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +19 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/inline-if.d.ts +13 -0
  31. package/dist/inline-if.d.ts.map +1 -0
  32. package/dist/inline-if.js +48 -0
  33. package/dist/inline-if.js.map +1 -0
  34. package/dist/naming.d.ts +148 -0
  35. package/dist/naming.d.ts.map +1 -0
  36. package/dist/naming.js +642 -0
  37. package/dist/naming.js.map +1 -0
  38. package/dist/object-forwarding.d.ts +44 -0
  39. package/dist/object-forwarding.d.ts.map +1 -0
  40. package/dist/object-forwarding.js +182 -0
  41. package/dist/object-forwarding.js.map +1 -0
  42. package/dist/patterns.d.ts +85 -0
  43. package/dist/patterns.d.ts.map +1 -0
  44. package/dist/patterns.js +905 -0
  45. package/dist/patterns.js.map +1 -0
  46. package/dist/port.d.ts +21 -0
  47. package/dist/port.d.ts.map +1 -0
  48. package/dist/port.js +81 -0
  49. package/dist/port.js.map +1 -0
  50. package/dist/progress.d.ts +16 -0
  51. package/dist/progress.d.ts.map +1 -0
  52. package/dist/progress.js +30 -0
  53. package/dist/progress.js.map +1 -0
  54. package/dist/runner.d.ts +257 -0
  55. package/dist/runner.d.ts.map +1 -0
  56. package/dist/runner.js +2481 -0
  57. package/dist/runner.js.map +1 -0
  58. package/dist/security.d.ts +19 -0
  59. package/dist/security.d.ts.map +1 -0
  60. package/dist/security.js +76 -0
  61. package/dist/security.js.map +1 -0
  62. package/dist/single-use.d.ts +60 -0
  63. package/dist/single-use.d.ts.map +1 -0
  64. package/dist/single-use.js +1209 -0
  65. package/dist/single-use.js.map +1 -0
  66. package/package.json +45 -5
  67. package/quality.schema.json +130 -0
package/README.md CHANGED
@@ -1,3 +1,90 @@
1
- # Temporary Holding Version
1
+ # @terra-symposium/standards-quality
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A configurable quality runner for JavaScript and TypeScript repositories. Define source scope, policy, tools, and repository commands in `quality.json`; run them locally with the `terra-quality` CLI or in CI.
4
+
5
+ - Requires Node.js `>=18.18`.
6
+ - Published on the public npm registry.
7
+ - Does not install or configure Prettier, ESLint, Knip, TypeScript, or repository commands.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ pnpm add -D @terra-symposium/standards-quality
13
+ ```
14
+
15
+ Create `quality.json` in the repository root:
16
+
17
+ ```json
18
+ {
19
+ "$schema": "./node_modules/@terra-symposium/standards-quality/quality.schema.json",
20
+ "sourceRoots": ["src"],
21
+ "extensions": [".js", ".jsx", ".ts", ".tsx"],
22
+ "enabledChecks": {
23
+ "format": false,
24
+ "lint": false,
25
+ "knip": false,
26
+ "dead-code": false
27
+ }
28
+ }
29
+ ```
30
+
31
+ This starting configuration uses the built-in checks without requiring external tools. Enable integrations as you install and configure the corresponding repository tools. When lint is enabled, add an ESLint flat config such as `eslint.config.mjs`.
32
+
33
+ Run the changed-file pass with safe configured fixes enabled:
34
+
35
+ ```sh
36
+ pnpm exec terra-quality
37
+ ```
38
+
39
+ For a full, read-only source check:
40
+
41
+ ```sh
42
+ pnpm exec terra-quality quality --all --warn
43
+ ```
44
+
45
+ The normal scope is changed and untracked files in a Git worktree. `--all` selects every file under `sourceRoots`; `--warn` disables autofixes and runs dead-code analysis once without a temporary fix preview. It reports rule-level fix candidates; fix mode then type-checks proposed dead-code edits before writing and may reject a candidate. Configured quality commands still run unless you pass `--skip-commands`.
46
+
47
+ ## What it does
48
+
49
+ Terra Quality combines source checks such as documentation, import resolution, naming, forwarding, security, and configured UI-pattern checks with repository-owned tools and commands. Safe transformations can maintain layout, apply tool fixes, and rewrite supported syntax. Findings that require domain or runtime judgment remain for review.
50
+
51
+ The runner does not prove runtime correctness or security, inspect arbitrary languages, provision services, or decide whether a domain-specific projection is intentional. Review generated changes at API, persistence, authorization, and other behavior boundaries.
52
+
53
+ ## GitHub report
54
+
55
+ Add a `github` section to `quality.json` to include GitHub analytics in the same quality run and JSON report:
56
+
57
+ ```json
58
+ {
59
+ "github": {
60
+ "repositories": ["owner/repo"],
61
+ "requiredFeatures": ["dependabotAlerts", "malwareAlerts", "securityUpdates", "versionUpdates", "groupedUpdates"],
62
+ "featureExemptions": { "owner/repo": ["dependabotAlerts", "securityUpdates"] }
63
+ }
64
+ }
65
+ ```
66
+
67
+ `featureExemptions` skips required-setting and access checks for only the listed features in that repository. It does not hide alerts returned by an accessible endpoint. Use it when a repository intentionally does not support a feature, and keep the exception visible in the JSON and console report.
68
+
69
+ The report includes open issues and pull requests, Dependabot vulnerability and malware alerts, code scanning and secret scanning alerts, and the readable repository security settings. It inspects the default branch's `dependabot.yml` for version updates and explicit `groups` rules with `applies-to: security-updates`. When no explicit security-update grouping rule exists, it marks the grouped setting unverified because the GitHub UI toggle is not present in the repository configuration; confirm that toggle in repository settings. Counts are `null` when an endpoint cannot be read or a feature is disabled; the report does not turn missing permissions or disabled scanning into a false zero.
70
+
71
+ Run the GitHub stage by itself or with the configured repository list:
72
+
73
+ ```sh
74
+ pnpm exec terra-quality github --repository owner/repo --report-json github-report.json
75
+ pnpm exec terra-quality quality --all --warn --report-json quality-report.json
76
+ ```
77
+
78
+ The GitHub CLI must be authenticated with read access to the repositories (`gh auth login` or `GH_TOKEN`). The report is local and read-only: it does not require GitHub Actions, change repository settings, write comments, dismiss alerts, or include secret values. Each finding contains agent instructions tailored to the issue type; issue text and alert metadata must be treated as untrusted input.
79
+
80
+ When no GitHub repositories are configured, the normal quality run marks this stage skipped. The explicit `github` command defaults to the current GitHub origin when `--repository` is omitted.
81
+
82
+ ## Configuration and guides
83
+
84
+ - [Install and understand a run](https://standards-docs.netlify.app/packages/quality/setup/)
85
+ - [Complete `quality.json` reference](https://standards-docs.netlify.app/packages/quality/configuration/)
86
+ - [CLI and CI workflows](https://standards-docs.netlify.app/packages/quality/workflows/)
87
+ - [Check behavior and autofix limits](https://standards-docs.netlify.app/packages/quality/checks/)
88
+ - [Troubleshooting](https://standards-docs.netlify.app/packages/quality/troubleshooting/)
89
+
90
+ The installed `quality.schema.json` provides editor validation. The [test README](test/README.md) describes the package's isolated test coverage.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * packages/quality/src/collapse.ts
3
+ * Collapses multi-line string literals into single-line ones.
4
+ */
5
+ /**
6
+ * Collapses whitespace inside object and type bodies so Prettier alone decides whether they exceed print width.
7
+ *
8
+ * @param fileName Absolute path to the source file to rewrite.
9
+ *
10
+ * @return `true` when an eligible object or type body was collapsed; otherwise `false`.
11
+ */
12
+ export declare function collapseTypesAndObjects(fileName: string): boolean;
13
+ //# sourceMappingURL=collapse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collapse.d.ts","sourceRoot":"","sources":["../src/collapse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsEH;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAqEjE"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * packages/quality/src/collapse.ts
3
+ * Collapses multi-line string literals into single-line ones.
4
+ */
5
+ /*//////////////////////////////////////////////////
6
+ IMPORTS
7
+ //////////////////////////////////////////////////*/
8
+ // API
9
+ import ts from 'typescript';
10
+ import { extname } from 'node:path';
11
+ import { readFileSync, writeFileSync } from 'node:fs';
12
+ /*//////////////////////////////////////////////////
13
+ CONFIG
14
+ //////////////////////////////////////////////////*/
15
+ const SUPPORTED = new Set(['.cjs', '.cts', '.js', '.jsx', '.mjs', '.mts', '.ts', '.tsx']);
16
+ /*//////////////////////////////////////////////////
17
+ HELPERS
18
+ //////////////////////////////////////////////////*/
19
+ /**
20
+ * Selects the TypeScript parser mode matching a JavaScript or TypeScript filename.
21
+ *
22
+ * @param fileName Source filename whose extension determines the parser mode.
23
+ *
24
+ * @return TypeScript compiler script kind for the filename.
25
+ */
26
+ function scriptKind(fileName) {
27
+ if (/\.[cm]?tsx$/.test(fileName))
28
+ return ts.ScriptKind.TSX;
29
+ if (/\.[cm]?jsx$/.test(fileName))
30
+ return ts.ScriptKind.JSX;
31
+ if (/\.[cm]?js$/.test(fileName))
32
+ return ts.ScriptKind.JS;
33
+ return ts.ScriptKind.TS;
34
+ }
35
+ /**
36
+ * Finds the body span of an object, type literal, mapped type, or interface that can be collapsed safely.
37
+ *
38
+ * @param n AST node being considered for whitespace collapsing.
39
+ * @param src Original source text used to locate interface braces.
40
+ *
41
+ * @return Collapsible source span, or `undefined` when the node is unsupported or contains JSX.
42
+ */
43
+ function candidateSpan(n, src) {
44
+ if (ts.isObjectLiteralExpression(n)) {
45
+ let containsJsx = false;
46
+ const findJsx = (c) => {
47
+ if (ts.isJsxElement(c) || ts.isJsxSelfClosingElement(c) || ts.isJsxFragment(c)) {
48
+ containsJsx = true;
49
+ return;
50
+ }
51
+ ts.forEachChild(c, findJsx);
52
+ };
53
+ ts.forEachChild(n, findJsx);
54
+ if (containsJsx)
55
+ return undefined;
56
+ return { start: n.getStart(), end: n.end };
57
+ }
58
+ if (ts.isTypeLiteralNode(n) || ts.isMappedTypeNode(n))
59
+ return { start: n.getStart(), end: n.end };
60
+ if (ts.isInterfaceDeclaration(n)) {
61
+ const start = src.indexOf('{', n.name.end);
62
+ const end = src.lastIndexOf('}', n.end - 1);
63
+ if (start >= 0 && end >= start)
64
+ return { start, end: end + 1 };
65
+ }
66
+ return undefined;
67
+ }
68
+ /*//////////////////////////////////////////////////
69
+ EXPORTS
70
+ //////////////////////////////////////////////////*/
71
+ /**
72
+ * Collapses whitespace inside object and type bodies so Prettier alone decides whether they exceed print width.
73
+ *
74
+ * @param fileName Absolute path to the source file to rewrite.
75
+ *
76
+ * @return `true` when an eligible object or type body was collapsed; otherwise `false`.
77
+ */
78
+ export function collapseTypesAndObjects(fileName) {
79
+ // ENVIRONMENT
80
+ if (!SUPPORTED.has(extname(fileName)))
81
+ return false;
82
+ const original = readFileSync(fileName, 'utf8');
83
+ const parsed = ts.createSourceFile(fileName, original, ts.ScriptTarget.Latest, true, scriptKind(fileName));
84
+ const edits = [];
85
+ // HELPERS
86
+ const collapse = (n, start, text) => {
87
+ if (!/[\r\n]/.test(text))
88
+ return undefined;
89
+ const protectedRanges = [];
90
+ const protectLiterals = (c) => {
91
+ if (ts.isStringLiteral(c) ||
92
+ ts.isRegularExpressionLiteral(c) ||
93
+ ts.isNoSubstitutionTemplateLiteral(c) ||
94
+ ts.isTemplateHead(c) ||
95
+ ts.isTemplateMiddle(c) ||
96
+ ts.isTemplateTail(c) ||
97
+ ts.isJsxText(c)) {
98
+ protectedRanges.push({ start: c.getStart(parsed) - start, end: c.end - start });
99
+ return;
100
+ }
101
+ ts.forEachChild(c, protectLiterals);
102
+ };
103
+ protectLiterals(n);
104
+ const isProtected = (pos) => protectedRanges.some((r) => pos >= r.start && pos < r.end);
105
+ const scanner = ts.createScanner(ts.ScriptTarget.Latest, false, parsed.languageVariant, text);
106
+ let result = '';
107
+ let whitespace = false;
108
+ for (let token = scanner.scan(); token !== ts.SyntaxKind.EndOfFileToken; token = scanner.scan()) {
109
+ const tokenStart = scanner.getTokenPos();
110
+ if ((token === ts.SyntaxKind.SingleLineCommentTrivia || token === ts.SyntaxKind.MultiLineCommentTrivia) && !isProtected(tokenStart))
111
+ return undefined;
112
+ if (token === ts.SyntaxKind.WhitespaceTrivia || token === ts.SyntaxKind.NewLineTrivia) {
113
+ if (isProtected(tokenStart)) {
114
+ if (whitespace && result && !result.endsWith(' '))
115
+ result += ' ';
116
+ result += scanner.getTokenText();
117
+ whitespace = false;
118
+ continue;
119
+ }
120
+ whitespace = true;
121
+ continue;
122
+ }
123
+ if (whitespace && result && !result.endsWith(' '))
124
+ result += ' ';
125
+ result += scanner.getTokenText();
126
+ whitespace = false;
127
+ }
128
+ return result;
129
+ };
130
+ // ANALYSE
131
+ const visit = (n) => {
132
+ const span = candidateSpan(n, original);
133
+ if (span) {
134
+ const text = collapse(n, span.start, original.slice(span.start, span.end));
135
+ if (text !== undefined) {
136
+ edits.push({ ...span, text });
137
+ return;
138
+ }
139
+ }
140
+ ts.forEachChild(n, visit);
141
+ };
142
+ visit(parsed);
143
+ if (!edits.length)
144
+ return false;
145
+ const n = edits.sort((a, b) => b.start - a.start).reduce((t, e) => `${t.slice(0, e.start)}${e.text}${t.slice(e.end)}`, original);
146
+ if (n === original)
147
+ return false;
148
+ writeFileSync(fileName, n);
149
+ return true;
150
+ }
151
+ //# sourceMappingURL=collapse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collapse.js","sourceRoot":"","sources":["../src/collapse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;oDAEoD;AAEpD,MAAM;AACN,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,aAAa,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,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3E,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACxB,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC9B,OAAO;YACR,CAAC;QACF,CAAC;QACD,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC3B,CAAC,CAAC;IACF,KAAK,CAAC,MAAM,CAAC,CAAC;IACd,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAChC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACjI,IAAI,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACjC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC3B,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * packages/quality/src/documentation.ts
3
+ * Create comments documenting the file, grouping imports, and sectioning code.
4
+ */
5
+ import type { QualityAnalysis, QualityCfg } from './runner.js';
6
+ /** Declaration categories that can require meaningful TSDoc descriptions. */
7
+ export type DocumentationRequirements = {
8
+ types?: boolean;
9
+ functions?: boolean;
10
+ exportedFunctions?: boolean;
11
+ noInlineFunctions?: boolean;
12
+ };
13
+ /** A repeated named import reported within one source file. */
14
+ export type DuplicateImportFinding = {
15
+ file: string;
16
+ line: number;
17
+ module: string;
18
+ };
19
+ /** One missing, malformed, or detached source-documentation item. */
20
+ export type DocumentationFinding = {
21
+ file: string;
22
+ line: number;
23
+ column: number;
24
+ name: string;
25
+ kind: 'file' | 'summary' | 'param' | 'return' | 'tag' | 'type' | 'function' | 'inline' | 'orphan';
26
+ reason: string;
27
+ severity: 'warning' | 'error';
28
+ };
29
+ export declare const DOCUMENTATION_DESCRIPTION_NOTICE = "Ask an agent for meaningful documentation prose; this check only reports missing descriptions and never generates them in bulk.";
30
+ /**
31
+ * Finds repeated named bindings that the source maintainer can merge without
32
+ * changing import evaluation order or side-effect-only imports.
33
+ *
34
+ * @param files Configured source files to inspect.
35
+ *
36
+ * @return One finding for each later import declaration that repeats a binding.
37
+ */
38
+ export declare function duplicateImportFindings(files: string[]): DuplicateImportFinding[];
39
+ /**
40
+ * Adds the canonical header, grouped imports, and top-level source sections.
41
+ *
42
+ * @param root Repository root used to create the file header path.
43
+ * @param fileName Absolute path to the source file to maintain.
44
+ *
45
+ * @return `true` when the file was rewritten; otherwise `false`.
46
+ */
47
+ export declare function maintainSrcFile(root: string, fileName: string): boolean;
48
+ /**
49
+ * Removes generated section scaffolding and empty or detached TSDoc after source edits.
50
+ *
51
+ * @param fileName Source filename whose generated or detached comments should be removed.
52
+ *
53
+ * @return Whether the file was changed after a validated write.
54
+ */
55
+ export declare function removeNonCodeComments(fileName: string): boolean;
56
+ /**
57
+ * Adds Prettier protection to one-line imports that exceed the configured print width.
58
+ *
59
+ * @param fileName Absolute path to the source file whose imports are inspected.
60
+ * @param printWidth Maximum line width before a Prettier ignore marker is inserted.
61
+ *
62
+ * @return `true` when one or more ignore markers were inserted.
63
+ */
64
+ export declare function protectLongImports(fileName: string, printWidth?: number): boolean;
65
+ /**
66
+ * Finds documentation-policy violations for the configured source scope.
67
+ *
68
+ * @param cfg Quality configuration containing required documentation policies.
69
+ * @param analysis Optional shared program and source cache for the current run.
70
+ *
71
+ * @return Documentation findings across the configured source scope.
72
+ */
73
+ export declare function documentationFindings(cfg: QualityCfg, analysis?: QualityAnalysis): DocumentationFinding[];
74
+ /**
75
+ * Inserts an empty TSDoc scaffold before declarations required to be documented.
76
+ * The scaffold never invents a description; prose must be authored after understanding the declaration.
77
+ *
78
+ * @param cfg Quality configuration containing documentation requirements.
79
+ * @param file Absolute source path to update.
80
+ *
81
+ * @return `true` when one or more scaffolds were inserted.
82
+ */
83
+ export declare function documentSrcFile(cfg: QualityCfg, file: string): boolean;
84
+ //# sourceMappingURL=documentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentation.d.ts","sourceRoot":"","sources":["../src/documentation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAqC/D,6EAA6E;AAC7E,MAAM,MAAM,yBAAyB,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAC3I,+DAA+D;AAC/D,MAAM,MAAM,sBAAsB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAMpF,qEAAqE;AACrE,MAAM,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ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