@c4a/context 0.6.1 → 0.6.3
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 +25 -6
- package/README.zh-CN.md +128 -0
- package/contracts.d.ts +5 -0
- package/docs/README.md +24 -8
- package/docs/getting-started.md +81 -35
- package/docs/guides/agent-dialogue.md +38 -350
- package/docs/guides/agent-guide.md +144 -94
- package/docs/guides/lark-resources.md +115 -0
- package/docs/guides/package-outputs.md +95 -25
- package/docs/reference/package-templates.md +121 -32
- package/docs/reference/project-api.md +261 -84
- package/docs/reference/template-variables.md +32 -15
- package/index.d.ts +13 -5
- package/index.js +113 -29
- package/package.json +4 -1
- package/phases.d.ts +75 -6
- package/templates/package-templates/kb/AGENTS.md +13 -16
- package/templates/package-templates/kb/skills/knowledge-query/SKILL.md +102 -177
- package/templates/package-templates/kb/skills/knowledge-query/scripts/search.mjs +268 -0
- package/templates/package-templates/kb/wikis/index.md +8 -8
- package/templates/package-templates/llms/llms.txt +0 -1
- package/templates/package-templates.zh-CN/kb/AGENTS.md +30 -0
- package/templates/package-templates.zh-CN/kb/skills/knowledge-query/SKILL.md +99 -0
- package/templates/package-templates.zh-CN/kb/skills/knowledge-query/scripts/search.mjs +268 -0
- package/templates/package-templates.zh-CN/kb/wikis/index.md +39 -0
- package/templates/package-templates.zh-CN/llms/llms.txt +8 -0
- package/templates/project-skills/maintain-project-knowledge/SKILL.md +58 -0
- package/templates/project-skills.zh-CN/maintain-project-knowledge/SKILL.md +48 -0
package/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { PackageSelectDefinition } from "./contracts.js";
|
|
1
|
+
import type { PackageNavigationDefinition, PackageSelectDefinition } from "./contracts.js";
|
|
2
2
|
import type { PhaseDefinition, PhaseResourceReference } from "./phases.js";
|
|
3
3
|
import type { ProjectSourceDefinition } from "./sources.js";
|
|
4
|
-
export type { CodegraphCollection, DocumentMainlineCollection, EntityStatus, KnowledgeCollection, MainlineCollection, MarkdownTransform, FileCaptureProcessorDefinition, OkfRoot, PackageKind, PackageSelectDefinition, TopLevelNamespace, } from "./contracts.js";
|
|
5
|
-
export { assertDocumentMainlineCollection, assertKnowledgeCollection, assertMainlineCollection, assertOkfRoot, assertTopLevelNamespace, DOC_MAINLINE_COLLECTIONS, KNOWLEDGE_COLLECTIONS, MAINLINE_COLLECTIONS, OKF_ROOTS, TOP_LEVEL_NAMESPACES, } from "./contracts.js";
|
|
4
|
+
export type { CodegraphCollection, DocumentMainlineCollection, EntityStatus, KnowledgeCollection, MainlineCollection, MarkdownTransform, FileCaptureProcessorDefinition, OkfRoot, PackageKind, PackageNavigationDefinition, PackageSelectDefinition, TopLevelNamespace, } from "./contracts.js";
|
|
5
|
+
export { assertDocumentMainlineCollection, assertKnowledgeCollection, assertMainlineCollection, assertOkfRoot, assertTopLevelNamespace, DOC_MAINLINE_COLLECTIONS, DEFAULT_PACKAGE_NAVIGATION, KNOWLEDGE_COLLECTIONS, MAINLINE_COLLECTIONS, OKF_ROOTS, TOP_LEVEL_NAMESPACES, } from "./contracts.js";
|
|
6
6
|
export { assertDocumentEvidenceSectionMetadata, DOCUMENT_COMPILE_ACTION_SCHEMA_VERSION, DOCUMENT_EVIDENCE_SECTION_VALIDATION_STAGES, DOCUMENT_SECTION_CONTENT_MODES, DOCUMENT_STRUCTURE_SCHEMA_VERSION, } from "./documentEvidence.js";
|
|
7
7
|
export type { DocumentEvidenceSectionMetadata, DocumentEvidenceSectionValidationOptions, DocumentEvidenceSectionValidationStage, DocumentSectionContentMode, } from "./documentEvidence.js";
|
|
8
|
-
export { alignProse, captureFile, captureLark, compileProse, customPhase, extractTs, ExtractTsConfigurationError, NO_ENTRY_DETECTED, mdxJsonDocs, reviewValidity, } from "./phases.js";
|
|
9
|
-
export type { AlignProsePhaseDefinition, CaptureFilePhaseDefinition, CaptureLarkPhaseDefinition, CompileProsePhaseDefinition, ContextPhase, ContextPhaseContext, CustomPhaseDefinition, ExtractTsPhaseDefinition, PhaseDefinition, PhaseResourceReference, ReviewValidityPhaseDefinition, ReviewValidityScope, } from "./phases.js";
|
|
8
|
+
export { alignProse, captureFile, captureLark, compileProse, customPhase, extractCustom, extractTs, ExtractTsConfigurationError, NO_ENTRY_DETECTED, mdxJsonDocs, reviewValidity, } from "./phases.js";
|
|
9
|
+
export type { AlignProsePhaseDefinition, CaptureFilePhaseDefinition, CaptureLarkPhaseDefinition, CompileProsePhaseDefinition, ContextPhase, ContextPhaseContext, CustomPhaseDefinition, CustomCodeCandidateDraft, CustomCodeCandidateEdge, CustomCodeCandidateReview, CustomCodeEvidence, CustomCodeExtractionContext, CustomCodeExtractionResult, CustomCodeExtractor, ExtractCustomPhaseDefinition, ExtractTsPhaseDefinition, PhaseDefinition, PhaseResourceReference, ReviewValidityPhaseDefinition, ReviewValidityScope, } from "./phases.js";
|
|
10
10
|
export { allSources, DEFAULT_FILE_SOURCES_REGISTRY_PATH, DEFAULT_LARK_SOURCES_REGISTRY_PATH, DEFAULT_REPO_SOURCES_REGISTRY_PATH, loadSourcesRegistry, resolveSourceReference, source, } from "./sources.js";
|
|
11
11
|
export type { DocumentSourceDefinition, DocumentSourceReference, DocumentSourceType, FileSourceDefinition, FileSourceReference, FileSourceRegistryEntry, LarkSourceDefinition, LarkSourceReference, LarkSourceRegistryEntry, LoadSourcesRegistryOptions, ProjectSourceDefinition, RepoProjectSourceDefinition, RepoSourceDefinition, RepoSourceReference, RepoSourceRegistryEntry, RepoSourcesRegistry, SourceCollectionReference, SourceDefinition, SourceReference, SourcesRegistry, SourceType, } from "./sources.js";
|
|
12
12
|
export type TemplateVarValue = string | number | boolean | null | Record<string, unknown> | readonly Record<string, unknown>[];
|
|
@@ -18,6 +18,10 @@ export type PackageTemplateInput = string | {
|
|
|
18
18
|
path: string;
|
|
19
19
|
vars?: Record<string, TemplateVarValue>;
|
|
20
20
|
};
|
|
21
|
+
export type PackageDistributionDefinition = {
|
|
22
|
+
/** @deprecated Accepted for older workspaces; package output roots are flat. */
|
|
23
|
+
knowledgeNamespace: string;
|
|
24
|
+
};
|
|
21
25
|
export type BasePackageDefinition = {
|
|
22
26
|
name: string;
|
|
23
27
|
reads: readonly PhaseResourceReference[];
|
|
@@ -28,6 +32,8 @@ export type BasePackageDefinition = {
|
|
|
28
32
|
};
|
|
29
33
|
export type KbPackageDefinition = BasePackageDefinition & {
|
|
30
34
|
kind: "package.kb";
|
|
35
|
+
navigation: PackageNavigationDefinition;
|
|
36
|
+
distribution?: PackageDistributionDefinition;
|
|
31
37
|
};
|
|
32
38
|
export type LlmsPackageDefinition = BasePackageDefinition & {
|
|
33
39
|
kind: "package.llms";
|
|
@@ -47,6 +53,8 @@ export declare const kbPackage: (definition: {
|
|
|
47
53
|
name: string;
|
|
48
54
|
template: PackageTemplateInput;
|
|
49
55
|
select?: PackageSelectDefinition;
|
|
56
|
+
navigation?: Partial<PackageNavigationDefinition>;
|
|
57
|
+
distribution?: PackageDistributionDefinition;
|
|
50
58
|
}) => KbPackageDefinition;
|
|
51
59
|
export declare const llmsPackage: (definition: {
|
|
52
60
|
name: string;
|
package/index.js
CHANGED
|
@@ -6916,6 +6916,10 @@ var require_public_api = __commonJS((exports) => {
|
|
|
6916
6916
|
});
|
|
6917
6917
|
|
|
6918
6918
|
// src/contracts.ts
|
|
6919
|
+
var DEFAULT_PACKAGE_NAVIGATION = {
|
|
6920
|
+
foldDirectoryIndexes: true,
|
|
6921
|
+
maxInlineEntries: 50
|
|
6922
|
+
};
|
|
6919
6923
|
var DOC_MAINLINE_COLLECTIONS = [
|
|
6920
6924
|
"business",
|
|
6921
6925
|
"product",
|
|
@@ -7084,9 +7088,9 @@ var sourceSnapshotResource = (sourceDefinition, sourceType) => ({
|
|
|
7084
7088
|
sourceType,
|
|
7085
7089
|
path: `sources/${sourceType}/${getSourceName(sourceDefinition)}/manifest.json`
|
|
7086
7090
|
});
|
|
7087
|
-
var
|
|
7088
|
-
kind: "
|
|
7089
|
-
path: "
|
|
7091
|
+
var lifecycleStructureResource = (collection, status) => ({
|
|
7092
|
+
kind: "lifecycle.structure",
|
|
7093
|
+
path: ".tmp/context-runtime/lifecycle/structure.yaml",
|
|
7090
7094
|
profileCollection: collection,
|
|
7091
7095
|
...status === undefined ? {} : { status }
|
|
7092
7096
|
});
|
|
@@ -7124,6 +7128,14 @@ var captureFile = (definition) => {
|
|
|
7124
7128
|
var captureLark = (definition) => {
|
|
7125
7129
|
const sourceDefinition = bindSourceType(definition.source, "lark", "captureLark source");
|
|
7126
7130
|
const sourceId = getSourceName(sourceDefinition);
|
|
7131
|
+
const maxBytesPerResource = definition.resources?.maxBytesPerResource ?? 20 * 1024 * 1024;
|
|
7132
|
+
const maxTotalBytes = definition.resources?.maxTotalBytes ?? 200 * 1024 * 1024;
|
|
7133
|
+
if (!Number.isSafeInteger(maxBytesPerResource) || maxBytesPerResource < 1) {
|
|
7134
|
+
throw new TypeError("captureLark resources.maxBytesPerResource must be a positive safe integer");
|
|
7135
|
+
}
|
|
7136
|
+
if (!Number.isSafeInteger(maxTotalBytes) || maxTotalBytes < maxBytesPerResource) {
|
|
7137
|
+
throw new TypeError("captureLark resources.maxTotalBytes must be a safe integer greater than or equal to maxBytesPerResource");
|
|
7138
|
+
}
|
|
7127
7139
|
return {
|
|
7128
7140
|
kind: "phase.capture.lark",
|
|
7129
7141
|
id: `capture:lark:${sourceId}`,
|
|
@@ -7132,7 +7144,12 @@ var captureLark = (definition) => {
|
|
|
7132
7144
|
source: sourceDefinition
|
|
7133
7145
|
}],
|
|
7134
7146
|
writes: [sourceSnapshotResource(sourceDefinition, "lark")],
|
|
7135
|
-
source: sourceDefinition
|
|
7147
|
+
source: sourceDefinition,
|
|
7148
|
+
resources: {
|
|
7149
|
+
videos: definition.resources?.videos ?? "reference-only",
|
|
7150
|
+
maxBytesPerResource,
|
|
7151
|
+
maxTotalBytes
|
|
7152
|
+
}
|
|
7136
7153
|
};
|
|
7137
7154
|
};
|
|
7138
7155
|
var alignProse = (definition) => {
|
|
@@ -7146,7 +7163,7 @@ var alignProse = (definition) => {
|
|
|
7146
7163
|
kind: "source",
|
|
7147
7164
|
source: definition.source
|
|
7148
7165
|
}],
|
|
7149
|
-
writes: [
|
|
7166
|
+
writes: [lifecycleStructureResource(definition.collection, "draft")],
|
|
7150
7167
|
source: definition.source,
|
|
7151
7168
|
collection: definition.collection
|
|
7152
7169
|
};
|
|
@@ -7156,7 +7173,7 @@ var alignProse = (definition) => {
|
|
|
7156
7173
|
kind: "phase.align.prose",
|
|
7157
7174
|
id: `align:${sourceType}:${sourceId}:${definition.collection}`,
|
|
7158
7175
|
reads: [sourceSnapshotResource(definition.source, sourceType)],
|
|
7159
|
-
writes: [
|
|
7176
|
+
writes: [lifecycleStructureResource(definition.collection, "draft")],
|
|
7160
7177
|
source: definition.source,
|
|
7161
7178
|
sourceType,
|
|
7162
7179
|
collection: definition.collection
|
|
@@ -7172,12 +7189,12 @@ var compileProse = (definition) => {
|
|
|
7172
7189
|
reads: [{
|
|
7173
7190
|
kind: "source",
|
|
7174
7191
|
source: definition.source
|
|
7175
|
-
},
|
|
7192
|
+
}, lifecycleStructureResource(definition.collection, "confirmed")],
|
|
7176
7193
|
writes: [
|
|
7177
|
-
|
|
7194
|
+
lifecycleStructureResource(definition.collection, "frozen"),
|
|
7178
7195
|
{
|
|
7179
|
-
kind: "
|
|
7180
|
-
path: "
|
|
7196
|
+
kind: "lifecycle.candidates",
|
|
7197
|
+
path: ".tmp/context-runtime/lifecycle/candidates.jsonl",
|
|
7181
7198
|
status: "draft"
|
|
7182
7199
|
}
|
|
7183
7200
|
],
|
|
@@ -7192,13 +7209,13 @@ var compileProse = (definition) => {
|
|
|
7192
7209
|
id: `compile:${sourceType}:${sourceId}:${definition.collection}`,
|
|
7193
7210
|
reads: [
|
|
7194
7211
|
sourceSnapshotResource(definition.source, sourceType),
|
|
7195
|
-
|
|
7212
|
+
lifecycleStructureResource(definition.collection, "confirmed")
|
|
7196
7213
|
],
|
|
7197
7214
|
writes: [
|
|
7198
|
-
|
|
7215
|
+
lifecycleStructureResource(definition.collection, "frozen"),
|
|
7199
7216
|
{
|
|
7200
|
-
kind: "
|
|
7201
|
-
path: "
|
|
7217
|
+
kind: "lifecycle.candidates",
|
|
7218
|
+
path: ".tmp/context-runtime/lifecycle/candidates.jsonl",
|
|
7202
7219
|
status: "draft"
|
|
7203
7220
|
}
|
|
7204
7221
|
],
|
|
@@ -7230,8 +7247,8 @@ var extractTs = (definition) => {
|
|
|
7230
7247
|
source: sourceDefinition
|
|
7231
7248
|
}],
|
|
7232
7249
|
writes: [{
|
|
7233
|
-
kind: "
|
|
7234
|
-
path: "
|
|
7250
|
+
kind: "lifecycle.candidates",
|
|
7251
|
+
path: ".tmp/context-runtime/lifecycle/candidates.jsonl",
|
|
7235
7252
|
collection: definition.collection,
|
|
7236
7253
|
status: "draft"
|
|
7237
7254
|
}],
|
|
@@ -7243,7 +7260,7 @@ var extractTs = (definition) => {
|
|
|
7243
7260
|
exportedOnly: definition.exportedOnly ?? mode === "exports",
|
|
7244
7261
|
out: {
|
|
7245
7262
|
kind: "codegraph-entities",
|
|
7246
|
-
candidateFile: "
|
|
7263
|
+
candidateFile: ".tmp/context-runtime/lifecycle/candidates.jsonl",
|
|
7247
7264
|
approvedPagesDir: `knowledge/${definition.collection}`,
|
|
7248
7265
|
initialStatus: "draft"
|
|
7249
7266
|
}
|
|
@@ -7253,6 +7270,31 @@ var extractTs = (definition) => {
|
|
|
7253
7270
|
}
|
|
7254
7271
|
return phase;
|
|
7255
7272
|
};
|
|
7273
|
+
var extractCustom = (definition) => {
|
|
7274
|
+
const id = definition.id.trim();
|
|
7275
|
+
if (id.length === 0)
|
|
7276
|
+
throw new TypeError("extractCustom id must be a non-empty phase id");
|
|
7277
|
+
if (definition.sources.length === 0)
|
|
7278
|
+
throw new TypeError("extractCustom sources must contain at least one repo source");
|
|
7279
|
+
if (definition.collection !== "codegraph") {
|
|
7280
|
+
throw new TypeError(`extractCustom collection must be codegraph: ${definition.collection}`);
|
|
7281
|
+
}
|
|
7282
|
+
const sources = definition.sources.map((sourceDefinition) => bindSourceType(sourceDefinition, "repo", "extractCustom source"));
|
|
7283
|
+
return {
|
|
7284
|
+
kind: "phase.extract.custom",
|
|
7285
|
+
id,
|
|
7286
|
+
reads: sources.map((sourceDefinition) => ({ kind: "source", source: sourceDefinition })),
|
|
7287
|
+
writes: [{
|
|
7288
|
+
kind: "lifecycle.candidates",
|
|
7289
|
+
path: ".tmp/context-runtime/lifecycle/candidates.jsonl",
|
|
7290
|
+
collection: definition.collection,
|
|
7291
|
+
status: "draft"
|
|
7292
|
+
}],
|
|
7293
|
+
sources,
|
|
7294
|
+
collection: definition.collection,
|
|
7295
|
+
extract: definition.extract
|
|
7296
|
+
};
|
|
7297
|
+
};
|
|
7256
7298
|
var reviewValidity = (definition) => {
|
|
7257
7299
|
const payload = definition.payload ?? "review-payload.json";
|
|
7258
7300
|
if ("scope" in definition) {
|
|
@@ -7263,8 +7305,8 @@ var reviewValidity = (definition) => {
|
|
|
7263
7305
|
kind: "phase.review.validity",
|
|
7264
7306
|
id: "review:all:validity",
|
|
7265
7307
|
reads: [{
|
|
7266
|
-
kind: "
|
|
7267
|
-
path: "
|
|
7308
|
+
kind: "lifecycle.candidates",
|
|
7309
|
+
path: ".tmp/context-runtime/lifecycle/candidates.jsonl",
|
|
7268
7310
|
status: "draft"
|
|
7269
7311
|
}],
|
|
7270
7312
|
writes: [
|
|
@@ -7277,8 +7319,12 @@ var reviewValidity = (definition) => {
|
|
|
7277
7319
|
path: "knowledge"
|
|
7278
7320
|
},
|
|
7279
7321
|
{
|
|
7280
|
-
kind: "
|
|
7281
|
-
path: "
|
|
7322
|
+
kind: "knowledge.decisions",
|
|
7323
|
+
path: "knowledge/decisions.json"
|
|
7324
|
+
},
|
|
7325
|
+
{
|
|
7326
|
+
kind: "lifecycle.candidates",
|
|
7327
|
+
path: ".tmp/context-runtime/lifecycle/candidates.jsonl",
|
|
7282
7328
|
status: "rejected"
|
|
7283
7329
|
}
|
|
7284
7330
|
],
|
|
@@ -7293,8 +7339,8 @@ var reviewValidity = (definition) => {
|
|
|
7293
7339
|
kind: "phase.review.validity",
|
|
7294
7340
|
id: `review:${definition.collection}:validity`,
|
|
7295
7341
|
reads: [{
|
|
7296
|
-
kind: "
|
|
7297
|
-
path: "
|
|
7342
|
+
kind: "lifecycle.candidates",
|
|
7343
|
+
path: ".tmp/context-runtime/lifecycle/candidates.jsonl",
|
|
7298
7344
|
collection: definition.collection,
|
|
7299
7345
|
status: "draft"
|
|
7300
7346
|
}],
|
|
@@ -7310,8 +7356,12 @@ var reviewValidity = (definition) => {
|
|
|
7310
7356
|
status: "approved"
|
|
7311
7357
|
},
|
|
7312
7358
|
{
|
|
7313
|
-
kind: "
|
|
7314
|
-
path: "
|
|
7359
|
+
kind: "knowledge.decisions",
|
|
7360
|
+
path: "knowledge/decisions.json"
|
|
7361
|
+
},
|
|
7362
|
+
{
|
|
7363
|
+
kind: "lifecycle.candidates",
|
|
7364
|
+
path: ".tmp/context-runtime/lifecycle/candidates.jsonl",
|
|
7315
7365
|
collection: definition.collection,
|
|
7316
7366
|
status: "rejected"
|
|
7317
7367
|
}
|
|
@@ -11818,7 +11868,20 @@ var normalizeSelect = (select) => {
|
|
|
11818
11868
|
}
|
|
11819
11869
|
return Object.keys(normalized).length > 0 ? normalized : undefined;
|
|
11820
11870
|
};
|
|
11871
|
+
var normalizePackageNavigation = (navigation) => {
|
|
11872
|
+
const maxInlineEntries = navigation?.maxInlineEntries ?? DEFAULT_PACKAGE_NAVIGATION.maxInlineEntries;
|
|
11873
|
+
if (!Number.isSafeInteger(maxInlineEntries) || maxInlineEntries < 1) {
|
|
11874
|
+
throw new TypeError(`Package navigation.maxInlineEntries must be a positive safe integer: ${maxInlineEntries}`);
|
|
11875
|
+
}
|
|
11876
|
+
return {
|
|
11877
|
+
foldDirectoryIndexes: navigation?.foldDirectoryIndexes ?? DEFAULT_PACKAGE_NAVIGATION.foldDirectoryIndexes,
|
|
11878
|
+
maxInlineEntries
|
|
11879
|
+
};
|
|
11880
|
+
};
|
|
11821
11881
|
var PACKAGE_NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/u;
|
|
11882
|
+
var PACKAGE_KNOWLEDGE_NAMESPACE_SEGMENT_PATTERN = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/u;
|
|
11883
|
+
var PACKAGE_KNOWLEDGE_NAMESPACE_SEGMENT_MAX_LENGTH = 48;
|
|
11884
|
+
var PACKAGE_KNOWLEDGE_NAMESPACE_MAX_LENGTH = 128;
|
|
11822
11885
|
var isSafeProjectRelativePath = (value) => {
|
|
11823
11886
|
if (value.length === 0)
|
|
11824
11887
|
return false;
|
|
@@ -11838,6 +11901,19 @@ var assertSelectCollections = (collections) => {
|
|
|
11838
11901
|
assertKnowledgeCollection(collection, "Package select.collections");
|
|
11839
11902
|
}
|
|
11840
11903
|
};
|
|
11904
|
+
var normalizePackageDistribution = (distribution) => {
|
|
11905
|
+
if (distribution === undefined)
|
|
11906
|
+
return;
|
|
11907
|
+
if (typeof distribution.knowledgeNamespace !== "string") {
|
|
11908
|
+
throw new TypeError("Package distribution.knowledgeNamespace must be a string.");
|
|
11909
|
+
}
|
|
11910
|
+
const knowledgeNamespace = distribution.knowledgeNamespace.trim();
|
|
11911
|
+
const segments = knowledgeNamespace.split("/");
|
|
11912
|
+
if (knowledgeNamespace.length > PACKAGE_KNOWLEDGE_NAMESPACE_MAX_LENGTH || segments.length === 0 || segments.some((segment) => segment.length > PACKAGE_KNOWLEDGE_NAMESPACE_SEGMENT_MAX_LENGTH || !PACKAGE_KNOWLEDGE_NAMESPACE_SEGMENT_PATTERN.test(segment))) {
|
|
11913
|
+
throw new TypeError(`Package distribution.knowledgeNamespace must contain safe lowercase path segments using letters, numbers, hyphens, or dots, separated by "/", and be at most ${PACKAGE_KNOWLEDGE_NAMESPACE_MAX_LENGTH} characters: ${distribution.knowledgeNamespace}`);
|
|
11914
|
+
}
|
|
11915
|
+
return { knowledgeNamespace };
|
|
11916
|
+
};
|
|
11841
11917
|
var assertSelectOkfRoots = (roots) => {
|
|
11842
11918
|
for (const root of roots) {
|
|
11843
11919
|
assertOkfRoot(root, "Package select.okfRoots");
|
|
@@ -11880,10 +11956,16 @@ var createPackageDefinitionBase = (kind, definition) => {
|
|
|
11880
11956
|
}
|
|
11881
11957
|
return packageDefinition;
|
|
11882
11958
|
};
|
|
11883
|
-
var kbPackage = (definition) =>
|
|
11884
|
-
|
|
11885
|
-
|
|
11886
|
-
|
|
11959
|
+
var kbPackage = (definition) => {
|
|
11960
|
+
const base = createPackageDefinitionBase("kb", definition);
|
|
11961
|
+
const distribution = normalizePackageDistribution(definition.distribution);
|
|
11962
|
+
return {
|
|
11963
|
+
kind: "package.kb",
|
|
11964
|
+
...base,
|
|
11965
|
+
navigation: normalizePackageNavigation(definition.navigation),
|
|
11966
|
+
...distribution === undefined ? {} : { distribution }
|
|
11967
|
+
};
|
|
11968
|
+
};
|
|
11887
11969
|
var llmsPackage = (definition) => ({
|
|
11888
11970
|
kind: "package.llms",
|
|
11889
11971
|
...createPackageDefinitionBase("llms", definition)
|
|
@@ -11897,6 +11979,7 @@ export {
|
|
|
11897
11979
|
llmsPackage,
|
|
11898
11980
|
kbPackage,
|
|
11899
11981
|
extractTs,
|
|
11982
|
+
extractCustom,
|
|
11900
11983
|
defineProject,
|
|
11901
11984
|
customPhase,
|
|
11902
11985
|
compileProse,
|
|
@@ -11922,6 +12005,7 @@ export {
|
|
|
11922
12005
|
DOCUMENT_EVIDENCE_SECTION_VALIDATION_STAGES,
|
|
11923
12006
|
DOCUMENT_COMPILE_ACTION_SCHEMA_VERSION,
|
|
11924
12007
|
DEFAULT_REPO_SOURCES_REGISTRY_PATH,
|
|
12008
|
+
DEFAULT_PACKAGE_NAVIGATION,
|
|
11925
12009
|
DEFAULT_LARK_SOURCES_REGISTRY_PATH,
|
|
11926
12010
|
DEFAULT_FILE_SOURCES_REGISTRY_PATH
|
|
11927
12011
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c4a/context",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Context SDK — project-local configuration and workspace primitives",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"knowledge",
|
|
16
16
|
"workspace"
|
|
17
17
|
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20"
|
|
20
|
+
},
|
|
18
21
|
"dependencies": {
|
|
19
22
|
"yaml": "^2.5.1",
|
|
20
23
|
"zod": "^3.23.8"
|
package/phases.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type FileCaptureProcessorDefinition, type KnowledgeCollection, type MarkdownTransform, type PackageKind, type PackageSelectDefinition, type DocumentMainlineCollection } from "./contracts.js";
|
|
2
2
|
import { DOCUMENT_COMPILE_ACTION_SCHEMA_VERSION } from "./documentEvidence.js";
|
|
3
3
|
import type { DocumentSourceDefinition, DocumentSourceType, FileSourceDefinition, FileSourceReference, LarkSourceDefinition, LarkSourceReference, RepoProjectSourceDefinition, SourceCollectionReference, SourceDefinition } from "./sources.js";
|
|
4
4
|
export type PhaseResourceReference = {
|
|
@@ -10,13 +10,13 @@ export type PhaseResourceReference = {
|
|
|
10
10
|
sourceType: DocumentSourceType;
|
|
11
11
|
path: string;
|
|
12
12
|
} | {
|
|
13
|
-
kind: "
|
|
13
|
+
kind: "lifecycle.candidates";
|
|
14
14
|
path: string;
|
|
15
15
|
collection?: KnowledgeCollection;
|
|
16
|
-
status?:
|
|
16
|
+
status?: "draft" | "rejected";
|
|
17
17
|
} | {
|
|
18
|
-
kind: "
|
|
19
|
-
path: "
|
|
18
|
+
kind: "lifecycle.structure";
|
|
19
|
+
path: ".tmp/context-runtime/lifecycle/structure.yaml";
|
|
20
20
|
profileCollection?: DocumentMainlineCollection;
|
|
21
21
|
status?: "draft" | "confirmed" | "frozen";
|
|
22
22
|
} | {
|
|
@@ -28,6 +28,9 @@ export type PhaseResourceReference = {
|
|
|
28
28
|
kind: "knowledge.approved";
|
|
29
29
|
path: "knowledge";
|
|
30
30
|
select?: PackageSelectDefinition;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "knowledge.decisions";
|
|
33
|
+
path: "knowledge/decisions.json";
|
|
31
34
|
} | {
|
|
32
35
|
kind: "package.template";
|
|
33
36
|
path: string;
|
|
@@ -71,6 +74,56 @@ export type ExtractTsPhaseDefinition = {
|
|
|
71
74
|
initialStatus: "draft";
|
|
72
75
|
};
|
|
73
76
|
};
|
|
77
|
+
export interface CustomCodeEvidence {
|
|
78
|
+
source: string;
|
|
79
|
+
file: string;
|
|
80
|
+
symbol: string;
|
|
81
|
+
kind: string;
|
|
82
|
+
digest: string;
|
|
83
|
+
line?: number;
|
|
84
|
+
}
|
|
85
|
+
export interface CustomCodeCandidateReview {
|
|
86
|
+
title: string;
|
|
87
|
+
summary: string;
|
|
88
|
+
behaviorSummary?: string;
|
|
89
|
+
edgeSummary?: string;
|
|
90
|
+
signals: readonly string[];
|
|
91
|
+
reason: string;
|
|
92
|
+
}
|
|
93
|
+
export interface CustomCodeCandidateEdge {
|
|
94
|
+
type: "contains" | "depends_on";
|
|
95
|
+
from: string;
|
|
96
|
+
to: string;
|
|
97
|
+
relationType: string;
|
|
98
|
+
evidence: readonly CustomCodeEvidence[];
|
|
99
|
+
}
|
|
100
|
+
export interface CustomCodeCandidateDraft {
|
|
101
|
+
nodeRef: string;
|
|
102
|
+
kind: string;
|
|
103
|
+
visibility: string;
|
|
104
|
+
module: string;
|
|
105
|
+
markdown: string;
|
|
106
|
+
evidence: readonly CustomCodeEvidence[];
|
|
107
|
+
review: CustomCodeCandidateReview;
|
|
108
|
+
edges?: readonly CustomCodeCandidateEdge[];
|
|
109
|
+
}
|
|
110
|
+
export interface CustomCodeExtractionResult {
|
|
111
|
+
candidates: readonly CustomCodeCandidateDraft[];
|
|
112
|
+
}
|
|
113
|
+
export interface CustomCodeExtractionContext {
|
|
114
|
+
projectRoot: string;
|
|
115
|
+
runId: string;
|
|
116
|
+
}
|
|
117
|
+
export type CustomCodeExtractor = (context: CustomCodeExtractionContext) => CustomCodeExtractionResult | Promise<CustomCodeExtractionResult>;
|
|
118
|
+
export type ExtractCustomPhaseDefinition = {
|
|
119
|
+
kind: "phase.extract.custom";
|
|
120
|
+
id: string;
|
|
121
|
+
reads: readonly PhaseResourceReference[];
|
|
122
|
+
writes: readonly PhaseResourceReference[];
|
|
123
|
+
sources: readonly RepoProjectSourceDefinition[];
|
|
124
|
+
collection: "codegraph";
|
|
125
|
+
extract: CustomCodeExtractor;
|
|
126
|
+
};
|
|
74
127
|
export declare const NO_ENTRY_DETECTED: "NO_ENTRY_DETECTED";
|
|
75
128
|
export declare class ExtractTsConfigurationError extends TypeError {
|
|
76
129
|
readonly code: "NO_ENTRY_DETECTED";
|
|
@@ -90,6 +143,11 @@ export type CaptureLarkPhaseDefinition = {
|
|
|
90
143
|
reads: readonly PhaseResourceReference[];
|
|
91
144
|
writes: readonly PhaseResourceReference[];
|
|
92
145
|
source: LarkSourceDefinition | LarkSourceReference;
|
|
146
|
+
resources: {
|
|
147
|
+
videos: "reference-only" | "bundle";
|
|
148
|
+
maxBytesPerResource: number;
|
|
149
|
+
maxTotalBytes: number;
|
|
150
|
+
};
|
|
93
151
|
};
|
|
94
152
|
export type AlignProsePhaseDefinition = {
|
|
95
153
|
kind: "phase.align.prose";
|
|
@@ -134,7 +192,7 @@ export type CustomPhaseDefinition = {
|
|
|
134
192
|
writes: readonly PhaseResourceReference[];
|
|
135
193
|
run: ContextPhase;
|
|
136
194
|
};
|
|
137
|
-
export type PhaseDefinition = ExtractTsPhaseDefinition | CaptureFilePhaseDefinition | CaptureLarkPhaseDefinition | AlignProsePhaseDefinition | CompileProsePhaseDefinition | ReviewValidityPhaseDefinition | CustomPhaseDefinition;
|
|
195
|
+
export type PhaseDefinition = ExtractTsPhaseDefinition | ExtractCustomPhaseDefinition | CaptureFilePhaseDefinition | CaptureLarkPhaseDefinition | AlignProsePhaseDefinition | CompileProsePhaseDefinition | ReviewValidityPhaseDefinition | CustomPhaseDefinition;
|
|
138
196
|
export declare function mdxJsonDocs(options?: {
|
|
139
197
|
include?: readonly string[];
|
|
140
198
|
documentExtensions?: readonly string[];
|
|
@@ -147,6 +205,11 @@ export declare const captureFile: (definition: {
|
|
|
147
205
|
}) => CaptureFilePhaseDefinition;
|
|
148
206
|
export declare const captureLark: (definition: {
|
|
149
207
|
source: LarkSourceDefinition | LarkSourceReference;
|
|
208
|
+
resources?: {
|
|
209
|
+
videos?: "reference-only" | "bundle";
|
|
210
|
+
maxBytesPerResource?: number;
|
|
211
|
+
maxTotalBytes?: number;
|
|
212
|
+
};
|
|
150
213
|
}) => CaptureLarkPhaseDefinition;
|
|
151
214
|
export declare const alignProse: (definition: {
|
|
152
215
|
source: DocumentSourceDefinition;
|
|
@@ -165,6 +228,12 @@ export declare const extractTs: (definition: {
|
|
|
165
228
|
exportedOnly?: boolean;
|
|
166
229
|
transform?: MarkdownTransform | readonly MarkdownTransform[];
|
|
167
230
|
}) => ExtractTsPhaseDefinition;
|
|
231
|
+
export declare const extractCustom: (definition: {
|
|
232
|
+
id: string;
|
|
233
|
+
sources: readonly RepoProjectSourceDefinition[];
|
|
234
|
+
collection: "codegraph";
|
|
235
|
+
extract: CustomCodeExtractor;
|
|
236
|
+
}) => ExtractCustomPhaseDefinition;
|
|
168
237
|
export declare const reviewValidity: (definition: {
|
|
169
238
|
collection: KnowledgeCollection;
|
|
170
239
|
payload?: string;
|
|
@@ -11,22 +11,19 @@ Approved knowledge files: `{{knowledgeCount}}`
|
|
|
11
11
|
Use the Markdown files in this package as source-linked product and code
|
|
12
12
|
knowledge. Prefer cited facts from the included knowledge pages over memory.
|
|
13
13
|
|
|
14
|
-
The
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`
|
|
21
|
-
|
|
22
|
-
`
|
|
23
|
-
`
|
|
24
|
-
`
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
`wikis/index.md` before build to describe the package scope and query guidance;
|
|
28
|
-
other selected OKF root indexes are generated unless this template supplies
|
|
29
|
-
them.
|
|
14
|
+
The bundled knowledge-query Skill teaches agents how to navigate OKF indexes
|
|
15
|
+
and cite copied OKF root directories, starting with `{{wikisRoot}}/`.
|
|
16
|
+
|
|
17
|
+
Selected OKF root directories such as `{{wikisRoot}}/`, `{{guidesRoot}}/`,
|
|
18
|
+
`{{rulesRoot}}/`, and `{{featsRoot}}/` follow an OKF-compatible Context profile:
|
|
19
|
+
OKF fields and Context extension fields stay at the top level, and no `context`
|
|
20
|
+
or `schema` field is emitted. Root mapping:
|
|
21
|
+
`{{wikisRoot}}/` maps from structured `codegraph`, `business`, and `product` knowledge;
|
|
22
|
+
`{{guidesRoot}}/` maps from `architecture`, `sop`, `faq`, `decision`, and `incident`;
|
|
23
|
+
`{{rulesRoot}}/` maps from `standards` and `test`; `{{featsRoot}}/` maps from `feats`. Treat
|
|
24
|
+
`{{wikisRoot}}/` as the entity-and-relationship layer; guides and rules may
|
|
25
|
+
explain or constrain that layer. Other selected OKF root indexes are generated
|
|
26
|
+
unless the template supplies them.
|
|
30
27
|
|
|
31
28
|
## Included Knowledge
|
|
32
29
|
|