@c4a/context 0.7.8 → 0.7.9
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/docs/guides/agent-dialogue.md +5 -4
- package/docs/guides/agent-guide.md +11 -5
- package/docs/guides/indexer-provider-and-customization.md +75 -20
- package/docs/guides/knowledge-updates.md +102 -4
- package/docs/guides/package-outputs.md +213 -47
- package/docs/reference/indexer-provider-protocol.md +19 -0
- package/docs/reference/project-api.md +53 -0
- package/index.d.ts +5 -1
- package/index.js +178 -84
- package/indexerArtifactPolicy.d.ts +4 -4
- package/indexerProtocolHash.d.ts +2 -0
- package/indexerProvider.d.ts +30 -30
- package/indexerRegistry.d.ts +606 -0
- package/indexerSemanticInput.d.ts +255 -951
- package/{readingStructure.d.ts → knowledgeMap.d.ts} +16 -16
- package/package.json +1 -1
- package/packageSite.d.ts +25 -0
|
@@ -65,6 +65,51 @@ worksets, Candidate creation, Review application and delivery. Code, Markdown,
|
|
|
65
65
|
Note and Sessions Providers can use authorized supporting documents without
|
|
66
66
|
creating a second capture or knowledge pipeline.
|
|
67
67
|
|
|
68
|
+
### Batch capture from the source registry
|
|
69
|
+
|
|
70
|
+
When all registered Lark documents are intended for this project and share capture
|
|
71
|
+
settings, read the registry once instead of copying its module names into
|
|
72
|
+
`src/index.ts`. For the standard `src/index.ts` entry:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { fileURLToPath } from "node:url";
|
|
76
|
+
import {
|
|
77
|
+
allSources, captureLark, defineProject, loadSourcesRegistry, source,
|
|
78
|
+
} from "@c4a/context";
|
|
79
|
+
|
|
80
|
+
const workspaceRoot = fileURLToPath(new URL("../", import.meta.url));
|
|
81
|
+
const registry = await loadSourcesRegistry({ rootDir: workspaceRoot });
|
|
82
|
+
const documents = registry.larks.map(entry =>
|
|
83
|
+
source(entry.name, { type: "lark" }),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
export default defineProject({
|
|
87
|
+
sources: [...allSources("repo"), ...documents],
|
|
88
|
+
phases: documents.map(document => captureLark({ source: document })),
|
|
89
|
+
packages: [],
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Merge this pattern into existing declarations; preserve unrelated phases and
|
|
94
|
+
package outputs. Adjust the root calculation if the entry lives elsewhere.
|
|
95
|
+
Registry loading only reads local registrations; it does not fetch documents.
|
|
96
|
+
|
|
97
|
+
- `sources/lark/index.yaml` owns document identities, URLs and titles. The project
|
|
98
|
+
selects those identities and declares capture settings. This example includes
|
|
99
|
+
future registrations too; use it only when the entire registered set is intended.
|
|
100
|
+
- For a subset, filter registry entries by the intended namespace or names before
|
|
101
|
+
mapping. Apply exceptional resource settings within the same map instead of
|
|
102
|
+
declaring a second phase for the same document.
|
|
103
|
+
- File documents use `registry.files`, `source(entry.name, { type: "file" })`
|
|
104
|
+
and `captureFile`. Group by actual processor needs; do not apply `mdxJsonDocs()`
|
|
105
|
+
indiscriminately to all file sources.
|
|
106
|
+
- `allSources("lark")` selects a collection; its array contains a collection
|
|
107
|
+
reference, not individual documents. It neither expands capture phases nor
|
|
108
|
+
supports mapping its entries into `captureLark`.
|
|
109
|
+
- The map declares one phase per document. It does not fetch URLs, change capture
|
|
110
|
+
permissions, or request parallel execution. Run the declared phases through the
|
|
111
|
+
existing CLI flow so each document retains independent refresh and retry behavior.
|
|
112
|
+
|
|
68
113
|
## `customPhase`
|
|
69
114
|
|
|
70
115
|
```ts
|
|
@@ -83,6 +128,7 @@ kbPackage({
|
|
|
83
128
|
name: "component-kb",
|
|
84
129
|
template: "src/package-templates/kb",
|
|
85
130
|
select: { collections: ["codeindex", "architecture"] },
|
|
131
|
+
site: { title: "Component knowledge", lang: "en-US", base: "/" },
|
|
86
132
|
});
|
|
87
133
|
|
|
88
134
|
llmsPackage({
|
|
@@ -95,6 +141,13 @@ llmsPackage({
|
|
|
95
141
|
Package selection reads approved `knowledge/` only. `dist/` is generated and
|
|
96
142
|
may be rebuilt; it is not an authoring source.
|
|
97
143
|
|
|
144
|
+
`kbPackage.site` optionally adds a VitePress website at `dist/<base>-site/` in
|
|
145
|
+
the same build, beside the KB directory. `<base>` removes one trailing `-kb`
|
|
146
|
+
from the package name, if present. Omit it for KB-only output. It accepts `title`, `description`,
|
|
147
|
+
`lang` and a deployment `base` path. Knowledge map is projected from
|
|
148
|
+
`src/knowledge-map.yaml` independently of KB directories; see
|
|
149
|
+
[Package Outputs](../guides/package-outputs.md#optional-static-documentation-website).
|
|
150
|
+
|
|
98
151
|
## Indexer registry
|
|
99
152
|
|
|
100
153
|
When this file is absent, the configuration Route supplies the initial schema:
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type PackageSiteDefinition } from "./packageSite.js";
|
|
2
|
+
export { packageSiteSchema, type PackageSiteDefinition } from "./packageSite.js";
|
|
1
3
|
import type { PackageNavigationDefinition, PackageSelectDefinition } from "./contracts.js";
|
|
2
4
|
import type { PhaseDefinition, PhaseResourceReference } from "./phases.js";
|
|
3
5
|
import type { ProjectSourceDefinition } from "./sources.js";
|
|
@@ -109,6 +111,7 @@ export type KbPackageDefinition = BasePackageDefinition & {
|
|
|
109
111
|
navigation: PackageNavigationDefinition;
|
|
110
112
|
distribution?: PackageDistributionDefinition;
|
|
111
113
|
assets?: PackageAssetDefinition;
|
|
114
|
+
site?: PackageSiteDefinition;
|
|
112
115
|
};
|
|
113
116
|
export type LlmsPackageDefinition = BasePackageDefinition & {
|
|
114
117
|
kind: "package.llms";
|
|
@@ -131,6 +134,7 @@ export declare const kbPackage: (definition: {
|
|
|
131
134
|
navigation?: Partial<PackageNavigationDefinition>;
|
|
132
135
|
distribution?: PackageDistributionDefinition;
|
|
133
136
|
assets?: PackageAssetDefinition;
|
|
137
|
+
site?: PackageSiteDefinition;
|
|
134
138
|
}) => KbPackageDefinition;
|
|
135
139
|
export declare const llmsPackage: (definition: {
|
|
136
140
|
name: string;
|
|
@@ -145,6 +149,6 @@ export { sessionChangeSchema, sessionChangesSchema, readSessionChanges, writeSes
|
|
|
145
149
|
export type { SessionChange } from "./sessionMetadata.js";
|
|
146
150
|
export { indexerArticleKeySchema, indexerArticlePlanSchema, validateIndexerArticlePlan, indexerArticleSectionKey, validateIndexerPlannedArticles } from "./indexerArticlePlan.js";
|
|
147
151
|
export type { IndexerArticlePlan } from "./indexerArticlePlan.js";
|
|
148
|
-
export * from "./
|
|
152
|
+
export * from "./knowledgeMap.js";
|
|
149
153
|
export * from "./indexerKnowledgeDependency.js";
|
|
150
154
|
export * from "./indexerApprovedKnowledge.js";
|
package/index.js
CHANGED
|
@@ -6915,55 +6915,6 @@ var require_public_api = __commonJS((exports) => {
|
|
|
6915
6915
|
exports.stringify = stringify;
|
|
6916
6916
|
});
|
|
6917
6917
|
|
|
6918
|
-
// src/contracts.ts
|
|
6919
|
-
var DEFAULT_PACKAGE_NAVIGATION = {
|
|
6920
|
-
foldDirectoryIndexes: true,
|
|
6921
|
-
maxInlineEntries: 50
|
|
6922
|
-
};
|
|
6923
|
-
var DOC_MAINLINE_COLLECTIONS = [
|
|
6924
|
-
"business",
|
|
6925
|
-
"product",
|
|
6926
|
-
"architecture",
|
|
6927
|
-
"sop",
|
|
6928
|
-
"faq",
|
|
6929
|
-
"standards",
|
|
6930
|
-
"decision",
|
|
6931
|
-
"incident",
|
|
6932
|
-
"test"
|
|
6933
|
-
];
|
|
6934
|
-
var MAINLINE_COLLECTIONS = ["codeindex", "codegraph", ...DOC_MAINLINE_COLLECTIONS];
|
|
6935
|
-
var TOP_LEVEL_NAMESPACES = [...MAINLINE_COLLECTIONS, "feats"];
|
|
6936
|
-
var OKF_ROOTS = ["guides", "rules", "wikis", "feats"];
|
|
6937
|
-
var KNOWLEDGE_COLLECTIONS = TOP_LEVEL_NAMESPACES;
|
|
6938
|
-
function assertKnowledgeCollection(value, field) {
|
|
6939
|
-
if (!KNOWLEDGE_COLLECTIONS.includes(value)) {
|
|
6940
|
-
throw new TypeError(`${field} must be one of ${KNOWLEDGE_COLLECTIONS.join(", ")}: ${value}`);
|
|
6941
|
-
}
|
|
6942
|
-
}
|
|
6943
|
-
function assertDocumentMainlineCollection(value, field) {
|
|
6944
|
-
if (!DOC_MAINLINE_COLLECTIONS.includes(value)) {
|
|
6945
|
-
throw new TypeError(`${field} must be one of ${DOC_MAINLINE_COLLECTIONS.join(", ")}: ${value}`);
|
|
6946
|
-
}
|
|
6947
|
-
}
|
|
6948
|
-
function assertMainlineCollection(value, field) {
|
|
6949
|
-
if (!MAINLINE_COLLECTIONS.includes(value)) {
|
|
6950
|
-
throw new TypeError(`${field} must be one of ${MAINLINE_COLLECTIONS.join(", ")}: ${value}`);
|
|
6951
|
-
}
|
|
6952
|
-
}
|
|
6953
|
-
function assertTopLevelNamespace(value, field) {
|
|
6954
|
-
if (!TOP_LEVEL_NAMESPACES.includes(value)) {
|
|
6955
|
-
throw new TypeError(`${field} must be one of ${TOP_LEVEL_NAMESPACES.join(", ")}: ${value}`);
|
|
6956
|
-
}
|
|
6957
|
-
}
|
|
6958
|
-
function assertOkfRoot(value, field) {
|
|
6959
|
-
if (!OKF_ROOTS.includes(value)) {
|
|
6960
|
-
throw new TypeError(`${field} must be one of ${OKF_ROOTS.join(", ")}: ${value}`);
|
|
6961
|
-
}
|
|
6962
|
-
}
|
|
6963
|
-
|
|
6964
|
-
// src/indexerProtocolCommon.ts
|
|
6965
|
-
import { createHash } from "node:crypto";
|
|
6966
|
-
|
|
6967
6918
|
// ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
|
|
6968
6919
|
var exports_external = {};
|
|
6969
6920
|
__export(exports_external, {
|
|
@@ -10937,6 +10888,133 @@ var coerce = {
|
|
|
10937
10888
|
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
10938
10889
|
};
|
|
10939
10890
|
var NEVER = INVALID;
|
|
10891
|
+
// src/packageSite.ts
|
|
10892
|
+
var packageSiteSchema = exports_external.object({
|
|
10893
|
+
title: exports_external.string().trim().min(1).optional(),
|
|
10894
|
+
description: exports_external.string().optional(),
|
|
10895
|
+
lang: exports_external.string().min(1).default("en-US"),
|
|
10896
|
+
base: exports_external.string().regex(/^\/(?:[a-zA-Z0-9_-]+\/)*$/, "Use / or a slash-delimited deployment path, such as /docs/").default("/")
|
|
10897
|
+
}).strict();
|
|
10898
|
+
function normalizePackageSite(value) {
|
|
10899
|
+
return value === undefined ? undefined : packageSiteSchema.parse(value);
|
|
10900
|
+
}
|
|
10901
|
+
// src/contracts.ts
|
|
10902
|
+
var DEFAULT_PACKAGE_NAVIGATION = {
|
|
10903
|
+
foldDirectoryIndexes: true,
|
|
10904
|
+
maxInlineEntries: 50
|
|
10905
|
+
};
|
|
10906
|
+
var DOC_MAINLINE_COLLECTIONS = [
|
|
10907
|
+
"business",
|
|
10908
|
+
"product",
|
|
10909
|
+
"architecture",
|
|
10910
|
+
"sop",
|
|
10911
|
+
"faq",
|
|
10912
|
+
"standards",
|
|
10913
|
+
"decision",
|
|
10914
|
+
"incident",
|
|
10915
|
+
"test"
|
|
10916
|
+
];
|
|
10917
|
+
var MAINLINE_COLLECTIONS = ["codeindex", "codegraph", ...DOC_MAINLINE_COLLECTIONS];
|
|
10918
|
+
var TOP_LEVEL_NAMESPACES = [...MAINLINE_COLLECTIONS, "feats"];
|
|
10919
|
+
var OKF_ROOTS = ["guides", "rules", "wikis", "feats"];
|
|
10920
|
+
var KNOWLEDGE_COLLECTIONS = TOP_LEVEL_NAMESPACES;
|
|
10921
|
+
function assertKnowledgeCollection(value, field) {
|
|
10922
|
+
if (!KNOWLEDGE_COLLECTIONS.includes(value)) {
|
|
10923
|
+
throw new TypeError(`${field} must be one of ${KNOWLEDGE_COLLECTIONS.join(", ")}: ${value}`);
|
|
10924
|
+
}
|
|
10925
|
+
}
|
|
10926
|
+
function assertDocumentMainlineCollection(value, field) {
|
|
10927
|
+
if (!DOC_MAINLINE_COLLECTIONS.includes(value)) {
|
|
10928
|
+
throw new TypeError(`${field} must be one of ${DOC_MAINLINE_COLLECTIONS.join(", ")}: ${value}`);
|
|
10929
|
+
}
|
|
10930
|
+
}
|
|
10931
|
+
function assertMainlineCollection(value, field) {
|
|
10932
|
+
if (!MAINLINE_COLLECTIONS.includes(value)) {
|
|
10933
|
+
throw new TypeError(`${field} must be one of ${MAINLINE_COLLECTIONS.join(", ")}: ${value}`);
|
|
10934
|
+
}
|
|
10935
|
+
}
|
|
10936
|
+
function assertTopLevelNamespace(value, field) {
|
|
10937
|
+
if (!TOP_LEVEL_NAMESPACES.includes(value)) {
|
|
10938
|
+
throw new TypeError(`${field} must be one of ${TOP_LEVEL_NAMESPACES.join(", ")}: ${value}`);
|
|
10939
|
+
}
|
|
10940
|
+
}
|
|
10941
|
+
function assertOkfRoot(value, field) {
|
|
10942
|
+
if (!OKF_ROOTS.includes(value)) {
|
|
10943
|
+
throw new TypeError(`${field} must be one of ${OKF_ROOTS.join(", ")}: ${value}`);
|
|
10944
|
+
}
|
|
10945
|
+
}
|
|
10946
|
+
|
|
10947
|
+
// src/indexerProtocolHash.ts
|
|
10948
|
+
import { createHash } from "node:crypto";
|
|
10949
|
+
function hashCanonicalIndexerJson(value, fallback) {
|
|
10950
|
+
const hash = createHash("sha256");
|
|
10951
|
+
let buffer = "";
|
|
10952
|
+
const unsupported = Symbol("non-json value");
|
|
10953
|
+
const active = new Set;
|
|
10954
|
+
const append = (text) => {
|
|
10955
|
+
buffer += text;
|
|
10956
|
+
if (buffer.length >= 16384) {
|
|
10957
|
+
hash.update(buffer);
|
|
10958
|
+
buffer = "";
|
|
10959
|
+
}
|
|
10960
|
+
};
|
|
10961
|
+
const visit = (item) => {
|
|
10962
|
+
if (item === null || typeof item !== "object") {
|
|
10963
|
+
const text = JSON.stringify(item);
|
|
10964
|
+
if (text === undefined)
|
|
10965
|
+
throw unsupported;
|
|
10966
|
+
append(text);
|
|
10967
|
+
return;
|
|
10968
|
+
}
|
|
10969
|
+
if (active.has(item))
|
|
10970
|
+
throw unsupported;
|
|
10971
|
+
active.add(item);
|
|
10972
|
+
if (Array.isArray(item)) {
|
|
10973
|
+
append("[");
|
|
10974
|
+
for (let i = 0;i < item.length; i++) {
|
|
10975
|
+
if (i !== 0)
|
|
10976
|
+
append(",");
|
|
10977
|
+
const child = item[i];
|
|
10978
|
+
if (child === undefined || typeof child === "function" || typeof child === "symbol")
|
|
10979
|
+
append("null");
|
|
10980
|
+
else
|
|
10981
|
+
visit(child);
|
|
10982
|
+
}
|
|
10983
|
+
append("]");
|
|
10984
|
+
} else {
|
|
10985
|
+
const entries = Object.entries(item).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
|
|
10986
|
+
if (entries.some(([key, child]) => key === "toJSON" && typeof child === "function"))
|
|
10987
|
+
throw unsupported;
|
|
10988
|
+
const ordered = Object.fromEntries(entries);
|
|
10989
|
+
append("{");
|
|
10990
|
+
let first = true;
|
|
10991
|
+
for (const key of Object.keys(ordered)) {
|
|
10992
|
+
const child = ordered[key];
|
|
10993
|
+
if (child === undefined || typeof child === "function" || typeof child === "symbol")
|
|
10994
|
+
continue;
|
|
10995
|
+
if (!first)
|
|
10996
|
+
append(",");
|
|
10997
|
+
first = false;
|
|
10998
|
+
append(JSON.stringify(key));
|
|
10999
|
+
append(":");
|
|
11000
|
+
visit(child);
|
|
11001
|
+
}
|
|
11002
|
+
append("}");
|
|
11003
|
+
}
|
|
11004
|
+
active.delete(item);
|
|
11005
|
+
};
|
|
11006
|
+
try {
|
|
11007
|
+
visit(value);
|
|
11008
|
+
if (buffer)
|
|
11009
|
+
hash.update(buffer);
|
|
11010
|
+
return `sha256:${hash.digest("hex")}`;
|
|
11011
|
+
} catch (error) {
|
|
11012
|
+
if (error !== unsupported)
|
|
11013
|
+
throw error;
|
|
11014
|
+
return `sha256:${createHash("sha256").update(fallback(value)).digest("hex")}`;
|
|
11015
|
+
}
|
|
11016
|
+
}
|
|
11017
|
+
|
|
10940
11018
|
// src/indexerProtocolCommon.ts
|
|
10941
11019
|
var INDEXER_PROVIDER_MANIFEST_NAME = "context-indexer.yaml";
|
|
10942
11020
|
var DEFAULT_INDEXER_REGISTRY_PATH = "src/indexers.yaml";
|
|
@@ -11031,7 +11109,7 @@ function canonicalIndexerJson(value) {
|
|
|
11031
11109
|
return JSON.stringify(canonicalize(value));
|
|
11032
11110
|
}
|
|
11033
11111
|
function indexerProtocolDigest(value) {
|
|
11034
|
-
return
|
|
11112
|
+
return hashCanonicalIndexerJson(value, canonicalIndexerJson);
|
|
11035
11113
|
}
|
|
11036
11114
|
function formatIndexerSchemaIssues(issues) {
|
|
11037
11115
|
return issues.map((issue) => {
|
|
@@ -13723,7 +13801,7 @@ var providerLayerSchema = exports_external.object({
|
|
|
13723
13801
|
});
|
|
13724
13802
|
}
|
|
13725
13803
|
});
|
|
13726
|
-
var
|
|
13804
|
+
var indexerRegistryEntryInputSchema = exports_external.object({
|
|
13727
13805
|
id: indexerIdSchema,
|
|
13728
13806
|
operations: exports_external.array(exports_external.enum(INDEXER_SEMANTIC_OPERATIONS)).min(1).default(["main-index"]),
|
|
13729
13807
|
requirement_bindings: exports_external.array(requirementBindingSchema).min(1),
|
|
@@ -13737,7 +13815,8 @@ var indexerRegistryEntrySchema = exports_external.object({
|
|
|
13737
13815
|
customization: exports_external.object({
|
|
13738
13816
|
mode: exports_external.enum(["extend", "replace"])
|
|
13739
13817
|
}).strict().optional()
|
|
13740
|
-
}).strict()
|
|
13818
|
+
}).strict();
|
|
13819
|
+
var indexerRegistryEntrySchema = indexerRegistryEntryInputSchema.transform((value) => ({
|
|
13741
13820
|
...value,
|
|
13742
13821
|
read_scope: value.read_scope ?? {
|
|
13743
13822
|
refs: [...new Set(value.requirement_bindings.flatMap((binding) => binding.role === "primary" ? [
|
|
@@ -28184,8 +28263,8 @@ function validateIndexerAgentStepInput(value) {
|
|
|
28184
28263
|
}
|
|
28185
28264
|
return input;
|
|
28186
28265
|
}
|
|
28187
|
-
// src/
|
|
28188
|
-
var
|
|
28266
|
+
// src/knowledgeMap.ts
|
|
28267
|
+
var knowledgeMapEntrySchema = exports_external.object({
|
|
28189
28268
|
key: exports_external.string().min(1),
|
|
28190
28269
|
parent: exports_external.string().min(1).nullable(),
|
|
28191
28270
|
title: exports_external.string().min(1),
|
|
@@ -28195,51 +28274,51 @@ var readingStructureEntrySchema = exports_external.object({
|
|
|
28195
28274
|
section_key: exports_external.string().min(1).optional()
|
|
28196
28275
|
}).strict().optional()
|
|
28197
28276
|
}).strict();
|
|
28198
|
-
var
|
|
28277
|
+
var knowledgeMapUpdateSchema = exports_external.object({
|
|
28199
28278
|
expected_revision: exports_external.string().nullable(),
|
|
28200
|
-
upsert: exports_external.array(
|
|
28279
|
+
upsert: exports_external.array(knowledgeMapEntrySchema).default([]),
|
|
28201
28280
|
remove: exports_external.array(exports_external.string().min(1)).default([])
|
|
28202
28281
|
}).strict();
|
|
28203
|
-
var
|
|
28204
|
-
protocol: exports_external.literal("context.
|
|
28282
|
+
var knowledgeMapSchema = exports_external.object({
|
|
28283
|
+
protocol: exports_external.literal("context.knowledge-map/v1"),
|
|
28205
28284
|
revision: exports_external.string().min(1),
|
|
28206
|
-
entries: exports_external.array(
|
|
28285
|
+
entries: exports_external.array(knowledgeMapEntrySchema)
|
|
28207
28286
|
}).strict();
|
|
28208
28287
|
function validateEntries(entries) {
|
|
28209
28288
|
const indexed = new Map(entries.map((entry) => [entry.key, entry]));
|
|
28210
28289
|
if (indexed.size !== entries.length)
|
|
28211
|
-
throw new TypeError("
|
|
28290
|
+
throw new TypeError("knowledge-map entries must have unique keys");
|
|
28212
28291
|
for (const entry of entries) {
|
|
28213
28292
|
const visited = new Set;
|
|
28214
28293
|
let current = entry;
|
|
28215
28294
|
while (current !== undefined) {
|
|
28216
28295
|
if (visited.has(current.key))
|
|
28217
|
-
throw new TypeError("
|
|
28296
|
+
throw new TypeError("knowledge map contains a parent cycle");
|
|
28218
28297
|
visited.add(current.key);
|
|
28219
28298
|
if (current.parent === null)
|
|
28220
28299
|
break;
|
|
28221
28300
|
const parent = indexed.get(current.parent);
|
|
28222
28301
|
if (parent === undefined)
|
|
28223
|
-
throw new TypeError(`
|
|
28302
|
+
throw new TypeError(`knowledge-map entry ${current.key} has an unknown parent`);
|
|
28224
28303
|
current = parent;
|
|
28225
28304
|
}
|
|
28226
28305
|
}
|
|
28227
28306
|
}
|
|
28228
|
-
function
|
|
28229
|
-
const result =
|
|
28307
|
+
function validateKnowledgeMap(value) {
|
|
28308
|
+
const result = knowledgeMapSchema.parse(value);
|
|
28230
28309
|
validateEntries(result.entries);
|
|
28231
28310
|
const { revision, ...payload2 } = result;
|
|
28232
28311
|
if (indexerProtocolDigest(payload2) !== revision)
|
|
28233
|
-
throw new TypeError("
|
|
28312
|
+
throw new TypeError("knowledge map revision does not match its content");
|
|
28234
28313
|
return result;
|
|
28235
28314
|
}
|
|
28236
|
-
function
|
|
28237
|
-
const update =
|
|
28315
|
+
function updateKnowledgeMap(current, value) {
|
|
28316
|
+
const update = knowledgeMapUpdateSchema.parse(value);
|
|
28238
28317
|
if ((current?.revision ?? null) !== update.expected_revision)
|
|
28239
|
-
throw new TypeError("
|
|
28318
|
+
throw new TypeError("knowledge map changed; reread the current structure before applying this edit");
|
|
28240
28319
|
const keys = update.upsert.map((entry) => entry.key);
|
|
28241
28320
|
if (new Set(keys).size !== keys.length || new Set(update.remove).size !== update.remove.length || keys.some((key) => update.remove.includes(key))) {
|
|
28242
|
-
throw new TypeError("
|
|
28321
|
+
throw new TypeError("knowledge map update contains conflicting entry identities");
|
|
28243
28322
|
}
|
|
28244
28323
|
const entries = new Map(current?.entries.map((entry) => [entry.key, entry]) ?? []);
|
|
28245
28324
|
for (const key of update.remove)
|
|
@@ -28247,13 +28326,13 @@ function updateReadingStructure(current, value) {
|
|
|
28247
28326
|
for (const entry of update.upsert)
|
|
28248
28327
|
entries.set(entry.key, entry);
|
|
28249
28328
|
const payload2 = {
|
|
28250
|
-
protocol: "context.
|
|
28329
|
+
protocol: "context.knowledge-map/v1",
|
|
28251
28330
|
entries: [...entries.values()].sort((a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0)
|
|
28252
28331
|
};
|
|
28253
28332
|
validateEntries(payload2.entries);
|
|
28254
28333
|
return { ...payload2, revision: indexerProtocolDigest(payload2) };
|
|
28255
28334
|
}
|
|
28256
|
-
function
|
|
28335
|
+
function projectKnowledgeMap(structure, targets) {
|
|
28257
28336
|
const children = new Map;
|
|
28258
28337
|
for (const entry of structure.entries)
|
|
28259
28338
|
children.set(entry.parent, [...children.get(entry.parent) ?? [], entry]);
|
|
@@ -28261,10 +28340,10 @@ function projectReadingStructure(structure, targets) {
|
|
|
28261
28340
|
function project(parent) {
|
|
28262
28341
|
return (children.get(parent) ?? []).sort((a, b) => a.order - b.order || a.key.localeCompare(b.key)).flatMap((entry) => {
|
|
28263
28342
|
const descendants = project(entry.key);
|
|
28264
|
-
const identity2 = entry.target === undefined ? undefined :
|
|
28343
|
+
const identity2 = entry.target === undefined ? undefined : knowledgeMapTargetKey(entry.target);
|
|
28265
28344
|
const href = identity2 === undefined ? undefined : targets.get(identity2);
|
|
28266
28345
|
if (identity2 !== undefined && href === undefined)
|
|
28267
|
-
warnings.push({ entry: entry.key, code: "
|
|
28346
|
+
warnings.push({ entry: entry.key, code: "knowledge-map-target-unavailable", target: identity2 });
|
|
28268
28347
|
if (href === undefined && descendants.length === 0)
|
|
28269
28348
|
return [];
|
|
28270
28349
|
return [{ key: entry.key, title: entry.title, ...href === undefined ? {} : { href }, children: descendants }];
|
|
@@ -28272,11 +28351,23 @@ function projectReadingStructure(structure, targets) {
|
|
|
28272
28351
|
}
|
|
28273
28352
|
return { entries: project(null), warnings };
|
|
28274
28353
|
}
|
|
28275
|
-
function
|
|
28354
|
+
function knowledgeMapTargetKey(target) {
|
|
28276
28355
|
return target.section_key === undefined ? target.artifact_ref : `${target.artifact_ref}#${encodeURIComponent(target.section_key)}`;
|
|
28277
28356
|
}
|
|
28278
28357
|
|
|
28279
28358
|
// src/indexerSemanticInput.ts
|
|
28359
|
+
var catalogProviderSelectionSchema = exports_external.object({
|
|
28360
|
+
id: indexerIdSchema,
|
|
28361
|
+
role: exports_external.enum(["primary", "extension"]).default("primary"),
|
|
28362
|
+
catalog_skill: indexerIdSchema,
|
|
28363
|
+
config: exports_external.record(indexerJsonSchema).optional()
|
|
28364
|
+
}).strict();
|
|
28365
|
+
var providerSelectionEntrySchema = indexerRegistryEntryInputSchema.extend({
|
|
28366
|
+
providers: exports_external.array(exports_external.union([
|
|
28367
|
+
catalogProviderSelectionSchema,
|
|
28368
|
+
indexerRegistryEntryInputSchema.shape.providers.element
|
|
28369
|
+
])).min(1)
|
|
28370
|
+
});
|
|
28280
28371
|
var providerObservationSchema = exports_external.object({
|
|
28281
28372
|
skill: exports_external.string().min(1),
|
|
28282
28373
|
version: exports_external.string().min(1).nullable(),
|
|
@@ -28290,7 +28381,7 @@ var providerObservationSchema = exports_external.object({
|
|
|
28290
28381
|
var indexerProviderSelectionSemanticInputSchema = exports_external.object({
|
|
28291
28382
|
stage: exports_external.literal("provider-selection"),
|
|
28292
28383
|
host_visible_skills: exports_external.array(providerObservationSchema).default([]),
|
|
28293
|
-
indexers: exports_external.array(
|
|
28384
|
+
indexers: exports_external.array(providerSelectionEntrySchema).min(1)
|
|
28294
28385
|
}).strict();
|
|
28295
28386
|
var indexerProviderResolutionSemanticInputSchema = exports_external.object({
|
|
28296
28387
|
stage: exports_external.literal("provider-resolution"),
|
|
@@ -28558,7 +28649,7 @@ var indexerPostAuthorBatchSemanticInputSchema = exports_external.object({
|
|
|
28558
28649
|
});
|
|
28559
28650
|
var structureReviewBaseSchema = exports_external.object({
|
|
28560
28651
|
stage: exports_external.literal("structure-review"),
|
|
28561
|
-
|
|
28652
|
+
knowledge_map: knowledgeMapUpdateSchema.optional(),
|
|
28562
28653
|
decision: exports_external.enum(["approved", "exclude-obsolete", "request-adjustment"]),
|
|
28563
28654
|
feedback: exports_external.string().min(1).optional()
|
|
28564
28655
|
}).strict();
|
|
@@ -34418,12 +34509,14 @@ var kbPackage = (definition) => {
|
|
|
34418
34509
|
const base = createPackageDefinitionBase("kb", definition);
|
|
34419
34510
|
const distribution = normalizePackageDistribution(definition.distribution);
|
|
34420
34511
|
const assets = normalizePackageAssets(definition.assets);
|
|
34512
|
+
const site = normalizePackageSite(definition.site);
|
|
34421
34513
|
return {
|
|
34422
34514
|
kind: "package.kb",
|
|
34423
34515
|
...base,
|
|
34424
34516
|
navigation: normalizePackageNavigation(definition.navigation),
|
|
34425
34517
|
...distribution === undefined ? {} : { distribution },
|
|
34426
|
-
assets
|
|
34518
|
+
assets,
|
|
34519
|
+
...site === undefined ? {} : { site }
|
|
34427
34520
|
};
|
|
34428
34521
|
};
|
|
34429
34522
|
var llmsPackage = (definition) => ({
|
|
@@ -34435,7 +34528,7 @@ export {
|
|
|
34435
34528
|
validatedIndexerCustomizationDraftSchema,
|
|
34436
34529
|
validateValidatedIndexerCustomizationDraft,
|
|
34437
34530
|
validateResolvedProviderBundle,
|
|
34438
|
-
|
|
34531
|
+
validateKnowledgeMap,
|
|
34439
34532
|
validateIndexerToolSnapshot,
|
|
34440
34533
|
validateIndexerTargetResolutionView,
|
|
34441
34534
|
validateIndexerSubjectKeyForSchema,
|
|
@@ -34575,7 +34668,7 @@ export {
|
|
|
34575
34668
|
validateArtifactResults,
|
|
34576
34669
|
validateAndRecordIndexerMainRun,
|
|
34577
34670
|
validateAndMaterializeIndexerLayerFragment,
|
|
34578
|
-
|
|
34671
|
+
updateKnowledgeMap,
|
|
34579
34672
|
startIndexerPostAuthorRun,
|
|
34580
34673
|
startIndexerMainRuns,
|
|
34581
34674
|
startIndexerMainRun,
|
|
@@ -34609,14 +34702,10 @@ export {
|
|
|
34609
34702
|
recoverIndexerPostAuthorRunLedger,
|
|
34610
34703
|
recoverIndexerMainRunLedger,
|
|
34611
34704
|
reconcileIndexerResults,
|
|
34612
|
-
readingTargetKey,
|
|
34613
|
-
readingStructureUpdateSchema,
|
|
34614
|
-
readingStructureSchema,
|
|
34615
|
-
readingStructureEntrySchema,
|
|
34616
34705
|
readSessionChanges,
|
|
34617
34706
|
readProcessedScopes,
|
|
34618
34707
|
questionPairs,
|
|
34619
|
-
|
|
34708
|
+
projectKnowledgeMap,
|
|
34620
34709
|
projectIndexerSourceIdentityInventory,
|
|
34621
34710
|
projectIndexerPublicContractTable,
|
|
34622
34711
|
projectIndexerPartitionSubjects,
|
|
@@ -34630,6 +34719,7 @@ export {
|
|
|
34630
34719
|
parseIndexerRegistry,
|
|
34631
34720
|
parseIndexerProviderManifest,
|
|
34632
34721
|
parseIndexerCurrentActionSubmission,
|
|
34722
|
+
packageSiteSchema,
|
|
34633
34723
|
ownerCells,
|
|
34634
34724
|
observeIndexerPostAuthorState,
|
|
34635
34725
|
observeIndexerMainWorksetState,
|
|
@@ -34651,6 +34741,10 @@ export {
|
|
|
34651
34741
|
loadIndexerRegistry,
|
|
34652
34742
|
loadIndexerProviderManifest,
|
|
34653
34743
|
llmsPackage,
|
|
34744
|
+
knowledgeMapUpdateSchema,
|
|
34745
|
+
knowledgeMapTargetKey,
|
|
34746
|
+
knowledgeMapSchema,
|
|
34747
|
+
knowledgeMapEntrySchema,
|
|
34654
34748
|
kbPackage,
|
|
34655
34749
|
isPortableIndexerPath,
|
|
34656
34750
|
isIndexerProviderProtocol,
|
|
@@ -10,11 +10,11 @@ export declare const indexerArtifactPolicyEligibilitySchema: z.ZodObject<{
|
|
|
10
10
|
path: z.ZodString;
|
|
11
11
|
value: z.ZodType<IndexerJson, z.ZodTypeDef, IndexerJson>;
|
|
12
12
|
}, "strict", z.ZodTypeAny, {
|
|
13
|
-
path: string;
|
|
14
13
|
value: IndexerJson;
|
|
15
|
-
}, {
|
|
16
14
|
path: string;
|
|
15
|
+
}, {
|
|
17
16
|
value: IndexerJson;
|
|
17
|
+
path: string;
|
|
18
18
|
}>, "many">;
|
|
19
19
|
provider_supported_variants: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
20
20
|
eligible_variants: z.ZodArray<z.ZodObject<{
|
|
@@ -71,8 +71,8 @@ export declare const indexerArtifactPolicyEligibilitySchema: z.ZodObject<{
|
|
|
71
71
|
profile_id: string;
|
|
72
72
|
profile_contract_digest: string;
|
|
73
73
|
canonical_facts: {
|
|
74
|
-
path: string;
|
|
75
74
|
value: IndexerJson;
|
|
75
|
+
path: string;
|
|
76
76
|
}[];
|
|
77
77
|
provider_supported_variants: string[];
|
|
78
78
|
eligible_variants: {
|
|
@@ -94,8 +94,8 @@ export declare const indexerArtifactPolicyEligibilitySchema: z.ZodObject<{
|
|
|
94
94
|
profile_id: string;
|
|
95
95
|
profile_contract_digest: string;
|
|
96
96
|
canonical_facts: {
|
|
97
|
-
path: string;
|
|
98
97
|
value: IndexerJson;
|
|
98
|
+
path: string;
|
|
99
99
|
}[];
|
|
100
100
|
provider_supported_variants: string[];
|
|
101
101
|
eligible_variants: {
|