@c4a/context 0.7.5 → 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.
Files changed (98) hide show
  1. package/README.md +12 -4
  2. package/README.zh-CN.md +11 -4
  3. package/docs/README.md +13 -1
  4. package/docs/README.zh-CN.md +13 -1
  5. package/docs/getting-started.md +95 -69
  6. package/docs/guides/agent-dialogue.md +20 -9
  7. package/docs/guides/agent-guide.md +48 -10
  8. package/docs/guides/code-indexer-skill-authoring.md +42 -11
  9. package/docs/guides/indexer-manifest-example.md +103 -0
  10. package/docs/guides/indexer-provider-and-customization.md +334 -15
  11. package/docs/guides/indexer-skill-creation.md +99 -0
  12. package/docs/guides/knowledge-updates.md +422 -0
  13. package/docs/guides/lark-resources.md +5 -1
  14. package/docs/guides/markdown-indexer-skill-authoring.md +16 -7
  15. package/docs/guides/note.md +37 -0
  16. package/docs/guides/package-outputs.md +231 -60
  17. package/docs/guides/sessions.md +50 -0
  18. package/docs/guides/workspace-commit.md +45 -0
  19. package/docs/guides/workspace-prepare.md +72 -0
  20. package/docs/guides/workspace-restore.md +59 -0
  21. package/docs/reference/code-extractors.md +23 -11
  22. package/docs/reference/indexer-provider-protocol.md +135 -22
  23. package/docs/reference/package-templates.md +10 -9
  24. package/docs/reference/project-api.md +100 -13
  25. package/docs/reference/template-variables.md +7 -7
  26. package/index.d.ts +15 -0
  27. package/index.js +1708 -626
  28. package/indexerAgentStepProtocol.d.ts +44 -0
  29. package/indexerApprovedKnowledge.d.ts +371 -0
  30. package/indexerArticlePlan.d.ts +83 -0
  31. package/indexerArtifact.d.ts +10 -7
  32. package/indexerArtifactDependencies.d.ts +5 -5
  33. package/indexerArtifactPolicy.d.ts +12 -12
  34. package/indexerArtifactResult.d.ts +76 -69
  35. package/indexerAuthoringFixture.d.ts +8 -8
  36. package/indexerAuthorizedWorksetView.d.ts +14 -14
  37. package/indexerBaseQuestionAmendment.d.ts +40 -0
  38. package/indexerCandidateCompile.d.ts +46 -36
  39. package/indexerCatalogFallback.d.ts +566 -48
  40. package/indexerContentLayers.d.ts +6 -4
  41. package/indexerContractDeclaration.d.ts +3 -0
  42. package/indexerControlledProgram.d.ts +1039 -238
  43. package/indexerCustomizationDraft.d.ts +188 -0
  44. package/indexerDependencyView.d.ts +17 -17
  45. package/indexerEffectiveArtifact.d.ts +26 -15
  46. package/indexerExampleFactDependencies.d.ts +17 -0
  47. package/indexerExampleIdentityAudit.d.ts +2 -2
  48. package/indexerInventoryDisposition.d.ts +44 -44
  49. package/indexerKnowledgeDependency.d.ts +46 -0
  50. package/indexerLayerComposition.d.ts +92 -54
  51. package/indexerLayoutChange.d.ts +8 -8
  52. package/indexerLayoutProposalSet.d.ts +15 -10
  53. package/indexerLayoutResolver.d.ts +15 -6
  54. package/indexerLayoutTransition.d.ts +8 -8
  55. package/indexerLifecycle.d.ts +1 -1
  56. package/indexerMainRunLedger.d.ts +3 -0
  57. package/indexerMainRunProtocol.d.ts +872 -196
  58. package/indexerMainWorkset.d.ts +50 -0
  59. package/indexerNavigationArtifactPlan.d.ts +2 -2
  60. package/indexerOverlayQuestionAmendment.d.ts +56 -16
  61. package/indexerOverlayQuestionApplyProposal.d.ts +98 -26
  62. package/indexerPartitionPlan.d.ts +585 -40
  63. package/indexerPhysicalArtifactAudit.d.ts +2 -2
  64. package/indexerPhysicalArtifactManifest.d.ts +24 -24
  65. package/indexerPostAuthorRunLedger.d.ts +60 -34
  66. package/indexerPrimaryProjection.d.ts +2 -2
  67. package/indexerProfileContract.d.ts +28 -28
  68. package/indexerProgramRunProtocol.d.ts +868 -194
  69. package/indexerProjectProposal.d.ts +36 -8
  70. package/indexerProjectedArtifactFanOutAudit.d.ts +2 -2
  71. package/indexerProtocolHash.d.ts +2 -0
  72. package/indexerProvider.d.ts +102 -58
  73. package/indexerProviderComposition.d.ts +4 -4
  74. package/indexerProviderRouting.d.ts +52 -0
  75. package/indexerProviderSelectionProposal.d.ts +48 -0
  76. package/indexerPublicContractFacts.d.ts +7 -0
  77. package/indexerPublicContractTable.d.ts +11 -0
  78. package/indexerReaderTargetInventory.d.ts +6 -6
  79. package/indexerReferenceOnlyAudit.d.ts +2 -2
  80. package/indexerRegistry.d.ts +658 -0
  81. package/indexerRequirementConfirmation.d.ts +48 -16
  82. package/indexerRequirementLifecycle.d.ts +154 -42
  83. package/indexerResultReconciliation.d.ts +12 -11
  84. package/indexerSemanticInput.d.ts +27168 -3813
  85. package/{indexerGeneratedAuthoringAudit.d.ts → indexerStructuredClaims.d.ts} +0 -84
  86. package/indexerStructuredDeclaration.d.ts +8 -8
  87. package/indexerTemplateRendering.d.ts +7 -7
  88. package/indexerToolSnapshot.d.ts +16 -16
  89. package/knowledgeMap.d.ts +188 -0
  90. package/managedSources.d.ts +15 -0
  91. package/package.json +1 -1
  92. package/packageSite.d.ts +25 -0
  93. package/phases.d.ts +0 -3
  94. package/processedScopes.d.ts +75 -0
  95. package/sessionMetadata.d.ts +49 -0
  96. package/sources.d.ts +9 -3
  97. package/templates/package-templates/kb/skills/knowledge-query/SKILL.md +15 -10
  98. package/templates/package-templates.zh-CN/kb/skills/knowledge-query/SKILL.md +8 -8
@@ -0,0 +1,49 @@
1
+ import { z } from "zod";
2
+ /** Associations are supplied by the caller, not proof of implementation or approval. */
3
+ export declare const sessionChangeSchema: z.ZodEffects<z.ZodObject<{
4
+ repository: z.ZodOptional<z.ZodString>;
5
+ commit: z.ZodOptional<z.ZodString>;
6
+ mr: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
7
+ }, "strict", z.ZodTypeAny, {
8
+ repository?: string | undefined;
9
+ commit?: string | undefined;
10
+ mr?: string | undefined;
11
+ }, {
12
+ repository?: string | undefined;
13
+ commit?: string | undefined;
14
+ mr?: string | undefined;
15
+ }>, {
16
+ repository?: string | undefined;
17
+ commit?: string | undefined;
18
+ mr?: string | undefined;
19
+ }, {
20
+ repository?: string | undefined;
21
+ commit?: string | undefined;
22
+ mr?: string | undefined;
23
+ }>;
24
+ export declare const sessionChangesSchema: z.ZodArray<z.ZodEffects<z.ZodObject<{
25
+ repository: z.ZodOptional<z.ZodString>;
26
+ commit: z.ZodOptional<z.ZodString>;
27
+ mr: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
28
+ }, "strict", z.ZodTypeAny, {
29
+ repository?: string | undefined;
30
+ commit?: string | undefined;
31
+ mr?: string | undefined;
32
+ }, {
33
+ repository?: string | undefined;
34
+ commit?: string | undefined;
35
+ mr?: string | undefined;
36
+ }>, {
37
+ repository?: string | undefined;
38
+ commit?: string | undefined;
39
+ mr?: string | undefined;
40
+ }, {
41
+ repository?: string | undefined;
42
+ commit?: string | undefined;
43
+ mr?: string | undefined;
44
+ }>, "many">;
45
+ export type SessionChange = z.infer<typeof sessionChangeSchema>;
46
+ export declare function readSessionChanges(markdown: string): SessionChange[] | undefined;
47
+ /** Omitted changes preserve inline metadata. Explicit [] removes associations.
48
+ * Only the source header is serialized; the summary body is never rewritten. */
49
+ export declare function writeSessionChanges(markdown: string, changes?: readonly SessionChange[]): string;
package/sources.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export type SourceType = "repo" | "file" | "lark";
2
- export type DocumentSourceType = Extract<SourceType, "file" | "lark">;
1
+ import { type ManagedDocumentSourceEntry, type ManagedDocumentSourceType } from "./managedSources.js";
2
+ export type SourceType = "repo" | "file" | "lark" | "note" | "sessions";
3
+ export type DocumentSourceType = Exclude<SourceType, "repo">;
3
4
  export declare const DEFAULT_REPO_SOURCES_REGISTRY_PATH = "sources/repo/index.yaml";
4
5
  export declare const DEFAULT_FILE_SOURCES_REGISTRY_PATH = "sources/file/index.yaml";
5
6
  export declare const DEFAULT_LARK_SOURCES_REGISTRY_PATH = "sources/lark/index.yaml";
@@ -60,7 +61,7 @@ export type SourceReference<TType extends SourceType = SourceType> = TypedSource
60
61
  export type RepoSourceReference = RegistrySourceReference | TypedSourceReference<"repo">;
61
62
  export type FileSourceReference = RegistrySourceReference | TypedSourceReference<"file">;
62
63
  export type LarkSourceReference = RegistrySourceReference | TypedSourceReference<"lark">;
63
- export type DocumentSourceReference = FileSourceReference | LarkSourceReference;
64
+ export type DocumentSourceReference = FileSourceReference | LarkSourceReference | TypedSourceReference<ManagedDocumentSourceType>;
64
65
  export type SourceCollectionReference<TType extends SourceType = SourceType> = {
65
66
  kind: "source.collection";
66
67
  type: TType;
@@ -123,6 +124,8 @@ export type SourcesRegistry = {
123
124
  repos: readonly RepoSourceRegistryEntry[];
124
125
  files: readonly FileSourceRegistryEntry[];
125
126
  larks: readonly LarkSourceRegistryEntry[];
127
+ notes: readonly ManagedDocumentSourceEntry[];
128
+ sessions: readonly ManagedDocumentSourceEntry[];
126
129
  };
127
130
  export type LoadSourcesRegistryOptions = {
128
131
  rootDir?: string;
@@ -135,6 +138,9 @@ export type SourceDefinition = RepoSourceDefinition | FileSourceDefinition | Lar
135
138
  export type DocumentSourceDefinition = FileSourceDefinition | LarkSourceDefinition | DocumentSourceReference;
136
139
  export type RepoProjectSourceDefinition = RepoSourceDefinition | RepoSourceReference | SourceCollectionReference<"repo">;
137
140
  export type ProjectSourceDefinition = SourceDefinition | SourceCollectionReference;
141
+ export declare function source(name: string, options: {
142
+ type: ManagedDocumentSourceType;
143
+ }): TypedSourceReference<ManagedDocumentSourceType>;
138
144
  export declare function source(name: string): RegistrySourceReference;
139
145
  export declare function source(namespace: string, module: string): RepoSourceReference;
140
146
  export declare function source(namespace: string, module: string, options: {
@@ -46,7 +46,7 @@ was not selected into this package.
46
46
  | Architecture, procedure, FAQ, decision, or incident | Start from `{{guidesRoot}}/index.md`. |
47
47
  | Standard, constraint, acceptance, or test question | Start from `{{rulesRoot}}/index.md`. |
48
48
  | Relationship or impact | Inspect typed edges, then read both endpoint pages. |
49
- | Detail inside a known page | Read the relevant `context:section` block. |
49
+ | Detail inside a known page | Read the relevant Markdown heading and its body. |
50
50
  | Coverage, gap, or inventory | Inspect the root indexes and `context-build-inventory.json`. |
51
51
 
52
52
  ## Evidence Contract
@@ -56,15 +56,20 @@ Use each opened page or package artifact as an evidence card:
56
56
  | Evidence | Valid use |
57
57
  |---|---|
58
58
  | Page path | Page identity and citation handle. |
59
- | Frontmatter title, description, stable node identity, and tags | Navigation and scope selection only. |
60
- | `context:section` id, kind, and `source_ref` | Section identity, citation, and source boundary. |
59
+ | Frontmatter title, description, and tags | Navigation and scope selection only. |
60
+ | Markdown headings | Locate and cite a section within its page. |
61
61
  | Reader-visible section body | Primary support for factual claims. |
62
62
  | `context-build-inventory.json` edge records | Typed relationship evidence. |
63
63
  | Root indexes and build inventory | Package scope and coverage evidence. |
64
64
 
65
- Do not infer a relationship from page co-occurrence. If a `source_ref` points to
66
- source material that is not bundled, cite the approved section that reviewed it
67
- and do not expand beyond its visible content.
65
+ Do not infer a relationship from page co-occurrence. Published pages do not need
66
+ production identifiers or source bookkeeping to be usable. Cite their readable
67
+ paths and headings; do not search for missing technical metadata or ask users
68
+ to supply it. Open the build inventory only for relationship or coverage questions,
69
+ or when a maintainer needs to locate the original approved page via
70
+ `dist_path` → `approved_path`. Original source attribution belongs to that
71
+ workspace's `knowledge/`, not to the published page. If the original material is
72
+ not bundled, answer only from the visible approved content and state its limits.
68
73
 
69
74
  ## Search Fallback
70
75
 
@@ -96,8 +101,7 @@ Use compact citations tied to claims:
96
101
 
97
102
  ```text
98
103
  Page: <claim> [<root>/path/page.md]
99
- Section: <claim> [<root>/path/page.md#section-id]
100
- Source-bound: <claim> [<root>/path/page.md#section-id, source_ref]
104
+ Section: <claim> [<root>/path/page.md, heading: <visible heading>]
101
105
  Relationship: <claim> [context-build-inventory.json#structure.edge_records edge:<type>]
102
106
  Coverage: <claim> [context-build-inventory.json]
103
107
  ```
@@ -107,7 +111,7 @@ When evidence is missing, return:
107
111
  ```text
108
112
  Gap: this package does not contain evidence for <missing point>.
109
113
  Checked: <indexes, pages, or artifacts>.
110
- Next useful source: <source, page, or source_ref if known>.
114
+ Next useful source: <source document or page if known>.
111
115
  ```
112
116
 
113
117
  Distinguish “not evidenced by this package” from “not true.” Do not fill gaps
@@ -123,7 +127,7 @@ from memory, previous conversations, or source files outside the package.
123
127
 
124
128
  Approved knowledge files: `{{knowledgeCount}}`
125
129
 
126
- ## Template Author Recommendation
130
+ {{!-- Template author guidance (not part of the published query Skill):
127
131
 
128
132
  This is a complete generic query Skill, but package authors should replace or
129
133
  edit it before publishing when the package has project-specific terminology,
@@ -131,3 +135,4 @@ common user intents, preferred entry pages, known limits, or task workflows.
131
135
  Update the description, routing table, and package-boundary guidance to match
132
136
  the actual package. If the generic behavior is intentionally sufficient,
133
137
  explicitly accept the unchanged default during Context package-template review.
138
+ --}}
@@ -36,7 +36,7 @@ description: 查询 {{displayName}} 中经过审核、可追溯来源的知识
36
36
  | 架构、流程、FAQ、决策或故障 | 从 `{{guidesRoot}}/index.md` 开始。 |
37
37
  | 标准、约束、验收或测试 | 从 `{{rulesRoot}}/index.md` 开始。 |
38
38
  | 关系或影响范围 | 检查类型化边,再读取两端页面。 |
39
- | 已知页面中的细节 | 读取对应 `context:section`。 |
39
+ | 已知页面中的细节 | 读取相关 Markdown 标题及其正文。 |
40
40
  | 覆盖范围或缺口 | 检查根索引和 `context-build-inventory.json`。 |
41
41
 
42
42
  ## 证据契约
@@ -44,13 +44,13 @@ description: 查询 {{displayName}} 中经过审核、可追溯来源的知识
44
44
  | 证据 | 可支持的内容 |
45
45
  |---|---|
46
46
  | 页面路径 | 页面身份和引用位置。 |
47
- | frontmatter 的标题、描述、稳定节点标识和标签 | 导航和范围选择。 |
48
- | `context:section` 的 id、kind、`source_ref` | 章节身份、引用位置和来源边界。 |
47
+ | frontmatter 的标题、描述和标签 | 导航和范围选择。 |
48
+ | Markdown 标题 | 定位和引用页面中的章节。 |
49
49
  | 读者可见的章节正文 | 事实结论的主要依据。 |
50
50
  | `context-build-inventory.json` 的边记录 | 类型化关系证据。 |
51
51
  | 根索引和构建清单 | 包的范围和覆盖情况。 |
52
52
 
53
- 不要根据页面同时出现来推断关系。如果 `source_ref` 指向未随包分发的来源,只能引用已经过审核的可见章节,不能扩展到正文没有表达的内容。
53
+ 不要根据页面同时出现来推断关系。发布页不需要生产标识或来源记账字段才能使用,直接引用可读路径和标题;不要寻找已经移除的技术元数据,也不要要求用户补齐。关系、覆盖问题,或维护者需要通过 `dist_path` → `approved_path` 定位原批准页时,才读取构建清单。原始来源归因留在生产工作区的 `knowledge/`,不要求写入发布页。原始材料未随包分发时,只根据已批准的可见正文回答并说明边界。
54
54
 
55
55
  ## 搜索兜底
56
56
 
@@ -70,8 +70,7 @@ node <当前 knowledge-query Skill 目录>/scripts/search.mjs --query '<关键
70
70
 
71
71
  ```text
72
72
  页面: <结论> [<root>/path/page.md]
73
- 章节: <结论> [<root>/path/page.md#section-id]
74
- 来源绑定: <结论> [<root>/path/page.md#section-id, source_ref]
73
+ 章节: <结论> [<root>/path/page.md, 标题:<可见标题>]
75
74
  关系: <结论> [context-build-inventory.json#structure.edge_records edge:<type>]
76
75
  覆盖: <结论> [context-build-inventory.json]
77
76
  ```
@@ -81,7 +80,7 @@ node <当前 knowledge-query Skill 目录>/scripts/search.mjs --query '<关键
81
80
  ```text
82
81
  缺口:本知识包没有包含 <缺失点> 的证据。
83
82
  已检查:<索引、页面或构建产物>。
84
- 下一步来源:<已知时填写来源、页面或 source_ref>。
83
+ 下一步来源:<已知时填写来源文档或页面>。
85
84
  ```
86
85
 
87
86
  “本包没有证据”不等于“事实不成立”。禁止使用模型记忆、旧对话或包外源码填补缺口。
@@ -94,6 +93,7 @@ node <当前 knowledge-query Skill 目录>/scripts/search.mjs --query '<关键
94
93
 
95
94
  已批准知识文件:`{{knowledgeCount}}`
96
95
 
97
- ## 模板作者建议
96
+ {{!-- 模板作者建议(不进入分发的查询 Skill):
98
97
 
99
98
  这是可直接工作的通用查询 Skill。正式发布前,如果知识包存在专用术语、常见用户意图、推荐入口、已知边界或固定任务流程,作者应修改 description、路由表和包边界说明;如果通用行为已经足够,应在 Context 的包模板 Review 中明确接受未修改模板。
99
+ --}}