@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
@@ -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,7 +1,7 @@
1
1
  {
2
2
  "name": "c4a",
3
3
  "displayName": "C4A Context",
4
- "version": "0.7.26",
4
+ "version": "0.7.30",
5
5
  "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.",
6
6
  "author": {
7
7
  "name": "Context4AI",
@@ -24,14 +24,37 @@ Do not execute returned production actions, initialize a replacement workspace,
24
24
  or install tools without existing authorization. Querying must not alter source
25
25
  registrations, snapshots, tasks, approvals or user checkouts.
26
26
 
27
- ## Search available material concurrently
28
-
29
- Check relevant knowledge packages, the workspace and reusable source checkouts
30
- in parallel. Search each as soon as it is readable; tool checks and authorized
31
- upgrades must not block independent reading. If a missing configured workspace
32
- is needed for further attribution, recover it into an isolated directory while
33
- package retrieval continues. Without a configured workspace, investigate the
34
- available packages directly; do not request or create one merely to start.
27
+ Resolve `CONTEXT_QUERY_SOURCE_MODE` from the host or Bot instance configuration
28
+ before choosing the first retrieval path. Supported values are:
29
+
30
+ - `repo-first` (default): search approved `knowledge/` in the configured knowledge
31
+ workspace first; trace authorized original sources only for material gaps.
32
+ Use an available package when approved knowledge is unavailable.
33
+ - `package-first`: inspect the selected package first, then use its recorded
34
+ workspace or repository sources for missing, stale or disputed evidence.
35
+ - `dual`: inspect the package and repository paths concurrently, then reconcile
36
+ relevant differences before answering.
37
+
38
+ An unknown or empty value is `repo-first`; do not invent a fourth mode. The
39
+ mode changes retrieval order, not authorization or evidence standards. It does
40
+ not make a missing secondary source mandatory: continue with readable configured
41
+ sources and identify only gaps that affect the answer.
42
+
43
+ ## Search available material according to the configured mode
44
+
45
+ Apply `CONTEXT_QUERY_SOURCE_MODE` before starting retrieval. In `repo-first`,
46
+ start with approved knowledge, not original-code checkout preparation. With
47
+ readable `knowledge/`, do not probe `dist/`, build inventories or installed
48
+ packages: distribution output is not a query prerequisite. An explicit request
49
+ to investigate delivered content is an exception. In `package-first`, start with
50
+ the selected readable package. In `dual`, start both paths concurrently. Search
51
+ each selected path as soon as it is readable; tool checks and authorized
52
+ upgrades must not block independent reading. If a configured primary path is
53
+ missing, continue with the readable fallback instead of stopping. If a missing
54
+ configured workspace is needed for further attribution, recover it into an
55
+ isolated directory while other selected retrieval continues. Without a
56
+ configured workspace, investigate available packages directly; do not request
57
+ or create one merely to start.
35
58
 
36
59
  A knowledge package may be workspace build output (usually `dist/`), a global
37
60
  installation, or an equivalent host-provided directory. Locate it from available
@@ -43,9 +66,11 @@ missing, use the host's configured, authorized package retrieval mechanism while
43
66
  other reading continues. Only check or prepare tools needed for the next actual
44
67
  operation; installation failure does not block independent local retrieval.
45
68
 
46
- For gaps or latest-content questions, also search approved knowledge when a workspace is available:
47
- use `knowledge/structure.yaml` and relevant `knowledge/` paths, trying business
48
- terms, symbols and synonyms, then read matching sections in context. Delivered
69
+ Search relevant `knowledge/` paths using business terms, symbols and synonyms,
70
+ then read matching sections in context; use `knowledge/structure.yaml` when
71
+ navigation or associations are needed, not as an exhaustive preflight. In
72
+ package-first or dual mode, approved knowledge can resolve gaps or freshness
73
+ questions in delivered material. Delivered
49
74
  content may lag approved knowledge; they are not independent corroboration.
50
75
  Candidates and temporary reports are not approved pages. A search miss does not
51
76
  prove a capability is absent. Do not build merely to answer a query; a separately
@@ -55,8 +80,11 @@ When package or approved knowledge leaves a gap, directly trace relevant sources
55
80
  without asking whether to deepen the query. Use available document, code-search
56
81
  or extraction tools within the authorized scope, recording source identity and
57
82
  version. Prepare sources while continuing other reading.
58
- One failed source blocks only dependent claims. Answer when evidence is
59
- sufficient, without completing unnecessary preparation.
83
+ One failed source blocks only dependent claims. If the read knowledge supports
84
+ the requested conclusion, its conditions and scope, answer without restoring
85
+ code or checking every associated source. Missing mechanisms, conflicting facts
86
+ or unsupported current-behavior claims still require targeted investigation;
87
+ an article title, search snippet or unread citation is not sufficient evidence.
60
88
 
61
89
  ## Trace and retrieve only relevant sources
62
90
 
@@ -67,18 +95,23 @@ registry is not a mandatory intermediate step. If the source identity or version
67
95
  cannot be established, retain package-grounded findings and qualify attribution;
68
96
  do not invent a repository or equate current source with the package's baseline.
69
97
 
70
- When a workspace and `context-build-inventory.json` are available, map a delivered page's
98
+ Only when tracing a delivered page and a build inventory is already available, map its
71
99
  `dist_path` through `approved_knowledge.files` to its `approved_path`, relative
72
- to the workspace's `knowledge/` root. Follow the approved page's associations in
73
- `knowledge/structure.yaml` and `sources/*/index.yaml`. Without a reliable mapping,
100
+ to the workspace's `knowledge/` root. For directly read approved pages, skip this
101
+ mapping entirely. Follow relevant associations in `knowledge/structure.yaml`
102
+ and `sources/*/index.yaml` only when source tracing is needed. Without a reliable mapping,
74
103
  continue package retrieval and follow explicit source references where available.
75
104
  Do not guess originals from similar filenames or claim attribution without
76
105
  checking the referenced material.
77
106
 
78
107
  Use the repository and recorded commit identified by the package or workspace
79
108
  as the source baseline.
80
- Reuse existing checkouts only after checking remote, commit, module coverage
81
- and local changes; do not reset them or change their sparse configuration.
109
+ Before reusing a checkout for source reads, group checks of remote, commit,
110
+ module coverage and local changes. Reuse those findings within this response
111
+ instead of checking again before each search or file read. Recheck affected
112
+ facts if the checkout/ref changes, sparse scope expands or there is evidence of
113
+ concurrent edits; do not treat a previous response's checks as current. Do not
114
+ reset user checkouts or change their sparse configuration.
82
115
  Missing code goes into a reusable query-owned path such as
83
116
  `.tmp/context-inspect/<host>/<repository-path>/<commit>/`, separate from user
84
117
  checkouts and production-managed sources. Use safe, credential-free path
@@ -107,17 +140,45 @@ capture/recovery actions. Production recovery gates do not block this independen
107
140
  inspection. Preserve unavailable-evidence gaps rather than changing production
108
141
  state to get past them.
109
142
 
110
- Compare relevant baseline files with current code when accessible, including
111
- relevant local changes. Use actual diffs to assess impact; current code is not a
112
- substitute for the baseline. Mention a missing comparison only when it limits
113
- the answer. For documents, notes and sessions, read saved bodies and necessary
143
+ Batch independent searches and related file reads once paths are known, such as
144
+ the entrypoint, state update and controlling render logic for one mechanism.
145
+ Read enough surrounding context and follow unresolved imports or calls; batching
146
+ must not truncate decisive evidence or turn a partial read into a complete audit.
147
+ Reuse already read evidence rather than rereading it to prepare each tool call.
148
+
149
+ Let evidence sufficiency determine whether a version comparison is needed.
150
+ When the available knowledge or identified baseline code resolves the question,
151
+ answer without fetching the default branch, recovering a second checkout or
152
+ reading history merely to confirm freshness. Compare narrowly when uncertainty,
153
+ conflicting evidence, suspected changes or an explicit version-comparison request
154
+ makes it useful. A question about current behavior requires judging whether the
155
+ available evidence supports that claim, not automatically comparing every branch.
156
+ Retain necessary source reads; do not equate a recorded baseline or branch HEAD
157
+ with a verified live deployment. When comparing, use actual relevant diffs,
158
+ including relevant local changes; current code is not a substitute for the baseline.
159
+ Mention a missing comparison only when it limits the answer.
160
+ For documents, notes and sessions, read saved bodies and necessary
114
161
  attachments; fetch missing accessible material within scope. A summary is not a
115
162
  full transcript, an unread link is not evidence, and current remote content does
116
163
  not prove a historical snapshot.
117
164
 
118
165
  ## Answer with evidence and hand off updates
119
166
 
120
- Lead with the conclusion and a concise evidence chain. Distinguish implementation,
167
+ Answer the user's question directly, keeping conditions that change the conclusion
168
+ beside it. For complex questions, explain the mechanism that determines the result,
169
+ not just the verdict and source links. Explain its practical meaning before using
170
+ a short code excerpt or concrete rule when that helps the reader verify or act.
171
+ Keep decisive evidence beside the claim it supports; separate supplementary facts
172
+ from the proof. State where a local rule applies rather than generalizing it to
173
+ the whole system, and do not infer presentation or behavior from data retrieval
174
+ alone without checking the controlling logic.
175
+
176
+ Adapt depth and structure to the question: keep simple answers short; use short
177
+ headings and, where supported, separators between major semantic sections in
178
+ longer answers. Do not impose a fixed outline, separate every paragraph, repeat
179
+ the conclusion, or remove necessary explanation just to shorten the answer.
180
+ Keep conditions affecting the answer prominent and supplementary reading secondary.
181
+ Distinguish implementation,
121
182
  declared contracts, test assertions, runtime observations and inferences. Perform
122
183
  bounded non-destructive validation only when useful; inspect its effects first
123
184
  and do not run unrelated scripts, builds or tests.
@@ -129,13 +190,25 @@ limitation. Do not dump internal reasoning, runtime identifiers or routine
129
190
  version comparisons. Explain only differences affecting the answer; hashes may
130
191
  appear in source URLs without requiring a separate version audit in the prose.
131
192
 
132
- For website links, use `context-site-map.json` from the selected package or
133
- sibling website output. Match `pages[].package_path` or `approved_path`, and
193
+ Collect citation targets after the relevant evidence is established and resolve
194
+ them in one batch using the host's existing link resolver when available. Reuse
195
+ known workspace, repository and site parameters; do not rediscover them per link.
196
+ If later evidence adds targets, resolve only those missing from the results.
197
+ Without a host resolver, use an already available `context-site-map.json` from
198
+ the selected package or website output. Do not search for `dist/` merely to
199
+ obtain links for readable approved knowledge. Match `pages[].package_path` or `approved_path`, and
134
200
  resolve `site_path` against `site_url` without prepending `base` again. Cite only
135
201
  matched pages, deduplicate links and do not invent anchors. If mapping is absent
136
202
  or invalid, retain local citations. Do not build, publish or probe remote sites
137
203
  just to format citations; a local map is not proof of the current online content.
138
204
 
205
+ Once the requested questions are supported or genuinely unavailable evidence is
206
+ clearly bounded, synthesize the final answer directly. Do not add another planning,
207
+ freshness-audit or summary round just to prepare it. Preserve necessary mechanisms,
208
+ exceptions, citations and verification limits; fewer preparation steps must not
209
+ mean weaker evidence or omitted questions. Host delivery and receipt requirements
210
+ still apply, without repeating the completed investigation.
211
+
139
212
  Suggest a knowledge update only with supporting evidence: identify the affected
140
213
  page or gap, proposed change and bounded source scope. Check neighboring content
141
214
  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