@c4a/context-cli 0.7.26 → 0.7.30

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 (29) hide show
  1. package/README.md +12 -0
  2. package/README.zh-CN.md +8 -0
  3. package/cli.js +148 -51
  4. package/indexers/contracts/profile-contract.json +245 -245
  5. package/indexers/release-manifest.json +1 -1
  6. package/package.json +12 -12
  7. package/parserEntryWorker.js +90 -10
  8. package/plugins/README.md +1 -1
  9. package/plugins/README_CN.md +1 -1
  10. package/plugins/VERSION +1 -1
  11. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  12. package/plugins/claude/commands/context-inspect-search.md +98 -25
  13. package/plugins/claude/skills/context-inspect-search/SKILL.md +98 -25
  14. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  15. package/plugins/codex/skills/context-inspect-search/SKILL.md +98 -25
  16. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  17. package/plugins/cursor/commands/c4a-context-inspect-search.md +98 -25
  18. package/plugins/cursor/skills/context-inspect-search/SKILL.md +98 -25
  19. package/plugins/skills/context-inspect-search/SKILL.md +98 -25
  20. package/providers/context/graphs/indexer.yaml +4 -0
  21. package/providers/context/manifest.json +25 -16
  22. package/providers/context/provider.yaml +1 -1
  23. package/providers/context/resources/dialogue/document-capture.md +8 -0
  24. package/providers/context/resources/manuals/guides/lark-resources.md +17 -1
  25. package/providers/context/resources/procedures/document-capture.md +88 -14
  26. package/providers/context/resources/procedures/document-code-investigation.md +45 -0
  27. package/providers/context/resources/procedures/repository-source-recovery.md +8 -1
  28. package/providers/context/resources/procedures/source-capture-detailed.md +6 -0
  29. package/providers/context/skills/work-production-stage/SKILL.md +4 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "protocol": "context.indexer.cli-release-manifest/v1",
3
3
  "package": "@c4a/context-cli",
4
- "version": "0.7.26",
4
+ "version": "0.7.30",
5
5
  "issuer": "context4ai/context",
6
6
  "bundles": [
7
7
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/context-cli",
3
- "version": "0.7.26",
3
+ "version": "0.7.30",
4
4
  "type": "module",
5
5
  "description": "Local runtime and Agent integration for traceable knowledge production",
6
6
  "license": "MIT",
@@ -24,17 +24,17 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@c4a/agent-graph": "0.3.0",
27
- "@c4a/context": "0.7.26",
28
- "@c4a/extract": "0.7.26",
29
- "@c4a/extract-contract": "0.7.26",
30
- "@c4a/extract-go": "0.7.26",
31
- "@c4a/extract-mdx": "0.7.26",
32
- "@c4a/extract-proto": "0.7.26",
33
- "@c4a/extract-rush": "0.7.26",
34
- "@c4a/extract-sql": "0.7.26",
35
- "@c4a/extract-style": "0.7.26",
36
- "@c4a/extract-thrift": "0.7.26",
37
- "@c4a/extract-ts": "0.7.26",
27
+ "@c4a/context": "0.7.30",
28
+ "@c4a/extract": "0.7.30",
29
+ "@c4a/extract-contract": "0.7.30",
30
+ "@c4a/extract-go": "0.7.30",
31
+ "@c4a/extract-mdx": "0.7.30",
32
+ "@c4a/extract-proto": "0.7.30",
33
+ "@c4a/extract-rush": "0.7.30",
34
+ "@c4a/extract-sql": "0.7.30",
35
+ "@c4a/extract-style": "0.7.30",
36
+ "@c4a/extract-thrift": "0.7.30",
37
+ "@c4a/extract-ts": "0.7.30",
38
38
  "@mermaid-js/layout-elk": "0.2.0",
39
39
  "commander": "^11.0.0",
40
40
  "fast-xml-parser": "^5.10.1",
@@ -20765,24 +20765,78 @@ var init_indexerSourceBoundary = __esm(() => {
20765
20765
  init_indexerReadScopeAuthorization();
20766
20766
  });
20767
20767
 
20768
+ // src/lib/errors.ts
20769
+ var ContextError;
20770
+ var init_errors2 = __esm(() => {
20771
+ ContextError = class ContextError extends Error {
20772
+ code;
20773
+ detail;
20774
+ constructor(code, message, detail) {
20775
+ super(message);
20776
+ this.name = "ContextError";
20777
+ this.code = code;
20778
+ this.detail = detail;
20779
+ }
20780
+ };
20781
+ });
20782
+
20783
+ // src/types/exitCode.ts
20784
+ var ExitCode;
20785
+ var init_exitCode = __esm(() => {
20786
+ ExitCode = {
20787
+ Success: 0,
20788
+ UserError: 1,
20789
+ WorkspaceStateError: 2,
20790
+ ExternalToolError: 3,
20791
+ UserAbort: 4
20792
+ };
20793
+ });
20794
+
20795
+ // src/lib/cliFeedback.ts
20796
+ function formatFeedback(block) {
20797
+ const subjectPart = block.subject ? ` ${block.subject}` : "";
20798
+ const lines = [`${block.symbol} ${block.action}${subjectPart}: ${block.headline}`];
20799
+ for (const item of block.body ?? []) {
20800
+ if (item === false || item === null || item === undefined)
20801
+ continue;
20802
+ if (typeof item === "string") {
20803
+ lines.push(item.length > 0 ? ` ${item}` : "");
20804
+ }
20805
+ }
20806
+ if (block.next) {
20807
+ lines.push(` next: ${block.next}`);
20808
+ }
20809
+ return `${lines.join(`
20810
+ `)}
20811
+ `;
20812
+ }
20813
+ var ErrorCategory;
20814
+ var init_cliFeedback = __esm(() => {
20815
+ ErrorCategory = {
20816
+ WorkspaceNotFound: "workspace-not-found",
20817
+ WorkspaceStateInvalid: "workspace-state-invalid",
20818
+ WorkflowRevisionStale: "workflow-revision-stale",
20819
+ SourceNotFound: "source-not-found",
20820
+ MountMatrixViolation: "mount-matrix-violation",
20821
+ SchemaInvalid: "schema-invalid",
20822
+ ProviderUnavailable: "provider-unavailable",
20823
+ ExternalToolFailed: "external-tool-failed",
20824
+ PartialFailure: "partial-failure",
20825
+ UserInputInvalid: "user-input-invalid",
20826
+ Unknown: "unknown"
20827
+ };
20828
+ });
20829
+
20768
20830
  // src/project/indexerParserSourceMaterialization.ts
20769
20831
  import { execFile } from "node:child_process";
20770
- import { lstat as lstat2, readFile as readFile6 } from "node:fs/promises";
20832
+ import { lstat as lstat2, readFile as readFile6, stat as stat2 } from "node:fs/promises";
20771
20833
  import { promisify } from "node:util";
20772
20834
  import { basename, extname, join as join4 } from "node:path";
20773
20835
  function sourceRefName(sourceRef) {
20774
20836
  return sourceRef.startsWith("repo:") ? sourceRef.slice("repo:".length) : null;
20775
20837
  }
20776
20838
  async function trackedPaths(root, ref) {
20777
- try {
20778
- await execFileAsync("git", ["diff", "--quiet", ref, "--", "."], { cwd: root });
20779
- } catch (error) {
20780
- const exitCode = error !== null && typeof error === "object" && "code" in error ? error.code : null;
20781
- if (exitCode === 1) {
20782
- throw new TypeError(`materialized repository source differs from its pinned ref: ${root}`);
20783
- }
20784
- throw error;
20785
- }
20839
+ await assertPinnedSource(root, ref);
20786
20840
  const { stdout } = await execFileAsync("git", ["ls-files", "-z", "--", "."], {
20787
20841
  cwd: root,
20788
20842
  encoding: "buffer",
@@ -20791,6 +20845,20 @@ async function trackedPaths(root, ref) {
20791
20845
  return Buffer.from(stdout).toString("utf8").split("\x00").filter(Boolean).sort();
20792
20846
  }
20793
20847
  async function assertPinnedSource(root, ref) {
20848
+ const sourceStat = await stat2(root).catch((error) => {
20849
+ if (error.code === "ENOENT" || error.code === "ENOTDIR")
20850
+ return;
20851
+ throw error;
20852
+ });
20853
+ if (!sourceStat?.isDirectory()) {
20854
+ throw new ContextError(ExitCode.WorkspaceStateError, `Repository source directory is unavailable: ${root}. Inspect recovery with context source recovery-plan --format json.`, {
20855
+ category: ErrorCategory.WorkspaceStateInvalid,
20856
+ reason_code: "repository-source-directory-unavailable",
20857
+ cwd: root,
20858
+ next_action: { command: "context source recovery-plan --format json" },
20859
+ input_schema: { type: "object", properties: {}, additionalProperties: false }
20860
+ });
20861
+ }
20794
20862
  try {
20795
20863
  await execFileAsync("git", ["diff", "--quiet", ref, "--", "."], { cwd: root });
20796
20864
  } catch (error) {
@@ -20798,6 +20866,15 @@ async function assertPinnedSource(root, ref) {
20798
20866
  if (exitCode === 1) {
20799
20867
  throw new TypeError(`materialized repository source differs from its pinned ref: ${root}`);
20800
20868
  }
20869
+ if (exitCode === "ENOENT") {
20870
+ throw new ContextError(ExitCode.ExternalToolError, `Git could not start for repository source ${root}. Check git --version and the source directory in the same host environment.`, {
20871
+ category: ErrorCategory.ExternalToolFailed,
20872
+ reason_code: "repository-git-spawn-unavailable",
20873
+ cwd: root,
20874
+ next_action: { command: "git --version" },
20875
+ input_schema: { type: "object", properties: {}, additionalProperties: false }
20876
+ });
20877
+ }
20801
20878
  throw error;
20802
20879
  }
20803
20880
  }
@@ -20861,6 +20938,9 @@ var init_indexerParserSourceMaterialization = __esm(() => {
20861
20938
  init_src();
20862
20939
  init_indexerReadScopeAuthorization();
20863
20940
  init_indexerSourceBoundary();
20941
+ init_errors2();
20942
+ init_exitCode();
20943
+ init_cliFeedback();
20864
20944
  execFileAsync = promisify(execFile);
20865
20945
  });
20866
20946
 
package/plugins/README.md CHANGED
@@ -31,7 +31,7 @@ Context workflow and Indexer Provider lifecycle.
31
31
  ## Query and attribute workspace knowledge
32
32
 
33
33
  Explicitly invoke `/c4a:context-inspect-search` (Cursor: `/c4a-context-inspect-search`),
34
- or let a host configuration route knowledge questions to the `context-inspect-search` Skill. It can start from a readable local, global or host-provided knowledge package and its query Skill without a local workspace. Without output, it
34
+ or let a host configuration route knowledge questions to the `context-inspect-search` Skill. `CONTEXT_QUERY_SOURCE_MODE` selects `repo-first` (the default), `package-first`, or `dual` retrieval. It can start from a readable local, global or host-provided knowledge package and its query Skill without a local workspace. Without output, it
35
35
  queries approved `knowledge` directly; a package build requires prior authorization for that workspace write.
36
36
  Read-only investigation and bounded non-destructive checks need no further approval. For code attribution, it
37
37
  retrieves the registered revision and checks relevant differences against current code without asking the user to select a version.
@@ -27,7 +27,7 @@ Skills 只能通过完成校验的 Context Indexer Provider 生命周期激活
27
27
  ## 查询知识与来源归因
28
28
 
29
29
  主动调用 `/c4a:context-inspect-search`(Cursor:`/c4a-context-inspect-search`),
30
- 或由宿主配置将知识问答路由到 `context-inspect-search` 技能。无需本地工作区即可检索本地、全局或宿主提供的知识包,优先使用包内查询技能;没有产物但有工作区时,
30
+ 或由宿主配置将知识问答路由到 `context-inspect-search` 技能。`CONTEXT_QUERY_SOURCE_MODE` 可选择默认的 `repo-first`、`package-first` 或 `dual` 检索。无需本地工作区也可检索本地、全局或宿主提供的知识包;没有产物但有工作区时,
31
31
  直接查询已批准的 `knowledge`,构建产物需事先获得写入工作区的授权。只读探索及有边界的
32
32
  非破坏性检查无需再次确认。代码归因自动取得登记版本,并核对相关文件与当前代码的差异,
33
33
  无需用户选择版本。通过构建清单关联批准原稿
package/plugins/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.26
1
+ 0.7.30
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "c4a",
3
3
  "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.",
4
- "version": "0.7.26",
4
+ "version": "0.7.30",
5
5
  "author": {
6
6
  "name": "c4a"
7
7
  },
@@ -26,14 +26,37 @@ Do not execute returned production actions, initialize a replacement workspace,
26
26
  or install tools without existing authorization. Querying must not alter source
27
27
  registrations, snapshots, tasks, approvals or user checkouts.
28
28
 
29
- ## Search available material concurrently
30
-
31
- Check relevant knowledge packages, the workspace and reusable source checkouts
32
- in parallel. Search each as soon as it is readable; tool checks and authorized
33
- upgrades must not block independent reading. If a missing configured workspace
34
- is needed for further attribution, recover it into an isolated directory while
35
- package retrieval continues. Without a configured workspace, investigate the
36
- available packages directly; do not request or create one merely to start.
29
+ Resolve `CONTEXT_QUERY_SOURCE_MODE` from the host or Bot instance configuration
30
+ before choosing the first retrieval path. Supported values are:
31
+
32
+ - `repo-first` (default): search approved `knowledge/` in the configured knowledge
33
+ workspace first; trace authorized original sources only for material gaps.
34
+ Use an available package when approved knowledge is unavailable.
35
+ - `package-first`: inspect the selected package first, then use its recorded
36
+ workspace or repository sources for missing, stale or disputed evidence.
37
+ - `dual`: inspect the package and repository paths concurrently, then reconcile
38
+ relevant differences before answering.
39
+
40
+ An unknown or empty value is `repo-first`; do not invent a fourth mode. The
41
+ mode changes retrieval order, not authorization or evidence standards. It does
42
+ not make a missing secondary source mandatory: continue with readable configured
43
+ sources and identify only gaps that affect the answer.
44
+
45
+ ## Search available material according to the configured mode
46
+
47
+ Apply `CONTEXT_QUERY_SOURCE_MODE` before starting retrieval. In `repo-first`,
48
+ start with approved knowledge, not original-code checkout preparation. With
49
+ readable `knowledge/`, do not probe `dist/`, build inventories or installed
50
+ packages: distribution output is not a query prerequisite. An explicit request
51
+ to investigate delivered content is an exception. In `package-first`, start with
52
+ the selected readable package. In `dual`, start both paths concurrently. Search
53
+ each selected path as soon as it is readable; tool checks and authorized
54
+ upgrades must not block independent reading. If a configured primary path is
55
+ missing, continue with the readable fallback instead of stopping. If a missing
56
+ configured workspace is needed for further attribution, recover it into an
57
+ isolated directory while other selected retrieval continues. Without a
58
+ configured workspace, investigate available packages directly; do not request
59
+ or create one merely to start.
37
60
 
38
61
  A knowledge package may be workspace build output (usually `dist/`), a global
39
62
  installation, or an equivalent host-provided directory. Locate it from available
@@ -45,9 +68,11 @@ missing, use the host's configured, authorized package retrieval mechanism while
45
68
  other reading continues. Only check or prepare tools needed for the next actual
46
69
  operation; installation failure does not block independent local retrieval.
47
70
 
48
- For gaps or latest-content questions, also search approved knowledge when a workspace is available:
49
- use `knowledge/structure.yaml` and relevant `knowledge/` paths, trying business
50
- terms, symbols and synonyms, then read matching sections in context. Delivered
71
+ Search relevant `knowledge/` paths using business terms, symbols and synonyms,
72
+ then read matching sections in context; use `knowledge/structure.yaml` when
73
+ navigation or associations are needed, not as an exhaustive preflight. In
74
+ package-first or dual mode, approved knowledge can resolve gaps or freshness
75
+ questions in delivered material. Delivered
51
76
  content may lag approved knowledge; they are not independent corroboration.
52
77
  Candidates and temporary reports are not approved pages. A search miss does not
53
78
  prove a capability is absent. Do not build merely to answer a query; a separately
@@ -57,8 +82,11 @@ When package or approved knowledge leaves a gap, directly trace relevant sources
57
82
  without asking whether to deepen the query. Use available document, code-search
58
83
  or extraction tools within the authorized scope, recording source identity and
59
84
  version. Prepare sources while continuing other reading.
60
- One failed source blocks only dependent claims. Answer when evidence is
61
- sufficient, without completing unnecessary preparation.
85
+ One failed source blocks only dependent claims. If the read knowledge supports
86
+ the requested conclusion, its conditions and scope, answer without restoring
87
+ code or checking every associated source. Missing mechanisms, conflicting facts
88
+ or unsupported current-behavior claims still require targeted investigation;
89
+ an article title, search snippet or unread citation is not sufficient evidence.
62
90
 
63
91
  ## Trace and retrieve only relevant sources
64
92
 
@@ -69,18 +97,23 @@ registry is not a mandatory intermediate step. If the source identity or version
69
97
  cannot be established, retain package-grounded findings and qualify attribution;
70
98
  do not invent a repository or equate current source with the package's baseline.
71
99
 
72
- When a workspace and `context-build-inventory.json` are available, map a delivered page's
100
+ Only when tracing a delivered page and a build inventory is already available, map its
73
101
  `dist_path` through `approved_knowledge.files` to its `approved_path`, relative
74
- to the workspace's `knowledge/` root. Follow the approved page's associations in
75
- `knowledge/structure.yaml` and `sources/*/index.yaml`. Without a reliable mapping,
102
+ to the workspace's `knowledge/` root. For directly read approved pages, skip this
103
+ mapping entirely. Follow relevant associations in `knowledge/structure.yaml`
104
+ and `sources/*/index.yaml` only when source tracing is needed. Without a reliable mapping,
76
105
  continue package retrieval and follow explicit source references where available.
77
106
  Do not guess originals from similar filenames or claim attribution without
78
107
  checking the referenced material.
79
108
 
80
109
  Use the repository and recorded commit identified by the package or workspace
81
110
  as the source baseline.
82
- Reuse existing checkouts only after checking remote, commit, module coverage
83
- and local changes; do not reset them or change their sparse configuration.
111
+ Before reusing a checkout for source reads, group checks of remote, commit,
112
+ module coverage and local changes. Reuse those findings within this response
113
+ instead of checking again before each search or file read. Recheck affected
114
+ facts if the checkout/ref changes, sparse scope expands or there is evidence of
115
+ concurrent edits; do not treat a previous response's checks as current. Do not
116
+ reset user checkouts or change their sparse configuration.
84
117
  Missing code goes into a reusable query-owned path such as
85
118
  `.tmp/context-inspect/<host>/<repository-path>/<commit>/`, separate from user
86
119
  checkouts and production-managed sources. Use safe, credential-free path
@@ -109,17 +142,45 @@ capture/recovery actions. Production recovery gates do not block this independen
109
142
  inspection. Preserve unavailable-evidence gaps rather than changing production
110
143
  state to get past them.
111
144
 
112
- Compare relevant baseline files with current code when accessible, including
113
- relevant local changes. Use actual diffs to assess impact; current code is not a
114
- substitute for the baseline. Mention a missing comparison only when it limits
115
- the answer. For documents, notes and sessions, read saved bodies and necessary
145
+ Batch independent searches and related file reads once paths are known, such as
146
+ the entrypoint, state update and controlling render logic for one mechanism.
147
+ Read enough surrounding context and follow unresolved imports or calls; batching
148
+ must not truncate decisive evidence or turn a partial read into a complete audit.
149
+ Reuse already read evidence rather than rereading it to prepare each tool call.
150
+
151
+ Let evidence sufficiency determine whether a version comparison is needed.
152
+ When the available knowledge or identified baseline code resolves the question,
153
+ answer without fetching the default branch, recovering a second checkout or
154
+ reading history merely to confirm freshness. Compare narrowly when uncertainty,
155
+ conflicting evidence, suspected changes or an explicit version-comparison request
156
+ makes it useful. A question about current behavior requires judging whether the
157
+ available evidence supports that claim, not automatically comparing every branch.
158
+ Retain necessary source reads; do not equate a recorded baseline or branch HEAD
159
+ with a verified live deployment. When comparing, use actual relevant diffs,
160
+ including relevant local changes; current code is not a substitute for the baseline.
161
+ Mention a missing comparison only when it limits the answer.
162
+ For documents, notes and sessions, read saved bodies and necessary
116
163
  attachments; fetch missing accessible material within scope. A summary is not a
117
164
  full transcript, an unread link is not evidence, and current remote content does
118
165
  not prove a historical snapshot.
119
166
 
120
167
  ## Answer with evidence and hand off updates
121
168
 
122
- Lead with the conclusion and a concise evidence chain. Distinguish implementation,
169
+ Answer the user's question directly, keeping conditions that change the conclusion
170
+ beside it. For complex questions, explain the mechanism that determines the result,
171
+ not just the verdict and source links. Explain its practical meaning before using
172
+ a short code excerpt or concrete rule when that helps the reader verify or act.
173
+ Keep decisive evidence beside the claim it supports; separate supplementary facts
174
+ from the proof. State where a local rule applies rather than generalizing it to
175
+ the whole system, and do not infer presentation or behavior from data retrieval
176
+ alone without checking the controlling logic.
177
+
178
+ Adapt depth and structure to the question: keep simple answers short; use short
179
+ headings and, where supported, separators between major semantic sections in
180
+ longer answers. Do not impose a fixed outline, separate every paragraph, repeat
181
+ the conclusion, or remove necessary explanation just to shorten the answer.
182
+ Keep conditions affecting the answer prominent and supplementary reading secondary.
183
+ Distinguish implementation,
123
184
  declared contracts, test assertions, runtime observations and inferences. Perform
124
185
  bounded non-destructive validation only when useful; inspect its effects first
125
186
  and do not run unrelated scripts, builds or tests.
@@ -131,13 +192,25 @@ limitation. Do not dump internal reasoning, runtime identifiers or routine
131
192
  version comparisons. Explain only differences affecting the answer; hashes may
132
193
  appear in source URLs without requiring a separate version audit in the prose.
133
194
 
134
- For website links, use `context-site-map.json` from the selected package or
135
- sibling website output. Match `pages[].package_path` or `approved_path`, and
195
+ Collect citation targets after the relevant evidence is established and resolve
196
+ them in one batch using the host's existing link resolver when available. Reuse
197
+ known workspace, repository and site parameters; do not rediscover them per link.
198
+ If later evidence adds targets, resolve only those missing from the results.
199
+ Without a host resolver, use an already available `context-site-map.json` from
200
+ the selected package or website output. Do not search for `dist/` merely to
201
+ obtain links for readable approved knowledge. Match `pages[].package_path` or `approved_path`, and
136
202
  resolve `site_path` against `site_url` without prepending `base` again. Cite only
137
203
  matched pages, deduplicate links and do not invent anchors. If mapping is absent
138
204
  or invalid, retain local citations. Do not build, publish or probe remote sites
139
205
  just to format citations; a local map is not proof of the current online content.
140
206
 
207
+ Once the requested questions are supported or genuinely unavailable evidence is
208
+ clearly bounded, synthesize the final answer directly. Do not add another planning,
209
+ freshness-audit or summary round just to prepare it. Preserve necessary mechanisms,
210
+ exceptions, citations and verification limits; fewer preparation steps must not
211
+ mean weaker evidence or omitted questions. Host delivery and receipt requirements
212
+ still apply, without repeating the completed investigation.
213
+
141
214
  Suggest a knowledge update only with supporting evidence: identify the affected
142
215
  page or gap, proposed change and bounded source scope. Check neighboring content
143
216
  before proposing a new page. Only after user acceptance, hand the evidence and
@@ -25,14 +25,37 @@ Do not execute returned production actions, initialize a replacement workspace,
25
25
  or install tools without existing authorization. Querying must not alter source
26
26
  registrations, snapshots, tasks, approvals or user checkouts.
27
27
 
28
- ## Search available material concurrently
29
-
30
- Check relevant knowledge packages, the workspace and reusable source checkouts
31
- in parallel. Search each as soon as it is readable; tool checks and authorized
32
- upgrades must not block independent reading. If a missing configured workspace
33
- is needed for further attribution, recover it into an isolated directory while
34
- package retrieval continues. Without a configured workspace, investigate the
35
- available packages directly; do not request or create one merely to start.
28
+ Resolve `CONTEXT_QUERY_SOURCE_MODE` from the host or Bot instance configuration
29
+ before choosing the first retrieval path. Supported values are:
30
+
31
+ - `repo-first` (default): search approved `knowledge/` in the configured knowledge
32
+ workspace first; trace authorized original sources only for material gaps.
33
+ Use an available package when approved knowledge is unavailable.
34
+ - `package-first`: inspect the selected package first, then use its recorded
35
+ workspace or repository sources for missing, stale or disputed evidence.
36
+ - `dual`: inspect the package and repository paths concurrently, then reconcile
37
+ relevant differences before answering.
38
+
39
+ An unknown or empty value is `repo-first`; do not invent a fourth mode. The
40
+ mode changes retrieval order, not authorization or evidence standards. It does
41
+ not make a missing secondary source mandatory: continue with readable configured
42
+ sources and identify only gaps that affect the answer.
43
+
44
+ ## Search available material according to the configured mode
45
+
46
+ Apply `CONTEXT_QUERY_SOURCE_MODE` before starting retrieval. In `repo-first`,
47
+ start with approved knowledge, not original-code checkout preparation. With
48
+ readable `knowledge/`, do not probe `dist/`, build inventories or installed
49
+ packages: distribution output is not a query prerequisite. An explicit request
50
+ to investigate delivered content is an exception. In `package-first`, start with
51
+ the selected readable package. In `dual`, start both paths concurrently. Search
52
+ each selected path as soon as it is readable; tool checks and authorized
53
+ upgrades must not block independent reading. If a configured primary path is
54
+ missing, continue with the readable fallback instead of stopping. If a missing
55
+ configured workspace is needed for further attribution, recover it into an
56
+ isolated directory while other selected retrieval continues. Without a
57
+ configured workspace, investigate available packages directly; do not request
58
+ or create one merely to start.
36
59
 
37
60
  A knowledge package may be workspace build output (usually `dist/`), a global
38
61
  installation, or an equivalent host-provided directory. Locate it from available
@@ -44,9 +67,11 @@ missing, use the host's configured, authorized package retrieval mechanism while
44
67
  other reading continues. Only check or prepare tools needed for the next actual
45
68
  operation; installation failure does not block independent local retrieval.
46
69
 
47
- For gaps or latest-content questions, also search approved knowledge when a workspace is available:
48
- use `knowledge/structure.yaml` and relevant `knowledge/` paths, trying business
49
- terms, symbols and synonyms, then read matching sections in context. Delivered
70
+ Search relevant `knowledge/` paths using business terms, symbols and synonyms,
71
+ then read matching sections in context; use `knowledge/structure.yaml` when
72
+ navigation or associations are needed, not as an exhaustive preflight. In
73
+ package-first or dual mode, approved knowledge can resolve gaps or freshness
74
+ questions in delivered material. Delivered
50
75
  content may lag approved knowledge; they are not independent corroboration.
51
76
  Candidates and temporary reports are not approved pages. A search miss does not
52
77
  prove a capability is absent. Do not build merely to answer a query; a separately
@@ -56,8 +81,11 @@ When package or approved knowledge leaves a gap, directly trace relevant sources
56
81
  without asking whether to deepen the query. Use available document, code-search
57
82
  or extraction tools within the authorized scope, recording source identity and
58
83
  version. Prepare sources while continuing other reading.
59
- One failed source blocks only dependent claims. Answer when evidence is
60
- sufficient, without completing unnecessary preparation.
84
+ One failed source blocks only dependent claims. If the read knowledge supports
85
+ the requested conclusion, its conditions and scope, answer without restoring
86
+ code or checking every associated source. Missing mechanisms, conflicting facts
87
+ or unsupported current-behavior claims still require targeted investigation;
88
+ an article title, search snippet or unread citation is not sufficient evidence.
61
89
 
62
90
  ## Trace and retrieve only relevant sources
63
91
 
@@ -68,18 +96,23 @@ registry is not a mandatory intermediate step. If the source identity or version
68
96
  cannot be established, retain package-grounded findings and qualify attribution;
69
97
  do not invent a repository or equate current source with the package's baseline.
70
98
 
71
- When a workspace and `context-build-inventory.json` are available, map a delivered page's
99
+ Only when tracing a delivered page and a build inventory is already available, map its
72
100
  `dist_path` through `approved_knowledge.files` to its `approved_path`, relative
73
- to the workspace's `knowledge/` root. Follow the approved page's associations in
74
- `knowledge/structure.yaml` and `sources/*/index.yaml`. Without a reliable mapping,
101
+ to the workspace's `knowledge/` root. For directly read approved pages, skip this
102
+ mapping entirely. Follow relevant associations in `knowledge/structure.yaml`
103
+ and `sources/*/index.yaml` only when source tracing is needed. Without a reliable mapping,
75
104
  continue package retrieval and follow explicit source references where available.
76
105
  Do not guess originals from similar filenames or claim attribution without
77
106
  checking the referenced material.
78
107
 
79
108
  Use the repository and recorded commit identified by the package or workspace
80
109
  as the source baseline.
81
- Reuse existing checkouts only after checking remote, commit, module coverage
82
- and local changes; do not reset them or change their sparse configuration.
110
+ Before reusing a checkout for source reads, group checks of remote, commit,
111
+ module coverage and local changes. Reuse those findings within this response
112
+ instead of checking again before each search or file read. Recheck affected
113
+ facts if the checkout/ref changes, sparse scope expands or there is evidence of
114
+ concurrent edits; do not treat a previous response's checks as current. Do not
115
+ reset user checkouts or change their sparse configuration.
83
116
  Missing code goes into a reusable query-owned path such as
84
117
  `.tmp/context-inspect/<host>/<repository-path>/<commit>/`, separate from user
85
118
  checkouts and production-managed sources. Use safe, credential-free path
@@ -108,17 +141,45 @@ capture/recovery actions. Production recovery gates do not block this independen
108
141
  inspection. Preserve unavailable-evidence gaps rather than changing production
109
142
  state to get past them.
110
143
 
111
- Compare relevant baseline files with current code when accessible, including
112
- relevant local changes. Use actual diffs to assess impact; current code is not a
113
- substitute for the baseline. Mention a missing comparison only when it limits
114
- the answer. For documents, notes and sessions, read saved bodies and necessary
144
+ Batch independent searches and related file reads once paths are known, such as
145
+ the entrypoint, state update and controlling render logic for one mechanism.
146
+ Read enough surrounding context and follow unresolved imports or calls; batching
147
+ must not truncate decisive evidence or turn a partial read into a complete audit.
148
+ Reuse already read evidence rather than rereading it to prepare each tool call.
149
+
150
+ Let evidence sufficiency determine whether a version comparison is needed.
151
+ When the available knowledge or identified baseline code resolves the question,
152
+ answer without fetching the default branch, recovering a second checkout or
153
+ reading history merely to confirm freshness. Compare narrowly when uncertainty,
154
+ conflicting evidence, suspected changes or an explicit version-comparison request
155
+ makes it useful. A question about current behavior requires judging whether the
156
+ available evidence supports that claim, not automatically comparing every branch.
157
+ Retain necessary source reads; do not equate a recorded baseline or branch HEAD
158
+ with a verified live deployment. When comparing, use actual relevant diffs,
159
+ including relevant local changes; current code is not a substitute for the baseline.
160
+ Mention a missing comparison only when it limits the answer.
161
+ For documents, notes and sessions, read saved bodies and necessary
115
162
  attachments; fetch missing accessible material within scope. A summary is not a
116
163
  full transcript, an unread link is not evidence, and current remote content does
117
164
  not prove a historical snapshot.
118
165
 
119
166
  ## Answer with evidence and hand off updates
120
167
 
121
- Lead with the conclusion and a concise evidence chain. Distinguish implementation,
168
+ Answer the user's question directly, keeping conditions that change the conclusion
169
+ beside it. For complex questions, explain the mechanism that determines the result,
170
+ not just the verdict and source links. Explain its practical meaning before using
171
+ a short code excerpt or concrete rule when that helps the reader verify or act.
172
+ Keep decisive evidence beside the claim it supports; separate supplementary facts
173
+ from the proof. State where a local rule applies rather than generalizing it to
174
+ the whole system, and do not infer presentation or behavior from data retrieval
175
+ alone without checking the controlling logic.
176
+
177
+ Adapt depth and structure to the question: keep simple answers short; use short
178
+ headings and, where supported, separators between major semantic sections in
179
+ longer answers. Do not impose a fixed outline, separate every paragraph, repeat
180
+ the conclusion, or remove necessary explanation just to shorten the answer.
181
+ Keep conditions affecting the answer prominent and supplementary reading secondary.
182
+ Distinguish implementation,
122
183
  declared contracts, test assertions, runtime observations and inferences. Perform
123
184
  bounded non-destructive validation only when useful; inspect its effects first
124
185
  and do not run unrelated scripts, builds or tests.
@@ -130,13 +191,25 @@ limitation. Do not dump internal reasoning, runtime identifiers or routine
130
191
  version comparisons. Explain only differences affecting the answer; hashes may
131
192
  appear in source URLs without requiring a separate version audit in the prose.
132
193
 
133
- For website links, use `context-site-map.json` from the selected package or
134
- sibling website output. Match `pages[].package_path` or `approved_path`, and
194
+ Collect citation targets after the relevant evidence is established and resolve
195
+ them in one batch using the host's existing link resolver when available. Reuse
196
+ known workspace, repository and site parameters; do not rediscover them per link.
197
+ If later evidence adds targets, resolve only those missing from the results.
198
+ Without a host resolver, use an already available `context-site-map.json` from
199
+ the selected package or website output. Do not search for `dist/` merely to
200
+ obtain links for readable approved knowledge. Match `pages[].package_path` or `approved_path`, and
135
201
  resolve `site_path` against `site_url` without prepending `base` again. Cite only
136
202
  matched pages, deduplicate links and do not invent anchors. If mapping is absent
137
203
  or invalid, retain local citations. Do not build, publish or probe remote sites
138
204
  just to format citations; a local map is not proof of the current online content.
139
205
 
206
+ Once the requested questions are supported or genuinely unavailable evidence is
207
+ clearly bounded, synthesize the final answer directly. Do not add another planning,
208
+ freshness-audit or summary round just to prepare it. Preserve necessary mechanisms,
209
+ exceptions, citations and verification limits; fewer preparation steps must not
210
+ mean weaker evidence or omitted questions. Host delivery and receipt requirements
211
+ still apply, without repeating the completed investigation.
212
+
140
213
  Suggest a knowledge update only with supporting evidence: identify the affected
141
214
  page or gap, proposed change and bounded source scope. Check neighboring content
142
215
  before proposing a new page. Only after user acceptance, hand the evidence and
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c4a",
3
- "version": "0.7.26",
3
+ "version": "0.7.30",
4
4
  "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.",
5
5
  "author": { "name": "c4a" },
6
6
  "homepage": "https://github.com/context4ai/c4a",
@@ -10,7 +10,7 @@
10
10
  "skills": "./skills/",
11
11
  "interface": {
12
12
  "displayName": "C4A Context",
13
- "shortDescription": "Initialize and advance a local, source-linked project knowledge workspace.\nv0.7.26",
13
+ "shortDescription": "Initialize and advance a local, source-linked project knowledge workspace.\nv0.7.30",
14
14
  "longDescription": "Create a Context workspace and use agent-guided next steps to register sources, run extraction, review candidates, build package outputs, and verify health without silently mutating source repositories.",
15
15
  "developerName": "c4a",
16
16
  "category": "Productivity",