GeezerVison is showing github.com — fix(contracts): simplify monogram length validation · pingdotgg/t3code@41e4f63
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/contracts/package.json +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 25 | 25 | "test": "vp test run" | 26 | 26 | }, | 27 | 27 | "dependencies": { | 28 | | - "effect": "catalog:", | 29 | | - "unicode-segmenter": "0.17.3" | | 28 | + "effect": "catalog:" | 30 | 29 | }, | 31 | 30 | "devDependencies": { | 32 | 31 | "@effect/vitest": "catalog:", | |
Collapse file Copy file name to clipboardExpand all lines: packages/contracts/src/mobile-runtime.test.ts +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,10 +13,14 @@ it("loads contracts and validates monograms without Intl.Segmenter", async () => | 13 | 13 | const Schema = await import("effect/Schema"); | 14 | 14 | const isMonogram = Schema.is(ProjectMonogramText); | 15 | 15 |
| 16 | | - for (const text of ["A", "T3", "e\u0301", "किखि", "\u1100\u1161\u11a8"]) { | | 16 | + for (const text of ["A", "T3", "e\u0301", "किखि", "\u1100\u1161\u11a8", "𐐀𐐁", "A\u200dB"]) { | 17 | 17 | expect(isMonogram(text), text).toBe(true); | 18 | 18 | } | 19 | 19 | for (const text of ["", "ABC", "किखिगि", "\u0301", "A B", "🚀"]) { | 20 | 20 | expect(isMonogram(text), text).toBe(false); | 21 | 21 | } | | 22 | + | | 23 | + // The lightweight limit counts consonants separately in complex Indic conjuncts. | | 24 | + expect(isMonogram("क्ष्म")).toBe(false); | | 25 | + expect(isMonogram("A\u200dB\u200dC")).toBe(false); | 22 | 26 | }); |
Collapse file Copy file name to clipboardExpand all lines: packages/contracts/src/orchestration.ts +5-3Lines changed: 5 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,7 +3,6 @@ import * as Schema from "effect/Schema"; | 3 | 3 | import * as SchemaIssue from "effect/SchemaIssue"; | 4 | 4 | import * as SchemaTransformation from "effect/SchemaTransformation"; | 5 | 5 | import * as Struct from "effect/Struct"; | 6 | | -import { countGraphemes } from "unicode-segmenter/grapheme"; | 7 | 6 | import { OrchestrationMessageContext } from "./composerContext.ts"; | 8 | 7 | import { ProviderOptionSelections } from "./model.ts"; | 9 | 8 | import { RepositoryIdentity, ThreadEnvMode } from "./environment.ts"; | @@ -463,8 +462,11 @@ const ProjectEmoji = TrimmedNonEmptyString.check(Schema.isMaxLength(32)); | 463 | 462 | export const ProjectMonogramText = TrimmedNonEmptyString.check( | 464 | 463 | Schema.isMaxLength(32), | 465 | 464 | Schema.isPattern(/^[\p{L}\p{N}][\p{L}\p{N}\p{M}\u200c\u200d]*$/u), | 466 | | - // These contracts also load in Hermes, which does not provide Intl.Segmenter. | 467 | | - Schema.makeFilter((text) => countGraphemes(text) <= 2), | | 465 | + // Approximate monogram length without Intl.Segmenter, which Hermes lacks. | | 466 | + // Normalize composed letters and ignore marks/joiners; complex conjuncts may count as multiple letters. | | 467 | + Schema.makeFilter( | | 468 | + (text) => [...text.normalize("NFC").replace(/[\p{M}\u200c\u200d]/gu, "")].length <= 2, | | 469 | + ), | 468 | 470 | ); | 469 | 471 |
| 470 | 472 | export const ProjectIconOverride = Schema.Union([ | |
Collapse file Copy file name to clipboardExpand all lines: pnpm-lock.yaml -8Lines changed: 0 additions & 8 deletions
|