@c4a/context-cli 0.7.29 → 0.7.34

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.
@@ -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
@@ -18,7 +18,8 @@ resource checks; it does not fetch that supplied body again. See
18
18
 
19
19
  | Resource | Default capture behavior |
20
20
  |---|---|
21
- | Image and attachment | Download the original file and link it from the Markdown projection. |
21
+ | Image | Download the original; on explicit download permission denial, try a same-identity preview once and mark it as a preview. |
22
+ | Attachment | Download the original file and link it from the Markdown projection. |
22
23
  | Sheet | Read the complete selected sheet, render a Markdown table, and retain a CSV snapshot. |
23
24
  | Base | Read the selected table/view with pagination, render a Markdown table, and retain a canonical JSON snapshot. |
24
25
  | Whiteboard and diagram | Retain a readable preview plus the raw structured export. |
@@ -34,21 +35,22 @@ preserves an unavailable-resource notice with the reason code
34
35
  `document.resource.source-missing`, reports a warning, and continues capture;
35
36
  it does not pretend that the deleted content was materialized. When the current
36
37
  identity can read the document body but the API explicitly returns
37
- `authorization/permission_denied` for an embedded resource, Context records
38
+ an explicit permission denial (including HTTP 403) for an embedded resource, Context records
38
39
  `document.resource.permission-denied`, keeps the stable resource identity in
39
40
  the audit layer, renders the same unavailable-resource notice, and continues
40
- with a warning. Missing scopes, transient network errors, malformed payloads,
41
- and unclassified authorization failures still block capture. Reference-only
41
+ with a warning. Explicit missing-scope and access-denied resource responses are
42
+ likewise recorded without changing identity. Transient network errors, malformed
43
+ payloads, and unclassified failures still block capture. Reference-only
42
44
  resources remain explicit in the capture report. Unknown non-empty XML blocks
43
45
  stay auditable in the raw XML and receive a warning; the CLI does not infer
44
46
  their meaning.
45
47
 
46
- Document and resource reads share one access identity. Context first uses the
47
- user identity; it falls back to the bot identity only when user credentials
48
- are unavailable, never when the source denies permission or reports missing
49
- scopes. This prevents a capture from mixing document text read by one identity
50
- with attachments read by another. A bot fallback is reported in the capture
51
- result and remains subject to the bot's own access boundary.
48
+ Document and resource reads share one access identity. The configured default is
49
+ user. Bot mode permits one whole-document user fallback for a body authorization
50
+ failure, restarting all pages. After the body is read, resources remain under
51
+ that identity. A resource failure never requests another identity's credentials.
52
+ Legacy explicit auto mode may select Bot when user credentials are unavailable;
53
+ all resources still use the identity that supplied the complete body.
52
54
 
53
55
  ## Storage lifecycle
54
56
 
@@ -133,8 +135,24 @@ assess the page with its non-text evidence.
133
135
 
134
136
  ## Image choices for a production task
135
137
 
138
+ Before capture, the Agent follows the document-capture Route procedure's task-wide
139
+ document threshold and image self-check, without asking for user confirmation.
140
+ Set `DOCUMENT_IMAGE_CAPTURE` in task instructions or workspace guidance to `ON`
141
+ (include images), `OFF` (references only), or a positive integer document threshold.
142
+ Omitting it uses `10`; exactly the threshold remains within normal acquisition.
143
+ Current-conversation instructions override workspace guidance for that task only.
144
+ For example, `DOCUMENT_IMAGE_CAPTURE: 20` skips image downloads when the task
145
+ contains more than 20 distinct documents. This is an Agent instruction, not an
146
+ environment variable, CLI flag or SDK field; no Bot configuration is required.
147
+ Above a numeric threshold, the default is body capture with image references,
148
+ unless the effective setting is overridden to `ON`. This workflow
149
+ choice uses the existing resource fields; it does not change SDK defaults or add
150
+ a CLI hard gate. Apply it before bulk capture or host prefetch, not after images
151
+ have already been downloaded.
152
+
136
153
  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
154
+ that will be acquired and has no explicit image handling policy. Reuse the
155
+ current-conversation image instruction when it already settles this choice. The choices are intelligent conversion and
138
156
  inclusion (recommended), include all as images with compression, or include none
139
157
  with placeholders. Count the whole task, not each capture or writing batch.
140
158
  Review reports show the resulting image handling and any fallbacks.
@@ -168,3 +186,13 @@ limits. The reading meaning of an image is handled in writing and Review.
168
186
  Source document links can be retained for viewing under the reader's permissions.
169
187
  Temporary signed media links are not durable image hosting. Do not embed access
170
188
  tokens in generated pages or claim that excluded images have been interpreted.
189
+
190
+ ### Capture identity and unavailable media
191
+
192
+ The selected document identity remains fixed for resource reads. In Bot mode,
193
+ only an authorization failure while reading the body can restart the article
194
+ as the current user. Resource failures never trigger that identity fallback.
195
+ Images may use the official same-identity preview endpoint after download
196
+ permission is denied. Previews are marked explicitly; unavailable resources
197
+ retain references and diagnostics. Use available body evidence without inferring
198
+ missing resource contents, and review evidence gaps before approving conclusions.
@@ -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,33 @@ 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 may fall back once to the current user only when
57
+ reading the document body fails with a credential, scope or access denial.
58
+ The fallback restarts the entire body, including pagination; never combine body
59
+ pages from different identities. Once the body is available, its identity is
60
+ fixed for all media, synced references, Sheets, Base and whiteboard reads.
61
+ Resource failures do not request user authorization or restart the article.
62
+ Network, rate-limit and format errors do not switch identity.
63
+
64
+ An image download denied by permissions may use the official preview endpoint
65
+ once with the same identity. A captured preview is explicitly marked as such.
66
+ Unavailable resources retain their location and failure reason; continue with
67
+ other resources and usable body text. Never infer missing image contents or
68
+ present a partial snapshot as a complete original. Assess any evidence gaps
69
+ before approving conclusions that depend on those resources.
70
+
71
+ This setting does not grant source access or change the intended audience of
72
+ the resulting knowledge. Do not use another person's credentials. For direct
73
+ host reads, explicitly pass the article's selected identity on every read.
74
+ Only an article-level fallback may request the current user's authorization;
75
+ use the managed runtime's authorization flow once when needed.
76
+ Local help and embedded skill discovery require no document authorization;
77
+ do not request user OAuth just to read a CLI guide.
78
+
79
+ If `docs +fetch` lacks the required `--doc-format`
57
80
  capability, follow the returned `lark-cli update` recovery and rerun the same
58
81
  Route command; do not replace the capture with a hand-written export.
59
82
 
@@ -63,9 +86,67 @@ are available while another capture remains pending. Keep unresolved sources in
63
86
  pending capture after the active production/review work, before delivery completes.
64
87
  This does not mark failed captures as complete or waive source-read authorization.
65
88
 
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.
89
+ ## Image acquisition before capture
90
+
91
+ The workflow instruction setting `DOCUMENT_IMAGE_CAPTURE` accepts `ON`, `OFF`,
92
+ or a positive integer document threshold; when absent it defaults to **10**.
93
+ Read it from the current task instructions or workspace guidance; a current
94
+ conversation instruction takes precedence. This is an Agent-interpreted setting,
95
+ not a CLI flag, environment variable, or SDK field. Hosts need not add a setting.
96
+
97
+ | Setting | Acquisition policy |
98
+ | --- | --- |
99
+ | `ON` | Include images without a document-count cutoff, subject to existing resource limits and explicit exclusions. |
100
+ | `OFF` | Capture bodies and image references only, regardless of document count. |
101
+ | positive integer `N` | Include images under the existing policy for at most `N` documents; above `N`, use references only. |
102
+ | absent | Use `10`. |
103
+
104
+ For an invalid value, report it and use `10` rather than silently enabling all
105
+ images or blocking the task. An explicit current-conversation request to include
106
+ all images selects `ON` for this task; an explicit request to skip images selects
107
+ `OFF`. If neither is present, use the configured setting. Do not write a temporary
108
+ conversation override back into permanent workspace guidance.
109
+
110
+ Count distinct documents
111
+ selected for this task, including Wiki descendants and in-scope linked documents,
112
+ not all historical workspace sources, API pages, retries, or output articles.
113
+ Deduplicate shortcuts and repeated links. Splitting the task into batches or
114
+ resuming it does not reset the count. Exactly 10 documents is within the default.
115
+
116
+ Before starting capture, the Agent separately checks the document count (or known
117
+ lower bound), setting, and effective image policy. This is an Agent self-check,
118
+ not a user confirmation gate: do not ask a question or wait for a reply. Above the
119
+ numeric threshold, automatically capture bodies with image references only; at or
120
+ below it, retain the existing image policy. `ON` and `OFF` apply regardless of count.
121
+ A generic
122
+ "capture everything", source-read permission, managed mode, or an old bundle setting
123
+ does not. Briefly report the count and applied policy in the work-start update and
124
+ retain the decision in task notes; do not repeat the update for every document.
125
+
126
+ If the count is unknown, first perform only authorized directory/metadata discovery
127
+ without image downloads. If body reads are needed to discover linked documents,
128
+ use a body-and-reference-only discovery pass within existing read authorization.
129
+ With a numeric setting, unknown totals do not authorize image acquisition; `ON`
130
+ does not require counting to enable images, and `OFF` never enables them.
131
+ Recalculate the task total before enabling images under a numeric setting.
132
+ If later expansion crosses the numeric threshold, apply the
133
+ reference-only policy before further acquisition and report the change without
134
+ waiting for a reply; retain any explicit all-image override and existing evidence.
135
+
136
+ For `OFF` or above-threshold tasks without an `ON` override, apply
137
+ `resources: { images: "reference-only", gifs: "reference-only" }` to the selected
138
+ Lark capture declarations before executing the Route. Preserve unrelated sources,
139
+ resource settings and existing stricter exclusions; inspect generated/dynamic
140
+ configuration rather than assuming registration applied the policy. Host prefetch
141
+ and import paths must honor the same choice, not download images before import.
142
+ Other resource types retain their existing policies. Do not edit snapshots or
143
+ invent unsupported flags; when a capture adapter cannot exclude images, explain
144
+ that limitation and resolve the acquisition method before downloading.
145
+
146
+ Preserve source links/placeholders and report skipped images as not acquired or
147
+ interpreted. This is a workflow instruction using existing resource policies, not
148
+ a new CLI hard gate or automatic document counter. For tasks that still include
149
+ images, retain the existing handling workflow for more than 30 distinct images
150
+ and reuse an explicit choice; do not invoke it for images skipped by this
151
+ preflight. Never substitute temporary signed media URLs as permanent
152
+ public image links.
@@ -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