pi-harness-runtime 1.1.416 → 1.1.418
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/package.json +2 -2
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +2 -2
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/dist/loader.d.ts +2 -1
- package/packages/skills/dist/loader.d.ts.map +1 -1
- package/packages/skills/dist/loader.js +4 -3
- package/packages/skills/dist/loader.js.map +1 -1
- package/packages/skills/dist/skill-commands.d.ts.map +1 -1
- package/packages/skills/dist/skill-commands.js +2 -1
- package/packages/skills/dist/skill-commands.js.map +1 -1
- package/packages/skills/dist/vector-schema.d.ts +28 -0
- package/packages/skills/dist/vector-schema.d.ts.map +1 -1
- package/packages/skills/dist/vector-schema.js +28 -0
- package/packages/skills/dist/vector-schema.js.map +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/skills/src/loader.ts +4 -2
- package/packages/skills/src/skill-commands.ts +2 -1
- package/packages/skills/src/vector-schema.ts +30 -0
- package/packages/skills/test/vector-threshold.test.ts +108 -0
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/tooling-preference/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/two-phase-review/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
|
@@ -10,6 +10,7 @@ import { resolve } from "node:path";
|
|
|
10
10
|
import type { ExtensionAPI, ExtensionContext, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
11
11
|
import { getGlobalSkillRegistry } from "./loader.js";
|
|
12
12
|
import { scanForSkillsSync } from "./scanner.js";
|
|
13
|
+
import { SKILL_MIN_SCORE } from "./vector-schema.js";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Skill command configuration
|
|
@@ -244,7 +245,7 @@ async function handleSkillSearch(
|
|
|
244
245
|
|
|
245
246
|
// Try vector search if requested and available
|
|
246
247
|
if (useVector && registry.isQdrantReady) {
|
|
247
|
-
const vectorResults = await registry.findVector(query, 5,
|
|
248
|
+
const vectorResults = await registry.findVector(query, 5, SKILL_MIN_SCORE);
|
|
248
249
|
if (vectorResults.length > 0) {
|
|
249
250
|
backend = "vector";
|
|
250
251
|
results = vectorResults.map(r => ({ skill: r.skill, score: r.score }));
|
|
@@ -42,6 +42,36 @@ export const LEGACY_SKILL_COLLECTION_MODEL = "sentence-transformers/all-MiniLM-L
|
|
|
42
42
|
/** The vector size of the legacy collection. */
|
|
43
43
|
export const LEGACY_SKILL_COLLECTION_DIMENSIONS = 384;
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* The score below which a hit of the runtime collection is not a hit.
|
|
47
|
+
*
|
|
48
|
+
* The score of a vector search is a cosine between two vectors, and its
|
|
49
|
+
* scale belongs to the model that produced them. Measured against the
|
|
50
|
+
* runtime collection (123 skills, `text-embedding-3-small`):
|
|
51
|
+
*
|
|
52
|
+
* - a query that names a skill scores 0.31 to 0.56,
|
|
53
|
+
* - a query about something else scores 0.10 to 0.23, and the wrong
|
|
54
|
+
* skill that it matched tops out at 0.2305.
|
|
55
|
+
*
|
|
56
|
+
* The threshold sits between the two (0.27). The old value of 0.5 belonged
|
|
57
|
+
* to the MiniLM collection, whose vectors are not comparable, and it
|
|
58
|
+
* threw away even a clear match (0.47) - so a search of the runtime
|
|
59
|
+
* collection returned nothing at all.
|
|
60
|
+
*
|
|
61
|
+
* It lives here, next to the model and the collection, so that the two
|
|
62
|
+
* cannot drift apart.
|
|
63
|
+
*/
|
|
64
|
+
export const SKILL_MIN_SCORE = 0.27;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The score below which a hit of the legacy collection is not a hit.
|
|
68
|
+
*
|
|
69
|
+
* The legacy collection holds MiniLM vectors. Their scale was never
|
|
70
|
+
* measured against a query, so the old value is kept. It is named here
|
|
71
|
+
* so it is not mistaken for the threshold of the runtime.
|
|
72
|
+
*/
|
|
73
|
+
export const LEGACY_SKILL_MIN_SCORE = 0.5;
|
|
74
|
+
|
|
45
75
|
/** The schema a skill collection is expected to have. */
|
|
46
76
|
export interface SkillVectorSchema {
|
|
47
77
|
/** The vector size. */
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The score that decides whether a hit of the vector store is a hit.
|
|
3
|
+
*
|
|
4
|
+
* The score of a vector search is a cosine between two vectors, and its
|
|
5
|
+
* scale belongs to the model that produced them. The runtime embeds with
|
|
6
|
+
* `text-embedding-3-small`, whose cosines for a query that names a skill
|
|
7
|
+
* land between 0.31 and 0.56 - while a query about something else reaches
|
|
8
|
+
* 0.23 at most.
|
|
9
|
+
*
|
|
10
|
+
* The threshold used to be 0.5, a value of the MiniLM collection, whose
|
|
11
|
+
* vectors are not comparable. Against the runtime collection it threw away
|
|
12
|
+
* every clear match (0.47) - a search of a filled collection returned
|
|
13
|
+
* nothing at all, and the skill was invisible.
|
|
14
|
+
*
|
|
15
|
+
* The threshold therefore lives next to the model, and the tests below
|
|
16
|
+
* hold it there.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { describe, expect, it } from "bun:test";
|
|
20
|
+
import { readFileSync } from "node:fs";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
|
|
23
|
+
import {
|
|
24
|
+
createSkillRegistry,
|
|
25
|
+
type QdrantClientLike,
|
|
26
|
+
type QdrantEmbedderLike,
|
|
27
|
+
} from "../src/loader.js";
|
|
28
|
+
import { SKILL_MIN_SCORE } from "../src/vector-schema.js";
|
|
29
|
+
|
|
30
|
+
/** A client that answers a query with the given points. */
|
|
31
|
+
function fakeClient(points: Array<{ id: number; score: number }>): QdrantClientLike {
|
|
32
|
+
return {
|
|
33
|
+
async upsert(): Promise<void> {},
|
|
34
|
+
async query(): Promise<unknown> {
|
|
35
|
+
return { points };
|
|
36
|
+
},
|
|
37
|
+
async getCollection(): Promise<unknown> {
|
|
38
|
+
return { config: { params: { vectors: { size: 1536, distance: "Cosine" } } } };
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** An embedder that returns a fixed vector. */
|
|
44
|
+
const fakeEmbedder: QdrantEmbedderLike = {
|
|
45
|
+
async createEmbedding() {
|
|
46
|
+
return { embedding: [0.1, 0.2, 0.3], tokens: 3 };
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const registryWith = (scores: number[]) =>
|
|
51
|
+
createSkillRegistry({
|
|
52
|
+
qdrantClient: fakeClient(
|
|
53
|
+
scores.map((score, index) => ({
|
|
54
|
+
id: index + 1,
|
|
55
|
+
score,
|
|
56
|
+
payload: { name: `skill-${index}`, description: "d", body: "b" },
|
|
57
|
+
})),
|
|
58
|
+
),
|
|
59
|
+
embedder: fakeEmbedder,
|
|
60
|
+
collection: "pi-harness-skills-test",
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("the score that decides whether a hit is a hit", () => {
|
|
64
|
+
it("belongs to the model of the collection", () => {
|
|
65
|
+
// The measured values: a query that names a skill scores 0.31 to
|
|
66
|
+
// 0.56, a query about something else 0.10 to 0.23.
|
|
67
|
+
expect(SKILL_MIN_SCORE).toBeGreaterThan(0.23);
|
|
68
|
+
expect(SKILL_MIN_SCORE).toBeLessThan(0.31);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("keeps a clear match that the old threshold of 0.5 threw away", async () => {
|
|
72
|
+
// 0.47 is a clear match of the runtime model - and below 0.5.
|
|
73
|
+
const registry = registryWith([0.47]);
|
|
74
|
+
|
|
75
|
+
const results = await registry.findVector("approve a purchase order");
|
|
76
|
+
|
|
77
|
+
expect(results).toHaveLength(1);
|
|
78
|
+
expect(results[0].score).toBe(0.47);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("drops a hit that is noise", async () => {
|
|
82
|
+
const registry = registryWith([0.23]);
|
|
83
|
+
|
|
84
|
+
const results = await registry.findVector("cook a risotto");
|
|
85
|
+
|
|
86
|
+
expect(results).toHaveLength(0);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("keeps the hits above it and drops the hits below it", async () => {
|
|
90
|
+
const registry = registryWith([0.55, 0.12, 0.4, 0.2]);
|
|
91
|
+
|
|
92
|
+
const results = await registry.findVector("a query");
|
|
93
|
+
|
|
94
|
+
expect(results.map((r) => r.score)).toEqual([0.55, 0.4]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("is the threshold of the skill command too", () => {
|
|
98
|
+
// The command passed 0.5 itself, so the fix of the default would
|
|
99
|
+
// not have reached the search of the user.
|
|
100
|
+
const source = readFileSync(
|
|
101
|
+
fileURLToPath(new URL("../src/skill-commands.ts", import.meta.url)),
|
|
102
|
+
"utf8",
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
expect(source).toContain("SKILL_MIN_SCORE");
|
|
106
|
+
expect(source).not.toMatch(/findVector\([^)]*,\s*5,\s*0\.5/);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-harness/two-phase-review",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.418",
|
|
4
4
|
"description": "pi-harness-runtime — two-phase implementation and review workflow (queue review signals, gate the phase, scope the diff)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|