@c4a/context 0.6.8 → 0.6.10
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 +46 -10
- package/README.zh-CN.md +39 -2
- package/docs/README.md +24 -5
- package/docs/README.zh-CN.md +60 -0
- package/docs/getting-started.md +26 -10
- package/docs/guides/agent-dialogue.md +12 -2
- package/docs/guides/agent-guide.md +7 -0
- package/docs/guides/package-outputs.md +1 -1
- package/docs/reference/package-templates.md +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,11 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
[简体中文](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
`@c4a/context` is the declarative
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
`@c4a/context` is the declarative model behind a Context knowledge workspace.
|
|
6
|
+
It lets the workspace describe which sources contribute knowledge, how evidence
|
|
7
|
+
is processed, where human review applies, and which reusable outputs should be
|
|
8
|
+
built.
|
|
9
|
+
|
|
10
|
+
Most users do not install or operate this SDK directly. They start through the
|
|
11
|
+
Context Agent entry, describe a knowledge goal, and let the selected workflow
|
|
12
|
+
Route guide the Agent when `src/index.ts` needs configuration. This README is
|
|
13
|
+
for knowledge-project authors, Agent maintainers, and developers who need to
|
|
14
|
+
understand that project declaration.
|
|
15
|
+
|
|
16
|
+
The SDK is intentionally declarative. It does not read sources, write workspace
|
|
17
|
+
state, execute an Agent, or build packages by itself. Those operations belong
|
|
18
|
+
to the [Context workflow runtime](../context-cli/README.md).
|
|
19
|
+
|
|
20
|
+
## Place in the knowledge workflow
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
User intent + source boundaries
|
|
24
|
+
↓
|
|
25
|
+
src/index.ts declaration ← this package
|
|
26
|
+
↓
|
|
27
|
+
Context Route + Agent judgment
|
|
28
|
+
↓
|
|
29
|
+
approved knowledge → package output
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The declaration answers four stable questions:
|
|
33
|
+
|
|
34
|
+
- Which registered source boundaries may contribute evidence?
|
|
35
|
+
- Which capture, extraction, alignment, compilation, and review phases exist?
|
|
36
|
+
- Which approved collections belong in each output?
|
|
37
|
+
- Which templates and asset-delivery policies shape the built package?
|
|
38
|
+
|
|
39
|
+
It does not encode current progress. Workspace facts and the bundled workflow
|
|
40
|
+
Provider select the next Route at runtime, so `src/index.ts` remains a project
|
|
41
|
+
contract rather than a second state machine.
|
|
10
42
|
|
|
11
43
|
## Project Model
|
|
12
44
|
|
|
@@ -42,11 +74,11 @@ export default defineProject({
|
|
|
42
74
|
});
|
|
43
75
|
```
|
|
44
76
|
|
|
45
|
-
`src/index.ts` is similar to a
|
|
46
|
-
what enters the project, which transformations and gates
|
|
47
|
-
at the end. The installed Agent
|
|
48
|
-
workflow
|
|
49
|
-
|
|
77
|
+
`src/index.ts` is similar to a build configuration for knowledge. It defines
|
|
78
|
+
what enters the project, which transformations and gates are available, and
|
|
79
|
+
what can be built at the end. The installed Agent entry stays thin; the current
|
|
80
|
+
workflow Route selects the exact procedures, schemas, and manuals needed to
|
|
81
|
+
maintain this declaration from the user's requirements.
|
|
50
82
|
|
|
51
83
|
## Public Surface
|
|
52
84
|
|
|
@@ -181,3 +213,7 @@ state. The CLI owns that runtime state and removes it after a successful close.
|
|
|
181
213
|
- [Lark Resource Materialization](./docs/guides/lark-resources.md)
|
|
182
214
|
- [Package Templates](./docs/reference/package-templates.md)
|
|
183
215
|
- [Template Variables](./docs/reference/template-variables.md)
|
|
216
|
+
|
|
217
|
+
The [documentation index](./docs/README.md) explains which references should be
|
|
218
|
+
read for each workflow decision. Agents should prefer Route-selected resources
|
|
219
|
+
over preloading every manual.
|
package/README.zh-CN.md
CHANGED
|
@@ -2,7 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
[English](./README.md)
|
|
4
4
|
|
|
5
|
-
`@c4a/context` 是 Context
|
|
5
|
+
`@c4a/context` 是 Context 知识工作区背后的声明模型。它让工作区说明哪些来源会
|
|
6
|
+
贡献知识、证据经过哪些处理、哪些地方需要人工审核,以及最终应该构建哪些可复用
|
|
7
|
+
产物。
|
|
8
|
+
|
|
9
|
+
多数用户不需要单独安装或直接操作这个 SDK。他们从 Context Agent 入口开始,说明
|
|
10
|
+
知识目标;当 `src/index.ts` 需要配置时,当前工作流 Route 会引导 Agent 完成修改。
|
|
11
|
+
这份 README 面向知识项目作者、Agent 维护者和需要理解项目声明的开发者。
|
|
12
|
+
|
|
13
|
+
SDK 有意保持声明式:它本身不读取来源、不写入工作区状态、不运行 Agent,也不
|
|
14
|
+
构建知识包。这些操作由 [Context 工作流运行时](../context-cli/README.zh-CN.md)
|
|
15
|
+
负责。
|
|
16
|
+
|
|
17
|
+
## 在知识生产工作流中的位置
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
用户意图 + 来源边界
|
|
21
|
+
↓
|
|
22
|
+
src/index.ts 项目声明 ← 本包
|
|
23
|
+
↓
|
|
24
|
+
Context Route + Agent 判断
|
|
25
|
+
↓
|
|
26
|
+
正式知识 → 知识包产物
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
项目声明回答四个长期稳定的问题:
|
|
30
|
+
|
|
31
|
+
- 哪些已经登记的来源边界可以贡献证据?
|
|
32
|
+
- 存在哪些采集、提取、对齐、编译和审核阶段?
|
|
33
|
+
- 每种产物应该选择哪些正式知识分类?
|
|
34
|
+
- 哪些模板和资源分发策略决定最终包的结构?
|
|
35
|
+
|
|
36
|
+
它不记录当前进度。工作区事实和随包发布的 Workflow Provider 会在运行时选择下一
|
|
37
|
+
条 Route,因此 `src/index.ts` 是项目契约,不是第二套状态机。
|
|
6
38
|
|
|
7
39
|
## 项目模型
|
|
8
40
|
|
|
@@ -38,7 +70,9 @@ export default defineProject({
|
|
|
38
70
|
});
|
|
39
71
|
```
|
|
40
72
|
|
|
41
|
-
`src/index.ts`
|
|
73
|
+
`src/index.ts` 类似知识项目的构建配置:它定义哪些内容进入项目、可以经过哪些转换
|
|
74
|
+
和门禁,以及最终能够构建什么产物。安装好的 Agent 入口保持精简,当前工作流
|
|
75
|
+
Route 会按需选择维护这份声明所需的操作说明、Schema 和手册。
|
|
42
76
|
|
|
43
77
|
## 主要 API
|
|
44
78
|
|
|
@@ -145,3 +179,6 @@ SDK 只负责声明。它可以描述读取、写入、阶段、审核和知识
|
|
|
145
179
|
- [飞书资源物化](./docs/guides/lark-resources.md)
|
|
146
180
|
- [知识包模板](./docs/reference/package-templates.md)
|
|
147
181
|
- [模板变量](./docs/reference/template-variables.md)
|
|
182
|
+
|
|
183
|
+
[文档索引](./docs/README.zh-CN.md)说明每类工作流决策应该查看哪些参考资料。Agent
|
|
184
|
+
应优先读取 Route 选择的资源,不要预加载整套手册。
|
package/docs/README.md
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
# Context SDK Docs
|
|
2
2
|
|
|
3
|
+
[简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
3
5
|
These docs ship inside the installed SDK package at:
|
|
4
6
|
|
|
5
7
|
```text
|
|
6
8
|
node_modules/@c4a/context/docs/
|
|
7
9
|
```
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
These manuals explain how a knowledge project declares sources, processing,
|
|
12
|
+
review, and package output. They are references inside the larger Agent-driven
|
|
13
|
+
workflow, not a second set of lifecycle instructions.
|
|
14
|
+
|
|
15
|
+
For active knowledge production, start through the installed Context Agent
|
|
16
|
+
entry. Agents should first consume the resources selected by
|
|
17
|
+
`workflow.current`, then read an SDK manual only when that Route requires
|
|
18
|
+
project configuration, package-template work, or a stable API reference. Do not
|
|
19
|
+
preload the whole manual set.
|
|
20
|
+
|
|
21
|
+
## Find the right document
|
|
22
|
+
|
|
23
|
+
| Current need | Read |
|
|
24
|
+
|---|---|
|
|
25
|
+
| Understand the whole knowledge-project shape | [Getting Started](./getting-started.md) |
|
|
26
|
+
| Know what the Agent may decide or change | [Agent Guide](./guides/agent-guide.md) and [Agent Dialogue](./guides/agent-dialogue.md) |
|
|
27
|
+
| Configure sources, phases, review, or packages | [Project API](./reference/project-api.md) |
|
|
28
|
+
| Choose a code extraction path | [Code Extractor Selection](./reference/code-extractors.md) |
|
|
29
|
+
| Choose an Agent package or LLM document | [Package Outputs](./guides/package-outputs.md) |
|
|
30
|
+
| Customize package files and indexes | [Package Templates](./reference/package-templates.md) and [Template Variables](./reference/template-variables.md) |
|
|
31
|
+
| Preserve Lark images and embedded resources | [Lark Resource Materialization](./guides/lark-resources.md) |
|
|
13
32
|
|
|
14
|
-
##
|
|
33
|
+
## Complete reference
|
|
15
34
|
|
|
16
35
|
- [Getting Started](./getting-started.md) — end-to-end component-library flow.
|
|
17
36
|
- [Agent Guide](./guides/agent-guide.md) — what an agent should do, and what it should not inspect manually.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Context SDK 文档
|
|
2
|
+
|
|
3
|
+
[English](./README.md)
|
|
4
|
+
|
|
5
|
+
这些手册说明知识项目如何声明来源、处理过程、审核和知识包产物。它们是 Agent
|
|
6
|
+
驱动工作流中的参考资料,不是另一套生命周期指令。
|
|
7
|
+
|
|
8
|
+
进行知识生产时,应先从已安装的 Context Agent 入口开始。Agent 优先消费
|
|
9
|
+
`workflow.current` 选择的资源;只有当前 Route 要求编辑项目配置、维护知识包模板
|
|
10
|
+
或查询稳定 API 时,才读取对应 SDK 手册,不要预加载整套文档。
|
|
11
|
+
|
|
12
|
+
## 按当前需要选择文档
|
|
13
|
+
|
|
14
|
+
| 当前需要 | 阅读内容 |
|
|
15
|
+
|---|---|
|
|
16
|
+
| 理解完整知识项目的形态 | [Getting Started](./getting-started.md) |
|
|
17
|
+
| 判断 Agent 可以决定或修改什么 | [Agent Guide](./guides/agent-guide.md) 和 [Agent Dialogue](./guides/agent-dialogue.md) |
|
|
18
|
+
| 配置来源、阶段、审核或产物 | [Project API](./reference/project-api.md) |
|
|
19
|
+
| 选择代码提取方式 | [Code Extractor Selection](./reference/code-extractors.md) |
|
|
20
|
+
| 选择 Agent 知识包或 LLM 文档 | [Package Outputs](./guides/package-outputs.md) |
|
|
21
|
+
| 自定义包文件和索引 | [Package Templates](./reference/package-templates.md) 和 [Template Variables](./reference/template-variables.md) |
|
|
22
|
+
| 保留飞书图片和内嵌资源 | [Lark Resource Materialization](./guides/lark-resources.md) |
|
|
23
|
+
|
|
24
|
+
## 完整参考
|
|
25
|
+
|
|
26
|
+
- [Getting Started](./getting-started.md):从来源到知识包的端到端组件库示例。
|
|
27
|
+
- [Agent Guide](./guides/agent-guide.md):Agent 应该执行什么,以及哪些状态不能手工探查或修改。
|
|
28
|
+
- [Agent Dialogue](./guides/agent-dialogue.md):稳定的对话原则和 Route-selected Gate 资源发现方式。
|
|
29
|
+
- [Package Outputs](./guides/package-outputs.md):如何选择 Agent 知识包、LLM 文本或不构建产物。
|
|
30
|
+
- [Lark Resource Materialization](./guides/lark-resources.md):内嵌资源如何从来源证据进入正式知识和知识包。
|
|
31
|
+
- [Project API](./reference/project-api.md):`defineProject`、来源、阶段、审核和知识包声明。
|
|
32
|
+
- [Code Extractor Selection](./reference/code-extractors.md):如何根据技术信号选择内建提取器、结构库或项目适配器。
|
|
33
|
+
- [Package Templates](./reference/package-templates.md):`kbPackage`、`llmsPackage`、模板变量和示例。
|
|
34
|
+
- [Template Variables](./reference/template-variables.md):Handlebars 变量、循环、注释和默认知识清单。
|
|
35
|
+
|
|
36
|
+
正式 Markdown 使用完整的 Context production profile。知识包内的知识页只保留
|
|
37
|
+
面向读者的元数据和正文;Node 身份、来源、Section 证据、审核指纹、符号清单、
|
|
38
|
+
生成子项和关系继续留在生产工作区或 `context-build-inventory.json` 中。构建清单
|
|
39
|
+
将每个分发路径映射回正式知识路径。知识包根目录可以包含 Agent 文件;可交换知识
|
|
40
|
+
位于所选的 `wikis/`、`guides/`、`rules/` 和 `feats/` 子树。
|
|
41
|
+
|
|
42
|
+
## 已安装模板
|
|
43
|
+
|
|
44
|
+
知识包模板示例随 SDK 安装在:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
node_modules/@c4a/context/templates/package-templates/
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
需要构建产物时,将合适的模板复制或映射到工作区的
|
|
51
|
+
`src/package-templates/`。
|
|
52
|
+
|
|
53
|
+
长期维护、多来源的生产工作区还可以使用可选的项目维护 Skill 模板:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
node_modules/@c4a/context/templates/project-skills/maintain-project-knowledge/SKILL.md
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
将它复制到项目 `.agents/skills/`,按项目重命名并填写来源归属与影响映射。它是
|
|
60
|
+
项目适配器,不会进入最终知识包,也不替代已安装的 Context Agent 入口。
|
package/docs/getting-started.md
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Knowledge Project Walkthrough
|
|
2
2
|
|
|
3
3
|
This guide shows the common Context workspace shape. The same workspace can
|
|
4
4
|
ingest source documents, code repositories, or both. Start with the user's
|
|
5
5
|
source boundary, then declare the matching phases in `src/index.ts`.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
For normal use, start from the installed Context Agent entry and describe the
|
|
8
|
+
knowledge goal. The entry resolves whether it should initialize a workspace,
|
|
9
|
+
enter an existing workspace, or continue the current production round:
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
/c4a:context Build a traceable knowledge package from this repository and the
|
|
13
|
+
documents I provide. Explain each source and structure decision before asking
|
|
14
|
+
for confirmation.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The remainder of this guide explains the project model behind that
|
|
18
|
+
conversation. Command examples are maintainer orientation; an Agent should
|
|
19
|
+
prefer the exact command and resources returned by `workflow.current`.
|
|
20
|
+
|
|
21
|
+
## 1. Establish the workspace
|
|
22
|
+
|
|
23
|
+
When initialization is required, the Agent runs the exact action returned by
|
|
24
|
+
`context entry`. A manual equivalent for automation or source development is:
|
|
8
25
|
|
|
9
26
|
```bash
|
|
10
27
|
context init context
|
|
@@ -28,11 +45,10 @@ inside a non-empty directory that is not already a Context workspace is blocked
|
|
|
28
45
|
before any files are written; use the returned `--allow-nonempty` command only
|
|
29
46
|
after confirming that the existing files should share the workspace root.
|
|
30
47
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
host-specific.
|
|
48
|
+
After initialization, return to the single installed Context Agent entry from
|
|
49
|
+
the project root. It consumes `workflow.current`, loads only the selected
|
|
50
|
+
resources, and calls lower-level CLI primitives as needed. Do not introduce a
|
|
51
|
+
separate continuation entry.
|
|
36
52
|
|
|
37
53
|
## 2. Choose And Register A Source Boundary
|
|
38
54
|
|
|
@@ -233,9 +249,9 @@ export default defineProject({
|
|
|
233
249
|
});
|
|
234
250
|
```
|
|
235
251
|
|
|
236
|
-
Then
|
|
237
|
-
|
|
238
|
-
|
|
252
|
+
Then return to the installed Context Agent entry. For maintainer inspection,
|
|
253
|
+
`context status --format json` exposes the same current Route. The normal
|
|
254
|
+
sequence is:
|
|
239
255
|
|
|
240
256
|
1. capture the source into committed snapshots;
|
|
241
257
|
2. investigate evidence and confirm the CLI-managed lifecycle structure;
|
|
@@ -21,6 +21,13 @@ not duplicated in this SDK manual.
|
|
|
21
21
|
This keeps a new Agent from loading every possible conversation script before
|
|
22
22
|
it knows which decision is current.
|
|
23
23
|
|
|
24
|
+
The ordinary path also selects short mode guidance after workspace creation
|
|
25
|
+
and source capture. Explain that ordinary review is the default, provides HTML
|
|
26
|
+
reports at review decisions, and is currently estimated to take about 40%
|
|
27
|
+
longer overall depending on scope and response time. Offer fully managed mode
|
|
28
|
+
for the current conversation while explaining that it gives the user fewer
|
|
29
|
+
opportunities to adjust intermediate content.
|
|
30
|
+
|
|
24
31
|
## Stable Principles
|
|
25
32
|
|
|
26
33
|
- Use the user's conversation language for explanations and questions.
|
|
@@ -47,7 +54,10 @@ context status --managed --format json
|
|
|
47
54
|
```
|
|
48
55
|
|
|
49
56
|
The returned route decides which delegatable gates may proceed without another
|
|
50
|
-
question.
|
|
51
|
-
|
|
57
|
+
question. A Gate may keep its ordinary inspection Action and dialogue resources
|
|
58
|
+
while replacing them with a direct revision-bound resolution path only for a
|
|
59
|
+
session-authority Route. Necessary evidence inspection remains selected for
|
|
60
|
+
semantic scope or classification work. This authority is not project
|
|
61
|
+
configuration and must not be persisted or reused in another conversation. It cannot choose source boundaries,
|
|
52
62
|
authorize unread external sources or external operations, or bypass validation
|
|
53
63
|
and verification.
|
|
@@ -30,6 +30,13 @@ without another question. Review uses the CLI's atomic `context review
|
|
|
30
30
|
approve-all ... --managed` route; valid structure staging records
|
|
31
31
|
`confirmed_by: managed-session`.
|
|
32
32
|
|
|
33
|
+
The Provider may omit an ordinary Gate's HTML inspection Action and
|
|
34
|
+
user-dialogue resources only on its session-authority Route, then expose the
|
|
35
|
+
authority-selected revision-bound resolution Action directly. The ordinary
|
|
36
|
+
inspection and resolution capabilities remain available in ordinary mode.
|
|
37
|
+
Evidence reads needed to choose an extraction scope or classify a captured
|
|
38
|
+
document are not removed.
|
|
39
|
+
|
|
33
40
|
After the first managed status evaluation, use
|
|
34
41
|
`context run --managed --until blocked-or-complete --format json` when the
|
|
35
42
|
current work can advance through consecutive mechanical routes. The CLI
|
|
@@ -116,7 +116,7 @@ metadata, how many codegraph views were selected, and how many package-visible
|
|
|
116
116
|
edges were emitted. An empty edge list is therefore explicit evidence of a
|
|
117
117
|
coverage state, not permission to invent a dependency.
|
|
118
118
|
|
|
119
|
-
The generated `wikis/` directory is the default OKF root and follows the
|
|
119
|
+
The generated `wikis/` directory is the default OKF root and follows the Context OKF
|
|
120
120
|
Profile. Internal production collections are mapped into package OKF roots such
|
|
121
121
|
as `wikis/`, `guides/`, `rules/`, or `feats/`; when selected, `context build`
|
|
122
122
|
copies them into the package and generates root-aware directory indexes for them
|
|
@@ -321,7 +321,7 @@ Approved Markdown under `knowledge/` is the production source of truth:
|
|
|
321
321
|
- Context production metadata such as `sources`, `node_type`, `visibility`,
|
|
322
322
|
`code_symbols`, relationship records, and `candidate_fingerprint` also lives
|
|
323
323
|
at the top level;
|
|
324
|
-
- do not nest
|
|
324
|
+
- do not nest Context production metadata under `context`; fields such as
|
|
325
325
|
`context.sources` and `context.code_symbols` are not part of the 0.6 profile;
|
|
326
326
|
- section provenance lives in `<!-- context:section ... source_ref="..." -->`
|
|
327
327
|
comments;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c4a/context",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Declarative SDK for Context knowledge sources, workflows, review, and package outputs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|