@harperfast/skills 1.6.1 → 1.7.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/dist/index.js +9 -9
- package/harper-best-practices/AGENTS.md +866 -361
- package/harper-best-practices/SKILL.md +24 -20
- package/harper-best-practices/rules/automatic-apis.md +140 -19
- package/harper-best-practices/rules/caching.md +133 -22
- package/harper-best-practices/rules/checking-authentication.md +138 -149
- package/harper-best-practices/rules/deploying-to-harper-fabric.md +96 -78
- package/harper-best-practices/rules/logging.md +153 -78
- package/harper-best-practices/rules/querying-rest-apis.md +189 -16
- package/harper-best-practices/rules/real-time-apps.md +79 -22
- package/harper-best-practices/rules/vector-indexing.md +12 -12
- package/harper-best-practices/rules.manifest.yaml +89 -11
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ metadata:
|
|
|
5
5
|
mode: generate
|
|
6
6
|
sources:
|
|
7
7
|
- reference/v5/database/schema.md#Vector Indexing
|
|
8
|
-
sourceCommit:
|
|
8
|
+
sourceCommit: b7fbddadd42eb4487190b650a9abc4bcfeef5819
|
|
9
9
|
inputHash: 3732961c671aac00
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -19,7 +19,7 @@ Apply this rule when adding a vector index to a Harper table schema or writing s
|
|
|
19
19
|
|
|
20
20
|
## How It Works
|
|
21
21
|
|
|
22
|
-
1. **Declare
|
|
22
|
+
1. **Declare the vector index on a `[Float]` field**: Add `@indexed(type: "HNSW")` to any `[Float]` attribute in a `@table` type. See [adding-tables-with-schemas.md](adding-tables-with-schemas.md) for general schema setup.
|
|
23
23
|
|
|
24
24
|
```graphql
|
|
25
25
|
type Document @table {
|
|
@@ -28,7 +28,7 @@ Apply this rule when adding a vector index to a Harper table schema or writing s
|
|
|
28
28
|
}
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
2. **Query by nearest neighbors using `sort`**: Call `Document.search()` with a `sort` object
|
|
31
|
+
2. **Query by nearest neighbors using `sort`**: Call `Document.search()` with a `sort` object containing `attribute` (the indexed field name) and `target` (the query vector). Include `limit` to cap results.
|
|
32
32
|
|
|
33
33
|
```javascript
|
|
34
34
|
let results = Document.search({
|
|
@@ -37,7 +37,7 @@ Apply this rule when adding a vector index to a Harper table schema or writing s
|
|
|
37
37
|
});
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
3. **Combine
|
|
40
|
+
3. **Combine with filter conditions**: Add a `conditions` array alongside `sort` to pre-filter records before ranking by similarity.
|
|
41
41
|
|
|
42
42
|
```javascript
|
|
43
43
|
let results = Document.search({
|
|
@@ -47,7 +47,7 @@ Apply this rule when adding a vector index to a Harper table schema or writing s
|
|
|
47
47
|
});
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
4. **Filter by distance threshold**:
|
|
50
|
+
4. **Filter by distance threshold**: To return only records within a similarity cutoff (without ranking), place `target` directly on the condition alongside `comparator` and `value`. Omit `sort`.
|
|
51
51
|
|
|
52
52
|
```javascript
|
|
53
53
|
let results = Document.search({
|
|
@@ -60,7 +60,7 @@ Apply this rule when adding a vector index to a Harper table schema or writing s
|
|
|
60
60
|
});
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
5. **Include computed distance in results**:
|
|
63
|
+
5. **Include computed distance in results**: Use the special `$distance` field in `select` to return the distance from the target vector. Works with both `sort`-based and `conditions`-based queries.
|
|
64
64
|
|
|
65
65
|
```javascript
|
|
66
66
|
let results = Document.search({
|
|
@@ -70,7 +70,7 @@ Apply this rule when adding a vector index to a Harper table schema or writing s
|
|
|
70
70
|
});
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
6. **Tune HNSW parameters**: Pass additional parameters to `@indexed(type: "HNSW", ...)` to control index quality and performance
|
|
73
|
+
6. **Tune HNSW parameters**: Pass additional parameters to `@indexed(type: "HNSW", ...)` to control index quality and performance.
|
|
74
74
|
|
|
75
75
|
| Parameter | Default | Description |
|
|
76
76
|
| ---------------------- | ----------------- | --------------------------------------------------------------------------------------------------- |
|
|
@@ -93,7 +93,7 @@ type Document @table {
|
|
|
93
93
|
}
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
**Nearest-neighbor search with distance
|
|
96
|
+
**Nearest-neighbor search with distance score:**
|
|
97
97
|
|
|
98
98
|
```javascript
|
|
99
99
|
let results = Document.search({
|
|
@@ -118,7 +118,7 @@ let results = Document.search({
|
|
|
118
118
|
|
|
119
119
|
## Notes
|
|
120
120
|
|
|
121
|
-
- The default `distance` function is `cosine`.
|
|
122
|
-
- `efConstruction` controls index build quality;
|
|
123
|
-
- `$distance` is
|
|
124
|
-
- `target`
|
|
121
|
+
- The default `distance` function is `cosine`. Pass `distance: "euclidean"` to switch.
|
|
122
|
+
- `efConstruction` controls index build quality; raising it improves recall at the cost of build time.
|
|
123
|
+
- `$distance` is available in both `sort`-based ranking and `conditions`-based threshold queries.
|
|
124
|
+
- Use the threshold (`conditions` + `target`) form when you want to bound result quality by a similarity cutoff rather than ranking by similarity.
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
# (rule bodies, AGENTS.md). See docs/plans/docs-driven-skills.md for the
|
|
6
6
|
# full schema definition and Manifest ↔ frontmatter reconciliation semantics.
|
|
7
7
|
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
8
|
+
# Phase 2 flipped vector-indexing to mode: generate.
|
|
9
|
+
# Phase 3 flips 7 obvious 1:1 rules to mode: generate (automatic-apis,
|
|
10
|
+
# querying-rest-apis, real-time-apps, checking-authentication, logging,
|
|
11
|
+
# deploying-to-harper-fabric, caching). All others remain synthesized.
|
|
12
12
|
|
|
13
13
|
rules:
|
|
14
14
|
# ===========================================================================
|
|
@@ -78,28 +78,75 @@ rules:
|
|
|
78
78
|
category: api
|
|
79
79
|
priority: 2
|
|
80
80
|
order: 1
|
|
81
|
-
mode:
|
|
81
|
+
mode: generate
|
|
82
|
+
sources:
|
|
83
|
+
- path: reference/v5/rest/overview.md
|
|
84
|
+
role: primary
|
|
85
|
+
- path: reference/v5/rest/websockets.md
|
|
86
|
+
role: supplemental
|
|
87
|
+
must_cover:
|
|
88
|
+
- 'rest: true'
|
|
89
|
+
- '@export'
|
|
90
|
+
- 'WebSocket'
|
|
91
|
+
cross_links:
|
|
92
|
+
- querying-rest-apis
|
|
93
|
+
- real-time-apps
|
|
82
94
|
|
|
83
95
|
- rule: querying-rest-apis
|
|
84
96
|
description: How to use query parameters to filter, sort, and paginate Harper REST APIs.
|
|
85
97
|
category: api
|
|
86
98
|
priority: 2
|
|
87
99
|
order: 2
|
|
88
|
-
mode:
|
|
100
|
+
mode: generate
|
|
101
|
+
sources:
|
|
102
|
+
- path: reference/v5/rest/querying.md
|
|
103
|
+
role: primary
|
|
104
|
+
must_cover:
|
|
105
|
+
- '=gt='
|
|
106
|
+
- '=lt='
|
|
107
|
+
- 'select('
|
|
108
|
+
- 'sort('
|
|
109
|
+
- 'limit('
|
|
110
|
+
cross_links:
|
|
111
|
+
- automatic-apis
|
|
89
112
|
|
|
90
113
|
- rule: real-time-apps
|
|
91
114
|
description: How to build real-time features in Harper using WebSockets and Pub/Sub.
|
|
92
115
|
category: api
|
|
93
116
|
priority: 2
|
|
94
117
|
order: 3
|
|
95
|
-
mode:
|
|
118
|
+
mode: generate
|
|
119
|
+
sources:
|
|
120
|
+
- path: reference/v5/rest/websockets.md
|
|
121
|
+
role: primary
|
|
122
|
+
must_cover:
|
|
123
|
+
- 'WebSocket'
|
|
124
|
+
- 'connect('
|
|
125
|
+
cross_links:
|
|
126
|
+
- automatic-apis
|
|
96
127
|
|
|
97
128
|
- rule: checking-authentication
|
|
98
129
|
description: How to handle user authentication and sessions in Harper Resources.
|
|
99
130
|
category: api
|
|
100
131
|
priority: 2
|
|
101
132
|
order: 4
|
|
102
|
-
mode:
|
|
133
|
+
mode: generate
|
|
134
|
+
sources:
|
|
135
|
+
- path: reference/v5/resources/resource-api.md
|
|
136
|
+
section: '`getCurrentUser(): User | undefined`'
|
|
137
|
+
role: primary
|
|
138
|
+
- path: reference/v5/resources/resource-api.md
|
|
139
|
+
section: 'Session and Login from a Resource'
|
|
140
|
+
role: primary
|
|
141
|
+
- path: reference/v5/security/jwt-authentication.md
|
|
142
|
+
role: supplemental
|
|
143
|
+
must_cover:
|
|
144
|
+
- 'getCurrentUser()'
|
|
145
|
+
- 'getContext()'
|
|
146
|
+
- 'context.login'
|
|
147
|
+
- 'enableSessions'
|
|
148
|
+
cross_links:
|
|
149
|
+
- custom-resources
|
|
103
150
|
|
|
104
151
|
# ===========================================================================
|
|
105
152
|
# Logic & Extension (priority 3 — MEDIUM)
|
|
@@ -138,7 +185,17 @@ rules:
|
|
|
138
185
|
category: logic
|
|
139
186
|
priority: 3
|
|
140
187
|
order: 5
|
|
141
|
-
mode:
|
|
188
|
+
mode: generate
|
|
189
|
+
sources:
|
|
190
|
+
- path: learn/developers/caching-with-harper.md
|
|
191
|
+
role: primary
|
|
192
|
+
must_cover:
|
|
193
|
+
- 'expiration'
|
|
194
|
+
- 'sourcedFrom'
|
|
195
|
+
- '@table'
|
|
196
|
+
cross_links:
|
|
197
|
+
- custom-resources
|
|
198
|
+
- automatic-apis
|
|
142
199
|
|
|
143
200
|
# ===========================================================================
|
|
144
201
|
# Infrastructure & Ops (priority 4 — MEDIUM)
|
|
@@ -149,7 +206,19 @@ rules:
|
|
|
149
206
|
category: ops
|
|
150
207
|
priority: 4
|
|
151
208
|
order: 1
|
|
152
|
-
mode:
|
|
209
|
+
mode: generate
|
|
210
|
+
sources:
|
|
211
|
+
- path: reference/v5/components/applications.md
|
|
212
|
+
section: 'Remote Management'
|
|
213
|
+
role: primary
|
|
214
|
+
- path: fabric/cluster-creation-management.md
|
|
215
|
+
section: 'Connecting the Harper CLI to a Cluster'
|
|
216
|
+
role: supplemental
|
|
217
|
+
must_cover:
|
|
218
|
+
- 'harper deploy'
|
|
219
|
+
- 'harper login'
|
|
220
|
+
cross_links:
|
|
221
|
+
- creating-a-fabric-account-and-cluster
|
|
153
222
|
|
|
154
223
|
- rule: creating-a-fabric-account-and-cluster
|
|
155
224
|
description: How to create a Harper Fabric account, organization, and cluster.
|
|
@@ -177,4 +246,13 @@ rules:
|
|
|
177
246
|
category: ops
|
|
178
247
|
priority: 4
|
|
179
248
|
order: 5
|
|
180
|
-
mode:
|
|
249
|
+
mode: generate
|
|
250
|
+
sources:
|
|
251
|
+
- path: reference/v5/logging/overview.md
|
|
252
|
+
role: primary
|
|
253
|
+
- path: reference/v5/logging/api.md
|
|
254
|
+
role: primary
|
|
255
|
+
must_cover:
|
|
256
|
+
- 'console.log'
|
|
257
|
+
- 'logger'
|
|
258
|
+
- 'withTag('
|