@lmzhen/dsh-evolution-skill-discovery 0.0.0 → 0.30.41
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 +16 -2
- package/lib/index.js +2456 -0
- package/lib/types/adapter.d.ts +48 -0
- package/lib/types/assignment-queue.d.ts +24 -0
- package/lib/types/assignment-sidecar.d.ts +30 -0
- package/lib/types/assignment.d.ts +131 -0
- package/lib/types/awareness.d.ts +9 -0
- package/lib/types/domain-bootstrap.d.ts +14 -0
- package/lib/types/domain-description.d.ts +19 -0
- package/lib/types/domain-generation-prompt.d.ts +14 -0
- package/lib/types/domain-generation-service.d.ts +23 -0
- package/lib/types/domain-generation.d.ts +48 -0
- package/lib/types/domain-map-store.d.ts +39 -0
- package/lib/types/domain-map.d.ts +52 -0
- package/lib/types/domain-metrics.d.ts +41 -0
- package/lib/types/domain-policy.d.ts +34 -0
- package/lib/types/domain-projection.d.ts +43 -0
- package/lib/types/domain-quality.d.ts +17 -0
- package/lib/types/domain-view.d.ts +15 -0
- package/lib/types/features.d.ts +11 -0
- package/lib/types/identity.d.ts +67 -0
- package/lib/types/index.d.ts +74 -0
- package/lib/types/maintenance.d.ts +62 -0
- package/lib/types/plugin.d.ts +37 -0
- package/lib/types/projection.d.ts +58 -0
- package/lib/types/runtime.d.ts +42 -0
- package/lib/types/search-judge.d.ts +26 -0
- package/lib/types/search.d.ts +84 -0
- package/lib/types/security.d.ts +14 -0
- package/lib/types/session-projection.d.ts +19 -0
- package/lib/types/session-store.d.ts +22 -0
- package/lib/types/shadow-evidence.d.ts +22 -0
- package/lib/types/stages.d.ts +6 -0
- package/lib/types/tool.d.ts +27 -0
- package/lib/types/ui.d.ts +69 -0
- package/lib/types/worker.d.ts +14 -0
- package/package.json +55 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { SkillSummary } from '@deepseek-ai/dsh-skill';
|
|
2
|
+
/** Stable identity for one winning skill: provider + source + name, JSON-encoded. */
|
|
3
|
+
export type SkillKey = string;
|
|
4
|
+
/** One view of the skill catalog: canonical cwd plus a stable scope key. */
|
|
5
|
+
export interface ViewIdentityInput {
|
|
6
|
+
readonly cwd: string;
|
|
7
|
+
readonly scopeKey?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
/** One normalized skill row in the read model. */
|
|
10
|
+
export interface SkillIndexRow {
|
|
11
|
+
readonly skillKey: SkillKey;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
readonly whenToUse?: string | undefined;
|
|
15
|
+
readonly provider: string;
|
|
16
|
+
readonly source: string;
|
|
17
|
+
readonly managed: boolean;
|
|
18
|
+
readonly modelInvocable: boolean;
|
|
19
|
+
readonly protected: boolean;
|
|
20
|
+
readonly pinned: boolean;
|
|
21
|
+
readonly threeFieldHash: string;
|
|
22
|
+
}
|
|
23
|
+
/** Policy identity inputs; revisions are supplied by the owning policy store. */
|
|
24
|
+
export interface PolicyDigestInput {
|
|
25
|
+
readonly globalPolicyRevision: string;
|
|
26
|
+
readonly workspaceOverlayRevision?: string | undefined;
|
|
27
|
+
readonly scopeOverlayRevision?: string | undefined;
|
|
28
|
+
readonly effectivePolicy: unknown;
|
|
29
|
+
}
|
|
30
|
+
/** Projection identity inputs. */
|
|
31
|
+
export interface ProjectionDigestInput {
|
|
32
|
+
readonly viewKey: string;
|
|
33
|
+
readonly mapVersion: string;
|
|
34
|
+
readonly policyDigest: string;
|
|
35
|
+
readonly viewCatalogDigest: string;
|
|
36
|
+
readonly adapterVersion: string;
|
|
37
|
+
readonly projectionSchemaVersion: string;
|
|
38
|
+
readonly discoveryMode: string;
|
|
39
|
+
}
|
|
40
|
+
/** Search index identity inputs. */
|
|
41
|
+
export interface SearchIndexKeyInput {
|
|
42
|
+
readonly viewKey: string;
|
|
43
|
+
readonly viewCatalogDigest: string;
|
|
44
|
+
readonly policyDigest: string;
|
|
45
|
+
readonly tokenizerVersion: string;
|
|
46
|
+
readonly indexSchemaVersion: string;
|
|
47
|
+
readonly discoveryMode: string;
|
|
48
|
+
}
|
|
49
|
+
/** @returns stable key for the winning provider/source/name tuple. */
|
|
50
|
+
export declare function skillKeyOf(summary: Pick<SkillSummary, 'provider' | 'source' | 'name'>): SkillKey;
|
|
51
|
+
/** @returns stable hash of the canonical cwd and optional scope key. */
|
|
52
|
+
export declare function viewKeyOf(input: ViewIdentityInput): string;
|
|
53
|
+
/** @returns hash of the three fields used by discovery/retrieval. */
|
|
54
|
+
export declare function threeFieldHashOf(input: Pick<SkillSummary, 'name' | 'description' | 'whenToUse'>): string;
|
|
55
|
+
/** @returns normalized row for one skill summary. */
|
|
56
|
+
export declare function skillIndexRowOf(summary: SkillSummary, managed: boolean, protectedSkill?: boolean, pinned?: boolean): SkillIndexRow;
|
|
57
|
+
/** @returns digest of the sorted rows plus completeness. */
|
|
58
|
+
export declare function catalogRevisionOf(rows: readonly SkillIndexRow[], complete: boolean): string;
|
|
59
|
+
/** @returns digest of a concrete per-view snapshot. */
|
|
60
|
+
export declare function viewCatalogDigestOf(viewKey: string, rows: readonly SkillIndexRow[], complete: boolean): string;
|
|
61
|
+
/** @returns digest of effective policy plus its revisions. */
|
|
62
|
+
export declare function policyDigestOf(input: PolicyDigestInput): string;
|
|
63
|
+
/** @returns view-cache identity for one projection. */
|
|
64
|
+
export declare function projectionDigestOf(input: ProjectionDigestInput): string;
|
|
65
|
+
/** @returns view-cache identity for one search index. */
|
|
66
|
+
export declare function searchIndexKeyOf(input: SearchIndexKeyInput): string;
|
|
67
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { SkillSummary } from '@deepseek-ai/dsh-skill';
|
|
2
|
+
import { type SkillIndexRow, type SkillKey } from './identity.ts';
|
|
3
|
+
/** Query for one catalog view. */
|
|
4
|
+
export interface SkillIndexQuery {
|
|
5
|
+
readonly cwd: string;
|
|
6
|
+
readonly scopeKey?: string | undefined;
|
|
7
|
+
readonly scope?: object | undefined;
|
|
8
|
+
readonly signal?: AbortSignal | undefined;
|
|
9
|
+
}
|
|
10
|
+
/** Raw observation supplied by the platform `ctx.skills` adapter. */
|
|
11
|
+
export interface SkillIndexSourceSnapshot {
|
|
12
|
+
readonly skills: readonly SkillSummary[];
|
|
13
|
+
readonly complete: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Read-only source the plugin adapter implements with `ctx.skills` + SkillLibrary. */
|
|
16
|
+
export interface SkillIndexSource {
|
|
17
|
+
snapshot(query: SkillIndexQuery): Promise<SkillIndexSourceSnapshot>;
|
|
18
|
+
managedSkillKeys(): Promise<ReadonlySet<SkillKey>>;
|
|
19
|
+
protectedSkillKeys?(): Promise<ReadonlySet<SkillKey>>;
|
|
20
|
+
pinnedSkillKeys?(): Promise<ReadonlySet<SkillKey>>;
|
|
21
|
+
}
|
|
22
|
+
/** One normalized per-view read model. */
|
|
23
|
+
export interface SkillIndexSnapshot {
|
|
24
|
+
readonly viewKey: string;
|
|
25
|
+
readonly catalogRevision: string;
|
|
26
|
+
readonly viewCatalogDigest: string;
|
|
27
|
+
readonly rows: readonly SkillIndexRow[];
|
|
28
|
+
readonly complete: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** Read-only view model; it does not cache or own a provider. */
|
|
31
|
+
export declare class SkillIndex {
|
|
32
|
+
private readonly source;
|
|
33
|
+
constructor(source: SkillIndexSource);
|
|
34
|
+
/**
|
|
35
|
+
* Read one view from the source.
|
|
36
|
+
* @param query - cwd/scope and cancellation for this observation.
|
|
37
|
+
* @returns normalized rows and completeness; incomplete data is not hidden.
|
|
38
|
+
*/
|
|
39
|
+
read(query: SkillIndexQuery): Promise<SkillIndexSnapshot>;
|
|
40
|
+
}
|
|
41
|
+
export * from './identity.ts';
|
|
42
|
+
export * from './domain-map.ts';
|
|
43
|
+
export * from './projection.ts';
|
|
44
|
+
export * from './adapter.ts';
|
|
45
|
+
export * from './features.ts';
|
|
46
|
+
export * from './stages.ts';
|
|
47
|
+
export * from './search.ts';
|
|
48
|
+
export * from './domain-map-store.ts';
|
|
49
|
+
export * from './domain-view.ts';
|
|
50
|
+
export * from './domain-policy.ts';
|
|
51
|
+
export * from './domain-generation.ts';
|
|
52
|
+
export * from './domain-description.ts';
|
|
53
|
+
export * from './domain-quality.ts';
|
|
54
|
+
export * from './domain-metrics.ts';
|
|
55
|
+
export * from './domain-projection.ts';
|
|
56
|
+
export * from './session-projection.ts';
|
|
57
|
+
export * from './tool.ts';
|
|
58
|
+
export * from './assignment.ts';
|
|
59
|
+
export * from './maintenance.ts';
|
|
60
|
+
export * from './ui.ts';
|
|
61
|
+
export * from './security.ts';
|
|
62
|
+
export * from './session-store.ts';
|
|
63
|
+
export * from './runtime.ts';
|
|
64
|
+
export * from './assignment-sidecar.ts';
|
|
65
|
+
export * from './search-judge.ts';
|
|
66
|
+
export * from './awareness.ts';
|
|
67
|
+
export * from './plugin.ts';
|
|
68
|
+
export * from './worker.ts';
|
|
69
|
+
export * from './domain-bootstrap.ts';
|
|
70
|
+
export * from './domain-generation-service.ts';
|
|
71
|
+
export * from './assignment-queue.ts';
|
|
72
|
+
export * from './domain-generation-prompt.ts';
|
|
73
|
+
export * from './shadow-evidence.ts';
|
|
74
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { DomainMapSnapshot } from './domain-map.ts';
|
|
2
|
+
import type { SkillKey } from './identity.ts';
|
|
3
|
+
/** Maintenance defaults from PLAN/MAP-009. */
|
|
4
|
+
export declare const MAINTENANCE_DEFAULTS: Readonly<{
|
|
5
|
+
splitSkillThreshold: 25;
|
|
6
|
+
coarsenDomainCount: 12;
|
|
7
|
+
maxVisibleDepth: 3;
|
|
8
|
+
minChildren: 2;
|
|
9
|
+
minMembersPerChild: 3;
|
|
10
|
+
coarsenMinDomains: 3;
|
|
11
|
+
coarsenMaxDomains: 8;
|
|
12
|
+
}>;
|
|
13
|
+
/** Read-only per-domain audit; no coverage claim is fabricated. */
|
|
14
|
+
export interface DomainAudit {
|
|
15
|
+
readonly domainId: string;
|
|
16
|
+
readonly definitionComplete: boolean;
|
|
17
|
+
readonly childCount: number;
|
|
18
|
+
readonly directSkillCount: number;
|
|
19
|
+
readonly indirectSkillCount: number;
|
|
20
|
+
readonly empty: boolean;
|
|
21
|
+
readonly orphan: boolean;
|
|
22
|
+
readonly lastUpdated: number;
|
|
23
|
+
}
|
|
24
|
+
/** Map-level audit. */
|
|
25
|
+
export interface DomainMapAudit {
|
|
26
|
+
readonly domains: readonly DomainAudit[];
|
|
27
|
+
readonly domainCount: number;
|
|
28
|
+
readonly unclassifiedCount: number;
|
|
29
|
+
}
|
|
30
|
+
/** One split candidate; no domains/edges are created. */
|
|
31
|
+
export interface SplitCandidate {
|
|
32
|
+
readonly domainId: string;
|
|
33
|
+
readonly directSkillCount: number;
|
|
34
|
+
readonly children: number;
|
|
35
|
+
readonly blockers: readonly string[];
|
|
36
|
+
}
|
|
37
|
+
/** One coarsen group; no edges are changed. */
|
|
38
|
+
export interface CoarsenGroup {
|
|
39
|
+
readonly domainIds: readonly string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Audit domain definitions/structure without mutating the map.
|
|
43
|
+
* @param snapshot - domain facts.
|
|
44
|
+
* @param visibleSkillKeys - optional view skills for unclassified count.
|
|
45
|
+
* @returns per-domain audit plus map-level counts.
|
|
46
|
+
*/
|
|
47
|
+
export declare function auditDomainMap(snapshot: DomainMapSnapshot, visibleSkillKeys?: ReadonlySet<SkillKey>): DomainMapAudit;
|
|
48
|
+
/**
|
|
49
|
+
* Find split candidates; no child domains are created and no skills are reassigned.
|
|
50
|
+
* @param snapshot - domain facts.
|
|
51
|
+
* @param threshold - minimum direct members to consider.
|
|
52
|
+
* @returns candidates with blockers.
|
|
53
|
+
*/
|
|
54
|
+
export declare function splitCandidates(snapshot: DomainMapSnapshot, threshold?: 25): readonly SplitCandidate[];
|
|
55
|
+
/**
|
|
56
|
+
* Find coarsen groups; only structure candidates, never edge rewrites.
|
|
57
|
+
* @param snapshot - domain facts.
|
|
58
|
+
* @param maxDomains - above this count coarsening is considered.
|
|
59
|
+
* @returns groups of 3–8 domains, at least 2 groups.
|
|
60
|
+
*/
|
|
61
|
+
export declare function coarsenCandidates(snapshot: DomainMapSnapshot, maxDomains?: 12): readonly CoarsenGroup[];
|
|
62
|
+
//# sourceMappingURL=maintenance.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { DomainGenerationProposal, GenerationSkillFact } from './domain-generation.ts';
|
|
3
|
+
import { type DomainGenerationPort } from './domain-generation-service.ts';
|
|
4
|
+
/** Plugin config; paths are supplied by the composition, never guessed. */
|
|
5
|
+
export interface Config {
|
|
6
|
+
readonly domainMapPath?: string | undefined;
|
|
7
|
+
readonly sessionPath?: string | undefined;
|
|
8
|
+
readonly featureEpoch: string;
|
|
9
|
+
readonly mode?: 'off' | 'shadow' | 'on' | 'auto';
|
|
10
|
+
readonly pinDomains?: readonly string[];
|
|
11
|
+
readonly disableDomains?: readonly string[];
|
|
12
|
+
readonly tokenBudget?: number;
|
|
13
|
+
readonly staleAfterHours?: number;
|
|
14
|
+
readonly mapStale?: boolean;
|
|
15
|
+
readonly searchAvailable?: boolean;
|
|
16
|
+
readonly shadowEvidencePath?: string | undefined;
|
|
17
|
+
readonly domainMinDomains?: number;
|
|
18
|
+
readonly domainMaxDomains?: number;
|
|
19
|
+
readonly provisionalThreshold?: number;
|
|
20
|
+
readonly shadowEvidence?: {
|
|
21
|
+
readonly samples: number;
|
|
22
|
+
readonly hiddenRecoverableRate: number;
|
|
23
|
+
readonly silentMisses: number;
|
|
24
|
+
};
|
|
25
|
+
readonly maxCards?: number;
|
|
26
|
+
readonly createClassificationEnabled?: boolean;
|
|
27
|
+
readonly bootstrapDomains?: DomainGenerationProposal;
|
|
28
|
+
readonly bootstrapSkillKeys?: Readonly<Record<string, string>>;
|
|
29
|
+
readonly domainGeneration?: DomainGenerationPort;
|
|
30
|
+
readonly domainGenerationSkills?: readonly GenerationSkillFact[];
|
|
31
|
+
readonly domainGenerationSkillKeys?: Readonly<Record<string, string>>;
|
|
32
|
+
}
|
|
33
|
+
export declare const name = "evolution-skill-discovery";
|
|
34
|
+
export declare const inject: string[];
|
|
35
|
+
/** Compose discovery services from platform ports; no catalog/provider replacement. */
|
|
36
|
+
export declare function apply(ctx: Context, config: Config): void;
|
|
37
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type SkillIndexRow, type SkillKey } from './identity.ts';
|
|
2
|
+
/** One skill entry from the platform catalog message. */
|
|
3
|
+
export interface CatalogEntry {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
}
|
|
7
|
+
/** One model-visible L1 domain card. */
|
|
8
|
+
export interface DomainCard {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly title: string;
|
|
11
|
+
readonly purpose: string;
|
|
12
|
+
readonly triggers: readonly string[];
|
|
13
|
+
readonly descriptionStatus: 'fresh' | 'stale' | 'failed';
|
|
14
|
+
readonly managedModelInvocableCount: number;
|
|
15
|
+
readonly externalCatalogCount: number;
|
|
16
|
+
readonly managedCount: number;
|
|
17
|
+
readonly externalCount: number;
|
|
18
|
+
readonly pendingCount: number;
|
|
19
|
+
readonly state: 'active' | 'provisional';
|
|
20
|
+
readonly asOf: string;
|
|
21
|
+
readonly mapVersion: string;
|
|
22
|
+
readonly mapStale: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** Input of the pure catalog projection contract. */
|
|
25
|
+
export interface ProjectionInput {
|
|
26
|
+
readonly entries: readonly CatalogEntry[];
|
|
27
|
+
readonly rows: readonly SkillIndexRow[];
|
|
28
|
+
readonly activeManagedSkillKeys: ReadonlySet<SkillKey>;
|
|
29
|
+
readonly cards: readonly DomainCard[];
|
|
30
|
+
readonly viewKey: string;
|
|
31
|
+
readonly scope: string;
|
|
32
|
+
readonly mapVersion: string;
|
|
33
|
+
readonly policyDigest: string;
|
|
34
|
+
readonly viewCatalogDigest: string;
|
|
35
|
+
readonly adapterVersion: string;
|
|
36
|
+
readonly projectionSchemaVersion: string;
|
|
37
|
+
readonly discoveryMode: string;
|
|
38
|
+
readonly complete: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Output of the pure catalog projection contract. */
|
|
41
|
+
export interface ProjectionResult {
|
|
42
|
+
readonly catalogEntries: readonly CatalogEntry[];
|
|
43
|
+
readonly context: string;
|
|
44
|
+
readonly hiddenNames: readonly string[];
|
|
45
|
+
readonly shadowHiddenNames?: readonly string[];
|
|
46
|
+
readonly shadowRecoveredNames?: readonly string[];
|
|
47
|
+
readonly scope: string;
|
|
48
|
+
readonly digest: string;
|
|
49
|
+
readonly complete: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Pure catalog projection: hide only active managed entries, preserve every
|
|
53
|
+
* other entry, and render L1 cards. Incomplete input fails open.
|
|
54
|
+
* @param input - view rows, active managed keys, cards, and identity inputs.
|
|
55
|
+
* @returns projected entries/context/hidden names and digest.
|
|
56
|
+
*/
|
|
57
|
+
export declare function projectCatalog(input: ProjectionInput): ProjectionResult;
|
|
58
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
2
|
+
import type { DomainMapStore } from './domain-map.ts';
|
|
3
|
+
import type { EffectiveDomainPolicy } from './domain-policy.ts';
|
|
4
|
+
import { type SkillIndexSource } from './index.ts';
|
|
5
|
+
import type { CatalogEntry, ProjectionResult } from './projection.ts';
|
|
6
|
+
import type { DiscoverySessionStore } from './session-store.ts';
|
|
7
|
+
/** Injectable composition ports; the platform adapter supplies concrete I/O. */
|
|
8
|
+
export interface DiscoveryRuntimePorts {
|
|
9
|
+
readonly skillIndexSource: SkillIndexSource;
|
|
10
|
+
readonly map: DomainMapStore;
|
|
11
|
+
readonly policy: EffectiveDomainPolicy;
|
|
12
|
+
readonly sessionStore: DiscoverySessionStore;
|
|
13
|
+
readonly featureEpoch: string;
|
|
14
|
+
readonly mapVersion: string;
|
|
15
|
+
readonly policyDigest: string;
|
|
16
|
+
readonly adapterVersion: string;
|
|
17
|
+
readonly projectionSchemaVersion: string;
|
|
18
|
+
readonly discoveryMode: string;
|
|
19
|
+
readonly maxCards?: number | undefined;
|
|
20
|
+
readonly tokenBudget?: number | undefined;
|
|
21
|
+
readonly autoMode?: boolean | undefined;
|
|
22
|
+
readonly promoted?: boolean | (() => boolean) | undefined;
|
|
23
|
+
readonly onProjection?: ((result: ProjectionResult) => void) | undefined;
|
|
24
|
+
readonly staleAfterHours?: number | undefined;
|
|
25
|
+
readonly maxVisibleDepth?: number | undefined;
|
|
26
|
+
readonly mode?: 'off' | 'shadow' | 'on' | undefined;
|
|
27
|
+
readonly mapStale?: boolean | undefined;
|
|
28
|
+
readonly searchAvailable?: boolean | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** G2 adapter provider wired from ports; no global platform dependency. */
|
|
31
|
+
export declare class DiscoveryRuntime {
|
|
32
|
+
private readonly ports;
|
|
33
|
+
constructor(ports: DiscoveryRuntimePorts);
|
|
34
|
+
/** @returns true only when persisted session metadata allows projection. */
|
|
35
|
+
shouldProject(agent: Agent): Promise<boolean>;
|
|
36
|
+
/** @returns a complete projection for this agent's catalog entries. */
|
|
37
|
+
project(input: {
|
|
38
|
+
readonly agent: Agent;
|
|
39
|
+
readonly catalogEntries: readonly CatalogEntry[];
|
|
40
|
+
}): Promise<ProjectionResult>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** One independent judge's EVAL-010 labels. */
|
|
2
|
+
export interface JudgeObservation {
|
|
3
|
+
readonly queryId: string;
|
|
4
|
+
readonly relevant: boolean;
|
|
5
|
+
readonly note?: string | undefined;
|
|
6
|
+
}
|
|
7
|
+
export interface JudgeRecord {
|
|
8
|
+
readonly schemaVersion: 1;
|
|
9
|
+
readonly querySet: 'eval-010';
|
|
10
|
+
readonly judgeKind: 'model' | 'human';
|
|
11
|
+
readonly judgeId: string;
|
|
12
|
+
readonly observations: readonly JudgeObservation[];
|
|
13
|
+
}
|
|
14
|
+
/** Validate a judge packet without accepting partial query coverage. */
|
|
15
|
+
export declare function validateJudgeRecord(record: JudgeRecord, expectedQueryIds: readonly string[]): readonly string[];
|
|
16
|
+
/** Aggregate two independent judges; no label is rewritten. */
|
|
17
|
+
export interface JudgeAggregate {
|
|
18
|
+
readonly queryCount: number;
|
|
19
|
+
readonly relevantRate: number | null;
|
|
20
|
+
readonly agreementRate: number | null;
|
|
21
|
+
readonly hasModel: boolean;
|
|
22
|
+
readonly hasHuman: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** @returns aggregate over model/human records; agreement only for shared queries. */
|
|
25
|
+
export declare function aggregateJudge(records: readonly JudgeRecord[], expectedQueryIds: readonly string[]): JudgeAggregate;
|
|
26
|
+
//# sourceMappingURL=search-judge.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type SkillIndexRow } from './identity.ts';
|
|
2
|
+
/** Tokenizer version; changing the algorithm requires rebuilding indexes. */
|
|
3
|
+
export declare const SKILL_SEARCH_TOKENIZER_VERSION = "cjk-bigram-v1";
|
|
4
|
+
/** Fields indexed by skill search; no body/path. */
|
|
5
|
+
export declare const SKILL_SEARCH_FIELDS: readonly ["name", "description", "whenToUse"];
|
|
6
|
+
/** Index schema version; bump when indexed fields/options change. */
|
|
7
|
+
export declare const SKILL_SEARCH_INDEX_SCHEMA_VERSION = "skill-search-v1";
|
|
8
|
+
/** One lexical search request. */
|
|
9
|
+
export interface SkillSearchQuery {
|
|
10
|
+
readonly query: string;
|
|
11
|
+
readonly limit?: number | undefined;
|
|
12
|
+
}
|
|
13
|
+
/** One lexical search hit; the model loads the body separately. */
|
|
14
|
+
export interface SkillSearchHit {
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly whenToUse?: string | undefined;
|
|
18
|
+
readonly matchedBy?: string | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Independent search read service. */
|
|
21
|
+
export interface SkillSearchResponse {
|
|
22
|
+
readonly results: readonly SkillSearchHit[];
|
|
23
|
+
readonly truncated: boolean;
|
|
24
|
+
readonly fallback?: boolean | undefined;
|
|
25
|
+
readonly stale?: boolean | undefined;
|
|
26
|
+
readonly degraded?: boolean | undefined;
|
|
27
|
+
readonly hint?: string | undefined;
|
|
28
|
+
}
|
|
29
|
+
export interface SkillSearch {
|
|
30
|
+
search(query: SkillSearchQuery, options?: {
|
|
31
|
+
readonly allowedSkillKeys?: ReadonlySet<string> | undefined;
|
|
32
|
+
}): Promise<SkillSearchResponse>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Split NFKC text into CJK overlapping bigrams plus tail, and ASCII/other runs.
|
|
36
|
+
* Parity source: plugin-market/src/search.ts searchTerms.
|
|
37
|
+
* @param text - indexed or queried text.
|
|
38
|
+
* @returns terms in text order; callers lowercase.
|
|
39
|
+
*/
|
|
40
|
+
export declare function searchTerms(text: string): string[];
|
|
41
|
+
/** Per-view MiniSearch index; no global engine and no projection-only filtering. */
|
|
42
|
+
export declare class SkillSearchIndex implements SkillSearch {
|
|
43
|
+
private engine;
|
|
44
|
+
private staleState;
|
|
45
|
+
readonly viewKey: string;
|
|
46
|
+
private constructor();
|
|
47
|
+
/** @returns an index over every modelInvocable row in this view. */
|
|
48
|
+
static fromRows(viewKey: string, rows: readonly SkillIndexRow[]): SkillSearchIndex;
|
|
49
|
+
/** Mark the current index stale before a rebuild finishes. */
|
|
50
|
+
markStale(): void;
|
|
51
|
+
/** Rebuild from this view's full rows; a failed rebuild keeps the old engine stale. */
|
|
52
|
+
rebuild(rows: readonly SkillIndexRow[]): Promise<boolean>;
|
|
53
|
+
/** @returns hits, truncation, and whether the index is stale. */
|
|
54
|
+
search(query: SkillSearchQuery, options?: {
|
|
55
|
+
readonly allowedSkillKeys?: ReadonlySet<string> | undefined;
|
|
56
|
+
}): Promise<SkillSearchResponse>;
|
|
57
|
+
}
|
|
58
|
+
/** Identity inputs for one per-view search index. */
|
|
59
|
+
export interface SearchIndexCacheKey {
|
|
60
|
+
readonly viewKey: string;
|
|
61
|
+
readonly viewCatalogDigest: string;
|
|
62
|
+
readonly policyDigest: string;
|
|
63
|
+
readonly discoveryMode: string;
|
|
64
|
+
}
|
|
65
|
+
/** Per-view cache keyed by searchIndexKey; never shares one engine across views. */
|
|
66
|
+
export declare class SkillSearchCache {
|
|
67
|
+
private readonly entries;
|
|
68
|
+
/**
|
|
69
|
+
* Get or build one view index. A failed rebuild retains the previous engine
|
|
70
|
+
* and marks it stale; no previous engine means undefined.
|
|
71
|
+
* @param key - identity inputs for searchIndexKey.
|
|
72
|
+
* @param rows - current full rows for the view.
|
|
73
|
+
* @returns index plus stale state, or undefined when no index is available.
|
|
74
|
+
*/
|
|
75
|
+
get(key: SearchIndexCacheKey, rows: readonly SkillIndexRow[]): Promise<{
|
|
76
|
+
index: SkillSearchIndex;
|
|
77
|
+
stale: boolean;
|
|
78
|
+
} | undefined>;
|
|
79
|
+
/** Drop every index for one view. */
|
|
80
|
+
invalidate(viewKey: string): void;
|
|
81
|
+
/** Drop every cached view index. */
|
|
82
|
+
clear(): void;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** One sanitized untrusted string. */
|
|
2
|
+
export interface SanitizedText {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
readonly truncated: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Treat description text as data: strip control characters, escape HTML
|
|
8
|
+
* delimiters, and cap length. It never turns data into instructions.
|
|
9
|
+
* @param value - untrusted domain/skill text.
|
|
10
|
+
* @param limit - maximum characters retained.
|
|
11
|
+
* @returns escaped text plus truncation flag.
|
|
12
|
+
*/
|
|
13
|
+
export declare function sanitizeUntrustedText(value: string, limit?: number): SanitizedText;
|
|
14
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Persisted discovery metadata used to keep old sessions full-catalog. */
|
|
2
|
+
export interface DiscoverySessionMeta {
|
|
3
|
+
readonly discoveryMode?: 'off' | 'shadow' | 'on' | undefined;
|
|
4
|
+
readonly featureEpoch?: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
/** @returns true only for a new, fully-enabled session in the current epoch. */
|
|
7
|
+
export declare function shouldHideCatalog(meta: DiscoverySessionMeta | undefined, currentFeatureEpoch: string): boolean;
|
|
8
|
+
/** @returns true when awareness may be emitted (shadow or on). */
|
|
9
|
+
export declare function shouldEmitAwareness(meta: DiscoverySessionMeta | undefined, currentFeatureEpoch: string): boolean;
|
|
10
|
+
/** @returns false when the same digest was already emitted in this session. */
|
|
11
|
+
export declare function shouldEmitDigest(previousDigest: string | undefined, nextDigest: string): boolean;
|
|
12
|
+
/** @returns off at <=2200 tokens, on at >=3000, shadow between. */
|
|
13
|
+
export declare function projectionBudgetMode(catalogTokens: number, promoted?: boolean): 'off' | 'shadow' | 'on';
|
|
14
|
+
/** @returns true when a resumed session already enabled discovery. */
|
|
15
|
+
export declare function shouldInstallAwarenessOnResume(record: {
|
|
16
|
+
readonly discoveryMode: 'off' | 'shadow' | 'on';
|
|
17
|
+
readonly featureEpoch: string;
|
|
18
|
+
} | undefined, featureEpoch: string): boolean;
|
|
19
|
+
//# sourceMappingURL=session-projection.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EvolutionIoLike } from '@lmzhen/dsh-evolution-core';
|
|
2
|
+
/** One persisted session's discovery mode. */
|
|
3
|
+
export interface DiscoverySessionRecord {
|
|
4
|
+
readonly sessionId: string;
|
|
5
|
+
readonly discoveryMode: 'off' | 'shadow' | 'on';
|
|
6
|
+
readonly featureEpoch: string;
|
|
7
|
+
readonly projectionDigest?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
/** Plugin-side session metadata; platform SessionHeader has no discovery fields. */
|
|
10
|
+
export declare class DiscoverySessionStore {
|
|
11
|
+
private readonly io;
|
|
12
|
+
private readonly path;
|
|
13
|
+
constructor(io: EvolutionIoLike, path: string);
|
|
14
|
+
private read;
|
|
15
|
+
/** @returns persisted metadata for one session. */
|
|
16
|
+
get(sessionId: string): Promise<DiscoverySessionRecord | undefined>;
|
|
17
|
+
/** Persist one session's mode/epoch; later writes win. */
|
|
18
|
+
put(record: DiscoverySessionRecord): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/** @returns true only for a persisted enabled session in the current feature epoch. */
|
|
21
|
+
export declare function shouldProjectPersistedSession(store: DiscoverySessionStore, sessionId: string, currentFeatureEpoch: string): Promise<boolean>;
|
|
22
|
+
//# sourceMappingURL=session-store.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EvolutionIoLike } from '@lmzhen/dsh-evolution-core';
|
|
2
|
+
import type { ProjectionResult } from './projection.ts';
|
|
3
|
+
/** Durable shadow-run evidence; every complete shadow projection is one sample. */
|
|
4
|
+
export declare class ShadowEvidenceStore {
|
|
5
|
+
private readonly io;
|
|
6
|
+
private readonly path;
|
|
7
|
+
private samples;
|
|
8
|
+
private recovered;
|
|
9
|
+
private hidden;
|
|
10
|
+
private silentMisses;
|
|
11
|
+
private loaded;
|
|
12
|
+
constructor(io: EvolutionIoLike, path: string);
|
|
13
|
+
load(): Promise<void>;
|
|
14
|
+
record(result: ProjectionResult): Promise<void>;
|
|
15
|
+
evidence(): {
|
|
16
|
+
samples: number;
|
|
17
|
+
hiddenRecoverableRate: number;
|
|
18
|
+
silentMisses: number;
|
|
19
|
+
};
|
|
20
|
+
canPromote(): boolean;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=shadow-evidence.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Ordered implementation stages from PLAN-DISC-001. */
|
|
2
|
+
export declare const DISCOVERY_STAGES: readonly ["G0-projection", "G1-domain", "G2-projection", "G3-search", "G4-assignment", "G5-maintenance", "G6-ui", "G7-migration", "G8-release"];
|
|
3
|
+
export type DiscoveryStage = (typeof DISCOVERY_STAGES)[number];
|
|
4
|
+
export declare function stageIndex(stage: DiscoveryStage): number;
|
|
5
|
+
export declare function mayAdvance(current: DiscoveryStage, next: DiscoveryStage): boolean;
|
|
6
|
+
//# sourceMappingURL=stages.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
|
+
import type { SkillSearch, SkillSearchQuery, SkillSearchResponse } from './search.ts';
|
|
4
|
+
/** Search dependency supplied by the composition; absent search degrades. */
|
|
5
|
+
export interface SkillSearchProvider {
|
|
6
|
+
search(query: SkillSearchQuery, options?: {
|
|
7
|
+
readonly allowedSkillKeys?: ReadonlySet<string> | undefined;
|
|
8
|
+
}, agent?: Agent | undefined): Promise<SkillSearchResponse>;
|
|
9
|
+
/** Optional current-view policy filter; called per tool call. */
|
|
10
|
+
allowedSkillKeys?(agent: Agent | undefined): ReadonlySet<string> | Promise<ReadonlySet<string>> | undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Static model-facing description; no dynamic domain list/tree. */
|
|
13
|
+
export declare const SKILL_SEARCH_DESCRIPTION = "Search skill summaries by name, description, or whenToUse when coverage is uncertain. Results are summaries, not bodies; a matching name can be loaded directly. Empty results are inconclusive; the full catalog remains available.";
|
|
14
|
+
/** @returns response or a degraded hint; never silent empty on failure. */
|
|
15
|
+
export declare function searchWithDegraded(provider: SkillSearchProvider | undefined, query: SkillSearchQuery, allowedSkillKeys?: ReadonlySet<string> | undefined, agent?: Agent | undefined): Promise<SkillSearchResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Register skill_search on the optional tools service. The description/schema are static; the
|
|
18
|
+
* provider is the only dynamic dependency.
|
|
19
|
+
* platform-declaration anchor: tools is declared in core PLATFORM_SERVICE_PROBES.
|
|
20
|
+
* @param ctx - plugin context.
|
|
21
|
+
* @param provider - search service or undefined when unavailable.
|
|
22
|
+
* @returns tool disposer.
|
|
23
|
+
*/
|
|
24
|
+
export declare function registerSkillSearchTool(ctx: Context, provider: SkillSearchProvider | undefined): () => void;
|
|
25
|
+
/** @returns true only for a search implementation; used by composition wiring. */
|
|
26
|
+
export declare function isSkillSearch(value: unknown): value is SkillSearch;
|
|
27
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Read-only card projection for UI; counts are intentionally separate. */
|
|
2
|
+
export interface DiscoveryCardView {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly title: string;
|
|
5
|
+
readonly purpose: string;
|
|
6
|
+
readonly descriptionStatus: 'fresh' | 'stale' | 'failed';
|
|
7
|
+
readonly triggers: readonly string[];
|
|
8
|
+
readonly managedModelInvocableCount: number;
|
|
9
|
+
readonly externalCatalogCount: number;
|
|
10
|
+
readonly pendingCount: number;
|
|
11
|
+
readonly mapStale: boolean;
|
|
12
|
+
readonly asOf: string;
|
|
13
|
+
}
|
|
14
|
+
/** Read-only product state; no L1/L2 tree or task view. */
|
|
15
|
+
export interface DiscoveryUiState {
|
|
16
|
+
readonly cards: readonly DiscoveryCardView[];
|
|
17
|
+
readonly unclassifiedCount: number;
|
|
18
|
+
readonly mapStale: boolean;
|
|
19
|
+
readonly completeness: 'complete' | 'partial' | 'unavailable';
|
|
20
|
+
readonly asOf: string;
|
|
21
|
+
readonly searchEnabled: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Allowed user policy fields; anything else is rejected. */
|
|
24
|
+
export interface DiscoveryUserPolicy {
|
|
25
|
+
readonly mode?: 'auto' | 'off' | 'on' | undefined;
|
|
26
|
+
readonly maxCards?: number | undefined;
|
|
27
|
+
readonly tokenBudget?: number | undefined;
|
|
28
|
+
readonly staleAfterHours?: number | undefined;
|
|
29
|
+
readonly pinDomains?: readonly string[] | undefined;
|
|
30
|
+
readonly disableDomains?: readonly string[] | undefined;
|
|
31
|
+
}
|
|
32
|
+
/** @returns true when the policy only edits supported fields. */
|
|
33
|
+
export declare function isDiscoveryUserPolicy(value: unknown): value is DiscoveryUserPolicy;
|
|
34
|
+
/** Static skill_manage description; no dynamic domain list/count/tree. */
|
|
35
|
+
export declare const SKILL_MANAGE_DESCRIPTION = "Manage skill content. create may include an optional domain proposal when create-side domain cards are available; no proposal means unclassified. Domain assignment never blocks skill creation and is stored as a sidecar.";
|
|
36
|
+
/** Future skill_domains contract; NOT a search parameter and not implemented in v0. */
|
|
37
|
+
export interface SkillDomainsContract {
|
|
38
|
+
readonly action: 'list' | 'expand';
|
|
39
|
+
readonly domainId?: string | undefined;
|
|
40
|
+
readonly depth?: 1 | 2 | undefined;
|
|
41
|
+
}
|
|
42
|
+
/** Replayable behavior metrics; no prompt sentence lock. */
|
|
43
|
+
export interface DiscoveryBehaviorObservation {
|
|
44
|
+
readonly awarenessShown: boolean;
|
|
45
|
+
readonly awarenessRecalled: boolean;
|
|
46
|
+
readonly silentMiss: boolean;
|
|
47
|
+
readonly searched: boolean;
|
|
48
|
+
readonly overSearch: boolean;
|
|
49
|
+
readonly underSearch: boolean;
|
|
50
|
+
readonly wrongLoad: boolean;
|
|
51
|
+
readonly taskSuccess: boolean;
|
|
52
|
+
readonly tokens: number;
|
|
53
|
+
readonly fallback: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** Behavior metrics for one fixture/replay batch. */
|
|
56
|
+
export interface DiscoveryBehaviorMetrics {
|
|
57
|
+
readonly awarenessRecall: number | null;
|
|
58
|
+
readonly silentMissRate: number | null;
|
|
59
|
+
readonly overSearchRate: number | null;
|
|
60
|
+
readonly underSearchRate: number | null;
|
|
61
|
+
readonly wrongLoadRate: number | null;
|
|
62
|
+
readonly taskSuccess: number | null;
|
|
63
|
+
readonly tokens: number;
|
|
64
|
+
readonly fallbackRate: number | null;
|
|
65
|
+
readonly total: number;
|
|
66
|
+
}
|
|
67
|
+
/** @returns recomputable behavior metrics; null means no denominator. */
|
|
68
|
+
export declare function computeBehaviorMetrics(observations: readonly DiscoveryBehaviorObservation[]): DiscoveryBehaviorMetrics;
|
|
69
|
+
//# sourceMappingURL=ui.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AssignmentQueueEntry, DomainAssignmentService } from './assignment.ts';
|
|
2
|
+
/** Queue view needed by the worker. */
|
|
3
|
+
export interface AssignmentQueueReader {
|
|
4
|
+
list(): readonly AssignmentQueueEntry[];
|
|
5
|
+
}
|
|
6
|
+
/** Drivable worker; the composition may call drain on a schedule. */
|
|
7
|
+
export declare class AssignmentWorker {
|
|
8
|
+
private readonly service;
|
|
9
|
+
private readonly queue;
|
|
10
|
+
constructor(service: DomainAssignmentService, queue: AssignmentQueueReader);
|
|
11
|
+
/** Process queued entries once; returns processed count. */
|
|
12
|
+
drain(limit?: number): Promise<number>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=worker.d.ts.map
|