@clockgrove/assetgrove-search 0.0.0-stage → 0.3.2

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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/embedder.d.ts +20 -0
  4. package/dist/embedder.js +21 -0
  5. package/dist/errors.d.ts +12 -0
  6. package/dist/errors.js +12 -0
  7. package/dist/extension.d.ts +38 -0
  8. package/dist/extension.js +589 -0
  9. package/dist/find.d.ts +115 -0
  10. package/dist/find.js +203 -0
  11. package/dist/flatten.d.ts +15 -0
  12. package/dist/flatten.js +19 -0
  13. package/dist/index.d.ts +19 -0
  14. package/dist/index.js +18 -0
  15. package/dist/indexer.d.ts +48 -0
  16. package/dist/indexer.js +187 -0
  17. package/dist/lance-store.d.ts +98 -0
  18. package/dist/lance-store.js +456 -0
  19. package/dist/library.d.ts +63 -0
  20. package/dist/library.js +32 -0
  21. package/dist/lock.d.ts +11 -0
  22. package/dist/lock.js +176 -0
  23. package/dist/memory-store.d.ts +26 -0
  24. package/dist/memory-store.js +111 -0
  25. package/dist/model-manifest.d.ts +20 -0
  26. package/dist/model-manifest.js +14 -0
  27. package/dist/model-manifest.json +38 -0
  28. package/dist/outliers.d.ts +14 -0
  29. package/dist/outliers.js +41 -0
  30. package/dist/platform.d.ts +4 -0
  31. package/dist/platform.js +6 -0
  32. package/dist/route-embedder.d.ts +20 -0
  33. package/dist/route-embedder.js +47 -0
  34. package/dist/scripted.d.ts +15 -0
  35. package/dist/scripted.js +35 -0
  36. package/dist/setup.d.ts +26 -0
  37. package/dist/setup.js +60 -0
  38. package/dist/siglip2.d.ts +6 -0
  39. package/dist/siglip2.js +84 -0
  40. package/dist/store.d.ts +129 -0
  41. package/dist/store.js +2 -0
  42. package/dist/tokens.d.ts +6 -0
  43. package/dist/tokens.js +22 -0
  44. package/dist/where.d.ts +20 -0
  45. package/dist/where.js +164 -0
  46. package/package.json +55 -3
  47. package/skills/assetgrove-search/SKILL.md +41 -0
  48. package/skills/assetgrove-search/references/commands.md +65 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Clockgrove
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ # @clockgrove/assetgrove-search
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Optional search package for Assetgrove (design section 7). Core never imports it.
4
+
5
+ ## Extension API
6
+
7
+ The package declares `"assetgrove": { "api": 3 }` and a peer range on `@clockgrove/assetgrove` that the installed core must satisfy, or core refuses it. It imports only from core's public exports: the search types from `@clockgrove/assetgrove/extension` (type-only, so the built package needs nothing from core at runtime) and, in its tests, the pack test kit `@clockgrove/assetgrove/testing` (a temporary project, core's CLI and MCP server, and the conformance suite in `test/conformance.test.ts`). It keeps no copy of core's contract. The tests run with `node --conditions=assetgrove-source`, which resolves the linked core to its TypeScript source; the same condition is in `tsconfig.json` for `tsc`.
8
+
9
+ ## Near matches before paid generation
10
+
11
+ With the package loaded and `search.nearMatch` on, the plan step of `plan`, `stage`, `apply` and `generate-sheet` lists up to three picked assets in `WorkPlan.nearMatches`, with a sheet, ranked closest to the request: its kind, subject and brief as words, fused with image similarity to its references (the spec's key pose, its subject's identity turnaround and, for `stage` and `generate-sheet`, the style bible's subject references tagged with the spec's subject and look; never the bible's style anchors). Only the kind filters. No similarity number cuts the list, because any number would be calibrated on one library's art; the person looking at the spend confirmation is the one who can judge whether one serves. The spend form names them; the request digest leaves them out.
12
+
13
+ With a paid (hosted) embedder nothing is embedded before the person confirms: neither the request nor library files not yet indexed. The list searches the index as it stands (reported not fresh), by stored vectors and full text only, and a reference counts only when an indexed file has the same bytes.
@@ -0,0 +1,20 @@
1
+ /** An embedder turns images and text into vectors of one space. */
2
+ export interface Embedder {
3
+ /** Stable name, e.g. `siglip2-base`. */
4
+ readonly id: string;
5
+ /** The pinned revision of the weights (a commit), or a version for scripted embedders. */
6
+ readonly revision: string;
7
+ readonly dimension: number;
8
+ /** A hosted embedder's provider route and model; absent for local embedders. */
9
+ readonly route?: string;
10
+ readonly model?: string;
11
+ /** True when each embedding call costs money (a hosted embedder); near matches then embed nothing about the request. */
12
+ readonly paid?: boolean;
13
+ /** Each image is encoded file bytes (any format the decoder reads). Returns unit vectors. */
14
+ embedImages(images: Uint8Array[]): Promise<Float32Array[]>;
15
+ /** Returns unit vectors. */
16
+ embedTexts(texts: string[]): Promise<Float32Array[]>;
17
+ }
18
+ /** Normalise to unit length in place-safe fashion (zero vectors stay zero). */
19
+ export declare function normalize(v: Float32Array): Float32Array;
20
+ export declare function cosine(a: ArrayLike<number>, b: ArrayLike<number>): number;
@@ -0,0 +1,21 @@
1
+ /** Normalise to unit length in place-safe fashion (zero vectors stay zero). */
2
+ export function normalize(v) {
3
+ let s = 0;
4
+ for (const x of v)
5
+ s += x * x;
6
+ const n = Math.sqrt(s);
7
+ return n === 0 ? v : v.map((x) => x / n);
8
+ }
9
+ export function cosine(a, b) {
10
+ let d = 0;
11
+ let na = 0;
12
+ let nb = 0;
13
+ for (let i = 0; i < a.length; i++) {
14
+ const x = a[i];
15
+ const y = b[i];
16
+ d += x * y;
17
+ na += x * x;
18
+ nb += y * y;
19
+ }
20
+ return na === 0 || nb === 0 ? 0 : d / Math.sqrt(na * nb);
21
+ }
@@ -0,0 +1,12 @@
1
+ /** A structured failure of the search package. `code` is stable; `hint` names the fix. */
2
+ export type SearchErrorCode = "model_missing" | "model_unpinned" | "setup_failed" | "hash_mismatch" | "invalid_input" | "settings_invalid" | "extension_unavailable" | "store_locked" | "embedder_changed";
3
+ export declare class SearchError extends Error {
4
+ readonly code: SearchErrorCode;
5
+ readonly hint: string | undefined;
6
+ readonly details: Record<string, unknown>;
7
+ constructor(code: SearchErrorCode, message: string, options?: {
8
+ hint?: string;
9
+ details?: Record<string, unknown>;
10
+ cause?: unknown;
11
+ });
12
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,12 @@
1
+ export class SearchError extends Error {
2
+ code;
3
+ hint;
4
+ details;
5
+ constructor(code, message, options = {}) {
6
+ super(message, options.cause === undefined ? undefined : { cause: options.cause });
7
+ this.name = "SearchError";
8
+ this.code = code;
9
+ this.hint = options.hint;
10
+ this.details = options.details ?? {};
11
+ }
12
+ }
@@ -0,0 +1,38 @@
1
+ import type { Extension, ExtensionContext, SearchContext, SearchFindResult, NearMatchQuery, SearchQuery, SearchSlot, SearchStoreSettings } from "@clockgrove/assetgrove/extension";
2
+ import type { Embedder } from "./embedder.ts";
3
+ import { SearchIndex } from "./find.ts";
4
+ import type { Store } from "./store.ts";
5
+ /**
6
+ * The storage options Lance is given: the settings' endpoint and region, and the credentials the
7
+ * settings name, under the keys the URI's scheme reads. A remote store is never opened without
8
+ * them, so the object store never authenticates with credentials it finds on the machine.
9
+ */
10
+ export declare function storageOptions(store: SearchStoreSettings, env: SearchContext["env"]): Record<string, string>;
11
+ /** The shipped find over an open local index and, when shared, the remote store: what `searchSlot.find` runs once settings name the embedder and stores. */
12
+ export declare function findWith(q: SearchQuery, o: {
13
+ embedder: Embedder;
14
+ local: SearchIndex;
15
+ /** The shared store and its tree key, when settings name one. */
16
+ remote?: {
17
+ store: Store;
18
+ tree: string;
19
+ };
20
+ /** A hosted embedder without its paid-run port: nothing is refreshed or embedded. */
21
+ spends?: boolean;
22
+ /** The work tree's commit, which a fresh shared store was built from. */
23
+ head?: () => Promise<string>;
24
+ /** Whether anything the shared store covers changed since a commit; see `SearchLibrary`. */
25
+ changedSince?: (commit: string) => Promise<boolean>;
26
+ }): Promise<SearchFindResult>;
27
+ /**
28
+ * The picked assets closest to the request, by rank: its kind, subject and brief as words, fused
29
+ * with image similarity to its references. Only the kind filters; no similarity cut applies. When
30
+ * the embedder is paid nothing is embedded, neither the request nor unindexed library files: the
31
+ * index is searched as it stands, by full text and stored vectors only, and reported not fresh.
32
+ */
33
+ export declare function nearMatchesWith(q: NearMatchQuery, ctx: SearchContext, options: {
34
+ paid: boolean;
35
+ }): Promise<SearchFindResult>;
36
+ export declare const searchSlot: SearchSlot;
37
+ /** Core's entry: refuses on darwin-x64 before LanceDB or Transformers.js is imported. */
38
+ export default function searchExtension(context: ExtensionContext): Extension;