@derive-ltd/uht-substrate 1.0.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 +242 -0
- package/dist/client.d.ts +107 -0
- package/dist/client.js +253 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/classify.d.ts +3 -0
- package/dist/commands/classify.js +29 -0
- package/dist/commands/classify.js.map +1 -0
- package/dist/commands/compare.d.ts +3 -0
- package/dist/commands/compare.js +20 -0
- package/dist/commands/compare.js.map +1 -0
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.js +36 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/entities.d.ts +3 -0
- package/dist/commands/entities.js +144 -0
- package/dist/commands/entities.js.map +1 -0
- package/dist/commands/facts.d.ts +3 -0
- package/dist/commands/facts.js +130 -0
- package/dist/commands/facts.js.map +1 -0
- package/dist/commands/impact.d.ts +3 -0
- package/dist/commands/impact.js +148 -0
- package/dist/commands/impact.js.map +1 -0
- package/dist/commands/info.d.ts +3 -0
- package/dist/commands/info.js +35 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/namespaces.d.ts +3 -0
- package/dist/commands/namespaces.js +34 -0
- package/dist/commands/namespaces.js.map +1 -0
- package/dist/commands/semantic.d.ts +3 -0
- package/dist/commands/semantic.js +34 -0
- package/dist/commands/semantic.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +58 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/output.d.ts +8 -0
- package/dist/output.js +310 -0
- package/dist/output.js.map +1 -0
- package/dist/types.d.ts +75 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# uht-substrate
|
|
2
|
+
|
|
3
|
+
CLI for the [Universal Hex Taxonomy](https://factory.universalhex.org) Substrate API — classify entities, compare concepts, manage facts, and explore semantic relationships from your terminal.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g uht-substrate
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx uht-substrate <command>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Setup
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uht-substrate config set token <your-api-token>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The default API URL is `https://substrate.universalhex.org/api`. To override:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
uht-substrate config set api-url https://your-server.com/api
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or use environment variables:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
export UHT_API_URL=https://substrate.universalhex.org/api
|
|
33
|
+
export UHT_TOKEN=your-token
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Classify an entity — get its 8-char hex code and 32 trait bits
|
|
40
|
+
uht-substrate classify hammer
|
|
41
|
+
uht-substrate classify "cognitive dissonance" -c "a psychology concept" --format pretty
|
|
42
|
+
|
|
43
|
+
# Reclassify with a rich description (skips cache)
|
|
44
|
+
uht-substrate classify "epistemic humility" \
|
|
45
|
+
-c "the intellectual virtue of recognizing the limits of one's knowledge" \
|
|
46
|
+
--force-refresh
|
|
47
|
+
|
|
48
|
+
# Compare two entities — Jaccard similarity, shared/unique traits
|
|
49
|
+
uht-substrate compare hammer screwdriver --format pretty
|
|
50
|
+
uht-substrate compare "Account (grounds)" democracy --format pretty
|
|
51
|
+
|
|
52
|
+
# Batch compare — rank candidates by similarity
|
|
53
|
+
uht-substrate batch-compare hammer wrench screwdriver pliers saw
|
|
54
|
+
|
|
55
|
+
# Semantic search across 16k+ entities
|
|
56
|
+
uht-substrate search "hand tools" --limit 10
|
|
57
|
+
|
|
58
|
+
# Disambiguate a polysemous term
|
|
59
|
+
uht-substrate disambiguate bank
|
|
60
|
+
|
|
61
|
+
# Infer properties from classification
|
|
62
|
+
uht-substrate infer hammer
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Commands
|
|
66
|
+
|
|
67
|
+
### Classification & Reasoning
|
|
68
|
+
|
|
69
|
+
| Command | Description |
|
|
70
|
+
|---------|-------------|
|
|
71
|
+
| `classify <entity>` | Classify an entity and get its hex code (`-c`, `-f`, `-n`) |
|
|
72
|
+
| `infer <entity>` | Infer properties from classification |
|
|
73
|
+
| `compare <a> <b>` | Compare two entities |
|
|
74
|
+
| `batch-compare <entity> <candidates...>` | Compare against multiple, ranked by Jaccard |
|
|
75
|
+
| `search <query>` | Semantic search across the entity corpus |
|
|
76
|
+
| `disambiguate <term>` | Get word senses for polysemous terms |
|
|
77
|
+
| `semantic-triangle <text>` | Ogden-Richards semantic triangle decomposition |
|
|
78
|
+
| `map-properties <props...>` | Map natural language properties to UHT trait bits |
|
|
79
|
+
|
|
80
|
+
### Entity Management
|
|
81
|
+
|
|
82
|
+
| Command | Description |
|
|
83
|
+
|---------|-------------|
|
|
84
|
+
| `entities list` | List entities (with uuid, description) |
|
|
85
|
+
| `entities get` | Get a single entity by `--name` or `--uuid` |
|
|
86
|
+
| `entities delete <name>` | Delete an entity from the local graph |
|
|
87
|
+
| `entities find-similar <entity>` | Find similar entities (experimental) |
|
|
88
|
+
| `entities explore <entity>` | Explore semantic neighborhood (experimental) |
|
|
89
|
+
| `entities search-traits` | Search entities by trait pattern |
|
|
90
|
+
|
|
91
|
+
#### Trait search example
|
|
92
|
+
|
|
93
|
+
Use `--<trait-name>` to require a trait, `--no-<trait-name>` to exclude:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
uht-substrate entities search-traits --synthetic --powered --no-biological
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Fact Management
|
|
100
|
+
|
|
101
|
+
| Command | Description |
|
|
102
|
+
|---------|-------------|
|
|
103
|
+
| `facts store <subject> <predicate> <object>` | Store a fact |
|
|
104
|
+
| `facts store-bulk --file <path>` | Store multiple facts from a JSON file |
|
|
105
|
+
| `facts upsert <subject> <predicate> <object>` | Create or update a fact |
|
|
106
|
+
| `facts query` | Query facts with filters |
|
|
107
|
+
| `facts update <fact-id>` | Update an existing fact |
|
|
108
|
+
| `facts delete <fact-id>` | Delete a fact |
|
|
109
|
+
| `facts user-context` | Get a user's stored facts |
|
|
110
|
+
| `facts namespace-context <namespace>` | Get all entities and facts under a namespace |
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Store a typed fact
|
|
114
|
+
uht-substrate facts store "spark plug" PART_OF "engine" --namespace SE:automotive
|
|
115
|
+
|
|
116
|
+
# Query facts
|
|
117
|
+
uht-substrate facts query --subject "spark plug" --category compositional
|
|
118
|
+
|
|
119
|
+
# Bulk store from JSON
|
|
120
|
+
echo '[{"subject":"bolt","predicate":"PART_OF","object_value":"frame"}]' | uht-substrate facts store-bulk -f -
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Namespace Management
|
|
124
|
+
|
|
125
|
+
| Command | Description |
|
|
126
|
+
|---------|-------------|
|
|
127
|
+
| `namespaces create <code> <name>` | Create a namespace |
|
|
128
|
+
| `namespaces list` | List namespaces |
|
|
129
|
+
| `namespaces assign <entity> <namespace>` | Assign an entity to a namespace |
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
uht-substrate namespaces create SE:automotive "Automotive Engineering"
|
|
133
|
+
uht-substrate namespaces assign "spark plug" SE:automotive
|
|
134
|
+
uht-substrate namespaces list --parent SE --descendants
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Reference
|
|
138
|
+
|
|
139
|
+
| Command | Description |
|
|
140
|
+
|---------|-------------|
|
|
141
|
+
| `info` | System information and overview |
|
|
142
|
+
| `traits` | All 32 trait definitions (with version) |
|
|
143
|
+
| `trait-prompts` | Classifier prompts sent to the LLM (edge cases, examples) |
|
|
144
|
+
| `patterns` | Reasoning patterns for tool orchestration |
|
|
145
|
+
|
|
146
|
+
### Configuration
|
|
147
|
+
|
|
148
|
+
| Command | Description |
|
|
149
|
+
|---------|-------------|
|
|
150
|
+
| `config set <key> <value>` | Set a config value (`api-url`, `token`, `format`) |
|
|
151
|
+
| `config show` | Show current configuration |
|
|
152
|
+
|
|
153
|
+
## Pipeline Integration
|
|
154
|
+
|
|
155
|
+
### Semantic Impact Analysis
|
|
156
|
+
|
|
157
|
+
Analyse the semantic impact of requirement changes from an [Airgen](https://airgen.io) diff. For each changed requirement, the command classifies the text using UHT and detects **semantic drift** — cases where a textual edit shifts the requirement into a different meaning-space.
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Generate a diff from airgen
|
|
161
|
+
airgen diff --json > diff.json
|
|
162
|
+
|
|
163
|
+
# Analyse impact
|
|
164
|
+
uht-substrate impact --airgen-diff diff.json --format pretty
|
|
165
|
+
uht-substrate impact --airgen-diff diff.json --json
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The input file must be the JSON output from `airgen diff --json`, structured as `{ summary, added, removed, modified }` where each requirement has `ref` and `text` fields, and modified entries have `old_text` and `new_text`.
|
|
169
|
+
|
|
170
|
+
**Pretty output:**
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
Summary: 1 added, 1 removed, 2 modified (1 with semantic drift)
|
|
174
|
+
|
|
175
|
+
Semantic Drift:
|
|
176
|
+
REQ-005 40802B01 → 40846B01
|
|
177
|
+
+ System-Integrated
|
|
178
|
+
+ Signalling
|
|
179
|
+
|
|
180
|
+
Added:
|
|
181
|
+
REQ-030 00802940 Intentionally Designed, Rule-Governed, Normative
|
|
182
|
+
|
|
183
|
+
Removed:
|
|
184
|
+
REQ-010 40C06900 Synthetic, Intentionally Designed, Outputs Effect
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**JSON output:**
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"summary": { "added": 1, "removed": 1, "modified": 2, "semantic_drift": 1 },
|
|
192
|
+
"drift": [{
|
|
193
|
+
"ref": "REQ-005",
|
|
194
|
+
"old_hex": "40802B01",
|
|
195
|
+
"new_hex": "40846B01",
|
|
196
|
+
"flipped_traits": [
|
|
197
|
+
{ "bit": 14, "name": "System-Integrated", "direction": "added" }
|
|
198
|
+
]
|
|
199
|
+
}],
|
|
200
|
+
"added": [{ "ref": "REQ-030", "hex": "00802940", "text": "...", "top_traits": ["..."] }],
|
|
201
|
+
"removed": [{ "ref": "REQ-010", "hex": "40C06900", "text": "...", "top_traits": ["..."] }]
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Global Options
|
|
206
|
+
|
|
207
|
+
| Option | Description |
|
|
208
|
+
|--------|-------------|
|
|
209
|
+
| `--api-url <url>` | API base URL |
|
|
210
|
+
| `--token <token>` | Bearer token for authentication |
|
|
211
|
+
| `--format <fmt>` | Output format: `json` (default) or `pretty` |
|
|
212
|
+
| `--verbose` | Show request/response details |
|
|
213
|
+
| `--version` | Show version |
|
|
214
|
+
|
|
215
|
+
## Output Formats
|
|
216
|
+
|
|
217
|
+
**JSON** (default) — machine-readable, pipe to `jq`:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
uht-substrate classify hammer | jq '.hex_code'
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Pretty** — colored terminal output:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
uht-substrate classify hammer --format pretty
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## What is UHT?
|
|
230
|
+
|
|
231
|
+
The Universal Hex Taxonomy encodes any concept as a 32-bit classification (8-char hex code) across four layers:
|
|
232
|
+
|
|
233
|
+
- **Physical** (bits 1–8): Material properties, boundaries, energy
|
|
234
|
+
- **Functional** (bits 9–16): Capabilities, interfaces, state
|
|
235
|
+
- **Abstract** (bits 17–24): Symbolic, temporal, rule-governed
|
|
236
|
+
- **Social** (bits 25–32): Cultural, economic, institutional
|
|
237
|
+
|
|
238
|
+
Two entities with similar hex codes share similar properties. Jaccard similarity measures meaningful overlap between classifications.
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Config } from "./config.js";
|
|
2
|
+
export declare class ApiError extends Error {
|
|
3
|
+
status: number;
|
|
4
|
+
body: string;
|
|
5
|
+
constructor(status: number, body: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class UHTClient {
|
|
8
|
+
private baseUrl;
|
|
9
|
+
private token;
|
|
10
|
+
verbose: boolean;
|
|
11
|
+
constructor(config: Config);
|
|
12
|
+
private request;
|
|
13
|
+
root(): Promise<unknown>;
|
|
14
|
+
info(): Promise<unknown>;
|
|
15
|
+
traits(): Promise<unknown>;
|
|
16
|
+
traitPrompts(opts?: {
|
|
17
|
+
entity_name?: string;
|
|
18
|
+
entity_description?: string;
|
|
19
|
+
bit?: number;
|
|
20
|
+
}): Promise<unknown>;
|
|
21
|
+
patterns(): Promise<unknown>;
|
|
22
|
+
classify(entity: string, opts?: {
|
|
23
|
+
context?: string;
|
|
24
|
+
use_semantic_priors?: boolean;
|
|
25
|
+
force_refresh?: boolean;
|
|
26
|
+
namespace?: string;
|
|
27
|
+
display_name?: string;
|
|
28
|
+
}): Promise<unknown>;
|
|
29
|
+
compare(entityA: string, entityB: string): Promise<unknown>;
|
|
30
|
+
batchCompare(entity: string, candidates: string[]): Promise<unknown>;
|
|
31
|
+
search(query: string, limit?: number): Promise<unknown>;
|
|
32
|
+
disambiguate(term: string, language?: string): Promise<unknown>;
|
|
33
|
+
semanticTriangle(text: string): Promise<unknown>;
|
|
34
|
+
mapPropertiesToTraits(properties: string[]): Promise<unknown>;
|
|
35
|
+
listEntities(opts?: {
|
|
36
|
+
name_contains?: string;
|
|
37
|
+
hex_pattern?: string;
|
|
38
|
+
namespace?: string;
|
|
39
|
+
limit?: number;
|
|
40
|
+
offset?: number;
|
|
41
|
+
count_only?: boolean;
|
|
42
|
+
}): Promise<unknown>;
|
|
43
|
+
getEntity(opts: {
|
|
44
|
+
name?: string;
|
|
45
|
+
uuid?: string;
|
|
46
|
+
}): Promise<unknown>;
|
|
47
|
+
deleteEntity(name: string, source?: string): Promise<unknown>;
|
|
48
|
+
deduplicateNamespace(namespace: string, dryRun?: boolean): Promise<unknown>;
|
|
49
|
+
reconcileFacts(namespace: string, tenant: string, project: string, opts?: {
|
|
50
|
+
airgen_url?: string;
|
|
51
|
+
airgen_email?: string;
|
|
52
|
+
airgen_password?: string;
|
|
53
|
+
}): Promise<unknown>;
|
|
54
|
+
inferProperties(entity: string): Promise<unknown>;
|
|
55
|
+
updateEntity(name: string, opts: {
|
|
56
|
+
display_name?: string;
|
|
57
|
+
}): Promise<unknown>;
|
|
58
|
+
getEntityHistory(name: string, limit?: number): Promise<unknown>;
|
|
59
|
+
mergeEntities(source: string, target: string): Promise<unknown>;
|
|
60
|
+
reclassifyEntity(name: string, opts?: {
|
|
61
|
+
context?: string;
|
|
62
|
+
namespace?: string;
|
|
63
|
+
}): Promise<unknown>;
|
|
64
|
+
findSimilar(entity: string, opts?: {
|
|
65
|
+
limit?: number;
|
|
66
|
+
min_shared_traits?: number;
|
|
67
|
+
}): Promise<unknown>;
|
|
68
|
+
searchByTraits(traits: Record<string, string>): Promise<unknown>;
|
|
69
|
+
createNamespace(code: string, name: string, description?: string): Promise<unknown>;
|
|
70
|
+
listNamespaces(opts?: {
|
|
71
|
+
parent?: string;
|
|
72
|
+
include_descendants?: boolean;
|
|
73
|
+
}): Promise<unknown>;
|
|
74
|
+
assignNamespace(entityName: string, namespace: string, primary?: boolean): Promise<unknown>;
|
|
75
|
+
storeFact(subject: string, predicate: string, objectValue: string, opts?: {
|
|
76
|
+
user_id?: string;
|
|
77
|
+
namespace?: string;
|
|
78
|
+
}): Promise<unknown>;
|
|
79
|
+
storeFactsBulk(facts: Array<{
|
|
80
|
+
subject: string;
|
|
81
|
+
predicate: string;
|
|
82
|
+
object_value: string;
|
|
83
|
+
user_id?: string;
|
|
84
|
+
namespace?: string;
|
|
85
|
+
}>): Promise<unknown>;
|
|
86
|
+
upsertFact(subject: string, predicate: string, objectValue: string, opts?: {
|
|
87
|
+
user_id?: string;
|
|
88
|
+
namespace?: string;
|
|
89
|
+
}): Promise<unknown>;
|
|
90
|
+
queryFacts(opts?: {
|
|
91
|
+
subject?: string;
|
|
92
|
+
object_value?: string;
|
|
93
|
+
predicate?: string;
|
|
94
|
+
category?: string;
|
|
95
|
+
user_id?: string;
|
|
96
|
+
namespace?: string;
|
|
97
|
+
limit?: number;
|
|
98
|
+
}): Promise<unknown>;
|
|
99
|
+
updateFact(factId: string, opts?: {
|
|
100
|
+
subject?: string;
|
|
101
|
+
predicate?: string;
|
|
102
|
+
object_value?: string;
|
|
103
|
+
}): Promise<unknown>;
|
|
104
|
+
deleteFact(factId: string): Promise<unknown>;
|
|
105
|
+
getUserContext(userId?: string): Promise<unknown>;
|
|
106
|
+
getNamespaceContext(namespace: string, userId?: string): Promise<unknown>;
|
|
107
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
export class ApiError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
body;
|
|
4
|
+
constructor(status, body) {
|
|
5
|
+
super(`API error ${status}: ${body}`);
|
|
6
|
+
this.status = status;
|
|
7
|
+
this.body = body;
|
|
8
|
+
this.name = "ApiError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class UHTClient {
|
|
12
|
+
baseUrl;
|
|
13
|
+
token;
|
|
14
|
+
verbose = false;
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.baseUrl = config.apiUrl.replace(/\/+$/, "");
|
|
17
|
+
this.token = config.token || undefined;
|
|
18
|
+
}
|
|
19
|
+
async request(method, path, body, query) {
|
|
20
|
+
// Ensure baseUrl ends with / and path doesn't start with / for correct URL joining
|
|
21
|
+
const base = this.baseUrl.endsWith("/") ? this.baseUrl : this.baseUrl + "/";
|
|
22
|
+
const relativePath = path.startsWith("/") ? path.slice(1) : path;
|
|
23
|
+
const url = new URL(relativePath, base);
|
|
24
|
+
if (query) {
|
|
25
|
+
for (const [k, v] of Object.entries(query)) {
|
|
26
|
+
if (v !== undefined && v !== "")
|
|
27
|
+
url.searchParams.set(k, v);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const headers = {};
|
|
31
|
+
if (body)
|
|
32
|
+
headers["Content-Type"] = "application/json";
|
|
33
|
+
if (this.token)
|
|
34
|
+
headers["Authorization"] = `Bearer ${this.token}`;
|
|
35
|
+
if (this.verbose) {
|
|
36
|
+
console.error(`${method} ${url.toString()}`);
|
|
37
|
+
if (body)
|
|
38
|
+
console.error(JSON.stringify(body, null, 2));
|
|
39
|
+
}
|
|
40
|
+
let response;
|
|
41
|
+
try {
|
|
42
|
+
response = await fetch(url.toString(), {
|
|
43
|
+
method,
|
|
44
|
+
headers,
|
|
45
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
throw new Error(`Network error: could not connect to ${this.baseUrl}. Check your API URL and network connection.`);
|
|
50
|
+
}
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
const text = await response.text();
|
|
53
|
+
throw new ApiError(response.status, text);
|
|
54
|
+
}
|
|
55
|
+
return (await response.json());
|
|
56
|
+
}
|
|
57
|
+
// --- Info ---
|
|
58
|
+
async root() {
|
|
59
|
+
return this.request("GET", "/");
|
|
60
|
+
}
|
|
61
|
+
async info() {
|
|
62
|
+
return this.request("GET", "/info");
|
|
63
|
+
}
|
|
64
|
+
async traits() {
|
|
65
|
+
return this.request("GET", "/traits");
|
|
66
|
+
}
|
|
67
|
+
async traitPrompts(opts) {
|
|
68
|
+
const query = {};
|
|
69
|
+
if (opts?.entity_name)
|
|
70
|
+
query["entity_name"] = opts.entity_name;
|
|
71
|
+
if (opts?.entity_description)
|
|
72
|
+
query["entity_description"] = opts.entity_description;
|
|
73
|
+
if (opts?.bit)
|
|
74
|
+
query["bit"] = String(opts.bit);
|
|
75
|
+
return this.request("GET", "/traits/prompts", undefined, query);
|
|
76
|
+
}
|
|
77
|
+
async patterns() {
|
|
78
|
+
return this.request("GET", "/patterns");
|
|
79
|
+
}
|
|
80
|
+
// --- Classification ---
|
|
81
|
+
async classify(entity, opts) {
|
|
82
|
+
return this.request("POST", "/classify", {
|
|
83
|
+
entity,
|
|
84
|
+
context: opts?.context ?? "",
|
|
85
|
+
use_semantic_priors: opts?.use_semantic_priors ?? false,
|
|
86
|
+
force_refresh: opts?.force_refresh ?? false,
|
|
87
|
+
namespace: opts?.namespace ?? "",
|
|
88
|
+
display_name: opts?.display_name ?? "",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
// --- Comparison ---
|
|
92
|
+
async compare(entityA, entityB) {
|
|
93
|
+
return this.request("POST", "/compare", { entity_a: entityA, entity_b: entityB });
|
|
94
|
+
}
|
|
95
|
+
async batchCompare(entity, candidates) {
|
|
96
|
+
return this.request("POST", "/batch-compare", { entity, candidates });
|
|
97
|
+
}
|
|
98
|
+
// --- Search ---
|
|
99
|
+
async search(query, limit) {
|
|
100
|
+
return this.request("POST", "/search", { query, limit: limit ?? 10 });
|
|
101
|
+
}
|
|
102
|
+
async disambiguate(term, language) {
|
|
103
|
+
return this.request("POST", "/disambiguate", { term, language: language ?? "en" });
|
|
104
|
+
}
|
|
105
|
+
async semanticTriangle(text) {
|
|
106
|
+
return this.request("POST", "/semantic-triangle", { text });
|
|
107
|
+
}
|
|
108
|
+
async mapPropertiesToTraits(properties) {
|
|
109
|
+
return this.request("POST", "/map-properties-to-traits", { properties });
|
|
110
|
+
}
|
|
111
|
+
// --- Entities ---
|
|
112
|
+
async listEntities(opts) {
|
|
113
|
+
const query = {};
|
|
114
|
+
if (opts?.name_contains)
|
|
115
|
+
query["name_contains"] = opts.name_contains;
|
|
116
|
+
if (opts?.hex_pattern)
|
|
117
|
+
query["hex_pattern"] = opts.hex_pattern;
|
|
118
|
+
if (opts?.namespace)
|
|
119
|
+
query["namespace"] = opts.namespace;
|
|
120
|
+
if (opts?.limit)
|
|
121
|
+
query["limit"] = String(opts.limit);
|
|
122
|
+
if (opts?.offset)
|
|
123
|
+
query["offset"] = String(opts.offset);
|
|
124
|
+
if (opts?.count_only)
|
|
125
|
+
query["count_only"] = "true";
|
|
126
|
+
return this.request("GET", "/entities", undefined, query);
|
|
127
|
+
}
|
|
128
|
+
async getEntity(opts) {
|
|
129
|
+
const query = {};
|
|
130
|
+
if (opts.name)
|
|
131
|
+
query["name"] = opts.name;
|
|
132
|
+
if (opts.uuid)
|
|
133
|
+
query["uuid"] = opts.uuid;
|
|
134
|
+
return this.request("GET", "/entities/get", undefined, query);
|
|
135
|
+
}
|
|
136
|
+
async deleteEntity(name, source) {
|
|
137
|
+
return this.request("POST", "/entities/delete", { name, source: source ?? "local" });
|
|
138
|
+
}
|
|
139
|
+
async deduplicateNamespace(namespace, dryRun = true) {
|
|
140
|
+
return this.request("POST", "/entities/deduplicate", { namespace, dry_run: dryRun });
|
|
141
|
+
}
|
|
142
|
+
async reconcileFacts(namespace, tenant, project, opts) {
|
|
143
|
+
return this.request("POST", "/facts/reconcile", {
|
|
144
|
+
namespace, tenant, project,
|
|
145
|
+
airgen_url: opts?.airgen_url ?? "",
|
|
146
|
+
airgen_email: opts?.airgen_email ?? "",
|
|
147
|
+
airgen_password: opts?.airgen_password ?? "",
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
async inferProperties(entity) {
|
|
151
|
+
return this.request("POST", "/entities/infer", { entity });
|
|
152
|
+
}
|
|
153
|
+
async updateEntity(name, opts) {
|
|
154
|
+
return this.request("POST", "/entities/update", {
|
|
155
|
+
name,
|
|
156
|
+
display_name: opts.display_name ?? "",
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
async getEntityHistory(name, limit) {
|
|
160
|
+
const query = { name };
|
|
161
|
+
if (limit)
|
|
162
|
+
query["limit"] = String(limit);
|
|
163
|
+
return this.request("GET", "/entities/history", undefined, query);
|
|
164
|
+
}
|
|
165
|
+
async mergeEntities(source, target) {
|
|
166
|
+
return this.request("POST", "/entities/merge", { source, target });
|
|
167
|
+
}
|
|
168
|
+
async reclassifyEntity(name, opts) {
|
|
169
|
+
return this.request("POST", "/entities/reclassify", {
|
|
170
|
+
name,
|
|
171
|
+
context: opts?.context ?? "",
|
|
172
|
+
namespace: opts?.namespace ?? "",
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
async findSimilar(entity, opts) {
|
|
176
|
+
return this.request("POST", "/entities/find-similar", {
|
|
177
|
+
entity,
|
|
178
|
+
limit: opts?.limit ?? 5,
|
|
179
|
+
min_shared_traits: opts?.min_shared_traits ?? 20,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async searchByTraits(traits) {
|
|
183
|
+
return this.request("GET", "/search/traits", undefined, traits);
|
|
184
|
+
}
|
|
185
|
+
// --- Namespaces ---
|
|
186
|
+
async createNamespace(code, name, description) {
|
|
187
|
+
return this.request("POST", "/namespaces/create", { code, name, description: description ?? "" });
|
|
188
|
+
}
|
|
189
|
+
async listNamespaces(opts) {
|
|
190
|
+
return this.request("POST", "/namespaces/list", {
|
|
191
|
+
parent: opts?.parent ?? "",
|
|
192
|
+
include_descendants: opts?.include_descendants ?? false,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async assignNamespace(entityName, namespace, primary) {
|
|
196
|
+
return this.request("POST", "/namespaces/assign", {
|
|
197
|
+
entity_name: entityName,
|
|
198
|
+
namespace,
|
|
199
|
+
primary: primary ?? true,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
// --- Facts ---
|
|
203
|
+
async storeFact(subject, predicate, objectValue, opts) {
|
|
204
|
+
return this.request("POST", "/facts/store", {
|
|
205
|
+
subject,
|
|
206
|
+
predicate,
|
|
207
|
+
object_value: objectValue,
|
|
208
|
+
user_id: opts?.user_id ?? "default",
|
|
209
|
+
namespace: opts?.namespace ?? "",
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
async storeFactsBulk(facts) {
|
|
213
|
+
return this.request("POST", "/facts/store-bulk", { facts });
|
|
214
|
+
}
|
|
215
|
+
async upsertFact(subject, predicate, objectValue, opts) {
|
|
216
|
+
return this.request("POST", "/facts/upsert", {
|
|
217
|
+
subject,
|
|
218
|
+
predicate,
|
|
219
|
+
object_value: objectValue,
|
|
220
|
+
user_id: opts?.user_id ?? "default",
|
|
221
|
+
namespace: opts?.namespace ?? "",
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
async queryFacts(opts) {
|
|
225
|
+
return this.request("POST", "/facts/query", {
|
|
226
|
+
subject: opts?.subject ?? "",
|
|
227
|
+
object_value: opts?.object_value ?? "",
|
|
228
|
+
predicate: opts?.predicate ?? "",
|
|
229
|
+
category: opts?.category ?? "",
|
|
230
|
+
user_id: opts?.user_id ?? "",
|
|
231
|
+
namespace: opts?.namespace ?? "",
|
|
232
|
+
limit: opts?.limit ?? 50,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
async updateFact(factId, opts) {
|
|
236
|
+
return this.request("POST", "/facts/update", {
|
|
237
|
+
fact_id: factId,
|
|
238
|
+
subject: opts?.subject ?? "",
|
|
239
|
+
predicate: opts?.predicate ?? "",
|
|
240
|
+
object_value: opts?.object_value ?? "",
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
async deleteFact(factId) {
|
|
244
|
+
return this.request("POST", "/facts/delete", { fact_id: factId });
|
|
245
|
+
}
|
|
246
|
+
async getUserContext(userId) {
|
|
247
|
+
return this.request("POST", "/facts/user-context", { user_id: userId ?? "default" });
|
|
248
|
+
}
|
|
249
|
+
async getNamespaceContext(namespace, userId) {
|
|
250
|
+
return this.request("POST", "/facts/namespace-context", { namespace, user_id: userId ?? "" });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAS,SAAQ,KAAK;IAExB;IACA;IAFT,YACS,MAAc,EACd,IAAY;QAEnB,KAAK,CAAC,aAAa,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC;QAH/B,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAGnB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,MAAM,OAAO,SAAS;IACZ,OAAO,CAAS;IAChB,KAAK,CAAqB;IAC3B,OAAO,GAAY,KAAK,CAAC;IAEhC,YAAY,MAAc;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC;IACzC,CAAC;IAEO,KAAK,CAAC,OAAO,CACnB,MAAsB,EACtB,IAAY,EACZ,IAA8B,EAC9B,KAA8B;QAE9B,mFAAmF;QACnF,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QAC5E,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACjE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACxC,IAAI,KA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assifyCommands(program, getClient, getFormat) {
|
|
3
|
+
program
|
|
4
|
+
.command("classify")
|
|
5
|
+
.description("Classify an entity and get its hex code")
|
|
6
|
+
.argument("<entity>", "Entity to classify")
|
|
7
|
+
.option("-c, --context <context>", "Additional context/description to guide classification")
|
|
8
|
+
.option("--semantic-priors", "Use semantic prior inference", false)
|
|
9
|
+
.option("-f, --force", "Reclassify in place — skip cache, update existing entity's hex code and traits", false)
|
|
10
|
+
.option("-n, --namespace <ns>", "Namespace code (e.g. 'SE', 'SE:aerospace')")
|
|
11
|
+
.option("--display-name <name>", "Short display name for presentation")
|
|
12
|
+
.action(async (entity, opts) => {
|
|
13
|
+
output(await getClient().classify(entity, {
|
|
14
|
+
context: opts.context,
|
|
15
|
+
use_semantic_priors: opts.semanticPriors,
|
|
16
|
+
force_refresh: opts.force,
|
|
17
|
+
namespace: opts.namespace,
|
|
18
|
+
display_name: opts.displayName,
|
|
19
|
+
}), getFormat());
|
|
20
|
+
});
|
|
21
|
+
program
|
|
22
|
+
.command("infer")
|
|
23
|
+
.description("Infer properties of an entity from its classification")
|
|
24
|
+
.argument("<entity>", "Entity to analyze")
|
|
25
|
+
.action(async (entity) => {
|
|
26
|
+
output(await getClient().inferProperties(entity), getFormat());
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=classify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classify.js","sourceRoot":"","sources":["../../src/commands/classify.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,UAAU,wBAAwB,CACtC,OAAgB,EAChB,SAA0B,EAC1B,SAAkC;IAElC,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,yCAAyC,CAAC;SACtD,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAC;SAC1C,MAAM,CAAC,yBAAyB,EAAE,wDAAwD,CAAC;SAC3F,MAAM,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