@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
@@ -4,8 +4,10 @@ Package outputs are generated folders under `dist/`. They turn approved
4
4
  knowledge from `knowledge/` into a shape that another consumer can install,
5
5
  read, or import.
6
6
 
7
- Package output is a human decision gate. Do not add package declarations until
8
- the user chooses the intended consumer and output shape.
7
+ Package output is a semantic decision: establish the intended consumer and output
8
+ shape before declaring it. Reuse the user's existing choice. A current managed
9
+ Route may delegate this decision to the Agent; it does not require a repeated
10
+ permission question.
9
11
 
10
12
  Package build consumes approved and closed knowledge. If status reports that
11
13
  close is required, run deterministic close before build. Current close derives
@@ -13,11 +15,85 @@ close is required, run deterministic close before build. Current close derives
13
15
  final verify gate without rewriting approved Markdown. References, changelog,
14
16
  package index, and section fingerprint rebuilds are not current close output.
15
17
 
16
- ## Recommended First Output: Agent Knowledge-Base Package
18
+ ## Default New-Workspace Outputs: Knowledge Base + Website
17
19
 
18
- Choose an agent knowledge-base package first when the knowledge should help
19
- Coding Agents work with the project. After the user chooses this semantic
20
- output shape, implement it with `kbPackage()`.
20
+ Output channels support multiple selection. In a new workspace without explicit
21
+ preferences, the Agent proposes and configures KB + website as the default. Honor
22
+ user feedback, session authority and existing workspace declarations; LLMS is an
23
+ additional selectable channel. This is an Agent configuration default, not an SDK
24
+ change that silently enables websites for existing packages.
25
+
26
+ ### Static documentation website
27
+
28
+ To include the default browser-readable site, enable `site` on the same
29
+ package. The normal `context build` produces both the Agent KB and a standalone
30
+ `dist/<base>-site/` directory containing `index.html`, article HTML,
31
+ local search, scripts, styles and the selected bundled resources.
32
+
33
+ `<base>` is the package name with one trailing `-kb` removed, when present.
34
+ For example, `project-kb` produces `dist/project-kb/` and `dist/project-site/`;
35
+ `project` produces `dist/project/` and `dist/project-site/`. Output directories
36
+ must not collide with another package or website. `site.base` controls URL
37
+ prefixes only, not filesystem output paths.
38
+
39
+ ```ts
40
+ kbPackage({
41
+ name: "project-kb",
42
+ template: "src/package-templates/kb",
43
+ site: { title: "Project knowledge", lang: "en-US", base: "/" },
44
+ });
45
+ ```
46
+
47
+ `site` is opt-in; omission keeps the existing KB-only output. Optional fields
48
+ are `title` (defaults to the package name), `description`, `lang` (defaults to
49
+ `en-US`), and `base` (defaults to `/`; use `/docs/` when hosted under that path).
50
+ The website uses a full-width VitePress theme with system fonts, compact navigation,
51
+ a wide reading area and a smaller article outline. It starts in
52
+ light mode regardless of the operating system; an explicit reader choice is
53
+ remembered in browser storage. Search runs locally, without a search service.
54
+ Mermaid renders in the browser with a restrained theme; invalid diagrams retain
55
+ their source instead of blocking publication. Code samples and raw HTML are
56
+ displayed as content, not executed as Vue components or scripts.
57
+
58
+ The accepted `src/knowledge-map.yaml` controls sidebar organization. Entries
59
+ bind to `artifact_ref` and optionally `section_key`; the builder resolves these
60
+ against this package's selected approved articles. Navigation labels and parent
61
+ groups do not determine website paths. One article may have several navigation
62
+ placements while keeping one URL. Pending/excluded targets generate warnings
63
+ and no invented link. Every selected article with an artifact identity must have
64
+ a valid reading target before packaging, including packages without a website.
65
+ Missing bindings or invalid section references block the staged output and
66
+ return the missing article list plus a navigation-only task adjustment input.
67
+ Category nodes can remain empty while future articles are planned. The builder
68
+ does not infer business categories or alter article content.
69
+
70
+ Top navigation contains the first-level reading directories. Selecting
71
+ a section shows only its descendants in the left sidebar; opening an article
72
+ directly selects its section. Skills and their Markdown references remain
73
+ reachable as linked read-only pages, but have no automatically added navigation
74
+ section. A reader-facing usage guide can link them where appropriate.
75
+ Section landing pages have stable URLs separate from article URLs.
76
+
77
+ `dist/<base>-site/context-site-map.json` records each article's approved path, KB path and
78
+ site path, plus the projected menu and unresolved targets. URLs are derived from
79
+ article identity; legacy pages without `artifact_ref` use their approved path,
80
+ so moving those legacy files changes their URL. The shared knowledge map,
81
+ KB layout and production Markdown remain unchanged.
82
+
83
+ Article pages include a small source footer from recorded article source references and the source registry. Repository entries link to the recorded revision and module (or an explicitly referenced file); document entries link to their registered HTTP(S) URL. Unrecorded associations are not inferred from prose. Source-footer changes participate in the website build fingerprint without modifying knowledge Markdown.
84
+
85
+ The website reuses resource delivery already performed for the KB: bundled
86
+ resources are copied into the site's `resources/`; Git raw links remain remote,
87
+ and explicit resource omission remains omission. It does not copy source trees
88
+ or capture audits. Website generation completes in a sibling staging directory
89
+ before either output is published, so a failed website build preserves the
90
+ previous KB and website. The website is not included in the KB directory.
91
+ Disabling the option removes the old site on the next successful package build.
92
+
93
+ Preview through an HTTP static server. Deploy the **contents of `dist/<base>-site/`** using
94
+ the user's chosen static hosting tool; no hosting SDK, login, deployment or
95
+ platform-specific skill is part of Context's build. Keep hosting credentials
96
+ out of package templates and published content.
21
97
 
22
98
  Typical output:
23
99
 
@@ -68,26 +144,29 @@ Do not ask for another distribution namespace. Older workspaces may still
68
144
  contain `distribution.knowledgeNamespace`; Context accepts that legacy input
69
145
  without using it to shape the package.
70
146
 
71
- Skill names are separate. Ask whether the author wants a short optional Skill
72
- prefix, then maintain the complete final template directory name directly—for
147
+ Skill names are separate. If a short prefix is useful, maintain the complete
148
+ final template directory name directly—for
73
149
  example `skills/android-query/SKILL.md`. Package-root layout never renames a
74
150
  Skill.
75
151
 
76
152
  The default `knowledge-query` Skill is a complete generic query entry. It
77
153
  carries the structure-first query discipline: start from OKF directory indexes, use
78
154
  `context-build-inventory.json` edge records for package-visible relationships,
79
- inspect page `sources` / `context:section` source_ref metadata, cite
80
- page/section evidence, and report explicit gaps when the package does not cover
81
- a requested fact. It does not treat direct grep over bundled OKF root
155
+ read candidate pages, cite their visible headings and relevant passages, and
156
+ report gaps when the package does not cover a requested fact. Consumer pages
157
+ omit `sources` and `context:section` metadata. For exact upstream attribution,
158
+ a maintainer needs the original workspace page mapped by the inventory; a
159
+ package-only reader must not claim to have read that source. It does not treat direct grep over bundled OKF root
82
160
  directories as the primary discovery path. When indexes do not narrow the
83
161
  scope, or a candidate page is too large to read directly, its bundled
84
162
  `scripts/search.mjs` provides deterministic BM25 ranking over mechanically
85
163
  bounded Markdown chunks. Search results are leads; page bodies and typed edge
86
- records remain the evidence. Its final template-author section
87
- requires package authors to replace or edit the generic routing when the
88
- package needs project-specific terminology, entry points, known limits, or
89
- task workflows. Authors may explicitly accept the generic default when it is
90
- intentionally sufficient.
164
+ records establish what the package actually says. Package authors edit the source
165
+ template when project-specific terminology, entry points or task workflows are
166
+ needed. Authoring instructions should be template comments or separate guidance,
167
+ not a final section addressed to authors in the delivered query Skill. The
168
+ current template-review Route can accept an intentionally sufficient generic
169
+ default under its applicable authority.
91
170
 
92
171
  When approved pages reference materialized resources, Context keeps their
93
172
  production copies in content-addressed `knowledge/assets/` paths and bundles
@@ -162,7 +241,7 @@ It links directly to pages in small child directories and to a child
162
241
  The default threshold is 50 selected knowledge pages. Use Handlebars variables such as
163
242
  `knowledgeGroups`, `knowledgeItems`, and `knowledgeTree` when a project needs
164
243
  custom navigation. Before customizing it, read
165
- `node_modules/@c4a/context/docs/reference/template-variables.md`.
244
+ [Template Variables](../reference/template-variables.md).
166
245
 
167
246
  Newly initialized generic templates must be replaced, edited, or explicitly
168
247
  accepted before the first build. `context status` exposes that choice as a
@@ -200,7 +279,9 @@ Typical output:
200
279
 
201
280
  ```text
202
281
  dist/<package-name>/
203
- └── llms.txt
282
+ ├── llms.txt # knowledge-map index
283
+ ├── llms-full.txt # consolidated approved text
284
+ └── llms/pages/<identity>.txt # individual approved articles
204
285
  ```
205
286
 
206
287
  Choose this when the user wants:
@@ -221,49 +302,139 @@ knowledge/
221
302
  └── ...
222
303
  ```
223
304
 
224
- ## How To Ask The User
225
-
226
- When `workflow.current.reason_code` is `route.package.output-required`,
227
- explain the choices with the output tree. Do not ask the user to pick from
228
- unexplained labels.
229
- Use the host's native multi-choice tool when available. If unavailable, fall
230
- back to a short Markdown A/B/C question. The option labels should be:
231
- agent knowledge-base package, LLM text bundle, and skip package output for now.
232
-
233
- Recommended question shape:
305
+ ## Agent configuration and delivery recipe
306
+
307
+ Use this guide when the user asks to generate a documentation website, selects
308
+ outputs in the work-start report, or the current Route asks for package output.
309
+ Read the current Route and existing `src/index.ts` first. Reuse settled choices;
310
+ follow its configuration/read-acknowledgement contract rather than replaying a
311
+ previous revision. The Agent edits SDK configuration; the user need not write code.
312
+
313
+ 1. Record all selected channels together. For new workspaces with no explicit
314
+ preference, use KB + website. Preserve existing declarations and explicit
315
+ KB-only, LLMS-only or deferred-delivery choices.
316
+ 2. Configure the existing KB declaration below, substituting the actual name,
317
+ title and workspace language. Retain its sources, phases, selection and resource
318
+ policy. This is one KB package with an additional website channel, not two KBs.
319
+ 3. If LLMS is selected, add its declaration and import in the same edit. Ensure
320
+ both template directories exist and resolve generic-template review using the
321
+ current Route. Do not independently ask approval for each already selected channel.
322
+ 4. Refresh `context status --format json`. Follow the returned continuation for
323
+ knowledge-map adjustment, required review, close, verification and build.
324
+ Missing article bindings require explicit targets from current CLI diagnostics;
325
+ do not classify articles from `wikis/` or `codeindex/` directory names alone.
326
+ 5. Run `context build` when ready. Verify each selected output and report its
327
+ actual location; a failed selected website is not completed delivery.
328
+ 6. Preview the generated website directory through a local HTTP server. Verify HTTP succeeds
329
+ before giving its URL. Publishing requires the user's chosen hosting tool and
330
+ authorization; do not install a hosting SDK merely to build the website.
234
331
 
235
- ```text
236
- The reviewed knowledge is approved. The next decision is how to package it.
237
-
238
- Recommended: agent knowledge-base package
239
- dist/<name>-kb/
240
- ├── AGENTS.md
241
- ├── skills/knowledge-query/SKILL.md
242
- └── wikis/
243
- ├── index.md
244
- ├── <group-page>.md
245
- └── <large-group>/index.md
246
-
247
- This is best if agents should use the knowledge as a reusable knowledge base.
248
-
249
- Alternative: LLM text bundle
250
- dist/<name>-llms/
251
- └── llms.txt
252
-
253
- This is best if you need one text bundle for model/RAG import.
254
-
255
- We can also skip package output for now and keep only knowledge/.
256
-
257
- Which one should I declare first?
332
+ ```ts
333
+ import { defineProject, kbPackage, llmsPackage } from "@c4a/context";
334
+
335
+ // Edit only the packages field of the existing defineProject declaration.
336
+ // Keep the actual project's other declarations intact.
337
+ const packages = [
338
+ kbPackage({
339
+ name: "project-kb",
340
+ template: "src/package-templates/kb",
341
+ site: { title: "Project knowledge", lang: "en-US", base: "/" },
342
+ }),
343
+ // Include this entry only when LLMS text is selected.
344
+ llmsPackage({ name: "project-llms", template: "src/package-templates/llms" }),
345
+ ];
346
+ // Existing defineProject({ ...existing declarations, packages }).
258
347
  ```
259
348
 
260
- If the user chooses the Agent knowledge-base package, explain that its OKF
261
- roots are flat within `dist/<package-name>/`; do not ask for a second namespace.
262
- Ask whether its Skills need a short prefix. The author maintains final Skill
263
- names independently from package paths.
349
+ The configuration is a small source edit, not custom frontend implementation.
350
+ Website output reuses approved articles, knowledge map and packaged assets;
351
+ rendering/search generation adds build time and size, not another indexing pass.
352
+ Measure actual cost instead of quoting a universal estimate.
353
+
354
+ | User request | Agent action |
355
+ | --- | --- |
356
+ | KB + website | One `kbPackage` with `site` enabled |
357
+ | KB only / disable website | Omit `site` on that KB and rebuild; old site output is removed |
358
+ | Add website later | Add `site` to existing KB, repair missing reading bindings, rebuild |
359
+ | Website only for distribution | Explain the KB is still built; share only the sibling website directory |
360
+ | Also produce LLMS | Add `llmsPackage` alongside the KB in the same change |
361
+ | Keep current knowledge only | Postpone packaging; do not label it completed package delivery |
362
+
363
+ ```sh
364
+ python3 -m http.server 8000 --bind 127.0.0.1 --directory dist/project-site
365
+ ```
264
366
 
265
- Do not offer `both` as a shortcut. If the user wants multiple outputs, add one
266
- package first, verify the shape, then add another package after confirmation.
267
- The default adaptive index policy avoids one-page directory indexes. Configure
268
- `kbPackage().navigation` when a package needs a different inline-entry
269
- threshold or a fully expanded index at every directory.
367
+ The completion report lists KB root, website directory and LLMS file separately,
368
+ with generated/failed/not-selected status. Include website navigation coverage,
369
+ verified preview URL when running, and any remaining errors. The website contains
370
+ source cards and article update times; it does not imply an article history browser.
371
+
372
+ ## How To Present The Choice
373
+
374
+ Include a compact multi-select list in the work-start report, and reuse it later:
375
+
376
+ - [x] Agent knowledge-base package — default for a new workspace.
377
+ - [x] Documentation website — default with the KB, local preview or later hosting.
378
+ - [ ] LLMS text — optional model-context or RAG input.
379
+
380
+ Explicit choices override defaults. When current Route authority requires a user
381
+ decision, ask once for the combination rather than a sequence of mutually exclusive
382
+ questions. If the host tool supports only single selection, let the user state the
383
+ combination in text instead of presenting it as multi-select. There is no `both`
384
+ factory, separate website skill, or second permission per selected output.
385
+
386
+ ## Website deployment handoff after every successful build
387
+
388
+ After every successful website build, including intermediate delivery and an
389
+ unchanged output reused by build, tell the user the website can be deployed with
390
+ a deployment skill. Include the actual `dist/<base>-site/` directory and whether
391
+ it contains only the currently delivered scope. This notice does not wait for the
392
+ whole knowledge task to finish and does not block its next Route.
393
+
394
+ Reuse existing publishing configuration and the user's chosen target. Otherwise,
395
+ inspect the available deployment skills, recommend a compatible static-site skill,
396
+ or let the user specify one. Do not invent installed skills or a deployed URL.
397
+ If no compatible skill is available, report that and provide the site directory
398
+ for the user's deployment tool. Do not install a deployment dependency by default.
399
+
400
+ When publishing is already authorized for that target, follow the selected skill
401
+ with the built site directory; otherwise offer deployment and wait for the user's
402
+ publishing instruction. Preserve the configured base path; rebuild if the target
403
+ requires a different base. Pass only the website output, not sources, private
404
+ workspace state or the entire KB package. Report success only after checking the
405
+ hosting result and published URL. A failed deployment leaves the local build valid;
406
+ report the deployment failure and its next step separately.
407
+
408
+
409
+ ### Persistent knowledge map and report proposals
410
+
411
+ `src/knowledge-map.yaml` is the persistent knowledge map; retain it after delivery.
412
+ Its protocol is `context.knowledge-map/v1`; structure and adjustment inputs use
413
+ `knowledge_map`, and SDK functions use `KnowledgeMap` naming. It organizes website
414
+ navigation and LLMS without changing article identities or section bindings.
415
+
416
+ The work-start report explains the proposed directory and chapters, followed by
417
+ a text wireframe of the website. Material changes are communicated with the updated
418
+ report link and a short explanation. This does not build a temporary website or
419
+ create a persistent article-plan file. Website packaging uses the accepted knowledge map
420
+ and approved articles; the report is not a configuration input.
421
+
422
+ ### Website LLM Docs
423
+
424
+ Every website build also builds LLMS from the same selected approved articles and
425
+ knowledge map. The final top-navigation item is always **LLM Docs**, opening
426
+ `llms/index.html`. This page links to `llms.txt`, the structured index,
427
+ `llms-full.txt`, the complete approved text, and raw Markdown text articles under
428
+ `llms/pages/`. These files ship inside the sibling website directory and use the configured site base.
429
+ No separate LLMS package declaration or additional build command is required.
430
+ Website LLMS text files include a UTF-8 BOM so browsers can identify the encoding
431
+ when a static host omits the charset. Hosting should serve them as
432
+ `text/plain; charset=utf-8`. The HTML landing page shows one index/full-text
433
+ toolbar followed by the knowledge map; Changelog is available in the site navbar.
434
+
435
+ The index preserves knowledge-map grouping, order and repeated placements. The
436
+ full text includes each selected article only once, in first-placement order.
437
+ Only approved selected content is exported. A map or article change invalidates
438
+ both website and LLMS outputs; failure preserves the previous staged package.
439
+ Standalone `llmsPackage()` uses the same map organization and supplies the full
440
+ text and raw article files alongside its template-rendered `llms.txt` index.
@@ -0,0 +1,50 @@
1
+ # Prepare a conversation-summary source
2
+
3
+ Use sessions for a bounded summary formed from an authorized conversation:
4
+ requirements, design, troubleshooting, operational or general knowledge.
5
+ Code association is optional. An Agent or external supplier prepares the summary
6
+ before import. Do not scan host history, ingest the full transcript, invent a
7
+ conversation from a diff, or move an unrelated conversation into note merely
8
+ because it lacks a commit.
9
+
10
+ Keep the problem, confirmed decisions, useful reasons, constraints and open
11
+ questions. Remove repetitive turns, tool logs and abandoned attempts unless they
12
+ explain a current limit. Preserve whether each statement was proposed, agreed,
13
+ implemented or verified. If only a supplied summary is available, say so; do not
14
+ claim to have read the original. Do not make up speakers, dates or approval.
15
+ A session with no reusable information can remain outside the workspace.
16
+
17
+ Save through `context source import --input <file> --format json`, using
18
+ `type: sessions`, `name: YYYYMMDD/topic.md` and the prepared `markdown` string.
19
+ Choose the actual conversation date, or collection date if unknown, and retain
20
+ the same path for corrections. The summary needs no mandatory body headings.
21
+
22
+ Optional `changes` associates one or several code changes. Each row accepts
23
+ `commit` (full 40/64 hexadecimal Git SHA), `mr` (HTTP(S) MR/PR URL), and optional
24
+ `repository`. At least commit or mr is needed per row; omit the entire field
25
+ for unrelated sessions. Use actual known identifiers, never fabricated hashes.
26
+ A reference does not prove merge, deployment, tests or authorize fetching code.
27
+ The CLI stores this field in the source's YAML frontmatter, discovers it from
28
+ that same file, and does not introduce a sidecar or separate registry.
29
+
30
+ For example, an import may have `changes: [{mr: "https://git.example.org/team/project/merge_requests/42"}]`.
31
+ This is an illustrative URL, not a lookup target. The same payload without
32
+ changes imports an independent requirements discussion normally. Use the current
33
+ base_digest to change text or associations; explicit `changes: []` clears the
34
+ associations. Omission leaves the source's inline changes intact. When replacing
35
+ only the summary body, preserve existing associations unless explicitly removed.
36
+ Do not duplicate commit/MR fields into knowledge frontmatter.
37
+
38
+ Saving alone does not start indexing. Select a compatible Sessions Provider for
39
+ an independent reader topic, or keep an existing page's Code/Markdown primary
40
+ and include the summary in its authorized evidence/read scope. If specialized
41
+ interpretation is needed, explicitly select an extension from the Sessions or
42
+ business Provider. Knowledge turns useful conclusions into answers, explanations
43
+ and procedures, not a meeting recap. Existing structure.yaml source references
44
+ connect each relevant page/section to the saved summary and its optional changes.
45
+
46
+ Correct a faulty summary through source import with current base_digest and task
47
+ adjustment for pinned inputs. If the summary is accurate but the page is wrong,
48
+ revise the approved page. A new topic goes through structure review then normal
49
+ Author/Review. Neither knowledge approval nor source storage approves an upstream
50
+ change. A failed update retains source and approved knowledge for recovery.
@@ -0,0 +1,45 @@
1
+ # Commit workspace results
2
+
3
+ Use Host Git tools, not an invented Context commit command. Commit only when
4
+ the user requests it; fully managed production does not itself authorize Git
5
+ commits or pushes. At the end of the entire requested production scope, after
6
+ close and all requested builds with no pending tasks, a single optional commit
7
+ suggestion is enough. Intermediate delivery is not that endpoint.
8
+
9
+ ## Select the files
10
+
11
+ Locate the Context workspace and its actual Git root. Inspect status, staged
12
+ changes, unstaged changes, untracked files and ignore rules. In an embedded
13
+ workspace the Git root may be a much larger source repository. Explicitly select
14
+ workspace files; never run blanket `git add -A` or commit the entire staged index.
15
+ Check source records for required recovery information; a commit does not bundle
16
+ ignored checkouts or runtime progress. Do not force-add ignored files or assume
17
+ `dist` belongs in Git. Generated files are included only if the project's rules
18
+ and selected scope require them.
19
+
20
+ If there is no Git repository, establish the intended repository location before
21
+ initializing one. If nothing changed, report that no commit is necessary. If the
22
+ user asks for an intermediate snapshot, explain which saved files it contains
23
+ and that it cannot resume ignored Author state from Git alone.
24
+
25
+ ## Commit the selected change
26
+
27
+ Summarize the actual change and choose a message consistent with repository rules.
28
+ Use precise paths and Git's scoped commit facilities or a carefully isolated
29
+ index. `git commit --only -- <paths>` can exclude unrelated staged files; new files
30
+ must first be known to the index. Inspect overlapping partially staged files
31
+ before selecting this approach: do not silently include changes the user did
32
+ not select. Preserve unrelated staged entries, including staged deletions.
33
+
34
+ Git identity, hooks, signing, conflicts and permissions are environmental
35
+ issues for the Agent to diagnose. Do not disable hooks or signing, rewrite global
36
+ Git configuration, stash other work or bypass ignore rules to force success.
37
+ Use an available authorized alternative or report the specific blocker.
38
+
39
+ ## Verify the result
40
+
41
+ Read the actual commit SHA and its changed files/diff; compare against the
42
+ selected scope. Verify unrelated worktree and index content remain unchanged.
43
+ If a hook changed the result, inspect and report it before claiming completion.
44
+ Report the SHA and a brief description. Do not push, publish or create a remote
45
+ repository without the corresponding explicit request.
@@ -0,0 +1,72 @@
1
+ # Prepare a workspace for the next task
2
+
3
+ Use only for an explicit workspace preparation request. The goal is usable
4
+ registered sources and no unfinished task, while retaining approved knowledge
5
+ and configuration. Lead with Host tools and actual observations; do not start
6
+ indexing merely because a status response offers production work.
7
+
8
+ ## Establish the scope
9
+
10
+ Use `context entry` to locate the workspace. Inspect current work, active
11
+ processes, Git changes and source registrations. Explain which unfinished
12
+ drafts and queued maintenance will be discarded. Reuse the user's explicit
13
+ authorization; ask only about an unresolved loss, version or access boundary.
14
+ Wait for an active writer to finish and obtain its receipt before changing state.
15
+ If status is broken, inspect its diagnostic and files with Host tools rather
16
+ than treating failure as proof that the workspace is empty.
17
+
18
+ ## End the old task
19
+
20
+ Run `context task prepare --format json`. It previews the exact Context-owned
21
+ task files, including production, Review and maintenance state. It preserves
22
+ approved pages, source records and snapshots, project configuration, repository
23
+ checkouts, other `.tmp` files and existing outputs. It does not claim the output
24
+ or sources are current.
25
+
26
+ Once discarding the shown scope is authorized, execute the returned apply
27
+ command with its plan digest. If the preview changes, inspect the new differences.
28
+ On interruption, rerun the preview and use its resume command; never clear a
29
+ transaction journal or repeat old Author submissions. Other incomplete writes
30
+ must be recovered before cleanup. The completion clears task state only; check
31
+ sources next. Do not manually delete the runtime directory to emulate this action.
32
+
33
+ Other caches are optional cleanup, not a requirement to empty `.tmp`. Inspect
34
+ their ownership and recoverability before deleting them with Host tools. Keep
35
+ reports, unique material, unknown files and modified checkouts unless their
36
+ specific loss is authorized. Do not delete locks, transaction records or active
37
+ tool directories. Empty task directories can remain.
38
+
39
+ ## Restore usable sources
40
+
41
+ For repositories, run `context source recovery-plan --format json` and read
42
+ the installed repository recovery procedure and schema supplied by entry's
43
+ workflow bundle: `repository-source-recovery.md` beside this guide and
44
+ `../../schemas/repository-source-recovery.schema.json`. Reuse a matching local
45
+ checkout or, when authorized, clone into a bounded location using
46
+ `context source restore --input <workspace-input-file> --format json`.
47
+ Group modules sharing a remote and fixed commit; do not clone per module.
48
+ Check registered commit and module paths. Never reset a supplied dirty checkout.
49
+ Authentication or checkout problems can be diagnosed with Host Git tools;
50
+ refresh the recovery plan after fixing them. Do not substitute a newer commit.
51
+
52
+ For Lark, inspect the stored body and required attachments against the source
53
+ records. Use the Host's document tools and the [existing capture guide](knowledge-updates.md)
54
+ to repair missing material, retaining the registered identity. A current remote
55
+ response is not proof of an older snapshot: if it differs, explain that source
56
+ updating is needed and resolve that choice before claiming recovery. If an old
57
+ snapshot is unavailable, report the exact limitation. Do not automatically
58
+ follow every document link or reread already complete materials.
59
+
60
+ For note, sessions and local files, preserve formal source content and verify
61
+ that declared paths can be read. Do not reconstruct lost original sources from
62
+ generated knowledge or scan arbitrary local directories.
63
+
64
+ ## Finish
65
+
66
+ Verify that no task files remain in the preparation preview, no writer remains,
67
+ the required configuration can load, and selected sources resolve to their
68
+ registered versions and paths. CLI inspection or direct Host checks are both
69
+ valid; a failed check is not ready. Report outstanding blockers and their next
70
+ action. Stop when ready for the next user request, without running Author or
71
+ recapturing everything. Historical restoration may additionally require a
72
+ close/build; see [restore a version](workspace-restore.md).
@@ -0,0 +1,59 @@
1
+ # Restore a historical workspace version
2
+
3
+ Use the Agent's Git and environment tools. This restores selected workspace
4
+ files and usable sources; it does not reset the entire repository, rewind source
5
+ repositories, or restore ignored runtime progress.
6
+
7
+ ## Resolve the target
8
+
9
+ Locate the workspace and Git root, then inspect history for that workspace path.
10
+ With no explicit target, select the most recent commit saving its state to undo
11
+ uncommitted results. “Previous version” instead selects the preceding relevant
12
+ saved state, not mechanically `HEAD~1` of a large repository. Validate an explicit
13
+ SHA. For dates, use the user's timezone and actual meaning (for example, as of
14
+ end of that day), inspect candidate history and resolve ambiguity with the user.
15
+ Git history can be nonlinear; do not choose an unrelated branch by timestamp.
16
+ The final target is a concrete SHA and path scope, never a date string alone.
17
+
18
+ Compare target files with current tracked, untracked and staged files. Include
19
+ current additions absent at the target in the proposed removal scope. Keep
20
+ unrelated files, existing staged work and ignored source checkouts. Account for
21
+ workspace moves or renames instead of treating a missing old path as an empty
22
+ version. Reuse explicit authorization; ask when the target or loss is unresolved.
23
+
24
+ ## Restore files and environment
25
+
26
+ Wait for active Context writers and obtain their result. Use the task-state
27
+ preview/apply from [workspace preparation](workspace-prepare.md) to abandon the
28
+ authorized old work before restoring files; it also clears pending maintenance.
29
+ Do not use an old Route after restoration.
30
+
31
+ Use Git to restore only the agreed paths from the selected SHA. A scoped
32
+ `git restore --source=<sha> --worktree -- <paths>` preserves branch history;
33
+ decide separately how authorized overlapping staged changes should be handled.
34
+ Use explicit deletion for agreed additions absent at the target. Never use a
35
+ whole-repository `reset --hard` or `clean -fdx` as a workspace shortcut.
36
+
37
+ Use the restored source records with the preparation guide to restore pinned
38
+ repository versions, module paths, document snapshots and attachments. New remote
39
+ content cannot stand in for lost old snapshots. Do not reclone usable sources.
40
+ On interruption, inspect the actual file diff and remaining source gaps and
41
+ continue those operations; do not assume the previous Git command completed or
42
+ replay old task submissions.
43
+
44
+ Old build output does not describe the restored version. If output is requested,
45
+ follow the current close/build or approved-output rebuild capability from the
46
+ [knowledge update guide](knowledge-updates.md); do not start full indexing merely
47
+ because the restored source configuration is available. Until rebuilt, state
48
+ that existing output is stale. If the historical schema is incompatible, diagnose
49
+ the available migration or tool-version choice, report necessary adaptations,
50
+ and do not pretend incompatible content is current or silently rewrite all pages.
51
+
52
+ ## Verify and stop
53
+
54
+ Compare the selected files with the target commit, identify any agreed adaptations,
55
+ verify unrelated changes/index entries survived, and check source readiness and
56
+ absence of old task state. When building was requested, check the new output as
57
+ well. If only some sources could be restored, report partial completion with the
58
+ specific missing access or version. No automatic commit, branch rewrite or push;
59
+ the user may separately [commit the restored results](workspace-commit.md).
@@ -20,20 +20,32 @@ declare a separate extraction phase in `src/index.ts`.
20
20
  | `@c4a/extract-ts` | TypeScript/JavaScript symbols, exports, imports, calls, and React Router routes |
21
21
  | `@c4a/extract-go` | Go declarations, imports, calls, and common HTTP routes |
22
22
  | `@c4a/extract-rush` | Rush projects, tags, entries, dependencies, and owner boundaries |
23
+ | `@c4a/extract-thrift` | Thrift services, methods and declared data types |
24
+ | `@c4a/extract-proto` | Protobuf messages, fields and service definitions |
25
+ | `@c4a/extract-mdx` | Markdown/MDX document structure and source spans |
26
+ | `@c4a/extract-contract` | Supported structured API contract declarations |
27
+ | `@c4a/extract-style` | Stylesheet declarations, selectors and related structure |
28
+ | `@c4a/extract-sql` | Supported SQL schema declarations |
23
29
  | `@c4a/extract` | Shared extraction result and adapter contracts |
24
30
 
25
31
  These packages do not create Candidate rows, write `knowledge/`, or control
26
- Review. The Code Indexer Provider owns those lifecycle responsibilities.
32
+ Review. The CLI owns those lifecycle responsibilities; Providers interpret the
33
+ supplied facts and sources and return structured semantic results. Package
34
+ presence alone does not prove a parser is selected or supports every dialect.
35
+ Use the selected profile's actual capabilities and parser diagnostics.
27
36
 
28
37
  ## Unsupported technologies
29
38
 
30
- When the current Provider cannot parse a required boundary, first use its
31
- supported customization ladder (`config`, instruction append, template
32
- override, then program extension). Add a reusable parser to the Provider only
33
- when the same technology boundary is useful across projects. Do not create a
34
- project-local parallel knowledge pipeline.
35
-
36
- Parser coverage is complete when every required inventory item has an explicit
37
- disposition and the resulting pages answer the declared reader questions. A
38
- large symbol count by itself is not useful coverage.
39
-
39
+ When a required boundary is unsupported, distinguish a parser limitation from
40
+ missing writing guidance. Config can select supported behavior; instructions or
41
+ templates cannot create missing structural facts. Follow the current Route's
42
+ capability-gap report and smallest supported customization step. A program
43
+ extension requires its existing execution authorization. Prefer a reusable
44
+ parser when the same technology is useful across projects; do not create a
45
+ parallel project-local knowledge pipeline.
46
+
47
+ Mechanical inventory closure requires an explicit disposition for each supplied
48
+ item. It does not prove that the pages answer the reader's questions. Review
49
+ checks usefulness and fidelity separately. Internal or out-of-scope items can
50
+ have justified exclusions without generating pages; symbol count is not a
51
+ knowledge-quality measure.