@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
@@ -1,12 +1,70 @@
1
1
  # Indexer Provider protocol
2
2
 
3
3
  Context defines one Provider manifest, `context-indexer.yaml`, with protocol
4
- `context.indexer.provider/v1`. Code and Markdown Providers use the same field
4
+ `context.indexer.provider/v1`. Code, Markdown, Note and Sessions Providers use the same field
5
5
  tree; `domains`, profiles and declared operations describe their applicable
6
6
  inputs.
7
7
 
8
8
  This page documents the protocol surface currently exposed by `@c4a/context`.
9
- It does not imply that the 0.7.0 CLI Route or its release channel is complete.
9
+ Use the current CLI Route for executable inputs, schemas and selected resources.
10
+ A protocol validator exported by the SDK is not a separate production workflow.
11
+
12
+ ## Articles supported by approved knowledge
13
+
14
+ An article plan may declare `knowledge_dependencies`: stable `artifact_ref`,
15
+ optional `section_refs` (empty means the approved article), and `required`.
16
+ Use references supplied by Context; reader titles and output paths are not
17
+ article identities. Each article keeps its existing primary subject and owned
18
+ members. Referencing another article does not assign its members again.
19
+
20
+ The current Partition/Author workflow delivers ready upstream articles before
21
+ dependent required articles. An unavailable dependency remains visible in the
22
+ structure preview; `request-adjustment` returns to planning. It cannot finish
23
+ as an empty Author wave. Optional Composer output does not satisfy a required
24
+ article plan.
25
+
26
+ Review saves the approved fact payloads, evidence coordinates and versions with
27
+ the approved Markdown transaction. These remain in `knowledge/structure.yaml`
28
+ after close and temporary-cache cleanup. Author receives authorized supporting
29
+ facts separately from approved interpretation. Current source captures, the
30
+ Provider's accepted evidence kinds and the approved article version constrain
31
+ that projection. A stored snapshot alone never expands source access.
32
+
33
+ Previously approved dependencies can reuse their registered source reader even
34
+ when that source has no owned Partition group in the current wave. Only the
35
+ referenced authorized files enter the supporting projection. Missing or changed
36
+ source files remain an upstream update task.
37
+
38
+ An approved dependency change produces a verification warning for downstream
39
+ articles. Use the existing `context revise` action on an affected article; its
40
+ current route exposes `knowledge_input` with supporting facts and interpretations.
41
+ Review accepts the refreshed supporting version even when the Agent confirms
42
+ that the wording can stay the same. A plain edit with unavailable support does
43
+ not clear the warning. `--regenerate` remains the existing program-block rebuild
44
+ option, not a prerequisite for revising a prose synthesis.
45
+
46
+ Writing style, chapter drift and ordinary Provider version differences remain
47
+ guidance. Changed source/approval identities invalidate an in-flight supporting
48
+ projection; they are not semantic content judgments.
49
+
50
+ ## Current CLI Author batches
51
+
52
+ Use the current Route's task keys and supplied scaffold. Within a CLI batch,
53
+ `group_key` may be omitted: preview and completion inherit it from the selected
54
+ current task. An explicitly different group is rejected. Standalone SDK semantic
55
+ results still require `group_key`. Intent and eligible policy use the existing
56
+ page-plan defaults; changing a page's purpose is not a metadata repair.
57
+
58
+ The inventory reading joins exact member/fact identities to parser names, kinds
59
+ and explicit `propsType` values. These are navigation references, not proof that
60
+ a symbol is public or a member has been covered. Keep semantic dispositions and
61
+ source evidence explicit.
62
+
63
+ On a stale revision, the CLI exposes a current Route snapshot and current tasks,
64
+ plus accepted identities available from the current main ledger and its Composers.
65
+ Task keys are local to each Route. Compare stable workset/request identities,
66
+ read the new Route and do not replay accepted work. Missing historical records
67
+ are not evidence that old work is unaccepted.
10
68
 
11
69
  ## Resources and execution
12
70
 
@@ -76,6 +134,15 @@ config against the Bundle's closed data-only schema, binds the project-local
76
134
  customization fingerprint and requires a policy digest for executable
77
135
  resources. Missing, duplicate, stale or extra inputs fail closed.
78
136
 
137
+ Selection validation is not an upgrade gate on an instruction-only bundled
138
+ Provider. On resume, the CLI resolves that Provider by Skill and portable
139
+ distribution from the current installation, checks the required capabilities,
140
+ and refreshes instruction delivery without comparing it to the registry's
141
+ historical version/integrity. Compatible persisted tasks keep their original
142
+ request/result identities. The current Route revision still prevents stale
143
+ submissions. This does not change staged program execution authorization or
144
+ allow results to be reused across changed source, config or result contracts.
145
+
79
146
  The final stable report excludes transport paths, delivery timestamps and
80
147
  runtime receipt digests. Those values remain in a separate runtime receipt
81
148
  projection, so rematerializing identical content does not make the selection
@@ -375,6 +442,19 @@ temporary Provider path.
375
442
 
376
443
  ## Controlled invocation
377
444
 
445
+ Author result acceptance checks the actual task, source/module, subject and
446
+ Provider layer. Provider integrity, bundle/config/customization fingerprints
447
+ remain recorded metadata, not byte-equality gates between a resumed request and
448
+ its result. Selected Facts are resolved by their supplied identity and source
449
+ references; their current values are recorded without comparing a previous
450
+ parser payload digest. Source-span line ranges may expand within the same file
451
+ content. Structured declarations resolve actual file/item identities, not a
452
+ previous inventory or signature fingerprint. Source file content checks,
453
+ unknown-reference rejection and atomic write protection remain in force.
454
+
455
+ These continuation rules do not relax executable program authorization or allow
456
+ an Agent to select undeclared sources.
457
+
378
458
  `context.indexer.controlled-invocation/v1` binds:
379
459
 
380
460
  - the exact Indexer, Provider, version, Bundle integrity and stable Provider
@@ -387,7 +467,7 @@ temporary Provider path.
387
467
  - a stable trust-policy and authority digest;
388
468
  - timeout and stdin/stdout/stderr byte limits.
389
469
 
390
- The 0.7.0 built-in Host capability is `sandboxed_program: false`. A first-party,
470
+ The built-in Host capability is `sandboxed_program: false`. A first-party,
391
471
  verified or exact project-authorized program may use the `trusted-program` path,
392
472
  which is not an isolation claim. An untrusted program without a real sandbox is
393
473
  not executable.
@@ -535,8 +615,11 @@ children, cycles, path collisions and unregistered files fail. Reader bodies
535
615
  over 1500 lines produce a non-blocking advisory only. Total physical Artifact
536
616
  count has no global maximum.
537
617
 
538
- An initial layout does not create a structural Gate. A content-only increment
539
- reuses the existing Artifact identity and also skips the Gate. Adding reader
618
+ An initial layout does not create the protected `confirm-layout-change` Gate.
619
+ The main lifecycle still reviews its semantic structure before Author in
620
+ ordinary mode; new topics in an update receive that structure review too.
621
+ A content-only increment reuses the existing Artifact identity and skips the
622
+ protected layout-change Gate. Adding reader
540
623
  fan-out to an already approved Node, removing or renaming an Artifact,
541
624
  splitting/merging its declared lineage, moving a logical Section, or changing
542
625
  an approved collection/path is represented by a digest-bound layout change
@@ -585,9 +668,11 @@ ledger, answer workset, or special close route for them.
585
668
  Newly captured Markdown, tool snapshots, or other authorized material re-enter
586
669
  the normal `main-index` operation. The affected Partition and Author worksets
587
670
  run again, reconciliation is recomputed, and the user reviews the resulting
588
- knowledge Candidate once. Successful close writes only approved knowledge and
589
- the recovery metadata in `knowledge/structure.yaml`, then clears transient
590
- Indexer runtime state.
671
+ knowledge Candidate through the existing content Review. Review apply writes
672
+ approved Markdown; close projects `knowledge/structure.yaml` and verifies it.
673
+ Delivery retains accepted work while more pages remain, then cleans completed
674
+ transient state. Durable `processed_scopes` advance only after the selected
675
+ scope's required work and build complete, not after one page in that scope.
591
676
 
592
677
  ## Detector and inspector
593
678
 
@@ -698,7 +783,7 @@ Only `{{variable:<id>}}` and `{{block:<id>}}` are accepted. Direct variables are
698
783
  semantic prose. A block source variable is a deterministic Fact projection,
699
784
  must bind canonical `fact_refs`, and must equal the CLI's normalized projection
700
785
  of those Facts. Blocks select one of
701
- the CLI-owned `bullet-list`, `key-value-table` or `json-code-block` renderers;
786
+ the CLI-owned `bullet-list`, `key-value-table`, `json-code-block` or `public-contract-table` renderers;
702
787
  templates cannot register code or helpers. A block directive occupies its own
703
788
  template line so the renderer can retain an exact content-layer boundary. The
704
789
  contract and body must declare exactly the same Sections and placeholders.
@@ -713,12 +798,13 @@ or sufficient evidence is absent from the rendered Candidate. A required
713
798
  Section in the same state becomes the already-declared material-question
714
799
  transition and makes `review_ready` false.
715
800
 
716
- Before a Candidate can enter Review, Context rejects unknown directives,
717
- unresolved variables, template comments, example placeholders, standalone or
718
- bracketed `TODO`/`TBD`/`待补充`/`待生成` markers, title-only Sections and budget
719
- overflow. A source-backed sentence that discusses a known TODO is not treated
720
- as a placeholder merely because it contains that token; it remains semantic
721
- prose and therefore requires Agent Review. The rendered
801
+ Context validates template-program directives, declared variable types and
802
+ expansion limits before rendering. Supplied variable values and Section prose
803
+ are content, not template programs: JSX, braces, comments, TODOs, headings and
804
+ example placeholders do not cause a content-validation failure. Missing or
805
+ invalid structured input is distinct from an author's choice of words.
806
+ Unfilled authoring placeholders can be mentioned during the existing Agent or
807
+ user Review, but are not an additional CLI gate. The rendered
722
808
  Section content, ordered content-layer ledger and evidence receive stable
723
809
  digests. Deterministic blocks contribute catalog completeness but never
724
810
  semantic-prose density. Later `build` projects this approved body; it does not
@@ -732,10 +818,37 @@ unit, one of its CLI-owned inventory members, or an authorized target-resolution
732
818
  identity. Missing owners, outside subjects, unknown evidence and evidence that
733
819
  is known globally but absent from the owner Section all fail Result validation.
734
820
 
735
- Main-run validation derives
736
- `context.indexer.generated-authoring-audit/v1`. It reports controlled generated
737
- placeholder and empty emitted-Section hard findings, proves that every emitted
738
- structured claim passed owner-local evidence coverage, and lists every
739
- semantic-prose block or direct authored template variable as
740
- `semantic-prose-agent-review-required`. It does not scan free prose to claim
741
- that unsupported natural-language assertions were mechanically detected.
821
+ Main-run validation does not produce a prose-quality audit. Content usefulness,
822
+ completeness and faithfulness belong to the existing Agent or user Review.
823
+ Structured owner/source checks still run, but no keyword, punctuation, heading
824
+ or sentence-pattern scan can reject an otherwise valid Result. Physical output
825
+ checks distinguish a missing or blank body from an authored body; they do not
826
+ decide whether headings, comments or short prose are sufficient knowledge.
827
+
828
+ ### Groups narrowed by a scope decision
829
+
830
+ The CLI may attach `scope_change.removed_member_ids` to a derived PartitionPlan
831
+ group after excluding only part of its membership. This is runtime provenance,
832
+ not an extra field Provider authors should invent in semantic Partition results.
833
+ The remaining identity stays stable; the old page form/template is no longer a
834
+ binding choice. Author receives the change in `page_plan.scope_change` and must
835
+ reassess the residual sources, title and reader task. It can choose an allowed
836
+ page form or an applicable non-publishing outcome. This metadata does not belong
837
+ in knowledge frontmatter and is not proof that remaining material is useful.
838
+
839
+ ## Incremental planning handoff
840
+
841
+ A semantic Partition group may declare `ready_for_author: true` when the Agent
842
+ has resolved its subject, primary ownership, reader task and shared dependencies.
843
+ The CLI can then deliver an initial wave before all Partition tasks are accepted.
844
+ This is an optional scheduling declaration, not a new evidence or approval gate.
845
+ Absent/false groups wait; every inventory member still needs a final disposition.
846
+ The original Partition ledger resumes after normal structure review, Author,
847
+ Composer, content Review, close and successful build. Later material for the same
848
+ subject reuses its page identity and approved prose. A wave finishing never means
849
+ the remaining source scope is complete.
850
+
851
+ Known code-symbol planning views provide member overviews with immutable full
852
+ fact links and bounded captured-source access. Providers must inspect details
853
+ when semantic boundaries are uncertain; unknown payload formats retain full
854
+ reading. Author receives full selected facts and source material.
@@ -182,7 +182,7 @@ Built-in variables:
182
182
  | `{{displayName}}` | Display name. Defaults to a title-cased `packageName`; override with `template.vars.displayName`. |
183
183
  | `{{knowledgeCount}}` | Number of selected approved Markdown files. |
184
184
  | `{{knowledgeTimestamp}}` | Latest `timestamp` from selected approved Markdown, or `1970-01-01T00:00:00.000Z` when empty. |
185
- | `{{knowledge}}` | Concatenated selected approved Markdown bundle. |
185
+ | `{{knowledge}}` | Concatenated consumer projection of selected approved pages, with path headings and without lifecycle metadata. |
186
186
  | `{{approvedKnowledge}}` | Alias for `{{knowledge}}`. |
187
187
  | `{{knowledgeItems}}` | Array of selected approved knowledge page metadata for loops. |
188
188
  | `{{knowledgeGroups}}` | Selected approved knowledge pages grouped by OKF root and first directory segment; each item also exposes `internal_collection`. |
@@ -322,7 +322,7 @@ Approved Markdown under `knowledge/` and its deterministic
322
322
  revision, or build. Do not copy a compact page as a new page without using a
323
323
  Context authoring command;
324
324
  - do not nest Context production metadata under `context`; fields such as
325
- `context.sources` and `context.code_symbols` are not part of the 0.6 profile;
325
+ `context.sources` and `context.code_symbols` are not accepted production fields;
326
326
  - section provenance lives in `<!-- context:section ... source_ref="..." -->`
327
327
  comments. When a Section needs more than one citation, the CLI preserves the
328
328
  complete set in its adjacent `context:source_refs` block;
@@ -352,8 +352,9 @@ treat the complete `source_ref` as opaque. Production pages do not expose
352
352
  Candidate fingerprints, Indexer digests, or `code_origin`.
353
353
 
354
354
  `#span:` refs retain source snapshot line ranges for human review, diffing, and
355
- stable re-pinning. They resolve against committed file/lark document snapshots,
356
- not the code symbol index.
355
+ stable re-pinning. They resolve against the stored file/Lark snapshot or the saved
356
+ Note/Sessions Markdown, not the code symbol index. A session's optional commit/MR
357
+ association stays in its source file; knowledge does not duplicate those fields.
357
358
 
358
359
  The kb package root may contain agent files such as `AGENTS.md` and `skills/`.
359
360
  The OKF-compatible surface is the selected `wikis/`, `guides/`, `rules/`, and
@@ -373,11 +374,11 @@ The OKF-compatible surface is the selected `wikis/`, `guides/`, `rules/`, and
373
374
  6. Writes output under `dist/<package-name>/`.
374
375
 
375
376
  `context-build-inventory.json` records what was selected and why. Each selected
376
- file includes `selected_by` entries such as `{ "kind": "collection" }` and a
377
- `production_metadata` object for selected page-level production fields. Child
378
- and relationship records use the inventory's canonical structure projection,
379
- `{ "kind": "okf_root" }`, `{ "kind": "include" }`, or
380
- `{ "kind": "default" }`. The inventory also exposes package-visible typed
377
+ file includes `selected_by` entries such as `{ "kind": "collection" }`,
378
+ `{ "kind": "okf_root" }`, `{ "kind": "include" }`, or `{ "kind": "default" }`,
379
+ and a `production_metadata` object for selected page-level production fields.
380
+ Child and relationship records use the inventory's canonical structure
381
+ projection. The inventory exposes package-visible typed
381
382
  edges under `structure.edge_records`; these records are filtered to edges whose
382
383
  endpoints are present in the selected package. Use those edge records for
383
384
  relationship citations inside the package instead of assuming the workspace
@@ -26,14 +26,30 @@ state.
26
26
 
27
27
  ```ts
28
28
  const repo = source("20260901", "component-lib");
29
- const docs = source("product-docs", { type: "file" });
30
- const handbook = source("handbook", { type: "lark" });
31
- const everyRepo = allSources("repo");
29
+ const docs = source("20260901/product-docs", { type: "file" });
30
+ const handbook = source("20260901/handbook", { type: "lark" });
31
+ const note = source("20260908/decision-context.md", { type: "note" });
32
+ const session = source("20260908/design-discussion.md", { type: "sessions" });
33
+ const everyRepo = allSources("repo"); // array: use ...everyRepo inside sources
34
+ const everySession = allSources("sessions");
32
35
  ```
33
36
 
34
- References resolve against `sources/repo/index.yaml`,
35
- `sources/file/index.yaml`, and `sources/lark/index.yaml`. Register or refresh
36
- sources through `context source ...`; do not invent snapshot directories.
37
+ Repo, file and Lark references resolve against their respective
38
+ `sources/<type>/index.yaml`. Their names include the registration date and module.
39
+ Register or refresh them through `context source ...`.
40
+
41
+ Note and Sessions references resolve directly to saved Markdown under
42
+ `sources/note/YYYYMMDD/topic.md` and `sources/sessions/YYYYMMDD/topic.md`.
43
+ Use `context source import` to save them; they have no separate registry or
44
+ capture phase. Explicitly include the desired typed references in `sources`,
45
+ for example `sources: [note, session]`, or use `sources: [...everySession]`
46
+ when all saved sessions are intended. Merely saving a source does not select it.
47
+
48
+ A project's source list enables acquisition and initial selection; requirements
49
+ and the selected Indexer's target/read scopes determine what it owns and may read.
50
+ Supporting text does not require a separate page or primary Indexer. See
51
+ [note preparation](../guides/note.md), [sessions preparation](../guides/sessions.md)
52
+ and [knowledge updates](../guides/knowledge-updates.md).
37
53
 
38
54
  ## Capture phases
39
55
 
@@ -44,8 +60,55 @@ captureLark({ source: handbook });
44
60
  ```
45
61
 
46
62
  Capture only creates a deterministic readable snapshot. Classification,
47
- partitioning, authoring, Candidate creation, and Review belong to the selected
48
- Markdown Indexer.
63
+ partitioning and authoring use the selected Provider's guidance. The CLI owns
64
+ worksets, Candidate creation, Review application and delivery. Code, Markdown,
65
+ Note and Sessions Providers can use authorized supporting documents without
66
+ creating a second capture or knowledge pipeline.
67
+
68
+ ### Batch capture from the source registry
69
+
70
+ When all registered Lark documents are intended for this project and share capture
71
+ settings, read the registry once instead of copying its module names into
72
+ `src/index.ts`. For the standard `src/index.ts` entry:
73
+
74
+ ```ts
75
+ import { fileURLToPath } from "node:url";
76
+ import {
77
+ allSources, captureLark, defineProject, loadSourcesRegistry, source,
78
+ } from "@c4a/context";
79
+
80
+ const workspaceRoot = fileURLToPath(new URL("../", import.meta.url));
81
+ const registry = await loadSourcesRegistry({ rootDir: workspaceRoot });
82
+ const documents = registry.larks.map(entry =>
83
+ source(entry.name, { type: "lark" }),
84
+ );
85
+
86
+ export default defineProject({
87
+ sources: [...allSources("repo"), ...documents],
88
+ phases: documents.map(document => captureLark({ source: document })),
89
+ packages: [],
90
+ });
91
+ ```
92
+
93
+ Merge this pattern into existing declarations; preserve unrelated phases and
94
+ package outputs. Adjust the root calculation if the entry lives elsewhere.
95
+ Registry loading only reads local registrations; it does not fetch documents.
96
+
97
+ - `sources/lark/index.yaml` owns document identities, URLs and titles. The project
98
+ selects those identities and declares capture settings. This example includes
99
+ future registrations too; use it only when the entire registered set is intended.
100
+ - For a subset, filter registry entries by the intended namespace or names before
101
+ mapping. Apply exceptional resource settings within the same map instead of
102
+ declaring a second phase for the same document.
103
+ - File documents use `registry.files`, `source(entry.name, { type: "file" })`
104
+ and `captureFile`. Group by actual processor needs; do not apply `mdxJsonDocs()`
105
+ indiscriminately to all file sources.
106
+ - `allSources("lark")` selects a collection; its array contains a collection
107
+ reference, not individual documents. It neither expands capture phases nor
108
+ supports mapping its entries into `captureLark`.
109
+ - The map declares one phase per document. It does not fetch URLs, change capture
110
+ permissions, or request parallel execution. Run the declared phases through the
111
+ existing CLI flow so each document retains independent refresh and retry behavior.
49
112
 
50
113
  ## `customPhase`
51
114
 
@@ -65,6 +128,7 @@ kbPackage({
65
128
  name: "component-kb",
66
129
  template: "src/package-templates/kb",
67
130
  select: { collections: ["codeindex", "architecture"] },
131
+ site: { title: "Component knowledge", lang: "en-US", base: "/" },
68
132
  });
69
133
 
70
134
  llmsPackage({
@@ -77,10 +141,19 @@ llmsPackage({
77
141
  Package selection reads approved `knowledge/` only. `dist/` is generated and
78
142
  may be rebuilt; it is not an authoring source.
79
143
 
144
+ `kbPackage.site` optionally adds a VitePress website at `dist/<base>-site/` in
145
+ the same build, beside the KB directory. `<base>` removes one trailing `-kb`
146
+ from the package name, if present. Omit it for KB-only output. It accepts `title`, `description`,
147
+ `lang` and a deployment `base` path. Knowledge map is projected from
148
+ `src/knowledge-map.yaml` independently of KB directories; see
149
+ [Package Outputs](../guides/package-outputs.md#optional-static-documentation-website).
150
+
80
151
  ## Indexer registry
81
152
 
82
- The Agent and CLI maintain `src/indexers.yaml` through typed proposals and
83
- Review gates. Each selected Indexer binds requirements and scopes to one
153
+ When this file is absent, the configuration Route supplies the initial schema:
154
+ write confirmed `requirements` with `indexers: []`, then re-evaluate. The Provider
155
+ selection Action supplies its own completion schema; that payload is not the
156
+ configuration file. Subsequent changes use typed proposals and applicable gates. Each selected Indexer binds requirements and scopes to one
84
157
  primary Provider, with optional declared layers or composers. Provider code
85
158
  must return the current Indexer result protocol; it must not write Candidate,
86
159
  knowledge, or Review files directly.
@@ -90,6 +163,20 @@ current workflow Route when it is needed.
90
163
 
91
164
  ## Persistent versus runtime state
92
165
 
93
- Commit source registries, `src/index.ts`, `src/indexers.yaml`, package templates,
94
- and approved knowledge. Do not commit `.tmp/context-runtime/`; it contains
95
- recoverable execution state and is cleaned after a successful close.
166
+ Source registries and snapshots, saved notes/summaries, project declarations,
167
+ package templates and approved knowledge are durable inputs. Version them only
168
+ when Git operations are authorized. Keep `.tmp/context-runtime/` out of Git;
169
+ it contains unfinished execution state, not the sole source of recovery truth.
170
+
171
+ `knowledge/structure.yaml` keeps shared page/source metadata and compact
172
+ `processed_scopes` for completed requirement/source/module ranges. A partial
173
+ update or failed build does not advance the whole range's processed version.
174
+ Session commit/MR associations stay in the saved source frontmatter, not copied
175
+ into every knowledge page. Use the CLI to adjust or roll back current work;
176
+ do not edit these baselines or remove runtime files to simulate completion.
177
+
178
+ ## Source visual conversion preference
179
+
180
+ Workspace `package.json` accepts `context.convertVisuals` (boolean, default `true`). Initialization writes it explicitly; older workspaces without the field also default to enabled. This lets a capable Author Agent attempt faithful structural diagram/table conversion. Explicit session instructions override the saved preference. It does not disable native table capture or existing Mermaid when false.
181
+
182
+ Diagram style follows the workspace’s editable `AGENTS.md`; newly initialized workspaces default to minimal theme-aware diagrams without decorative colors. If the Agent cannot read the image or cannot preserve its meaning, it retains the original through the existing asset workflow. Source-based reuse avoids rereading unchanged visuals; file integrity and package hashes continue to reflect actual output changes.
@@ -19,7 +19,7 @@ Approved pages: {{knowledgeCount}}
19
19
  Values support dotted paths:
20
20
 
21
21
  ```md
22
- {{context.package}}
22
+ {{buildInventory.package.name}}
23
23
  ```
24
24
 
25
25
  ### Loop
@@ -102,7 +102,7 @@ Read node_modules/@c4a/context/docs/reference/template-variables.md.
102
102
  | `skillPath` | string | Final package-relative `SKILL.md` path for the Skill currently being rendered. Empty outside a Skill template. |
103
103
  | `knowledgeCount` | number | Selected approved Markdown file count. |
104
104
  | `knowledgeTimestamp` | string | Latest selected approved Markdown `timestamp`, or epoch when empty. |
105
- | `knowledge` | string | Concatenated selected approved Markdown bundle. Use carefully; it can be large. |
105
+ | `knowledge` | string | Concatenated consumer projection of selected approved pages, with path headings. It omits lifecycle metadata and can be large. |
106
106
  | `approvedKnowledge` | string | Alias for `knowledge`. |
107
107
  | `knowledgeItems` | array | One record per selected approved Markdown page. |
108
108
  | `knowledgeGroups` | array | Selected pages grouped by OKF root and the first directory segment under that root; each item also exposes `internal_collection`. |
@@ -131,7 +131,7 @@ Each item contains:
131
131
 
132
132
  | Field | Meaning |
133
133
  |---|---|
134
- | `path` | Package-relative OKF path, for example `wikis/component-lib/symbol/button.md`. |
134
+ | `path` | Package-relative OKF path, for example `guides/architecture/entity/button.md`. |
135
135
  | `sourcePath` | Approved knowledge path before OKF output mapping, for example `architecture/entity/button.md`. |
136
136
  | `approved_path` | Alias for `sourcePath`. |
137
137
  | `dist_path` | Alias for `path`. |
@@ -142,11 +142,11 @@ Each item contains:
142
142
  | `okf_root_path` | Final flat package-relative OKF root. |
143
143
  | `node_ref` | Stable NodeRef from approved frontmatter, for example `entity/button`. |
144
144
  | `view_ref` | Stable ViewRef from approved frontmatter, for example `architecture:entity/button`. |
145
- | `pathWithinCollection` | Path below the OKF root, for example `component-lib/symbol/button.md`. |
145
+ | `pathWithinCollection` | Path below the OKF root, for example `architecture/entity/button.md`. |
146
146
  | `href` | Link relative to the template file currently being rendered. Use this in custom templates. |
147
147
  | `hrefFromTemplate` | Alias for `href`. |
148
- | `hrefFromPackageRoot` | Link from a package-root file such as `AGENTS.md`, for example `./wikis/component-lib/symbol/button.md`. |
149
- | `hrefFromCollectionIndex` | Link from the current OKF root index, for example `./component-lib/symbol/button.md` for a `wikis` item. |
148
+ | `hrefFromPackageRoot` | Link from a package-root file such as `AGENTS.md`, for example `./guides/architecture/entity/button.md`. |
149
+ | `hrefFromCollectionIndex` | Link from the current OKF root index, for example `./architecture/entity/button.md` for a `guides` item. |
150
150
  | `title` | Page title from frontmatter, or a title derived from the file name. |
151
151
  | `type` | OKF `type` from frontmatter. |
152
152
  | `description` | OKF `description` from frontmatter, when present. |
@@ -182,7 +182,7 @@ Each group contains:
182
182
  | `count` | Number of selected pages in this group. |
183
183
  | `hasIndex` | Whether the active package navigation policy generates `indexPath`. |
184
184
  | `has_index` | Alias for `hasIndex`. |
185
- | `indexPath` | OKF-root-aware index path, for example `wikis/component-lib/index.md`, `guides/component-lib/index.md`, or `rules/index.md` for a root group. |
185
+ | `indexPath` | OKF-root-aware index path, for example `wikis/codeindex/index.md`, `guides/architecture/index.md`, or `rules/index.md` for a root group. |
186
186
  | `indexHrefFromTemplate` | Link from the template file currently being rendered to `indexPath`. Check `hasIndex` before rendering it. |
187
187
  | `indexHrefFromCollectionIndex` | Link from the OKF root index to `indexPath`. |
188
188
  | `items` | `knowledgeItems` in the group. |
package/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { type PackageSiteDefinition } from "./packageSite.js";
2
+ export { packageSiteSchema, type PackageSiteDefinition } from "./packageSite.js";
1
3
  import type { PackageNavigationDefinition, PackageSelectDefinition } from "./contracts.js";
2
4
  import type { PhaseDefinition, PhaseResourceReference } from "./phases.js";
3
5
  import type { ProjectSourceDefinition } from "./sources.js";
@@ -109,6 +111,7 @@ export type KbPackageDefinition = BasePackageDefinition & {
109
111
  navigation: PackageNavigationDefinition;
110
112
  distribution?: PackageDistributionDefinition;
111
113
  assets?: PackageAssetDefinition;
114
+ site?: PackageSiteDefinition;
112
115
  };
113
116
  export type LlmsPackageDefinition = BasePackageDefinition & {
114
117
  kind: "package.llms";
@@ -131,9 +134,21 @@ export declare const kbPackage: (definition: {
131
134
  navigation?: Partial<PackageNavigationDefinition>;
132
135
  distribution?: PackageDistributionDefinition;
133
136
  assets?: PackageAssetDefinition;
137
+ site?: PackageSiteDefinition;
134
138
  }) => KbPackageDefinition;
135
139
  export declare const llmsPackage: (definition: {
136
140
  name: string;
137
141
  template: PackageTemplateInput;
138
142
  select?: PackageSelectDefinition;
139
143
  }) => LlmsPackageDefinition;
144
+ export { projectIndexerPublicContractTable } from "./indexerPublicContractTable.js";
145
+ export { processedScopeSchema, processedScopesSchema, processedScopeKey, readProcessedScopes, mergeProcessedScopes, processedVersionForScope, type ProcessedScope } from "./processedScopes.js";
146
+ export { assertManagedDocumentName, assertManagedDocumentPath, discoverManagedDocuments } from "./managedSources.js";
147
+ export type { ManagedDocumentSourceType, ManagedDocumentSourceEntry } from "./managedSources.js";
148
+ export { sessionChangeSchema, sessionChangesSchema, readSessionChanges, writeSessionChanges } from "./sessionMetadata.js";
149
+ export type { SessionChange } from "./sessionMetadata.js";
150
+ export { indexerArticleKeySchema, indexerArticlePlanSchema, validateIndexerArticlePlan, indexerArticleSectionKey, validateIndexerPlannedArticles } from "./indexerArticlePlan.js";
151
+ export type { IndexerArticlePlan } from "./indexerArticlePlan.js";
152
+ export * from "./knowledgeMap.js";
153
+ export * from "./indexerKnowledgeDependency.js";
154
+ export * from "./indexerApprovedKnowledge.js";