@c4a/context 0.6.0-beta.8 → 0.6.1-beta.2

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/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",
@@ -11768,8 +11772,22 @@ function assertUniquePhaseIds(phases) {
11768
11772
  firstById.set(phase.id, { index, kind: phase.kind });
11769
11773
  }
11770
11774
  }
11775
+ function assertUniquePackageKnowledgeNamespaces(packages) {
11776
+ const firstByNamespace = new Map;
11777
+ for (const [index, pkg] of packages.entries()) {
11778
+ const namespace = pkg.kind === "package.kb" ? pkg.distribution?.knowledgeNamespace : undefined;
11779
+ if (namespace === undefined)
11780
+ continue;
11781
+ const first = firstByNamespace.get(namespace);
11782
+ if (first !== undefined) {
11783
+ throw new TypeError(`Duplicate package knowledge namespace ${JSON.stringify(namespace)}: packages[${first.index}] (${first.name}) conflicts with packages[${index}] (${pkg.name}). Every distributable knowledge package namespace must be unique.`);
11784
+ }
11785
+ firstByNamespace.set(namespace, { index, name: pkg.name });
11786
+ }
11787
+ }
11771
11788
  var defineProject = (project) => {
11772
11789
  assertUniquePhaseIds(project.phases);
11790
+ assertUniquePackageKnowledgeNamespaces(project.packages);
11773
11791
  return {
11774
11792
  kind: "context.project",
11775
11793
  project
@@ -11818,7 +11836,20 @@ var normalizeSelect = (select) => {
11818
11836
  }
11819
11837
  return Object.keys(normalized).length > 0 ? normalized : undefined;
11820
11838
  };
11839
+ var normalizePackageNavigation = (navigation) => {
11840
+ const maxInlineEntries = navigation?.maxInlineEntries ?? DEFAULT_PACKAGE_NAVIGATION.maxInlineEntries;
11841
+ if (!Number.isSafeInteger(maxInlineEntries) || maxInlineEntries < 1) {
11842
+ throw new TypeError(`Package navigation.maxInlineEntries must be a positive safe integer: ${maxInlineEntries}`);
11843
+ }
11844
+ return {
11845
+ foldDirectoryIndexes: navigation?.foldDirectoryIndexes ?? DEFAULT_PACKAGE_NAVIGATION.foldDirectoryIndexes,
11846
+ maxInlineEntries
11847
+ };
11848
+ };
11821
11849
  var PACKAGE_NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/u;
11850
+ var PACKAGE_KNOWLEDGE_NAMESPACE_SEGMENT_PATTERN = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/u;
11851
+ var PACKAGE_KNOWLEDGE_NAMESPACE_SEGMENT_MAX_LENGTH = 48;
11852
+ var PACKAGE_KNOWLEDGE_NAMESPACE_MAX_LENGTH = 128;
11822
11853
  var isSafeProjectRelativePath = (value) => {
11823
11854
  if (value.length === 0)
11824
11855
  return false;
@@ -11838,6 +11869,19 @@ var assertSelectCollections = (collections) => {
11838
11869
  assertKnowledgeCollection(collection, "Package select.collections");
11839
11870
  }
11840
11871
  };
11872
+ var normalizePackageDistribution = (distribution) => {
11873
+ if (distribution === undefined)
11874
+ return;
11875
+ if (typeof distribution.knowledgeNamespace !== "string") {
11876
+ throw new TypeError("Package distribution.knowledgeNamespace must be a string.");
11877
+ }
11878
+ const knowledgeNamespace = distribution.knowledgeNamespace.trim();
11879
+ const segments = knowledgeNamespace.split("/");
11880
+ 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))) {
11881
+ 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}`);
11882
+ }
11883
+ return { knowledgeNamespace };
11884
+ };
11841
11885
  var assertSelectOkfRoots = (roots) => {
11842
11886
  for (const root of roots) {
11843
11887
  assertOkfRoot(root, "Package select.okfRoots");
@@ -11880,10 +11924,19 @@ var createPackageDefinitionBase = (kind, definition) => {
11880
11924
  }
11881
11925
  return packageDefinition;
11882
11926
  };
11883
- var kbPackage = (definition) => ({
11884
- kind: "package.kb",
11885
- ...createPackageDefinitionBase("kb", definition)
11886
- });
11927
+ var kbPackage = (definition) => {
11928
+ const base = createPackageDefinitionBase("kb", definition);
11929
+ const distribution = normalizePackageDistribution(definition.distribution ?? { knowledgeNamespace: definition.name });
11930
+ if (distribution === undefined) {
11931
+ throw new TypeError("KB package distribution must resolve to a knowledge namespace.");
11932
+ }
11933
+ return {
11934
+ kind: "package.kb",
11935
+ ...base,
11936
+ navigation: normalizePackageNavigation(definition.navigation),
11937
+ distribution
11938
+ };
11939
+ };
11887
11940
  var llmsPackage = (definition) => ({
11888
11941
  kind: "package.llms",
11889
11942
  ...createPackageDefinitionBase("llms", definition)
@@ -11922,6 +11975,7 @@ export {
11922
11975
  DOCUMENT_EVIDENCE_SECTION_VALIDATION_STAGES,
11923
11976
  DOCUMENT_COMPILE_ACTION_SCHEMA_VERSION,
11924
11977
  DEFAULT_REPO_SOURCES_REGISTRY_PATH,
11978
+ DEFAULT_PACKAGE_NAVIGATION,
11925
11979
  DEFAULT_LARK_SOURCES_REGISTRY_PATH,
11926
11980
  DEFAULT_FILE_SOURCES_REGISTRY_PATH
11927
11981
  };
package/package.json CHANGED
@@ -1,7 +1,20 @@
1
1
  {
2
2
  "name": "@c4a/context",
3
- "version": "0.6.0-beta.8",
3
+ "version": "0.6.1-beta.2",
4
4
  "type": "module",
5
+ "description": "Context SDK — project-local configuration and workspace primitives",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/context4ai/context.git",
10
+ "directory": "packages/context"
11
+ },
12
+ "keywords": [
13
+ "context",
14
+ "sdk",
15
+ "knowledge",
16
+ "workspace"
17
+ ],
5
18
  "dependencies": {
6
19
  "yaml": "^2.5.1",
7
20
  "zod": "^3.23.8"
@@ -11,20 +11,20 @@ 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 `skills/knowledge-query/SKILL.md` entry teaches agents how to navigate OKF
15
- indexes and cite copied OKF root directories, starting with
16
- `wikis/`. Customize template files before build when the package needs
14
+ The bundled knowledge-query Skill teaches agents how to navigate OKF indexes
15
+ and cite copied OKF root directories, starting with
16
+ `{{wikisRoot}}/`. Customize template files before build when the package needs
17
17
  product-specific skills or routing rules.
18
18
 
19
- Selected OKF root directories such as `wikis/`, `guides/`, `rules/`, and
20
- `feats/` follow the C4A OKF Profile: OKF fields and C4A extension fields stay
19
+ Selected OKF root directories such as `{{wikisRoot}}/`, `{{guidesRoot}}/`,
20
+ `{{rulesRoot}}/`, and `{{featsRoot}}/` follow the C4A OKF Profile: OKF fields and C4A extension fields stay
21
21
  at the top level, and no `context` or `schema` field is emitted. Root mapping:
22
- `wikis/` maps from structured `codegraph`, `business`, and `product` knowledge;
23
- `guides/` maps from `architecture`, `sop`, `faq`, `decision`, and `incident`;
24
- `rules/` maps from `standards` and `test`; `feats/` maps from `feats`. Treat
25
- `wikis/` as the entity-and-relationship layer; guides and rules may explain or
22
+ `{{wikisRoot}}/` maps from structured `codegraph`, `business`, and `product` knowledge;
23
+ `{{guidesRoot}}/` maps from `architecture`, `sop`, `faq`, `decision`, and `incident`;
24
+ `{{rulesRoot}}/` maps from `standards` and `test`; `{{featsRoot}}/` maps from `feats`. Treat
25
+ `{{wikisRoot}}/` as the entity-and-relationship layer; guides and rules may explain or
26
26
  constrain that layer. Customize
27
- `wikis/index.md` before build to describe the package scope and query guidance;
27
+ the logical `wikis/index.md` template before build to describe the package scope and query guidance;
28
28
  other selected OKF root indexes are generated unless this template supplies
29
29
  them.
30
30
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: knowledge-query
2
+ name: {{skillName}}
3
3
  description: Query the approved knowledge bundled with {{displayName}}.
4
4
  ---
5
5
 
@@ -48,10 +48,10 @@ beyond the packaged content.
48
48
 
49
49
  | User intent | First move | Evidence move |
50
50
  |---|---|---|
51
- | Vague topic or unknown name | Open the package's OKF root index, usually `wikis/index.md`, then child indexes such as `wikis/<group>/index.md`. If the package includes other selected OKF roots such as `guides/` or `rules/`, use their indexes too. | Choose candidate pages by title, path, frontmatter, and index grouping. |
52
- | Architecture, procedure, FAQ, decision, incident, or troubleshooting question | Start from `guides/index.md` when present. These pages are mapped from internal `architecture`, `sop`, `faq`, `decision`, and `incident` collections. | Use guide pages for explanations, design narratives, decisions, steps, operational context, and troubleshooting; cite the relevant sections. |
53
- | Structured product or business question | Start from `wikis/index.md`, then the `product` or `business` group index. | Use entity pages and typed relationships to establish scope before reading supporting narratives. |
54
- | Standard, constraint, acceptance, or test scenario question | Start from `rules/index.md` when present. These pages are mapped from internal `standards` and `test` collections. | Use rule pages for normative constraints, acceptance criteria, and validation scenarios. |
51
+ | Vague topic or unknown name | Open the package's OKF root index, usually `{{wikisRoot}}/index.md`, then its child indexes. If the package includes other selected OKF roots such as `{{guidesRoot}}/` or `{{rulesRoot}}/`, use their indexes too. | Choose candidate pages by title, path, frontmatter, and index grouping. |
52
+ | Architecture, procedure, FAQ, decision, incident, or troubleshooting question | Start from `{{guidesRoot}}/index.md` when present. These pages are mapped from internal `architecture`, `sop`, `faq`, `decision`, and `incident` collections. | Use guide pages for explanations, design narratives, decisions, steps, operational context, and troubleshooting; cite the relevant sections. |
53
+ | Structured product or business question | Start from `{{wikisRoot}}/index.md`, then the `product` or `business` group index. | Use entity pages and typed relationships to establish scope before reading supporting narratives. |
54
+ | Standard, constraint, acceptance, or test scenario question | Start from `{{rulesRoot}}/index.md` when present. These pages are mapped from internal `standards` and `test` collections. | Use rule pages for normative constraints, acceptance criteria, and validation scenarios. |
55
55
  | Specific entity/domain/action named | Open the matching page or nearest group index. | Read the page sections and source metadata. |
56
56
  | Relationship or impact question | Check `context-build-inventory.json` `structure.edge_records`, then related endpoint pages. | Cite typed edge evidence if available; otherwise cite page sections and mark relation gaps. |
57
57
  | Detail within a known page | Read that page's relevant `context:section` block. | Cite the section id/source_ref and quote or summarize only supported text. |
@@ -79,11 +79,11 @@ matches.
79
79
 
80
80
  ## Workflow
81
81
 
82
- 1. Start with the relevant OKF root index, usually `wikis/index.md`, to
82
+ 1. Start with the relevant OKF root index, usually `{{wikisRoot}}/index.md`, to
83
83
  understand the package scope.
84
- 2. Follow OKF directory indexes such as `wikis/<group>/index.md` before opening
85
- pages. If the package includes other selected OKF roots, inspect their
86
- indexes the same way.
84
+ 2. Follow the links exposed by that index. Small directories may link directly
85
+ to pages; larger directories may expose their own `index.md`. If the package
86
+ includes other selected OKF roots, inspect their root indexes the same way.
87
87
  3. Open only the candidate pages needed for the question; avoid workspace-wide
88
88
  reading unless the user asks for an inventory.
89
89
  4. Inspect frontmatter `node_type`, `sources`, and `context:section` comments to
@@ -184,13 +184,14 @@ the user it is false; distinguish "not evidenced here" from "not true."
184
184
 
185
185
  ## Knowledge Boundary
186
186
 
187
- - The bundled OKF root directories, usually including `wikis/`, are the source
187
+ - The bundled OKF root directories, usually including `{{wikisRoot}}/`, are the source
188
188
  of truth for this skill.
189
- - OKF root mapping: `wikis/` maps from the structured `codegraph`, `business`,
190
- and `product` collections; `guides/` maps from `architecture`, `sop`, `faq`,
191
- `decision`, and `incident`; `rules/` maps from `standards` and `test`;
192
- `feats/` maps from `feats`.
193
- - Treat `wikis/` as the primary entity-and-relationship layer. Guides and rules
189
+ - OKF root mapping: `{{wikisRoot}}/` maps from the structured `codegraph`,
190
+ `business`, and `product` collections; `{{guidesRoot}}/` maps from
191
+ `architecture`, `sop`, `faq`, `decision`, and `incident`;
192
+ `{{rulesRoot}}/` maps from `standards` and `test`; `{{featsRoot}}/` maps from
193
+ `feats`.
194
+ - Treat `{{wikisRoot}}/` as the primary entity-and-relationship layer. Guides and rules
194
195
  may explain, operationalize, or constrain that structured knowledge, but
195
196
  directory co-location alone is not relationship evidence.
196
197
  - Bundled OKF root directories follow the C4A OKF Profile.
@@ -6,7 +6,7 @@ tags:
6
6
  - context
7
7
  - knowledge-base
8
8
  timestamp: "{{knowledgeTimestamp}}"
9
- resource: "context://package/{{packageName}}/wikis"
9
+ resource: "context://package/{{packageName}}/{{wikisRoot}}"
10
10
  package: "{{packageName}}"
11
11
  package_kind: "{{packageKind}}"
12
12
  knowledge_count: {{knowledgeCount}}
@@ -14,7 +14,7 @@ knowledge_count: {{knowledgeCount}}
14
14
 
15
15
  <!-- context:template
16
16
  This file is a starter template. It is rendered by `context build` and copied to
17
- `dist/<package-name>/wikis/index.md`.
17
+ `dist/<package-name>/{{wikisRoot}}/index.md`.
18
18
 
19
19
  Template comments that start with `context:template` are removed from build output.
20
20
  Read the template variable guide before customizing:
@@ -22,9 +22,9 @@ node_modules/@c4a/context/docs/reference/template-variables.md
22
22
 
23
23
  Customize this file before calling the package usable. Add the bundle scope,
24
24
  intended readers, recommended reading order, known gaps, product scenarios,
25
- or task-focused entry sections. The default root index lists only the
26
- next-level directories; context build generates directory-level index.md
27
- files below it.
25
+ or task-focused entry sections. The default root index links small directory
26
+ contents directly and links to child index.md files when a directory exceeds
27
+ the package navigation threshold.
28
28
  -->
29
29
 
30
30
  # {{displayName}}
@@ -38,6 +38,6 @@ Use this index as the entry point, then open the linked knowledge pages for sour
38
38
 
39
39
  ## How To Use
40
40
 
41
- - Start from the directory list above, then open child indexes and linked knowledge pages for source-linked details.
42
- - Use `skills/knowledge-query/SKILL.md` when this bundle is installed as an agent knowledge package.
41
+ - Start from the navigation above, then open linked pages or child indexes for source-linked details.
42
+ - Use the bundled knowledge-query Skill when this bundle is installed as an agent knowledge package.
43
43
  - Customize `src/package-templates/kb/wikis/index.md` before build to add bundle scope, known gaps, project-specific reading paths, or task entry points.