@c4a/context 0.7.43 → 0.7.50

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.
@@ -18,6 +18,17 @@ actual behavior, a confirmed decision, and a proposal that is not implemented.
18
18
 
19
19
  ## Keep planning local to the change
20
20
 
21
+ Same-repository originals use `repo-content.yaml` rather than another capture.
22
+ For editing/registering them, use the `context-repo-content` Skill without
23
+ starting production. An explicitly requested source update can select
24
+ `repo-content:<entry-id>` in its confirmed requirement and update scope. The
25
+ prepared update includes current local changes and chapter impact candidates.
26
+ Docs compare cited regions; Skills compare the whole owning Skill directory,
27
+ including untracked additions. Missing historical objects are unknown, not an
28
+ empty diff. Inspect/edit does not advance references; delivery or an explicit
29
+ no-impact outcome settles the selected scope. Historical locators always store
30
+ the real repository path at the cited commit, not today's registration path.
31
+
21
32
  Before starting production, compare the proposed content with the workspace's
22
33
  reader purpose. For clearly unrelated anecdotes or personal rankings, briefly
23
34
  recommend leaving them out of the formal manual or saving them separately because
@@ -17,6 +17,11 @@ package index, and section fingerprint rebuilds are not current close output.
17
17
 
18
18
  ## Default New-Workspace Outputs: Knowledge Base + Website
19
19
 
20
+ Same-repository originals have an optional [repository entrance](repo-content.md):
21
+ `repoContentPage: true` in a KB declaration projects README and Skill summaries,
22
+ not the full document tree. It does not expose that page on a configured website;
23
+ use `repoContentPage: { site: true }` to opt in. Existing declarations are kept.
24
+
20
25
  Output channels support multiple selection. In a new workspace without explicit
21
26
  preferences, the Agent proposes and configures KB + website as the default. Honor
22
27
  user feedback, session authority and existing workspace declarations; LLMS is an
@@ -0,0 +1,71 @@
1
+ # Same-repository content
2
+
3
+ Keep project documentation and authored Skills at their original locations.
4
+ Context registers an entrance without copying their bodies to knowledge or
5
+ source snapshots. For selection and editing use `context-repo-content`.
6
+
7
+ At the Context workspace root, create `repo-content.yaml`:
8
+
9
+ ```yaml
10
+ protocol: context.repo-content/v1
11
+ entries:
12
+ docs:
13
+ kind: docs
14
+ path: docs
15
+ tools:
16
+ kind: skills
17
+ path: .agents/skills
18
+ ```
19
+
20
+ Paths are Git-root-relative, not workspace-relative. Kinds are `docs`,
21
+ `document`, `skills`, and `skill`. Optional `group` is one module level;
22
+ `mount` overrides the default `[group/]<basename>`. Optional `exclude` globs
23
+ are relative to the entry; they are not access control. Overlapping entries,
24
+ outside targets, nested repositories and cycles are rejected.
25
+
26
+ `context source ensure repo-content --format json` maintains relative symlinks
27
+ in `repo-content/`; `source inspect repo-content` and `status` inspect without
28
+ repairing. Ordinary files are not overwritten. With disabled symlinks, search
29
+ real paths from the registry rather than reading Git placeholders. No Git
30
+ configuration or index is changed. Registry and relative links can be committed
31
+ by the user; originals remain the only authoring location.
32
+
33
+ Invalid registration is advisory in `status` and automatic pre-operation link
34
+ maintenance: correct `repo-content.yaml`; existing links are left unchanged.
35
+ The repair command is suggested only for missing or misdirected symlinks, not
36
+ invalid registration, missing targets, ordinary-file conflicts or disabled
37
+ symlinks. Fix those reported conditions rather than repeatedly running ensure.
38
+ Explicit repository-content updates and `context build` require valid
39
+ registration. An invalid registry stops build before replacing existing package
40
+ outputs; it is not treated as an empty registry. Missing source files and
41
+ unavailable Git objects follow the documented fallback behavior instead.
42
+
43
+ Article navigation uses `[Guide](context:repo/docs/guide.md)`. Build projects
44
+ this to an upstream link when available, otherwise a plain location. Evidence
45
+ instead records `repo-content:docs@<full-commit>` plus real historical path,
46
+ line range and content digest. Uncommitted evidence uses `<commit>+worktree`.
47
+ The evidence Wasm supports these references without treating their existence
48
+ as proof that the source was read in the current query.
49
+
50
+ ## Optional entrance page
51
+
52
+ ```ts
53
+ kbPackage({
54
+ name: "project-kb",
55
+ template: { path: "src/package-templates/kb" },
56
+ repoContentPage: true,
57
+ });
58
+ ```
59
+
60
+ SDK default is off. New initialization with an existing nonempty registry
61
+ creates a KB declaration with the entrance enabled; existing declarations are
62
+ preserved. It projects a group's README and Skill names/descriptions under
63
+ `wikis/repo-content.md` and optional group pages, not all docs or Skill scripts.
64
+ HEAD objects are preferred without network fetching, with declared worktree
65
+ fallback when unavailable. Review README sensitivity before exposing it.
66
+ With a configured website, `{ site: true }` opts into a top-level site entrance;
67
+ plain `true` keeps these pages out of the site.
68
+
69
+ Other repositories and externally installed Skills are not same-repository
70
+ content. Registering an entrance does not imply installation, execution,
71
+ production or publication authority.
package/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import type { PackageNavigationDefinition, PackageSelectDefinition } from "./con
5
5
  import type { PhaseDefinition, PhaseResourceReference } from "./phases.js";
6
6
  import type { ProjectSourceDefinition } from "./sources.js";
7
7
  export * from "./indexerCoreExports.js";
8
+ export { repoContentRegistrySchema, repoContentEntrySchema, repoContentPathSchema, repoContentMount, parseRepoContentRef, repoContentScopeMatches, type RepoContentEntry, type RepoContentRegistry } from "./repoContent.js";
8
9
  export { indexerComposerContractSchema, indexerComposerDeclarationSchema, indexerExecutionSchema, indexerProviderLayerFragmentSchema, indexerProviderManifestSchema, indexerProviderOperationSchema, indexerToolSourceDeclarationSchema, isIndexerLayerFragmentKind, isIndexerProviderProtocol, loadIndexerProviderManifest, parseIndexerProviderManifest, } from "./indexerProvider.js";
9
10
  export type { IndexerComposerContract, IndexerComposerDeclaration, IndexerExecution, IndexerProviderLayerFragment, IndexerProviderManifest, IndexerProviderOperation, IndexerToolSourceDeclaration, } from "./indexerProvider.js";
10
11
  export { canonicalOwnerCellRef, indexRequirementSchema, indexRequirementSetSchema, indexerRegistryDigests, indexerDistributionSchema, indexerRegistryEntrySchema, indexerRegistrySchema, loadIndexerRegistry, parseIndexerRegistry, requirementSetFromRegistry, validateFinalizedIndexerRegistry, } from "./indexerRegistry.js";
@@ -109,6 +110,9 @@ export type KbPackageDefinition = BasePackageDefinition & {
109
110
  distribution?: PackageDistributionDefinition;
110
111
  assets?: PackageAssetDefinition;
111
112
  site?: PackageSiteDefinition;
113
+ repoContentPage?: boolean | {
114
+ site: true;
115
+ };
112
116
  };
113
117
  export type LlmsPackageDefinition = BasePackageDefinition & {
114
118
  kind: "package.llms";
@@ -132,6 +136,9 @@ export declare const kbPackage: (definition: {
132
136
  distribution?: PackageDistributionDefinition;
133
137
  assets?: PackageAssetDefinition;
134
138
  site?: PackageSiteDefinition;
139
+ repoContentPage?: boolean | {
140
+ site: true;
141
+ };
135
142
  }) => KbPackageDefinition;
136
143
  export declare const llmsPackage: (definition: {
137
144
  name: string;
package/index.js CHANGED
@@ -22134,6 +22134,38 @@ function validateCurrentIndexerBenchmarkReport(input) {
22134
22134
  }
22135
22135
  return report;
22136
22136
  }
22137
+ // src/repoContent.ts
22138
+ var repoContentPathSchema = exports_external.string().min(1).refine((value) => !/[\\\u0000-\u001f\u007f:]/u.test(value) && value.split("/").every((part) => part !== "" && part !== "." && part !== ".." && part.toLowerCase() !== ".git"), "Use a repository-relative path without traversal or .git components");
22139
+ var segment = exports_external.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);
22140
+ var repoContentEntrySchema = exports_external.object({
22141
+ kind: exports_external.enum(["docs", "skills", "document", "skill"]),
22142
+ path: repoContentPathSchema,
22143
+ exclude: exports_external.array(exports_external.string().min(1)).optional(),
22144
+ group: segment.optional(),
22145
+ mount: repoContentPathSchema.optional(),
22146
+ title: exports_external.string().min(1).optional(),
22147
+ description: exports_external.string().optional()
22148
+ }).strict();
22149
+ var repoContentRegistrySchema = exports_external.object({
22150
+ protocol: exports_external.literal("context.repo-content/v1"),
22151
+ entries: exports_external.record(segment, repoContentEntrySchema)
22152
+ }).strict();
22153
+ function repoContentMount(entry) {
22154
+ return entry.mount ?? [entry.group, entry.path.split("/").at(-1)].filter(Boolean).join("/");
22155
+ }
22156
+ function parseRepoContentRef(value) {
22157
+ const match = /^repo-content:([A-Za-z0-9][A-Za-z0-9._-]*)(?:@([a-fA-F0-9]{40}(?:[a-fA-F0-9]{24})?)(\+worktree)?)?$/u.exec(value);
22158
+ if (!match)
22159
+ return;
22160
+ return { id: match[1], ...match[2] ? { commit: match[2] } : {}, worktree: !!match[3] };
22161
+ }
22162
+ function repoContentScopeMatches(scope, reference) {
22163
+ if (scope === reference)
22164
+ return true;
22165
+ const selected = parseRepoContentRef(scope);
22166
+ const cited = parseRepoContentRef(reference);
22167
+ return !!selected && !selected.commit && !!cited && selected.id === cited.id;
22168
+ }
22137
22169
  // src/indexerRequirementComparison.ts
22138
22170
  function setRelation(oldValues, newValues) {
22139
22171
  const oldContained = [...oldValues].every((value) => newValues.has(value));
@@ -32170,7 +32202,7 @@ var normalizePackageDistribution = (distribution) => {
32170
32202
  }
32171
32203
  const knowledgeNamespace = distribution.knowledgeNamespace.trim();
32172
32204
  const segments = knowledgeNamespace.split("/");
32173
- 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))) {
32205
+ if (knowledgeNamespace.length > PACKAGE_KNOWLEDGE_NAMESPACE_MAX_LENGTH || segments.length === 0 || segments.some((segment2) => segment2.length > PACKAGE_KNOWLEDGE_NAMESPACE_SEGMENT_MAX_LENGTH || !PACKAGE_KNOWLEDGE_NAMESPACE_SEGMENT_PATTERN.test(segment2))) {
32174
32206
  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}`);
32175
32207
  }
32176
32208
  return { knowledgeNamespace };
@@ -32238,7 +32270,7 @@ var createPackageDefinitionBase = (kind, definition) => {
32238
32270
  }
32239
32271
  const select = normalizeSelect(definition.select);
32240
32272
  const acronymSegments = new Set(["ai", "api", "cli", "db", "id", "kb", "llm", "llms", "sdk", "ui"]);
32241
- const defaultDisplayName = definition.name.replace(/[._-]+/gu, " ").trim().replace(/\b[a-z0-9]+\b/gu, (segment) => acronymSegments.has(segment) ? segment.toUpperCase() : `${segment.slice(0, 1).toUpperCase()}${segment.slice(1)}`);
32273
+ const defaultDisplayName = definition.name.replace(/[._-]+/gu, " ").trim().replace(/\b[a-z0-9]+\b/gu, (segment2) => acronymSegments.has(segment2) ? segment2.toUpperCase() : `${segment2.slice(0, 1).toUpperCase()}${segment2.slice(1)}`);
32242
32274
  const builtInVars = {
32243
32275
  displayName: defaultDisplayName.length > 0 ? defaultDisplayName : definition.name,
32244
32276
  packageName: definition.name,
@@ -32274,13 +32306,20 @@ var kbPackage = (definition) => {
32274
32306
  const distribution = normalizePackageDistribution(definition.distribution);
32275
32307
  const assets = normalizePackageAssets(definition.assets);
32276
32308
  const site = normalizePackageSite(definition.site);
32309
+ if (definition.repoContentPage !== undefined && typeof definition.repoContentPage !== "boolean" && (!definition.repoContentPage || typeof definition.repoContentPage !== "object" || definition.repoContentPage.site !== true || Object.keys(definition.repoContentPage).some((key) => key !== "site"))) {
32310
+ throw new TypeError("repoContentPage must be a boolean or { site: true }");
32311
+ }
32312
+ if (typeof definition.repoContentPage === "object" && !site) {
32313
+ throw new TypeError("repoContentPage.site requires a configured site");
32314
+ }
32277
32315
  return {
32278
32316
  kind: "package.kb",
32279
32317
  ...base,
32280
32318
  navigation: normalizePackageNavigation(definition.navigation),
32281
32319
  ...distribution === undefined ? {} : { distribution },
32282
32320
  assets,
32283
- ...site === undefined ? {} : { site }
32321
+ ...site === undefined ? {} : { site },
32322
+ ...definition.repoContentPage === undefined ? {} : { repoContentPage: definition.repoContentPage }
32284
32323
  };
32285
32324
  };
32286
32325
  var llmsPackage = (definition) => ({
@@ -32452,6 +32491,11 @@ export {
32452
32491
  resolveEffectiveIndexerComposers,
32453
32492
  requirementSetFromRegistry,
32454
32493
  requirementRef,
32494
+ repoContentScopeMatches,
32495
+ repoContentRegistrySchema,
32496
+ repoContentPathSchema,
32497
+ repoContentMount,
32498
+ repoContentEntrySchema,
32455
32499
  renderIndexerDeterministicFacts,
32456
32500
  relocateUnchangedArticleRegion,
32457
32501
  relevantResults,
@@ -32470,6 +32514,7 @@ export {
32470
32514
  processedScopeSchema,
32471
32515
  processedScopeKey,
32472
32516
  planIndexerPostAuthorComposition,
32517
+ parseRepoContentRef,
32473
32518
  parseLarkSourcesRegistry,
32474
32519
  parseIndexerRegistry,
32475
32520
  parseIndexerProviderManifest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/context",
3
- "version": "0.7.43",
3
+ "version": "0.7.50",
4
4
  "type": "module",
5
5
  "description": "Declarative SDK for Context knowledge sources, workflows, review, and package outputs",
6
6
  "license": "MIT",
@@ -0,0 +1,87 @@
1
+ import { z } from "zod";
2
+ export declare const repoContentPathSchema: z.ZodEffects<z.ZodString, string, string>;
3
+ export declare const repoContentEntrySchema: z.ZodObject<{
4
+ kind: z.ZodEnum<["docs", "skills", "document", "skill"]>;
5
+ path: z.ZodEffects<z.ZodString, string, string>;
6
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
7
+ group: z.ZodOptional<z.ZodString>;
8
+ mount: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
9
+ title: z.ZodOptional<z.ZodString>;
10
+ description: z.ZodOptional<z.ZodString>;
11
+ }, "strict", z.ZodTypeAny, {
12
+ path: string;
13
+ kind: "document" | "skill" | "docs" | "skills";
14
+ title?: string | undefined;
15
+ description?: string | undefined;
16
+ exclude?: string[] | undefined;
17
+ group?: string | undefined;
18
+ mount?: string | undefined;
19
+ }, {
20
+ path: string;
21
+ kind: "document" | "skill" | "docs" | "skills";
22
+ title?: string | undefined;
23
+ description?: string | undefined;
24
+ exclude?: string[] | undefined;
25
+ group?: string | undefined;
26
+ mount?: string | undefined;
27
+ }>;
28
+ export declare const repoContentRegistrySchema: z.ZodObject<{
29
+ protocol: z.ZodLiteral<"context.repo-content/v1">;
30
+ entries: z.ZodRecord<z.ZodString, z.ZodObject<{
31
+ kind: z.ZodEnum<["docs", "skills", "document", "skill"]>;
32
+ path: z.ZodEffects<z.ZodString, string, string>;
33
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
34
+ group: z.ZodOptional<z.ZodString>;
35
+ mount: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
36
+ title: z.ZodOptional<z.ZodString>;
37
+ description: z.ZodOptional<z.ZodString>;
38
+ }, "strict", z.ZodTypeAny, {
39
+ path: string;
40
+ kind: "document" | "skill" | "docs" | "skills";
41
+ title?: string | undefined;
42
+ description?: string | undefined;
43
+ exclude?: string[] | undefined;
44
+ group?: string | undefined;
45
+ mount?: string | undefined;
46
+ }, {
47
+ path: string;
48
+ kind: "document" | "skill" | "docs" | "skills";
49
+ title?: string | undefined;
50
+ description?: string | undefined;
51
+ exclude?: string[] | undefined;
52
+ group?: string | undefined;
53
+ mount?: string | undefined;
54
+ }>>;
55
+ }, "strict", z.ZodTypeAny, {
56
+ entries: Record<string, {
57
+ path: string;
58
+ kind: "document" | "skill" | "docs" | "skills";
59
+ title?: string | undefined;
60
+ description?: string | undefined;
61
+ exclude?: string[] | undefined;
62
+ group?: string | undefined;
63
+ mount?: string | undefined;
64
+ }>;
65
+ protocol: "context.repo-content/v1";
66
+ }, {
67
+ entries: Record<string, {
68
+ path: string;
69
+ kind: "document" | "skill" | "docs" | "skills";
70
+ title?: string | undefined;
71
+ description?: string | undefined;
72
+ exclude?: string[] | undefined;
73
+ group?: string | undefined;
74
+ mount?: string | undefined;
75
+ }>;
76
+ protocol: "context.repo-content/v1";
77
+ }>;
78
+ export type RepoContentEntry = z.infer<typeof repoContentEntrySchema>;
79
+ export type RepoContentRegistry = z.infer<typeof repoContentRegistrySchema>;
80
+ export declare function repoContentMount(entry: RepoContentEntry): string;
81
+ /** Scope selectors omit a revision; evidence references always include one. */
82
+ export declare function parseRepoContentRef(value: string): {
83
+ id: string;
84
+ commit?: string;
85
+ worktree: boolean;
86
+ } | undefined;
87
+ export declare function repoContentScopeMatches(scope: string, reference: string): boolean;
@@ -25,6 +25,12 @@ as evidence rather than relying on memory or frontmatter summaries.
25
25
 
26
26
  ## Package Roots
27
27
 
28
+ If present, `{{wikisRoot}}/repo-content.md` is a generated repository entrance:
29
+ project README content and Skill summaries, not an approved knowledge article
30
+ or a bundled copy of all project docs. Follow its original links when authorized
31
+ and needed; reading a Skill description does not install or execute it. The
32
+ original repository remains authoritative, and the page states its build baseline.
33
+
28
34
  | Root | Use |
29
35
  |---|---|
30
36
  | `{{wikisRoot}}/` | Code, business and product reference articles. |
@@ -18,6 +18,10 @@ description: 查询 {{displayName}} 中经过审核、可追溯来源的知识
18
18
 
19
19
  ## 知识根目录
20
20
 
21
+ 若存在 `{{wikisRoot}}/repo-content.md`,它是生成的仓库入口页:README 与 Skill
22
+ 简介,不是批准知识文章,也不包含全部项目文档。需要且有权访问时沿链接读取原文;
23
+ 阅读 Skill 说明不代表安装或执行。原仓库是真源,页面标明构建所用基线。
24
+
21
25
  | 根目录 | 用途 |
22
26
  |---|---|
23
27
  | `{{wikisRoot}}/` | 来自 codeindex、business、product 的代码、业务和产品说明。 |
@@ -12,6 +12,13 @@ mappings here.
12
12
 
13
13
  ## Repository sources
14
14
 
15
+ Same-repository docs and authored Skills registered in `repo-content.yaml` are
16
+ not captured source copies. For original edits or registration use
17
+ `context-repo-content`, without starting production. A separately requested
18
+ knowledge update may select `repo-content:<id>`; compare cited document regions
19
+ and entire cited Skill directories, including untracked additions. Inspecting
20
+ or editing never advances the processed baseline. Keep historical real paths.
21
+
15
22
  Start with the current Context Route. If registered repository modules are
16
23
  missing or their local links are broken, follow the route-selected repository
17
24
  recovery procedure. Let the user choose an existing checkout, authorize a scan
@@ -11,6 +11,11 @@ Skill,并以当前 Route、资源和命令为权威;这里只保留稳定的
11
11
 
12
12
  ## 仓库来源的获取和更新
13
13
 
14
+ `repo-content.yaml` 登记的同仓文档和自有 Skills 不是采集副本。编辑原文或登记时
15
+ 使用 `context-repo-content`,不启动生产。另行授权的知识更新可选择
16
+ `repo-content:<id>`;文档检查引用区域,Skill 检查整个目录及未跟踪新增文件。
17
+ 检查与编辑不推进处理基线,旧证据保留当时的真实仓库路径。
18
+
14
19
  先检查当前 Context Route。已登记仓库模块缺失或本地链接断开时,使用 Route
15
20
  选择的仓库恢复流程,让用户选择已有 checkout、授权在一个限定目录内扫描,
16
21
  或明确允许 clone 已登记的固定 commit。