@owlmeans/basic-ids 0.1.18-rc.4 → 0.1.18-rc.40

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 (49) hide show
  1. package/README.md +5 -5
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/basic-ids/SKILL.md +44 -8
  4. package/build/consts.d.ts +11 -0
  5. package/build/consts.d.ts.map +1 -1
  6. package/build/consts.js +11 -0
  7. package/build/consts.js.map +1 -1
  8. package/build/helper/types.d.ts +25 -0
  9. package/build/helper/types.d.ts.map +1 -0
  10. package/build/helper/types.js +2 -0
  11. package/build/helper/types.js.map +1 -0
  12. package/build/helper.d.ts +8 -3
  13. package/build/helper.d.ts.map +1 -1
  14. package/build/helper.js +30 -16
  15. package/build/helper.js.map +1 -1
  16. package/build/index.d.ts +3 -0
  17. package/build/index.d.ts.map +1 -1
  18. package/build/index.js +2 -0
  19. package/build/index.js.map +1 -1
  20. package/build/random.d.ts +4 -0
  21. package/build/random.d.ts.map +1 -0
  22. package/build/random.js +17 -0
  23. package/build/random.js.map +1 -0
  24. package/build/wordlists/consts.d.ts +25 -0
  25. package/build/wordlists/consts.d.ts.map +1 -0
  26. package/build/wordlists/consts.js +539 -0
  27. package/build/wordlists/consts.js.map +1 -0
  28. package/build/wordlists/list-a.d.ts +13 -0
  29. package/build/wordlists/list-a.d.ts.map +1 -0
  30. package/build/wordlists/list-a.js +270 -0
  31. package/build/wordlists/list-a.js.map +1 -0
  32. package/build/wordlists/list-b.d.ts +13 -0
  33. package/build/wordlists/list-b.d.ts.map +1 -0
  34. package/build/wordlists/list-b.js +270 -0
  35. package/build/wordlists/list-b.js.map +1 -0
  36. package/package.json +6 -6
  37. package/scripts/curate-wordlists.d.ts +2 -0
  38. package/scripts/curate-wordlists.d.ts.map +1 -0
  39. package/scripts/curate-wordlists.js +145 -0
  40. package/scripts/curate-wordlists.js.map +1 -0
  41. package/scripts/curate-wordlists.ts +188 -0
  42. package/src/consts.ts +13 -0
  43. package/src/helper/types.ts +24 -0
  44. package/src/helper.ts +39 -16
  45. package/src/index.ts +3 -0
  46. package/src/random.ts +18 -0
  47. package/src/wordlists/consts.ts +539 -0
  48. package/tests/word-slug.spec.ts +65 -0
  49. package/tsconfig.json +7 -1
@@ -0,0 +1,65 @@
1
+ import { describe, test, expect } from 'bun:test'
2
+ import { WORDLIST_A, WORDLIST_B } from '../src/wordlists/consts.js'
3
+ import { idHelper } from '../src/helper.js'
4
+ import { WORDLIST_SIZE } from '../src/consts.js'
5
+
6
+ const WORD = /^[a-z]{3,8}$/
7
+
8
+ /**
9
+ * The invariants the lists are curated to hold. They are asserted here rather than trusted because
10
+ * `generateWordSlug` masks 11 bits to index them: a list that is not exactly 2048 entries long
11
+ * either skews toward its front or indexes past its end, and both fail silently.
12
+ */
13
+ describe.each([
14
+ ['list-a', WORDLIST_A],
15
+ ['list-b', WORDLIST_B],
16
+ ])('%s', (name, list) => {
17
+ test('holds exactly one power-of-two block of words', () => {
18
+ expect(list.length).toBe(WORDLIST_SIZE)
19
+ })
20
+
21
+ test('every word is lowercase ascii, 3-8 characters', () => {
22
+ const bad = list.filter(word => !WORD.test(word))
23
+ expect(bad).toEqual([])
24
+ })
25
+
26
+ test('has no duplicates', () => {
27
+ expect(new Set(list).size).toBe(list.length)
28
+ })
29
+ })
30
+
31
+ test('the lists are disjoint, so a slug never repeats its own word', () => {
32
+ const a = new Set(WORDLIST_A)
33
+ expect(WORDLIST_B.filter(word => a.has(word))).toEqual([])
34
+ })
35
+
36
+ describe('generateWordSlug', () => {
37
+ test('produces a two-word slug that is a valid DNS label', () => {
38
+ for (let i = 0; i < 200; ++i) {
39
+ const slug = idHelper.generateWordSlug()
40
+ expect(slug).toMatch(/^[a-z]{3,8}-[a-z]{3,8}$/)
41
+ expect(slug.length).toBeLessThanOrEqual(63)
42
+ }
43
+ })
44
+
45
+ test('draws from both lists, in order', () => {
46
+ const [first, second] = idHelper.generateWordSlug().split('-')
47
+ expect(WORDLIST_A).toContain(first)
48
+ expect(WORDLIST_B).toContain(second)
49
+ })
50
+
51
+ test('spreads across the space rather than repeating one pair', () => {
52
+ const seen = new Set(Array.from({ length: 200 }, () => idHelper.generateWordSlug()))
53
+ // 22 bits of entropy: 200 draws colliding more than a handful of times means the index
54
+ // masking is broken, not that we got unlucky.
55
+ expect(seen.size).toBeGreaterThan(190)
56
+ })
57
+ })
58
+
59
+ describe('nextSlugCandidate', () => {
60
+ test('leaves the first attempt bare and numbers the rest', () => {
61
+ expect(idHelper.nextSlugCandidate('brisk-otter', 1)).toBe('brisk-otter')
62
+ expect(idHelper.nextSlugCandidate('brisk-otter', 2)).toBe('brisk-otter-2')
63
+ expect(idHelper.nextSlugCandidate('brisk-otter', 5)).toBe('brisk-otter-5')
64
+ })
65
+ })
package/tsconfig.json CHANGED
@@ -6,5 +6,11 @@
6
6
  "rootDir": "./src/",
7
7
  "outDir": "./build/"
8
8
  },
9
- "exclude": ["./dist/**/*", "./build/**/*", "./*.ts"]
9
+ "exclude": [
10
+ "./dist/**/*",
11
+ "./build/**/*",
12
+ "./tests/**/*",
13
+ "./scripts/**/*",
14
+ "./*.ts"
15
+ ]
10
16
  }