@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
@@ -36,6 +36,10 @@ nodes:
36
36
  kind: action
37
37
  reasonCode: route.production.planning-required
38
38
  action: actions/work-production-stage.yaml
39
+ resources:
40
+ recommended:
41
+ - resources/procedures/document-code-investigation.md
42
+ - resources/procedures/repository-source-recovery.md
39
43
  satisfiedBy:
40
44
  - path: production.planning_complete
41
45
  equals: true
@@ -2,14 +2,14 @@
2
2
  "schema": "agent-graph.bundle.v1",
3
3
  "provider": {
4
4
  "id": "c4a/context",
5
- "version": "0.7.26"
5
+ "version": "0.7.30"
6
6
  },
7
7
  "providerManifest": "provider.yaml",
8
8
  "graphs": [
9
9
  {
10
10
  "id": "indexer",
11
11
  "path": "graphs/indexer.yaml",
12
- "digest": "sha256:4992b548a9d19c6d7fd25a5dc0ae6b78a4a494ce39d37633144d389362f21122"
12
+ "digest": "sha256:d52242180fbe1afea09946bb223a698f7e0637f81d619d9245acb74732f2409e"
13
13
  },
14
14
  {
15
15
  "id": "workspace",
@@ -183,7 +183,7 @@
183
183
  {
184
184
  "id": "context.sdk.lark-resources",
185
185
  "path": "resources/manuals/guides/lark-resources.md",
186
- "digest": "sha256:b1ffb74a145962ff89a5db29cffd1318e4ec038b97884dcd43804170cb0f6f64"
186
+ "digest": "sha256:d5b6b44fe800f302232300adbdb4f32b04b78588ea7879dc9a5c247f36658b9d"
187
187
  },
188
188
  {
189
189
  "id": "context.sdk.package-outputs",
@@ -248,7 +248,7 @@
248
248
  {
249
249
  "id": "dialogue.document-capture",
250
250
  "path": "resources/dialogue/document-capture.md",
251
- "digest": "sha256:eab34072dc96d77c0749148463f722d2483d8e7d83899ce489e927176a1178e4"
251
+ "digest": "sha256:20bb708f2c471591c0f633742d75a1353bcd4762917ce9528d3de0c7f4babbe8"
252
252
  },
253
253
  {
254
254
  "id": "dialogue.human-gates",
@@ -288,7 +288,12 @@
288
288
  {
289
289
  "id": "procedure.document-capture",
290
290
  "path": "resources/procedures/document-capture.md",
291
- "digest": "sha256:9d0d1b9187bbe540a4afffb366cd549385dbf61bfaffa96ae51de848b2dd5460"
291
+ "digest": "sha256:2e6b4e45587fffc1930a3dce0fc6b68d659499a034a367e1cc34a2ef46cb50d9"
292
+ },
293
+ {
294
+ "id": "procedure.document-code-investigation",
295
+ "path": "resources/procedures/document-code-investigation.md",
296
+ "digest": "sha256:eff8e54b9e1c1139c5df82a0685a365bce902dfb4a19c17e380967ee1c1762f5"
292
297
  },
293
298
  {
294
299
  "id": "procedure.homogeneous-source-review",
@@ -343,7 +348,7 @@
343
348
  {
344
349
  "id": "procedure.repository-source-recovery",
345
350
  "path": "resources/procedures/repository-source-recovery.md",
346
- "digest": "sha256:024f6e2947ef421b9a5f5e138c9af65a054d676a7f484dbf80b43a620ee2c95d"
351
+ "digest": "sha256:20a8112df985a20481e914a564c64c231218c73c1630d74cd46d72987e54f714"
347
352
  },
348
353
  {
349
354
  "id": "procedure.runtime-event-delivery",
@@ -363,7 +368,7 @@
363
368
  {
364
369
  "id": "procedure.source-capture-detailed",
365
370
  "path": "resources/procedures/source-capture-detailed.md",
366
- "digest": "sha256:75694361543f5c44a1077b5e6c4ed9bca844ec9b46c1773198f66e0f20ba3748"
371
+ "digest": "sha256:39644875f09bac66580332357c3d9701c234da036b61205c8a02029165455f76"
367
372
  },
368
373
  {
369
374
  "id": "procedure.source-update",
@@ -562,7 +567,7 @@
562
567
  },
563
568
  {
564
569
  "path": "graphs/indexer.yaml",
565
- "digest": "sha256:4992b548a9d19c6d7fd25a5dc0ae6b78a4a494ce39d37633144d389362f21122"
570
+ "digest": "sha256:d52242180fbe1afea09946bb223a698f7e0637f81d619d9245acb74732f2409e"
566
571
  },
567
572
  {
568
573
  "path": "graphs/workspace.yaml",
@@ -570,7 +575,7 @@
570
575
  },
571
576
  {
572
577
  "path": "provider.yaml",
573
- "digest": "sha256:7e5a25e5636983a6fb881621e826c102680f44cde9d21086c627861e119d1f7a"
578
+ "digest": "sha256:50adfb493675f902e6df4d6eade84bb279c64b767084aa15277d65870825458e"
574
579
  },
575
580
  {
576
581
  "path": "resources/contracts/indexer-provider-guide.yaml",
@@ -594,7 +599,7 @@
594
599
  },
595
600
  {
596
601
  "path": "resources/dialogue/document-capture.md",
597
- "digest": "sha256:eab34072dc96d77c0749148463f722d2483d8e7d83899ce489e927176a1178e4"
602
+ "digest": "sha256:20bb708f2c471591c0f633742d75a1353bcd4762917ce9528d3de0c7f4babbe8"
598
603
  },
599
604
  {
600
605
  "path": "resources/dialogue/human-gates.md",
@@ -630,7 +635,7 @@
630
635
  },
631
636
  {
632
637
  "path": "resources/manuals/guides/lark-resources.md",
633
- "digest": "sha256:b1ffb74a145962ff89a5db29cffd1318e4ec038b97884dcd43804170cb0f6f64"
638
+ "digest": "sha256:d5b6b44fe800f302232300adbdb4f32b04b78588ea7879dc9a5c247f36658b9d"
634
639
  },
635
640
  {
636
641
  "path": "resources/manuals/guides/markdown-indexer-skill-authoring.md",
@@ -690,7 +695,11 @@
690
695
  },
691
696
  {
692
697
  "path": "resources/procedures/document-capture.md",
693
- "digest": "sha256:9d0d1b9187bbe540a4afffb366cd549385dbf61bfaffa96ae51de848b2dd5460"
698
+ "digest": "sha256:2e6b4e45587fffc1930a3dce0fc6b68d659499a034a367e1cc34a2ef46cb50d9"
699
+ },
700
+ {
701
+ "path": "resources/procedures/document-code-investigation.md",
702
+ "digest": "sha256:eff8e54b9e1c1139c5df82a0685a365bce902dfb4a19c17e380967ee1c1762f5"
694
703
  },
695
704
  {
696
705
  "path": "resources/procedures/homogeneous-source-review.md",
@@ -734,7 +743,7 @@
734
743
  },
735
744
  {
736
745
  "path": "resources/procedures/repository-source-recovery.md",
737
- "digest": "sha256:024f6e2947ef421b9a5f5e138c9af65a054d676a7f484dbf80b43a620ee2c95d"
746
+ "digest": "sha256:20a8112df985a20481e914a564c64c231218c73c1630d74cd46d72987e54f714"
738
747
  },
739
748
  {
740
749
  "path": "resources/procedures/runtime-event-delivery.md",
@@ -750,7 +759,7 @@
750
759
  },
751
760
  {
752
761
  "path": "resources/procedures/source-capture-detailed.md",
753
- "digest": "sha256:75694361543f5c44a1077b5e6c4ed9bca844ec9b46c1773198f66e0f20ba3748"
762
+ "digest": "sha256:39644875f09bac66580332357c3d9701c234da036b61205c8a02029165455f76"
754
763
  },
755
764
  {
756
765
  "path": "resources/procedures/source-update.md",
@@ -862,12 +871,12 @@
862
871
  },
863
872
  {
864
873
  "path": "skills/work-production-stage/SKILL.md",
865
- "digest": "sha256:b7aa28c032e00f93f67d3c9dc3589cf1513451456f589262e22ad7f73d265de7"
874
+ "digest": "sha256:676289693df57b5887f104d751dd9c8cc73fb1c903e4df7088f110ef6147388a"
866
875
  }
867
876
  ],
868
877
  "graphDependencies": {
869
878
  "indexer": [],
870
879
  "workspace": []
871
880
  },
872
- "digest": "sha256:3f380c5b4a1adbc92847189b7072ec7515990dce621785bf25469268f9bbb252"
881
+ "digest": "sha256:36c06f801f991b92bb78cc94676c8d338389bdc031f49577eb196a96628b2f76"
873
882
  }
@@ -1,6 +1,6 @@
1
1
  schema: agent-graph.provider.v1
2
2
  id: c4a/context
3
- version: 0.7.26
3
+ version: 0.7.30
4
4
  name: Context workflow
5
5
  description: Internal work contract for Context knowledge workspaces.
6
6
  graphs:
@@ -23,6 +23,14 @@ refresh, or capture preview before permission is clear. A request that
23
23
  explicitly says to ingest, fetch, capture, or read the named documents grants
24
24
  that scope; merely mentioning a possible source does not.
25
25
 
26
+ The image preflight in the document-capture procedure is an Agent self-check,
27
+ not an additional user question. Before capture, briefly report the task-wide
28
+ document count and applied policy. Reference-only images keep source references
29
+ but are not downloaded or interpreted. Do not wait for confirmation or infer an
30
+ all-image override from managed execution. Unknown scope requires authorized
31
+ metadata or body-and-reference-only discovery first. Existing source-read
32
+ permission requirements remain unchanged.
33
+
26
34
  If deterministic inspection detects `.mdx`, route metadata, sidebars, or a docs
27
35
  configuration, explain that the boundary looks like a documentation site and
28
36
  ask whether to use the Context document-site processor. Do not infer that
@@ -133,8 +133,24 @@ assess the page with its non-text evidence.
133
133
 
134
134
  ## Image choices for a production task
135
135
 
136
+ Before capture, the Agent follows the document-capture Route procedure's task-wide
137
+ document threshold and image self-check, without asking for user confirmation.
138
+ Set `DOCUMENT_IMAGE_CAPTURE` in task instructions or workspace guidance to `ON`
139
+ (include images), `OFF` (references only), or a positive integer document threshold.
140
+ Omitting it uses `10`; exactly the threshold remains within normal acquisition.
141
+ Current-conversation instructions override workspace guidance for that task only.
142
+ For example, `DOCUMENT_IMAGE_CAPTURE: 20` skips image downloads when the task
143
+ contains more than 20 distinct documents. This is an Agent instruction, not an
144
+ environment variable, CLI flag or SDK field; no Bot configuration is required.
145
+ Above a numeric threshold, the default is body capture with image references,
146
+ unless the effective setting is overridden to `ON`. This workflow
147
+ choice uses the existing resource fields; it does not change SDK defaults or add
148
+ a CLI hard gate. Apply it before bulk capture or host prefetch, not after images
149
+ have already been downloaded.
150
+
136
151
  The work-start report asks once when a task contains more than 30 distinct images
137
- and has no explicit image policy. The choices are intelligent conversion and
152
+ that will be acquired and has no explicit image handling policy. Reuse the
153
+ current-conversation image instruction when it already settles this choice. The choices are intelligent conversion and
138
154
  inclusion (recommended), include all as images with compression, or include none
139
155
  with placeholders. Count the whole task, not each capture or writing batch.
140
156
  Review reports show the resulting image handling and any fallbacks.
@@ -13,14 +13,16 @@ Before capture:
13
13
 
14
14
  1. every registered document module must have a matching capture declaration;
15
15
  2. the user must have allowed the external read in the current conversation;
16
- 3. execute only the current route command.
16
+ 3. perform the Agent's task-wide image acquisition preflight below before capture;
17
+ 4. execute only the current route command.
17
18
 
18
19
  An explicit request to capture, ingest, fetch, or read named file/remote
19
20
  documents grants source-read permission for those named modules. A mention,
20
21
  possible-source discussion, or register-only request does not. An explicit
21
22
  refusal always wins.
22
23
 
23
- When that permission is already present in the conversation, execute the
24
+ When that permission is already present and the Agent's image acquisition
25
+ preflight is complete, execute the
24
26
  Gate's returned authority-carrying command. In managed mode it runs the
25
27
  deterministic capture batch until the next real blocker; in ordinary mode it
26
28
  reevaluates status with `context.source-read`. The authority remains in the
@@ -48,12 +50,26 @@ boundary is a documentation site rather than plain Markdown, use the
48
50
  Context-provided processor/configuration diagnostic; do not invent rendered
49
51
  text or scan outside the confirmed boundary.
50
52
 
51
- For Lark reads, Context prefers the authenticated user identity. If that
52
- identity is unavailable because its credential is missing, expired, or cannot
53
- be refreshed, Context may retry the same registered source with the bot
54
- identity. It does not switch identity after a permission or missing-scope
55
- response. Once selected, the same identity is used for the document body and
56
- all embedded resources. If `docs +fetch` lacks the required `--doc-format`
53
+ For Lark reads, set `CONTEXT_LARK_IDENTITY=user|bot` in the environment of every
54
+ Context invocation that may read Lark; the default is `user`. A host/Bot prompt
55
+ setting alone is not an exported environment variable. User mode reads only
56
+ as the current user. Bot mode reads as the configured application, then retries
57
+ once as the current user on a credential, scope or access denial. Subsequent
58
+ reads in that capture use the fallback identity, including pagination, synced
59
+ references, media, Sheets, Base and whiteboards. Network, rate-limit and format
60
+ errors do not switch identity. The diagnostic records any fallback.
61
+
62
+ This setting does not grant source access or change the intended audience of
63
+ the resulting knowledge. Do not use another person's credentials. For direct
64
+ host `lark-cli` reads, explicitly pass the selected `--as bot` or `--as user`
65
+ on every business read, including Wiki resolution/listing and asset reads.
66
+ If Bot access fails for the reasons above, retry that read once as user; stop
67
+ and report a pending source if user authorization is required. In a managed
68
+ runtime, use its authorization flow rather than repeatedly running `auth login`.
69
+ Local help and embedded skill discovery require no document authorization;
70
+ do not request user OAuth just to read a CLI guide.
71
+
72
+ If `docs +fetch` lacks the required `--doc-format`
57
73
  capability, follow the returned `lark-cli update` recovery and rerun the same
58
74
  Route command; do not replace the capture with a hand-written export.
59
75
 
@@ -63,9 +79,67 @@ are available while another capture remains pending. Keep unresolved sources in
63
79
  pending capture after the active production/review work, before delivery completes.
64
80
  This does not mark failed captures as complete or waive source-read authorization.
65
81
 
66
- For image-heavy tasks, reuse the image choice in the work-start report. When
67
- source descriptors already show more than 30 distinct images across the task,
68
- resolve that question before bulk media acquisition. If counts emerge only from
69
- capture, stop further image processing to confirm the choice during planning.
70
- Use explicit image/GIF reference-only policies for exclusions; never substitute
71
- temporary signed media URLs as permanent public image links.
82
+ ## Image acquisition before capture
83
+
84
+ The workflow instruction setting `DOCUMENT_IMAGE_CAPTURE` accepts `ON`, `OFF`,
85
+ or a positive integer document threshold; when absent it defaults to **10**.
86
+ Read it from the current task instructions or workspace guidance; a current
87
+ conversation instruction takes precedence. This is an Agent-interpreted setting,
88
+ not a CLI flag, environment variable, or SDK field. Hosts need not add a setting.
89
+
90
+ | Setting | Acquisition policy |
91
+ | --- | --- |
92
+ | `ON` | Include images without a document-count cutoff, subject to existing resource limits and explicit exclusions. |
93
+ | `OFF` | Capture bodies and image references only, regardless of document count. |
94
+ | positive integer `N` | Include images under the existing policy for at most `N` documents; above `N`, use references only. |
95
+ | absent | Use `10`. |
96
+
97
+ For an invalid value, report it and use `10` rather than silently enabling all
98
+ images or blocking the task. An explicit current-conversation request to include
99
+ all images selects `ON` for this task; an explicit request to skip images selects
100
+ `OFF`. If neither is present, use the configured setting. Do not write a temporary
101
+ conversation override back into permanent workspace guidance.
102
+
103
+ Count distinct documents
104
+ selected for this task, including Wiki descendants and in-scope linked documents,
105
+ not all historical workspace sources, API pages, retries, or output articles.
106
+ Deduplicate shortcuts and repeated links. Splitting the task into batches or
107
+ resuming it does not reset the count. Exactly 10 documents is within the default.
108
+
109
+ Before starting capture, the Agent separately checks the document count (or known
110
+ lower bound), setting, and effective image policy. This is an Agent self-check,
111
+ not a user confirmation gate: do not ask a question or wait for a reply. Above the
112
+ numeric threshold, automatically capture bodies with image references only; at or
113
+ below it, retain the existing image policy. `ON` and `OFF` apply regardless of count.
114
+ A generic
115
+ "capture everything", source-read permission, managed mode, or an old bundle setting
116
+ does not. Briefly report the count and applied policy in the work-start update and
117
+ retain the decision in task notes; do not repeat the update for every document.
118
+
119
+ If the count is unknown, first perform only authorized directory/metadata discovery
120
+ without image downloads. If body reads are needed to discover linked documents,
121
+ use a body-and-reference-only discovery pass within existing read authorization.
122
+ With a numeric setting, unknown totals do not authorize image acquisition; `ON`
123
+ does not require counting to enable images, and `OFF` never enables them.
124
+ Recalculate the task total before enabling images under a numeric setting.
125
+ If later expansion crosses the numeric threshold, apply the
126
+ reference-only policy before further acquisition and report the change without
127
+ waiting for a reply; retain any explicit all-image override and existing evidence.
128
+
129
+ For `OFF` or above-threshold tasks without an `ON` override, apply
130
+ `resources: { images: "reference-only", gifs: "reference-only" }` to the selected
131
+ Lark capture declarations before executing the Route. Preserve unrelated sources,
132
+ resource settings and existing stricter exclusions; inspect generated/dynamic
133
+ configuration rather than assuming registration applied the policy. Host prefetch
134
+ and import paths must honor the same choice, not download images before import.
135
+ Other resource types retain their existing policies. Do not edit snapshots or
136
+ invent unsupported flags; when a capture adapter cannot exclude images, explain
137
+ that limitation and resolve the acquisition method before downloading.
138
+
139
+ Preserve source links/placeholders and report skipped images as not acquired or
140
+ interpreted. This is a workflow instruction using existing resource policies, not
141
+ a new CLI hard gate or automatic document counter. For tasks that still include
142
+ images, retain the existing handling workflow for more than 30 distinct images
143
+ and reuse an explicit choice; do not invoke it for images skipped by this
144
+ preflight. Never substitute temporary signed media URLs as permanent
145
+ public image links.
@@ -0,0 +1,45 @@
1
+ ---
2
+ id: procedure.document-code-investigation
3
+ kind: procedure
4
+ mediaType: text/markdown
5
+ ---
6
+
7
+ # Assess code needs during document investigation
8
+
9
+ Register the requested document sources before preparing their article plan.
10
+ Continue authorized document capture even when unrelated registered repositories
11
+ are unavailable. Existing workspace coverage does not select the current task's
12
+ code dependencies.
13
+
14
+ After reading outlines, representative bodies and related approved articles,
15
+ group the reader topics and assess whether code investigation is needed before
16
+ submitting the plan and work-start report. Large collections can be investigated
17
+ in batches while capture continues. If the expected production plan exceeds 30
18
+ article tasks, explicitly perform this assessment before bulk writing. This is
19
+ Agent guidance, not a CLI validation threshold. Wiki nodes, documents and article
20
+ tasks are different counts; more than 30 document nodes calls for early batched
21
+ investigation, not an assumption of 30 articles or automatic repository recovery.
22
+
23
+ Code evidence is useful when the reader task requires implementation behavior,
24
+ call chains, interface constraints or debugging entry points, or when incomplete
25
+ or conflicting documents require checking code. Explicit file, symbol or API
26
+ references strengthen that assessment. A repository link or service name alone
27
+ does not establish a dependency. Keep document-supported topics independent.
28
+
29
+ Use existing plan briefs or report prose to explain which reader questions need
30
+ which registered modules and why; no separate assessment receipt, score or
31
+ required schema field is needed. If code is needed, inspect its availability with
32
+ `context source recovery-plan <registered-name> --format json`. Follow
33
+ [repository source recovery](repository-source-recovery.md), reusing applicable
34
+ authorization and local checkouts. Prefer the smallest sufficient registered
35
+ module scope. Expand to a shared physical checkout or whole repository when
36
+ cross-module calls, common dependencies or uncertain boundaries require it;
37
+ do not substitute a different remote or pinned commit.
38
+
39
+ If recovery is unavailable, continue independent document tasks. Keep questions
40
+ requiring unread code pending, or narrow the article to supported document
41
+ claims and explain its limits. Do not present inferred implementation as verified
42
+ code, delete configured sources, or clear a stage to bypass unavailable evidence.
43
+ After recovery, follow its returned preparation command and current task handles;
44
+ retain accepted work instead of restarting the task. Reassess code needs when
45
+ later reading exposes a dependency that the initial sample did not show.
@@ -17,7 +17,9 @@ remote and pinned commit, so one physical checkout can restore every module in
17
17
  that group. Do not create one clone per module. Groups already marked `ready`
18
18
  need no decision; when every group is ready, the plan has no recovery action.
19
19
 
20
- For each missing physical checkout, ask the user to choose one option:
20
+ For each missing physical checkout, reuse an applicable choice and authorization
21
+ already supplied in the current task. If the recovery choice is unresolved, ask
22
+ the user to choose one option:
21
23
 
22
24
  1. provide an existing local Git checkout;
23
25
  2. name a bounded directory that the Agent may scan, then choose one of the
@@ -43,3 +45,8 @@ Repository sources are ready only when every selected module resolves to the
43
45
  registered remote and pinned commit, every registered subpath exists, no local
44
46
  path was overwritten, Context materialization succeeds, and the selected recovery
45
47
  plan reports them ready.
48
+
49
+ Recovery failure does not stop unrelated document capture or independent article
50
+ tasks. Preserve pending code-dependent questions and follow the returned recovery
51
+ diagnostic. After a successful restore, follow `next_action` to refresh affected
52
+ production material; keep accepted articles and use the newly returned handles.
@@ -71,6 +71,12 @@ settled scope, not a new confirmation step.
71
71
 
72
72
  ## Workflow
73
73
 
74
+ Before any capture or host prefetch, follow the task-wide image threshold and
75
+ Agent self-check in [Document capture](document-capture.md#image-acquisition-before-capture).
76
+ Do not ask the user to confirm this default or infer an all-image override from
77
+ source-read permission. Apply the effective resource policy before a managed batch;
78
+ registration defaults must not silently re-enable excluded images.
79
+
74
80
  Capture is entirely CLI-driven — your role is to register the right source,
75
81
  declare the matching capture phase, run the current `context run capture:*`
76
82
  command, and preserve its machine fields while summarizing the outcome in the
@@ -19,6 +19,10 @@ where needed to decide reader topics, source grouping and writing batches.
19
19
  Indexer guidance discovers a skeleton, not a mandatory deep parse or a ledger
20
20
  of every symbol. Declare relevant available skills and record planned uses;
21
21
  do not collect skill hashes, versions or article ownership credentials.
22
+ After reading representative documents and grouping reader topics, apply
23
+ [document and code investigation guidance](../../resources/procedures/document-code-investigation.md)
24
+ before submitting the article plan. Revisit it when new implementation questions
25
+ appear during writing. This assessment adds no approval gate or required field.
22
26
  Submit the plan before presenting the work-start report. Planning does not
23
27
  authorize writing or approve the report.
24
28