@caelo-cms/shared 0.10.22 → 0.10.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-tools.d.ts +289 -273
- package/dist/ai-tools.d.ts.map +1 -1
- package/dist/ai-tools.js +342 -323
- package/dist/ai-tools.js.map +1 -1
- package/dist/auth-forms.d.ts.map +1 -1
- package/dist/auth-forms.js +4 -1
- package/dist/auth-forms.js.map +1 -1
- package/dist/base-css.d.ts +35 -0
- package/dist/base-css.d.ts.map +1 -0
- package/dist/base-css.js +40 -0
- package/dist/base-css.js.map +1 -0
- package/dist/build-page.d.ts +330 -0
- package/dist/build-page.d.ts.map +1 -0
- package/dist/build-page.js +282 -0
- package/dist/build-page.js.map +1 -0
- package/dist/content.d.ts +322 -9
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js +354 -11
- package/dist/content.js.map +1 -1
- package/dist/css-gradient-scan.d.ts +14 -0
- package/dist/css-gradient-scan.d.ts.map +1 -0
- package/dist/css-gradient-scan.js +81 -0
- package/dist/css-gradient-scan.js.map +1 -0
- package/dist/css-var-scan.d.ts +56 -0
- package/dist/css-var-scan.d.ts.map +1 -0
- package/dist/css-var-scan.js +97 -0
- package/dist/css-var-scan.js.map +1 -0
- package/dist/design-draft-shell.d.ts +21 -0
- package/dist/design-draft-shell.d.ts.map +1 -0
- package/dist/design-draft-shell.js +81 -0
- package/dist/design-draft-shell.js.map +1 -0
- package/dist/design-manifest.d.ts +36 -0
- package/dist/design-manifest.d.ts.map +1 -0
- package/dist/design-manifest.js +90 -0
- package/dist/design-manifest.js.map +1 -0
- package/dist/fonts.d.ts +89 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +241 -0
- package/dist/fonts.js.map +1 -0
- package/dist/genesis-inventory.d.ts +32 -0
- package/dist/genesis-inventory.d.ts.map +1 -0
- package/dist/genesis-inventory.js +186 -0
- package/dist/genesis-inventory.js.map +1 -0
- package/dist/genesis.d.ts +102 -0
- package/dist/genesis.d.ts.map +1 -0
- package/dist/genesis.js +145 -0
- package/dist/genesis.js.map +1 -0
- package/dist/i18n.d.ts +29 -36
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +53 -128
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/interactions.d.ts +23 -0
- package/dist/interactions.d.ts.map +1 -0
- package/dist/interactions.js +44 -0
- package/dist/interactions.js.map +1 -0
- package/dist/media.d.ts +101 -16
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +126 -15
- package/dist/media.js.map +1 -1
- package/dist/page-log.d.ts +94 -0
- package/dist/page-log.d.ts.map +1 -0
- package/dist/page-log.js +111 -0
- package/dist/page-log.js.map +1 -0
- package/dist/preview-compose.d.ts +85 -12
- package/dist/preview-compose.d.ts.map +1 -1
- package/dist/preview-compose.js +157 -67
- package/dist/preview-compose.js.map +1 -1
- package/dist/proposal-status.d.ts +40 -0
- package/dist/proposal-status.d.ts.map +1 -0
- package/dist/proposal-status.js +34 -0
- package/dist/proposal-status.js.map +1 -0
- package/dist/responsive-images.d.ts +64 -0
- package/dist/responsive-images.d.ts.map +1 -0
- package/dist/responsive-images.js +98 -0
- package/dist/responsive-images.js.map +1 -0
- package/dist/safe-keys.d.ts +9 -0
- package/dist/safe-keys.d.ts.map +1 -0
- package/dist/safe-keys.js +20 -0
- package/dist/safe-keys.js.map +1 -0
- package/dist/seo.d.ts +11 -16
- package/dist/seo.d.ts.map +1 -1
- package/dist/seo.js +7 -23
- package/dist/seo.js.map +1 -1
- package/dist/skills.d.ts +14 -68
- package/dist/skills.d.ts.map +1 -1
- package/dist/skills.js +19 -113
- package/dist/skills.js.map +1 -1
- package/dist/strip-cdata.d.ts +7 -0
- package/dist/strip-cdata.d.ts.map +1 -0
- package/dist/strip-cdata.js +48 -0
- package/dist/strip-cdata.js.map +1 -0
- package/dist/structured-sets.d.ts +6 -52
- package/dist/structured-sets.d.ts.map +1 -1
- package/dist/structured-sets.js +6 -68
- package/dist/structured-sets.js.map +1 -1
- package/dist/subagents.d.ts +105 -3
- package/dist/subagents.d.ts.map +1 -1
- package/dist/subagents.js +224 -41
- package/dist/subagents.js.map +1 -1
- package/dist/template-engine.d.ts +85 -0
- package/dist/template-engine.d.ts.map +1 -0
- package/dist/template-engine.js +403 -0
- package/dist/template-engine.js.map +1 -0
- package/dist/theme-importers/auto-detect.d.ts +26 -0
- package/dist/theme-importers/auto-detect.d.ts.map +1 -0
- package/dist/theme-importers/auto-detect.js +42 -0
- package/dist/theme-importers/auto-detect.js.map +1 -0
- package/dist/theme-importers/css-comments.d.ts +12 -0
- package/dist/theme-importers/css-comments.d.ts.map +1 -0
- package/dist/theme-importers/css-comments.js +15 -0
- package/dist/theme-importers/css-comments.js.map +1 -0
- package/dist/theme-importers/dtcg.d.ts +46 -0
- package/dist/theme-importers/dtcg.d.ts.map +1 -0
- package/dist/theme-importers/dtcg.js +111 -0
- package/dist/theme-importers/dtcg.js.map +1 -0
- package/dist/theme-importers/loose.d.ts +3 -0
- package/dist/theme-importers/loose.d.ts.map +1 -0
- package/dist/theme-importers/loose.js +76 -0
- package/dist/theme-importers/loose.js.map +1 -0
- package/dist/theme-importers/shadcn.d.ts +24 -0
- package/dist/theme-importers/shadcn.d.ts.map +1 -0
- package/dist/theme-importers/shadcn.js +135 -0
- package/dist/theme-importers/shadcn.js.map +1 -0
- package/dist/theme-importers/style-dictionary.d.ts +17 -0
- package/dist/theme-importers/style-dictionary.d.ts.map +1 -0
- package/dist/theme-importers/style-dictionary.js +125 -0
- package/dist/theme-importers/style-dictionary.js.map +1 -0
- package/dist/theme-importers/tailwind.d.ts +3 -0
- package/dist/theme-importers/tailwind.d.ts.map +1 -0
- package/dist/theme-importers/tailwind.js +218 -0
- package/dist/theme-importers/tailwind.js.map +1 -0
- package/dist/theme-literal-binding.d.ts +37 -0
- package/dist/theme-literal-binding.d.ts.map +1 -0
- package/dist/theme-literal-binding.js +138 -0
- package/dist/theme-literal-binding.js.map +1 -0
- package/dist/theme-normalize.d.ts +31 -0
- package/dist/theme-normalize.d.ts.map +1 -0
- package/dist/theme-normalize.js +587 -0
- package/dist/theme-normalize.js.map +1 -0
- package/dist/theme-ramp.d.ts +55 -0
- package/dist/theme-ramp.d.ts.map +1 -0
- package/dist/theme-ramp.js +149 -0
- package/dist/theme-ramp.js.map +1 -0
- package/dist/theme-render.d.ts +105 -0
- package/dist/theme-render.d.ts.map +1 -0
- package/dist/theme-render.js +441 -0
- package/dist/theme-render.js.map +1 -0
- package/dist/themes-errors.d.ts +109 -0
- package/dist/themes-errors.d.ts.map +1 -0
- package/dist/themes-errors.js +170 -0
- package/dist/themes-errors.js.map +1 -0
- package/dist/themes.d.ts +343 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +697 -0
- package/dist/themes.js.map +1 -0
- package/dist/version.d.ts +7 -4
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +6 -3
- package/dist/version.js.map +1 -1
- package/package.json +10 -2
- package/src/__tests__/redos-hardening.test.ts +160 -0
- package/src/ai-tools-add-module-modes.test.ts +106 -0
- package/src/ai-tools-position.test.ts +134 -0
- package/src/ai-tools.test.ts +81 -0
- package/src/ai-tools.ts +1105 -0
- package/src/auth-forms.ts +36 -0
- package/src/base-css.ts +42 -0
- package/src/build-page.test.ts +228 -0
- package/src/build-page.ts +319 -0
- package/src/cap-failures.ts +67 -0
- package/src/content.test.ts +170 -0
- package/src/content.ts +620 -0
- package/src/context.ts +43 -0
- package/src/css-gradient-scan.ts +88 -0
- package/src/css-var-scan.test.ts +96 -0
- package/src/css-var-scan.ts +144 -0
- package/src/derive-module-type.test.ts +80 -0
- package/src/design-draft-shell.test.ts +85 -0
- package/src/design-draft-shell.ts +109 -0
- package/src/design-manifest.ts +93 -0
- package/src/fonts.test.ts +157 -0
- package/src/fonts.ts +296 -0
- package/src/genesis-inventory.test.ts +86 -0
- package/src/genesis-inventory.ts +215 -0
- package/src/genesis-sanitize.test.ts +35 -0
- package/src/genesis.ts +158 -0
- package/src/i18n.test.ts +58 -0
- package/src/i18n.ts +91 -0
- package/src/index.test.ts +10 -0
- package/src/index.ts +59 -0
- package/src/interactions.ts +48 -0
- package/src/logger.ts +147 -0
- package/src/media.test.ts +160 -0
- package/src/media.ts +355 -0
- package/src/page-log.test.ts +163 -0
- package/src/page-log.ts +124 -0
- package/src/preview-compose.test.ts +637 -0
- package/src/preview-compose.ts +656 -0
- package/src/preview-scanner.test.ts +96 -0
- package/src/preview-scanner.ts +214 -0
- package/src/proposal-status.test.ts +69 -0
- package/src/proposal-status.ts +40 -0
- package/src/responsive-images.test.ts +104 -0
- package/src/responsive-images.ts +151 -0
- package/src/result.ts +29 -0
- package/src/safe-keys.ts +21 -0
- package/src/seo.test.ts +194 -0
- package/src/seo.ts +233 -0
- package/src/skills.ts +48 -0
- package/src/snapshots.test.ts +80 -0
- package/src/snapshots.ts +81 -0
- package/src/strip-cdata.test.ts +41 -0
- package/src/strip-cdata.ts +50 -0
- package/src/structured-sets.ts +114 -0
- package/src/subagents.test.ts +262 -0
- package/src/subagents.ts +432 -0
- package/src/template-engine.test.ts +379 -0
- package/src/template-engine.ts +520 -0
- package/src/theme-gradient.test.ts +92 -0
- package/src/theme-importers/__tests__/proto-pollution.test.ts +54 -0
- package/src/theme-importers/auto-detect.ts +84 -0
- package/src/theme-importers/css-comments.ts +15 -0
- package/src/theme-importers/dtcg.ts +106 -0
- package/src/theme-importers/loose.ts +76 -0
- package/src/theme-importers/shadcn.ts +133 -0
- package/src/theme-importers/style-dictionary.ts +125 -0
- package/src/theme-importers/tailwind.ts +217 -0
- package/src/theme-literal-binding.test.ts +71 -0
- package/src/theme-literal-binding.ts +159 -0
- package/src/theme-motion.test.ts +115 -0
- package/src/theme-normalize-envelope.test.ts +43 -0
- package/src/theme-normalize-gradient.test.ts +135 -0
- package/src/theme-normalize.ts +661 -0
- package/src/theme-ramp.ts +187 -0
- package/src/theme-render-sanitize.test.ts +45 -0
- package/src/theme-render.test.ts +119 -0
- package/src/theme-render.ts +487 -0
- package/src/theme-shadow.test.ts +56 -0
- package/src/themes-errors.ts +199 -0
- package/src/themes.ts +842 -0
- package/src/version.ts +66 -0
- package/dist/translation.d.ts +0 -127
- package/dist/translation.d.ts.map +0 -1
- package/dist/translation.js +0 -208
- package/dist/translation.js.map +0 -1
package/dist/skills.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Skill metadata shapes shared across the Query API + chat-runner.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Skills use PROGRESSIVE DISCLOSURE (the Anthropic Agent Skills shape): a
|
|
5
|
+
* static `## Skills` index (slug + description) sits in the cached system
|
|
6
|
+
* prompt, and the model pulls a skill's full body into the conversation on
|
|
7
|
+
* demand via the `load_skill` tool (its body then lives in the append-only
|
|
8
|
+
* message history for the rest of the chat).
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* `skillAutoEngagementHints` no longer drives SELECTION — the model
|
|
11
|
+
* self-selects from the descriptions. The hints now only shape how prominently
|
|
12
|
+
* a skill is presented in the index: `alwaysOn` skills get an "always applies"
|
|
13
|
+
* callout, `chipTrigger` skills a "when element chips are attached" callout.
|
|
14
|
+
* (The old keyword/chip/always-on MATCHER + engagement resolver were removed
|
|
15
|
+
* once progressive disclosure replaced them.)
|
|
12
16
|
*/
|
|
13
17
|
import { z } from "zod";
|
|
14
18
|
export declare const skillAutoEngagementHints: z.ZodObject<{
|
|
@@ -17,37 +21,9 @@ export declare const skillAutoEngagementHints: z.ZodObject<{
|
|
|
17
21
|
alwaysOn: z.ZodDefault<z.ZodBoolean>;
|
|
18
22
|
}, z.core.$strict>;
|
|
19
23
|
export type SkillAutoEngagementHints = z.infer<typeof skillAutoEngagementHints>;
|
|
20
|
-
|
|
21
|
-
readonly id: string;
|
|
22
|
-
readonly slug: string;
|
|
23
|
-
readonly displayName: string;
|
|
24
|
-
readonly hints: SkillAutoEngagementHints;
|
|
25
|
-
}
|
|
26
|
-
export interface MatcherInput {
|
|
27
|
-
readonly userMessage: string;
|
|
28
|
-
/** Element-reference chips attached to this turn (P5 click-to-chat). */
|
|
29
|
-
readonly chipCount: number;
|
|
30
|
-
readonly skills: readonly CandidateSkill[];
|
|
31
|
-
/** Top-K cap. Defaults to 5 — engaging more than 5 skills bloats the system prompt. */
|
|
32
|
-
readonly topK?: number;
|
|
33
|
-
}
|
|
34
|
-
export interface SkillMatch {
|
|
35
|
-
readonly skillId: string;
|
|
36
|
-
readonly slug: string;
|
|
37
|
-
readonly displayName: string;
|
|
38
|
-
readonly score: number;
|
|
39
|
-
readonly rationale: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Score every candidate skill against the turn context. Returns the
|
|
43
|
-
* top-K matches sorted by score (descending). `alwaysOn` skills always
|
|
44
|
-
* score at least 1; `chipTrigger` skills score 100 when chips present;
|
|
45
|
-
* keywords add 1 per matching keyword (case-insensitive substring).
|
|
46
|
-
*
|
|
47
|
-
* Skills with score 0 are dropped — they never engage automatically.
|
|
48
|
-
*/
|
|
49
|
-
export declare function matchSkills(input: MatcherInput): SkillMatch[];
|
|
24
|
+
/** How a loaded skill came to be engaged this chat. */
|
|
50
25
|
export type EngagementSource = "auto" | "manual" | "pinned";
|
|
26
|
+
/** A skill the model has loaded (via load_skill) in the current chat. */
|
|
51
27
|
export interface ChatEngagement {
|
|
52
28
|
readonly skillId: string;
|
|
53
29
|
readonly slug: string;
|
|
@@ -55,34 +31,4 @@ export interface ChatEngagement {
|
|
|
55
31
|
readonly source: EngagementSource;
|
|
56
32
|
readonly rationale: string;
|
|
57
33
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Resolve the final per-call engagement set. Composition rules:
|
|
60
|
-
* - Manual ENGAGE overrides matcher (always engaged).
|
|
61
|
-
* - Manual DISENGAGE overrides matcher + pinned (never engaged).
|
|
62
|
-
* - Pinned defaults engage unless manually disengaged.
|
|
63
|
-
* - Auto matches engage unless manually disengaged.
|
|
64
|
-
*
|
|
65
|
-
* Returns the final set tagged with the source so the UI panel can
|
|
66
|
-
* render badges + the user can see which decisions came from where.
|
|
67
|
-
*/
|
|
68
|
-
export interface ResolveEngagementsInput {
|
|
69
|
-
readonly autoMatches: readonly SkillMatch[];
|
|
70
|
-
/**
|
|
71
|
-
* Manual overrides per chat. NULL = no overrides yet (auto + pinned only).
|
|
72
|
-
* Empty array = explicit "user disengaged everything" intent.
|
|
73
|
-
* Non-empty = list of explicit engages + disengages.
|
|
74
|
-
*/
|
|
75
|
-
readonly manualOverrides: ReadonlyArray<{
|
|
76
|
-
skillId: string;
|
|
77
|
-
slug: string;
|
|
78
|
-
displayName: string;
|
|
79
|
-
intent: "engage" | "disengage";
|
|
80
|
-
}> | null;
|
|
81
|
-
readonly pinnedSkills: ReadonlyArray<{
|
|
82
|
-
skillId: string;
|
|
83
|
-
slug: string;
|
|
84
|
-
displayName: string;
|
|
85
|
-
}>;
|
|
86
|
-
}
|
|
87
|
-
export declare function resolveEngagements(input: ResolveEngagementsInput): ChatEngagement[];
|
|
88
34
|
//# sourceMappingURL=skills.d.ts.map
|
package/dist/skills.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,wBAAwB;;;;kBAa1B,CAAC;AACZ,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,uDAAuD;AACvD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5D,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
|
package/dist/skills.js
CHANGED
|
@@ -1,127 +1,33 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MPL-2.0
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Skill metadata shapes shared across the Query API + chat-runner.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Skills use PROGRESSIVE DISCLOSURE (the Anthropic Agent Skills shape): a
|
|
6
|
+
* static `## Skills` index (slug + description) sits in the cached system
|
|
7
|
+
* prompt, and the model pulls a skill's full body into the conversation on
|
|
8
|
+
* demand via the `load_skill` tool (its body then lives in the append-only
|
|
9
|
+
* message history for the rest of the chat).
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* `skillAutoEngagementHints` no longer drives SELECTION — the model
|
|
12
|
+
* self-selects from the descriptions. The hints now only shape how prominently
|
|
13
|
+
* a skill is presented in the index: `alwaysOn` skills get an "always applies"
|
|
14
|
+
* callout, `chipTrigger` skills a "when element chips are attached" callout.
|
|
15
|
+
* (The old keyword/chip/always-on MATCHER + engagement resolver were removed
|
|
16
|
+
* once progressive disclosure replaced them.)
|
|
13
17
|
*/
|
|
14
18
|
import { z } from "zod";
|
|
15
19
|
export const skillAutoEngagementHints = z
|
|
16
20
|
.object({
|
|
17
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Lowercase substrings that once boosted the auto-matcher. The matcher is
|
|
23
|
+
* gone (progressive disclosure); retained in the schema so seeded rows that
|
|
24
|
+
* still carry keywords parse under `.strict()`. No runtime effect today.
|
|
25
|
+
*/
|
|
18
26
|
keywords: z.array(z.string().min(1).max(80)).default([]),
|
|
19
|
-
/**
|
|
27
|
+
/** Listed under the index's "when element chips are attached" callout. */
|
|
20
28
|
chipTrigger: z.boolean().default(false),
|
|
21
|
-
/**
|
|
29
|
+
/** Listed under the index's "always applies" callout (e.g. brand-voice-guard). */
|
|
22
30
|
alwaysOn: z.boolean().default(false),
|
|
23
31
|
})
|
|
24
32
|
.strict();
|
|
25
|
-
/**
|
|
26
|
-
* Score every candidate skill against the turn context. Returns the
|
|
27
|
-
* top-K matches sorted by score (descending). `alwaysOn` skills always
|
|
28
|
-
* score at least 1; `chipTrigger` skills score 100 when chips present;
|
|
29
|
-
* keywords add 1 per matching keyword (case-insensitive substring).
|
|
30
|
-
*
|
|
31
|
-
* Skills with score 0 are dropped — they never engage automatically.
|
|
32
|
-
*/
|
|
33
|
-
export function matchSkills(input) {
|
|
34
|
-
const topK = input.topK ?? 5;
|
|
35
|
-
const lowered = input.userMessage.toLowerCase();
|
|
36
|
-
const matches = [];
|
|
37
|
-
for (const s of input.skills) {
|
|
38
|
-
let score = 0;
|
|
39
|
-
const reasons = [];
|
|
40
|
-
if (s.hints.alwaysOn) {
|
|
41
|
-
score += 1;
|
|
42
|
-
reasons.push("always-on");
|
|
43
|
-
}
|
|
44
|
-
if (s.hints.chipTrigger && input.chipCount > 0) {
|
|
45
|
-
score += 100;
|
|
46
|
-
reasons.push(`element chips (${input.chipCount})`);
|
|
47
|
-
}
|
|
48
|
-
const matchedKeywords = [];
|
|
49
|
-
for (const k of s.hints.keywords) {
|
|
50
|
-
const needle = k.toLowerCase();
|
|
51
|
-
if (needle.length > 0 && lowered.includes(needle)) {
|
|
52
|
-
matchedKeywords.push(k);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (matchedKeywords.length > 0) {
|
|
56
|
-
score += matchedKeywords.length;
|
|
57
|
-
const sample = matchedKeywords.slice(0, 3).join(", ");
|
|
58
|
-
reasons.push(matchedKeywords.length > 3
|
|
59
|
-
? `keywords: ${sample}, +${matchedKeywords.length - 3}`
|
|
60
|
-
: `keywords: ${sample}`);
|
|
61
|
-
}
|
|
62
|
-
if (score > 0) {
|
|
63
|
-
matches.push({
|
|
64
|
-
skillId: s.id,
|
|
65
|
-
slug: s.slug,
|
|
66
|
-
displayName: s.displayName,
|
|
67
|
-
score,
|
|
68
|
-
rationale: reasons.join("; "),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
matches.sort((a, b) => b.score - a.score || a.slug.localeCompare(b.slug));
|
|
73
|
-
return matches.slice(0, topK);
|
|
74
|
-
}
|
|
75
|
-
export function resolveEngagements(input) {
|
|
76
|
-
const disengaged = new Set();
|
|
77
|
-
const engagedManual = new Map();
|
|
78
|
-
if (input.manualOverrides) {
|
|
79
|
-
for (const m of input.manualOverrides) {
|
|
80
|
-
if (m.intent === "disengage") {
|
|
81
|
-
disengaged.add(m.skillId);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
engagedManual.set(m.skillId, {
|
|
85
|
-
skillId: m.skillId,
|
|
86
|
-
slug: m.slug,
|
|
87
|
-
displayName: m.displayName,
|
|
88
|
-
source: "manual",
|
|
89
|
-
rationale: "manually engaged",
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
const out = new Map();
|
|
95
|
-
// Pinned defaults first (lowest priority among engaged).
|
|
96
|
-
for (const p of input.pinnedSkills) {
|
|
97
|
-
if (disengaged.has(p.skillId))
|
|
98
|
-
continue;
|
|
99
|
-
out.set(p.skillId, {
|
|
100
|
-
skillId: p.skillId,
|
|
101
|
-
slug: p.slug,
|
|
102
|
-
displayName: p.displayName,
|
|
103
|
-
source: "pinned",
|
|
104
|
-
rationale: "pinned default",
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
// Auto matches — overwrite pinned label only if not already in out.
|
|
108
|
-
for (const a of input.autoMatches) {
|
|
109
|
-
if (disengaged.has(a.skillId))
|
|
110
|
-
continue;
|
|
111
|
-
if (out.has(a.skillId))
|
|
112
|
-
continue;
|
|
113
|
-
out.set(a.skillId, {
|
|
114
|
-
skillId: a.skillId,
|
|
115
|
-
slug: a.slug,
|
|
116
|
-
displayName: a.displayName,
|
|
117
|
-
source: "auto",
|
|
118
|
-
rationale: a.rationale,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
// Manual engages always win — always overwrite.
|
|
122
|
-
for (const m of engagedManual.values()) {
|
|
123
|
-
out.set(m.skillId, m);
|
|
124
|
-
}
|
|
125
|
-
return [...out.values()];
|
|
126
|
-
}
|
|
127
33
|
//# sourceMappingURL=skills.js.map
|
package/dist/skills.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,CAAC;IACN;;;;OAIG;IACH,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACxD,0EAA0E;IAC1E,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACvC,kFAAkF;IAClF,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACrC,CAAC;KACD,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip XHTML-style CDATA-section guard delimiters from module HTML,
|
|
3
|
+
* preserving the content they wrapped. Returns the input unchanged when
|
|
4
|
+
* no guard is present (fast path for the overwhelming clean-HTML case).
|
|
5
|
+
*/
|
|
6
|
+
export declare function stripCdataGuards(html: string): string;
|
|
7
|
+
//# sourceMappingURL=strip-cdata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-cdata.d.ts","sourceRoot":"","sources":["../src/strip-cdata.ts"],"names":[],"mappings":"AAyCA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGrD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
/**
|
|
3
|
+
* CDATA-guard normalization for module HTML.
|
|
4
|
+
*
|
|
5
|
+
* The AI sometimes authors chrome/layout module HTML with XHTML-style
|
|
6
|
+
* CDATA guards wrapping inline `<style>`/`<script>` content — e.g.
|
|
7
|
+
*
|
|
8
|
+
* <script>
|
|
9
|
+
* //<![CDATA[
|
|
10
|
+
* doStuff();
|
|
11
|
+
* //]]>
|
|
12
|
+
* </script>
|
|
13
|
+
*
|
|
14
|
+
* or the block-comment / bare forms (`/*<![CDATA[* /`, `<![CDATA[`).
|
|
15
|
+
* These are legal in XHTML but MEANINGLESS in HTML5: the compose
|
|
16
|
+
* pipeline is byte-preserving by design (see `preview-scanner.ts`), so
|
|
17
|
+
* the guards survive verbatim into the rendered page. Chrome/layout
|
|
18
|
+
* modules render straight from their stored HTML (no content_instance
|
|
19
|
+
* indirection), so a bare `<![CDATA[` in the body is parsed by the
|
|
20
|
+
* browser as a bogus comment up to the first `>`, leaving a stray,
|
|
21
|
+
* visible `]]>` in the header/footer/nav.
|
|
22
|
+
*
|
|
23
|
+
* We normalize at the module-HTML write boundary (canonical) and again
|
|
24
|
+
* defensively at render, so both freshly-authored and already-stored
|
|
25
|
+
* modules stay clean. Only the DELIMITERS are removed — the wrapped
|
|
26
|
+
* CSS/JS/markup content is preserved.
|
|
27
|
+
*
|
|
28
|
+
* This is normalization of malformed authored markup, not a data
|
|
29
|
+
* fallback (CLAUDE.md §2): there is no "missing" data to point at, and
|
|
30
|
+
* the inner content is kept intact.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Matches every CDATA-guard delimiter form the model emits. The
|
|
34
|
+
* comment-wrapped variants come first so they're consumed as a unit
|
|
35
|
+
* before the bare `<![CDATA[` / `]]>` alternatives can match a subset.
|
|
36
|
+
*/
|
|
37
|
+
const CDATA_GUARDS = /\/\*\s*<!\[CDATA\[\s*\*\/|\/\*\s*\]\]>\s*\*\/|\/\/[ \t]*<!\[CDATA\[|\/\/[ \t]*\]\]>|<!\[CDATA\[|\]\]>/g;
|
|
38
|
+
/**
|
|
39
|
+
* Strip XHTML-style CDATA-section guard delimiters from module HTML,
|
|
40
|
+
* preserving the content they wrapped. Returns the input unchanged when
|
|
41
|
+
* no guard is present (fast path for the overwhelming clean-HTML case).
|
|
42
|
+
*/
|
|
43
|
+
export function stripCdataGuards(html) {
|
|
44
|
+
if (!html.includes("CDATA") && !html.includes("]]>"))
|
|
45
|
+
return html;
|
|
46
|
+
return html.replace(CDATA_GUARDS, "");
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=strip-cdata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-cdata.js","sourceRoot":"","sources":["../src/strip-cdata.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;;;;GAIG;AACH,MAAM,YAAY,GAChB,wGAAwG,CAAC;AAE3G;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAClE,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -35,18 +35,6 @@ export declare const taxonomyItem: z.ZodObject<{
|
|
|
35
35
|
parentSlug: z.ZodOptional<z.ZodString>;
|
|
36
36
|
description: z.ZodOptional<z.ZodString>;
|
|
37
37
|
}, z.core.$strict>;
|
|
38
|
-
/** One CSS variable. Renderer emits `<style>:root{--<token>: <value>;…}</style>`. */
|
|
39
|
-
export declare const themeToken: z.ZodObject<{
|
|
40
|
-
token: z.ZodString;
|
|
41
|
-
value: z.ZodString;
|
|
42
|
-
scope: z.ZodOptional<z.ZodEnum<{
|
|
43
|
-
color: "color";
|
|
44
|
-
font: "font";
|
|
45
|
-
space: "space";
|
|
46
|
-
radius: "radius";
|
|
47
|
-
shadow: "shadow";
|
|
48
|
-
}>>;
|
|
49
|
-
}, z.core.$strict>;
|
|
50
38
|
/** Flat tag — used by post taxonomies, content filtering. */
|
|
51
39
|
export declare const tagItem: z.ZodObject<{
|
|
52
40
|
slug: z.ZodString;
|
|
@@ -59,28 +47,17 @@ export declare const linkListItem: z.ZodObject<{
|
|
|
59
47
|
href: z.ZodString;
|
|
60
48
|
description: z.ZodOptional<z.ZodString>;
|
|
61
49
|
}, z.core.$strict>;
|
|
62
|
-
/**
|
|
63
|
-
* P9 review-pass — `language-selector` kind. Items are user-supplied
|
|
64
|
-
* overrides (e.g. force a specific display label per locale); empty
|
|
65
|
-
* array means "auto-populate from the locale registry at render time."
|
|
66
|
-
* The renderer (apps/static-generator + preview op) reads the locale
|
|
67
|
-
* registry + the current page's slug + resolveLocaleUrl to emit
|
|
68
|
-
* `<a hreflang lang href>` rows. Closes CMS_REQUIREMENTS §7.8.
|
|
69
|
-
*/
|
|
70
|
-
export declare const languageSelectorOverride: z.ZodObject<{
|
|
71
|
-
locale: z.ZodString;
|
|
72
|
-
label: z.ZodOptional<z.ZodString>;
|
|
73
|
-
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
-
}, z.core.$strict>;
|
|
75
50
|
/** Discriminated kind → items array. The Query API op picks the
|
|
76
|
-
* validator at runtime by reading `kind` first.
|
|
51
|
+
* validator at runtime by reading `kind` first.
|
|
52
|
+
*
|
|
53
|
+
* v0.11.0 (#45) — `theme` is no longer a structured-set kind. The
|
|
54
|
+
* theme primitive moved to its own `themes` table with DTCG-shaped
|
|
55
|
+
* jsonb tokens; see `themes.ts` + `theme-render.ts`. */
|
|
77
56
|
export declare const structuredSetKind: z.ZodEnum<{
|
|
57
|
+
"link-list": "link-list";
|
|
78
58
|
"nav-menu": "nav-menu";
|
|
79
59
|
taxonomy: "taxonomy";
|
|
80
|
-
theme: "theme";
|
|
81
60
|
tags: "tags";
|
|
82
|
-
"link-list": "link-list";
|
|
83
|
-
"language-selector": "language-selector";
|
|
84
61
|
}>;
|
|
85
62
|
export type StructuredSetKind = z.infer<typeof structuredSetKind>;
|
|
86
63
|
/** Validate `items` against the right schema for `kind`. Throws a
|
|
@@ -88,29 +65,6 @@ export type StructuredSetKind = z.infer<typeof structuredSetKind>;
|
|
|
88
65
|
export declare function validateStructuredSetItems(kind: StructuredSetKind, items: unknown): unknown[];
|
|
89
66
|
export type NavMenuItem = z.infer<typeof navMenuItem>;
|
|
90
67
|
export type TaxonomyItem = z.infer<typeof taxonomyItem>;
|
|
91
|
-
export type ThemeToken = z.infer<typeof themeToken>;
|
|
92
68
|
export type TagItem = z.infer<typeof tagItem>;
|
|
93
69
|
export type LinkListItem = z.infer<typeof linkListItem>;
|
|
94
|
-
export type LanguageSelectorOverride = z.infer<typeof languageSelectorOverride>;
|
|
95
|
-
/**
|
|
96
|
-
* Render a `<nav class="caelo-language-selector">` with one `<a>`
|
|
97
|
-
* per locale that has a published variant of the current page. Pure
|
|
98
|
-
* function — caller threads the page's published-locale list and a
|
|
99
|
-
* URL resolver. Used by `composePagePreview` (admin) and the static
|
|
100
|
-
* generator (deploy) so byte-for-byte output parity holds.
|
|
101
|
-
*
|
|
102
|
-
* Per CMS_REQUIREMENTS §7.8: locales with no published variant for the
|
|
103
|
-
* current page are excluded.
|
|
104
|
-
*/
|
|
105
|
-
export declare function renderLanguageSelector(args: {
|
|
106
|
-
/** Each locale that has a published variant of the current page. */
|
|
107
|
-
readonly availableLocales: ReadonlyArray<{
|
|
108
|
-
code: string;
|
|
109
|
-
displayName: string;
|
|
110
|
-
href: string;
|
|
111
|
-
isCurrent: boolean;
|
|
112
|
-
}>;
|
|
113
|
-
/** Owner-supplied overrides (relabel a locale, hide one). */
|
|
114
|
-
readonly overrides?: ReadonlyArray<LanguageSelectorOverride>;
|
|
115
|
-
}): string;
|
|
116
70
|
//# sourceMappingURL=structured-sets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured-sets.d.ts","sourceRoot":"","sources":["../src/structured-sets.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,+DAA+D;AAC/D,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC5B,QAAQ,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC7C,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAUA,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,YAAY;;;;;kBAOd,CAAC;AAEZ,
|
|
1
|
+
{"version":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,CAAC,CAAC"}
|
package/dist/structured-sets.js
CHANGED
|
@@ -36,18 +36,6 @@ export const taxonomyItem = z
|
|
|
36
36
|
description: z.string().max(2000).optional(),
|
|
37
37
|
})
|
|
38
38
|
.strict();
|
|
39
|
-
/** One CSS variable. Renderer emits `<style>:root{--<token>: <value>;…}</style>`. */
|
|
40
|
-
export const themeToken = z
|
|
41
|
-
.object({
|
|
42
|
-
token: z
|
|
43
|
-
.string()
|
|
44
|
-
.min(1)
|
|
45
|
-
.max(80)
|
|
46
|
-
.regex(/^[a-z][a-z0-9-]*$/, "lowercase kebab-case"),
|
|
47
|
-
value: z.string().min(1).max(500),
|
|
48
|
-
scope: z.enum(["color", "font", "space", "radius", "shadow"]).optional(),
|
|
49
|
-
})
|
|
50
|
-
.strict();
|
|
51
39
|
/** Flat tag — used by post taxonomies, content filtering. */
|
|
52
40
|
export const tagItem = z
|
|
53
41
|
.object({
|
|
@@ -71,34 +59,13 @@ export const linkListItem = z
|
|
|
71
59
|
description: z.string().max(500).optional(),
|
|
72
60
|
})
|
|
73
61
|
.strict();
|
|
74
|
-
/**
|
|
75
|
-
* P9 review-pass — `language-selector` kind. Items are user-supplied
|
|
76
|
-
* overrides (e.g. force a specific display label per locale); empty
|
|
77
|
-
* array means "auto-populate from the locale registry at render time."
|
|
78
|
-
* The renderer (apps/static-generator + preview op) reads the locale
|
|
79
|
-
* registry + the current page's slug + resolveLocaleUrl to emit
|
|
80
|
-
* `<a hreflang lang href>` rows. Closes CMS_REQUIREMENTS §7.8.
|
|
81
|
-
*/
|
|
82
|
-
export const languageSelectorOverride = z
|
|
83
|
-
.object({
|
|
84
|
-
/** BCP-47 locale code; must match a row in the locales registry. */
|
|
85
|
-
locale: z.string().min(2).max(10),
|
|
86
|
-
/** Override the locale's display_name when rendering this entry. */
|
|
87
|
-
label: z.string().min(1).max(120).optional(),
|
|
88
|
-
/** Hide this locale from the rendered selector even if it has a published page. */
|
|
89
|
-
hidden: z.boolean().optional(),
|
|
90
|
-
})
|
|
91
|
-
.strict();
|
|
92
62
|
/** Discriminated kind → items array. The Query API op picks the
|
|
93
|
-
* validator at runtime by reading `kind` first.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"link-list",
|
|
100
|
-
"language-selector",
|
|
101
|
-
]);
|
|
63
|
+
* validator at runtime by reading `kind` first.
|
|
64
|
+
*
|
|
65
|
+
* v0.11.0 (#45) — `theme` is no longer a structured-set kind. The
|
|
66
|
+
* theme primitive moved to its own `themes` table with DTCG-shaped
|
|
67
|
+
* jsonb tokens; see `themes.ts` + `theme-render.ts`. */
|
|
68
|
+
export const structuredSetKind = z.enum(["nav-menu", "taxonomy", "tags", "link-list"]);
|
|
102
69
|
/** Validate `items` against the right schema for `kind`. Throws a
|
|
103
70
|
* ZodError on mismatch — callers wrap and return `Err(ValidationFailed)`. */
|
|
104
71
|
export function validateStructuredSetItems(kind, items) {
|
|
@@ -116,39 +83,10 @@ export function validateStructuredSetItems(kind, items) {
|
|
|
116
83
|
return items.map((it) => navMenuItem.parse(it));
|
|
117
84
|
case "taxonomy":
|
|
118
85
|
return items.map((it) => taxonomyItem.parse(it));
|
|
119
|
-
case "theme":
|
|
120
|
-
return items.map((it) => themeToken.parse(it));
|
|
121
86
|
case "tags":
|
|
122
87
|
return items.map((it) => tagItem.parse(it));
|
|
123
88
|
case "link-list":
|
|
124
89
|
return items.map((it) => linkListItem.parse(it));
|
|
125
|
-
case "language-selector":
|
|
126
|
-
return items.map((it) => languageSelectorOverride.parse(it));
|
|
127
90
|
}
|
|
128
91
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Render a `<nav class="caelo-language-selector">` with one `<a>`
|
|
131
|
-
* per locale that has a published variant of the current page. Pure
|
|
132
|
-
* function — caller threads the page's published-locale list and a
|
|
133
|
-
* URL resolver. Used by `composePagePreview` (admin) and the static
|
|
134
|
-
* generator (deploy) so byte-for-byte output parity holds.
|
|
135
|
-
*
|
|
136
|
-
* Per CMS_REQUIREMENTS §7.8: locales with no published variant for the
|
|
137
|
-
* current page are excluded.
|
|
138
|
-
*/
|
|
139
|
-
export function renderLanguageSelector(args) {
|
|
140
|
-
const overrideByLocale = new Map((args.overrides ?? []).map((o) => [o.locale, o]));
|
|
141
|
-
const enc = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
142
|
-
const items = args.availableLocales
|
|
143
|
-
.filter((l) => !overrideByLocale.get(l.code)?.hidden)
|
|
144
|
-
.map((l) => {
|
|
145
|
-
const override = overrideByLocale.get(l.code);
|
|
146
|
-
const label = override?.label ?? l.displayName;
|
|
147
|
-
const aria = l.isCurrent ? ' aria-current="true"' : "";
|
|
148
|
-
return `<a hreflang="${enc(l.code)}" lang="${enc(l.code)}" href="${enc(l.href)}"${aria}>${enc(label)}</a>`;
|
|
149
|
-
});
|
|
150
|
-
if (items.length === 0)
|
|
151
|
-
return "";
|
|
152
|
-
return `<nav class="caelo-language-selector" aria-label="Language">${items.join("")}</nav>`;
|
|
153
|
-
}
|
|
154
92
|
//# sourceMappingURL=structured-sets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured-sets.js","sourceRoot":"","sources":["../src/structured-sets.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,+DAA+D;AAC/D,MAAM,CAAC,MAAM,WAAW,GAOnB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACf,CAAC;KACE,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAChC,MAAM,EAAE,CA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