@harperfast/skills 1.6.0 → 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.
@@ -5,8 +5,8 @@ metadata:
5
5
  mode: generate
6
6
  sources:
7
7
  - reference/v5/database/schema.md#Vector Indexing
8
- sourceCommit: e8fc9e51c7c04637b8ec02d073eed42d495034f1
9
- inputHash: 9c47b18c8795e403
8
+ sourceCommit: b7fbddadd42eb4487190b650a9abc4bcfeef5819
9
+ inputHash: 3732961c671aac00
10
10
  ---
11
11
 
12
12
  # Vector Indexing
@@ -15,11 +15,11 @@ Instructions for the agent to follow when enabling and querying vector indexes f
15
15
 
16
16
  ## When to Use
17
17
 
18
- Apply this rule when adding a vector index to a Harper table schema to support approximate nearest-neighbor (similarity) search on high-dimensional float arrays. Use it whenever a query requires ranking results by vector similarity, optionally combined with filter conditions.
18
+ Apply this rule when adding a vector index to a Harper table schema or writing similarity search queries against high-dimensional vector fields. Use it whenever you need approximate nearest-neighbor search, distance-threshold filtering, or distance-scored results.
19
19
 
20
20
  ## How It Works
21
21
 
22
- 1. **Define the table schema with a vector index**: Add `@indexed(type: "HNSW")` to a `[Float]` attribute on a `@table` type. See [adding-tables-with-schemas](adding-tables-with-schemas.md) for general schema setup.
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 to support a
28
28
  }
29
29
  ```
30
30
 
31
- 2. **Query by nearest neighbors**: Call `.search()` with a `sort` parameter specifying the indexed `attribute` and a `target` vector. The `target` is the query vector to compare against.
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 to support a
37
37
  });
38
38
  ```
39
39
 
40
- 3. **Combine with filter conditions**: Add a `conditions` array alongside `sort` to filter results before ranking by similarity.
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,30 @@ Apply this rule when adding a vector index to a Harper table schema to support a
47
47
  });
48
48
  ```
49
49
 
50
- 4. **Tune HNSW parameters**: Pass additional parameters directly in the `@indexed` directive to control index quality and performance.
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
+
52
+ ```javascript
53
+ let results = Document.search({
54
+ conditions: {
55
+ attribute: 'textEmbeddings',
56
+ comparator: 'lt',
57
+ value: 0.1,
58
+ target: searchVector,
59
+ },
60
+ });
61
+ ```
62
+
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
+
65
+ ```javascript
66
+ let results = Document.search({
67
+ select: ['name', '$distance'],
68
+ sort: { attribute: 'textEmbeddings', target: searchVector },
69
+ limit: 5,
70
+ });
71
+ ```
72
+
73
+ 6. **Tune HNSW parameters**: Pass additional parameters to `@indexed(type: "HNSW", ...)` to control index quality and performance.
51
74
 
52
75
  | Parameter | Default | Description |
53
76
  | ---------------------- | ----------------- | --------------------------------------------------------------------------------------------------- |
@@ -60,16 +83,7 @@ Apply this rule when adding a vector index to a Harper table schema to support a
60
83
 
61
84
  ## Examples
62
85
 
63
- Schema with default settings:
64
-
65
- ```graphql
66
- type Document @table {
67
- id: Long @primaryKey
68
- textEmbeddings: [Float] @indexed(type: "HNSW")
69
- }
70
- ```
71
-
72
- Schema with custom parameters (euclidean distance, routing disabled, higher search recall):
86
+ **Schema with custom HNSW parameters:**
73
87
 
74
88
  ```graphql
75
89
  type Document @table {
@@ -79,19 +93,32 @@ type Document @table {
79
93
  }
80
94
  ```
81
95
 
82
- Filtered nearest-neighbor search:
96
+ **Nearest-neighbor search with distance score:**
83
97
 
84
98
  ```javascript
85
99
  let results = Document.search({
86
- conditions: [{ attribute: 'price', comparator: 'lt', value: 50 }],
100
+ select: ['name', '$distance'],
87
101
  sort: { attribute: 'textEmbeddings', target: searchVector },
88
102
  limit: 5,
89
103
  });
90
104
  ```
91
105
 
106
+ **Distance-threshold filter (no ranking):**
107
+
108
+ ```javascript
109
+ let results = Document.search({
110
+ conditions: {
111
+ attribute: 'textEmbeddings',
112
+ comparator: 'lt',
113
+ value: 0.1,
114
+ target: searchVector,
115
+ },
116
+ });
117
+ ```
118
+
92
119
  ## Notes
93
120
 
94
- - The default `distance` function is `cosine`. Use `"euclidean"` when your vectors are not normalized or when Euclidean geometry better fits your use case.
95
- - Increasing `efConstruction` improves index recall at the cost of build performance.
96
- - `mL` is computed automatically from `M` unless explicitly overridden.
97
- - Always pair `sort` with a `limit` to bound the number of nearest-neighbor results returned.
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
- # All 20 rules currently use mode: synthesized (hand-authored bodies),
9
- # matching the state of the repo at the time this manifest was introduced.
10
- # Subsequent phases progressively flip individual rules to mode: generate
11
- # or mode: direct as docs sources are wired up.
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: synthesized
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: synthesized
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: synthesized
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: synthesized
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: synthesized
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: synthesized
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: synthesized
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('
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harperfast/skills",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Best practices for making awesome Harper apps with your favorite Agent",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/harperfast",