@cavelang/core 0.1.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.
- package/README.md +76 -0
- package/dist/src/claim.d.ts +108 -0
- package/dist/src/claim.d.ts.map +1 -0
- package/dist/src/claim.js +65 -0
- package/dist/src/claim.js.map +1 -0
- package/dist/src/confidence.d.ts +26 -0
- package/dist/src/confidence.d.ts.map +1 -0
- package/dist/src/confidence.js +34 -0
- package/dist/src/confidence.js.map +1 -0
- package/dist/src/context.d.ts +26 -0
- package/dist/src/context.d.ts.map +1 -0
- package/dist/src/context.js +31 -0
- package/dist/src/context.js.map +1 -0
- package/dist/src/entity.d.ts +26 -0
- package/dist/src/entity.d.ts.map +1 -0
- package/dist/src/entity.js +41 -0
- package/dist/src/entity.js.map +1 -0
- package/dist/src/index.d.ts +23 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +23 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/key.d.ts +28 -0
- package/dist/src/key.d.ts.map +1 -0
- package/dist/src/key.js +49 -0
- package/dist/src/key.js.map +1 -0
- package/dist/src/multiplier.d.ts +17 -0
- package/dist/src/multiplier.d.ts.map +1 -0
- package/dist/src/multiplier.js +19 -0
- package/dist/src/multiplier.js.map +1 -0
- package/dist/src/tag.d.ts +29 -0
- package/dist/src/tag.d.ts.map +1 -0
- package/dist/src/tag.js +28 -0
- package/dist/src/tag.js.map +1 -0
- package/dist/src/uncertainty.d.ts +21 -0
- package/dist/src/uncertainty.d.ts.map +1 -0
- package/dist/src/uncertainty.js +26 -0
- package/dist/src/uncertainty.js.map +1 -0
- package/dist/src/uuidv7.d.ts +28 -0
- package/dist/src/uuidv7.d.ts.map +1 -0
- package/dist/src/uuidv7.js +69 -0
- package/dist/src/uuidv7.js.map +1 -0
- package/dist/src/value.d.ts +57 -0
- package/dist/src/value.d.ts.map +1 -0
- package/dist/src/value.js +104 -0
- package/dist/src/value.js.map +1 -0
- package/dist/src/verb.d.ts +47 -0
- package/dist/src/verb.d.ts.map +1 -0
- package/dist/src/verb.js +55 -0
- package/dist/src/verb.js.map +1 -0
- package/package.json +39 -0
- package/src/claim.ts +148 -0
- package/src/confidence.ts +42 -0
- package/src/context.ts +43 -0
- package/src/entity.ts +49 -0
- package/src/index.ts +23 -0
- package/src/key.ts +55 -0
- package/src/multiplier.ts +28 -0
- package/src/tag.ts +42 -0
- package/src/uncertainty.ts +29 -0
- package/src/uuidv7.ts +76 -0
- package/src/value.ts +138 -0
- package/src/verb.ts +78 -0
package/src/verb.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verbs (spec §5).
|
|
3
|
+
*
|
|
4
|
+
* Verbs are uppercase atoms. Two bootstrap verbs (`IS`, `HAS`) can define
|
|
5
|
+
* everything else in-band; the standard set below exists for graph quality.
|
|
6
|
+
* Extension verbs (spec §5.4) and inverse declarations (spec §5.5 `REVERSE`)
|
|
7
|
+
* are ordinary claims, not syntax — this module only knows the lexical shape
|
|
8
|
+
* and the standard vocabulary.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type Verb = string
|
|
12
|
+
|
|
13
|
+
export type t = Verb
|
|
14
|
+
|
|
15
|
+
/** Bootstrap verbs (spec §5.1). */
|
|
16
|
+
export const bootstrap = ['IS', 'HAS'] as const
|
|
17
|
+
|
|
18
|
+
/** Identity and taxonomy (spec §5.2). */
|
|
19
|
+
export const identity = ['IS', 'EXTENDS', 'ALIAS', 'LIKE', 'EXISTS'] as const
|
|
20
|
+
|
|
21
|
+
/** Causation and change (spec §5.2). */
|
|
22
|
+
export const causation = ['CAUSE', 'FIX', 'BECOMES'] as const
|
|
23
|
+
|
|
24
|
+
/** Dependency and production (spec §5.2). */
|
|
25
|
+
export const dependency = ['NEEDS', 'USES', 'YIELDS', 'ENABLES', 'BLOCKS'] as const
|
|
26
|
+
|
|
27
|
+
/** Structure and ordering (spec §5.2). */
|
|
28
|
+
export const structure = ['CONTAINS', 'PRECEDES', 'EXCEEDS', 'VS'] as const
|
|
29
|
+
|
|
30
|
+
/** Qualifier verbs — appear indented under another claim (spec §5.2, §8.2). */
|
|
31
|
+
export const qualifiers = ['WHEN', 'UNLESS', 'VIA', 'BECAUSE'] as const
|
|
32
|
+
|
|
33
|
+
export type Qualifier = (typeof qualifiers)[number]
|
|
34
|
+
|
|
35
|
+
/** The inverse-declaration verb (spec §5.5). */
|
|
36
|
+
export const REVERSE = 'REVERSE'
|
|
37
|
+
|
|
38
|
+
/** The standard inverse names (spec §5.5's declaration block). */
|
|
39
|
+
export const standardInverses = [
|
|
40
|
+
'PART-OF', 'CAUSED-BY', 'FOLLOWS', 'USED-BY',
|
|
41
|
+
'NEEDED-BY', 'ENABLED-BY', 'BLOCKED-BY', 'EXTENDED-BY'
|
|
42
|
+
] as const
|
|
43
|
+
|
|
44
|
+
/** All standard relational verbs (qualifiers excluded). */
|
|
45
|
+
export const standard: readonly Verb[] = [
|
|
46
|
+
...identity,
|
|
47
|
+
...causation,
|
|
48
|
+
...dependency,
|
|
49
|
+
...structure
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
const standardSet = new Set<string>(standard)
|
|
53
|
+
const qualifierSet = new Set<string>(qualifiers)
|
|
54
|
+
const knownSet = new Set<string>([...standard, 'HAS', REVERSE, ...standardInverses])
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @returns `true` if `s` has the lexical shape of a verb — an uppercase atom:
|
|
58
|
+
* uppercase letters and internal `-` (spec §16 `uppercase_atom`).
|
|
59
|
+
*/
|
|
60
|
+
export const isVerbToken = (s: string): boolean =>
|
|
61
|
+
/^[A-Z](?:[A-Z-]*[A-Z])?$/.test(s)
|
|
62
|
+
|
|
63
|
+
/** @returns `true` if `v` is one of the standard relational verbs. */
|
|
64
|
+
export const isStandard = (v: string): boolean =>
|
|
65
|
+
standardSet.has(v)
|
|
66
|
+
|
|
67
|
+
/** @returns `true` if `v` is a qualifier verb (`WHEN`, `UNLESS`, `VIA`, `BECAUSE`). */
|
|
68
|
+
export const isQualifier = (v: string): v is Qualifier =>
|
|
69
|
+
qualifierSet.has(v)
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @returns `true` if `v` belongs to the known standard vocabulary —
|
|
73
|
+
* standard verbs, `HAS`, `REVERSE`, and the standard §5.5 inverse names.
|
|
74
|
+
* Used by the parser's indentation tiebreak: `USES JWT` is a continuation
|
|
75
|
+
* (JWT is not a known verb) while `API NEEDS auth` is a full triple.
|
|
76
|
+
*/
|
|
77
|
+
export const isKnown = (v: string): boolean =>
|
|
78
|
+
knownSet.has(v)
|