@corvio/cli 0.1.0-beta.33 → 0.1.0-beta.35

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 (3) hide show
  1. package/README.md +3 -1
  2. package/dist/cli.js +119 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -15,6 +15,8 @@ corvio files get <asset_id> --content --json
15
15
  corvio files organize <asset_id> --instruction 'Create a reusable decision brief' --yes --json
16
16
  corvio files operation <operation_id> --json
17
17
  corvio files resume <operation_id> --yes --json
18
+ corvio docs read <workspace_id/document_id> --mode auto --json
19
+ corvio docs patch <workspace_id/document_id> --input ./patch.json --operation-id <id> --yes --json
18
20
  corvio docs table-read <workspace_id/document_id> --limit 25 --json
19
21
  corvio docs table-mutate <workspace_id/document_id> --input ./table-change.json --change-summary 'Updated owner and due date' --yes --json
20
22
  corvio sync init --dir ./knowledge --root-node-id <node_id> --json
@@ -34,7 +36,7 @@ fresh host session. Until a reviewed WorkBuddy marketplace listing is live, a Wo
34
36
  auto-update from Corvio. Remote MCP changes are server-delivered and normally need only a refreshed host session unless new OAuth scopes
35
37
  require reauthorization.
36
38
 
37
- The CLI rejects unknown/duplicate options and malformed integer bounds before network access. Normal API calls have a bounded timeout (`CORVIO_REQUEST_TIMEOUT_MS`, maximum ten minutes); only reads, explicit idempotency contracts, revision guards, and other owner-declared safe operations retry automatically. Document commands accept both bare document IDs and canonical `workspace_id/document_id` handles; a canonical handle that disagrees with the selected Workspace fails before remote access, and successful reads return `canonical_id` for direct reuse. Document updates preflight the current revision when `--expected-revision` is omitted. `docs table-read` returns a bounded stable-ID projection; `docs table-mutate` accepts a JSON payload for at most 50 cell updates or row appends and requires the fetched revision, while formulas, styles, structure, sorting, and semantic transformations remain `corvio ask --allow-actions` work. When the executing principal is a connected Agent, document and table mutations also require `--change-summary`, create a visible document-level comment after the guarded update, and return its receipt; a comment failure is reported as a partial effect rather than silent success. When a Corvio document or comment supplied the task, use `corvio agent closeout` to return the verified outcome, optionally resolve the thread, and read both document and thread back. Downloads, uploads, and Markdown pulls verify SHA-256 receipts before replacing local files; local writes are atomic, remote default filenames cannot escape the current directory, and Sync refuses symbolic-link traversal while checkpointing each successful push.
39
+ The CLI rejects unknown/duplicate options and malformed integer bounds before network access. Normal API calls have a bounded timeout (`CORVIO_REQUEST_TIMEOUT_MS`, maximum ten minutes); only reads, explicit idempotency contracts, revision guards, and other owner-declared safe operations retry automatically. Document commands accept both bare document IDs and canonical `workspace_id/document_id` handles; a canonical handle that disagrees with the selected Workspace fails before remote access, and successful reads return `canonical_id` for direct reuse. `docs read --mode auto` returns a complete small Page or a large-Page overview, then supports exact section, line-range, literal-search, and full projections. `docs patch` applies 1–20 exact non-overlapping L# replacements at the fetched revision and returns a compact readback instead of replaying untouched content. `docs get --output` keeps compatibility full-body download but omits the body from stdout; create/update request compact mutation receipts. Document updates preflight only a bounded overview for the current revision when `--expected-revision` is omitted. `docs table-read` returns a bounded stable-ID projection; `docs table-mutate` accepts a JSON payload for at most 50 cell updates or row appends and requires the fetched revision, while formulas, styles, structure, sorting, and semantic transformations remain `corvio ask --allow-actions` work. When the executing principal is a connected Agent, document and table mutations also require `--change-summary`, create a visible document-level comment after the guarded update, and return its receipt; a comment failure is reported as a partial effect rather than silent success. When a Corvio document or comment supplied the task, use `corvio agent closeout` to return the verified outcome, optionally resolve the thread, and read both document and thread back. Downloads, uploads, and Markdown pulls verify SHA-256 receipts before replacing local files; local writes are atomic, remote default filenames cannot escape the current directory, and Sync refuses symbolic-link traversal while checkpointing each successful push.
38
40
 
39
41
  For `corvio ask`, pass the user's natural goal, complete decision-relevant context, and explicit constraints. Unless the user chose them,
40
42
  do not invent taxonomy, titles, artifact counts, or Corvio's internal plan. Read the terminal Question receipt and use `artifact.url` or
package/dist/cli.js CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  agentCredentialPath,
40
40
  } from "./core.js";
41
41
 
42
- const VERSION = "0.1.0-beta.33";
42
+ const VERSION = "0.1.0-beta.35";
43
43
  const DEFAULT_API_BASE = "https://api.corvio.ai/v1";
44
44
  const DEFAULT_APP_BASE = "https://corvio.ai";
45
45
  const USER_AGENT = `corvio-cli/${VERSION}`;
@@ -104,6 +104,11 @@ const COMMAND_OPTIONS = Object.freeze({
104
104
  "search:": ["query", "limit", "page-id", "node-id"],
105
105
  "docs:list": ["limit", "cursor", "lifecycle"],
106
106
  "docs:get": ["id", "output"],
107
+ "docs:read": [
108
+ "id", "mode", "start-line", "end-line", "section-ref", "heading", "query",
109
+ "max-chars", "max-sections", "context-lines", "max-matches", "case-sensitive",
110
+ ],
111
+ "docs:patch": ["id", "input", "operation-id", "change-summary", "yes"],
107
112
  "docs:table-read": ["id", "table-id", "after-row-id", "limit"],
108
113
  "docs:table-mutate": ["id", "input", "operation-id", "change-summary", "yes"],
109
114
  "docs:create": ["title", "file", "markdown", "parent-node-id", "idempotency-key"],
@@ -152,7 +157,7 @@ Usage:
152
157
  corvio questions list|get [id]
153
158
  corvio conversations list|get [id]
154
159
  corvio search <query>
155
- corvio docs list|get|table-read|table-mutate|create|update|move|archive|restore|share|open [id]
160
+ corvio docs list|get|read|patch|table-read|table-mutate|create|update|move|archive|restore|share|open [id]
156
161
  corvio projects list|create
157
162
  corvio files list|get|download|upload|organize|operation|resume|cancel|open [id]
158
163
  corvio sync init|status|plan|pull|push|resolve
@@ -181,9 +186,9 @@ const COMMAND_HELP = Object.freeze({
181
186
  questions: `Usage:\n corvio questions list [--limit <n>] [--cursor <cursor>] [--conversation-id <id>]\n corvio questions get <question-id>`,
182
187
  conversations: `Usage:\n corvio conversations list [--limit <n>] [--cursor <cursor>]\n corvio conversations get <conversation-id>`,
183
188
  search: `Usage: corvio search <query> [--limit <n>] [--page-id <id>] [--node-id <id>]`,
184
- docs: `Usage:\n corvio docs list [--limit <n>] [--cursor <cursor>] [--lifecycle active|archived]\n corvio docs get <id> [--output <path>]\n corvio docs table-read <id> [--table-id <id>] [--after-row-id <id>] [--limit <1-100>]\n corvio docs table-mutate <id> --input <json> --yes [--operation-id <id>] [--change-summary <text>]\n corvio docs create --title <title> [--file <path>|--markdown <text>] [--parent-node-id <id>] [--idempotency-key <key>]\n corvio docs update <id> [--title <title>] [--file <path>|--markdown <text>] [--expected-revision <n>] [--change-summary <text>]\n corvio docs move <id> --parent-node-id <id>\n corvio docs archive <id> --yes\n corvio docs restore <id> --yes\n corvio docs share <id> --yes [--display-name <name>]\n corvio docs open <id>\n\nA selected Markdown file is uploaded once as a provenance-preserving Asset, then its source_asset_id becomes an editable Page without resending the body; inspect the returned document ID, node ID, revision, and URL. Other formats or semantic restructuring belong to \`corvio files organize\` or \`corvio ask --allow-actions\`. \`docs update\` replaces a non-Project Page body: use it only when whole-body replacement is the smallest faithful change. A Project is a structure container, so direct body replacement returns \`project_structure_container_body_write_disabled\`; use \`files organize\` or \`ask --allow-actions\` for Work Model maintenance, or update a child Page. A title-only Project rename remains valid. Delegate large localized semantic edits, reorder, splice, or formatting to \`corvio ask --allow-actions\` with the canonical document handle. Use table-read plus table-mutate for bounded stable-ID cell updates or row appends without round-tripping a whole document. \`docs move\` accepts a non-Project document and a Project destination; Projects stay at the Workspace root and cannot be nested. Use \`corvio files organize\` or \`corvio ask --allow-actions\` when deeper structure needs semantic branch Pages and leaves. Agent-authenticated document changes require --change-summary and create a visible document-level comment after the guarded update. When a document/comment is the task owner, use \`corvio agent closeout\` to return verified work to that same collaboration surface and read it back.`,
189
+ docs: `Usage:\n corvio docs list [--limit <n>] [--cursor <cursor>] [--lifecycle active|archived]\n corvio docs get <id> [--output <path>]\n corvio docs read <id> [--mode auto|overview|line-range|section|search|full] [--start-line <n> --end-line <n>|--section-ref <S#>|--query <text>] [--max-chars <n>]\n corvio docs patch <id> --input <json> --yes [--operation-id <id>] [--change-summary <text>]\n corvio docs table-read <id> [--table-id <id>] [--after-row-id <id>] [--limit <1-100>]\n corvio docs table-mutate <id> --input <json> --yes [--operation-id <id>] [--change-summary <text>]\n corvio docs create --title <title> [--file <path>|--markdown <text>] [--parent-node-id <id>] [--idempotency-key <key>]\n corvio docs update <id> [--title <title>] [--file <path>|--markdown <text>] [--expected-revision <n>] [--change-summary <text>]\n corvio docs move <id> --parent-node-id <id>\n corvio docs archive <id> --yes\n corvio docs restore <id> --yes\n corvio docs share <id> --yes [--display-name <name>]\n corvio docs open <id>\n\nUse \`docs read --mode auto\` first for a small full body or a large-document overview, then read an exact section or line range. Use \`docs patch\` when the host already knows 1-20 exact L# replacements; it preserves untouched lines and returns a compact verified delta. A selected Markdown file can become an editable Page without resending the body through the model. Use \`docs update\` only when whole-body replacement is the smallest faithful change. Delegate document-wide judgment, cross-source synthesis, structure/formatting interpretation, and typed Spreadsheet, Presentation, Code, or HTML work to \`corvio ask --allow-actions\`. A Project is a structure container; body writes fail with project_structure_container_body_write_disabled, while a title-only Project rename remains valid. Projects stay at the Workspace root and cannot be nested; use \`files organize\` or \`ask --allow-actions\` for Work Model maintenance. Use table-read plus table-mutate for bounded stable-ID cell updates or row appends. Agent-authenticated document changes require --change-summary and create a visible document-level comment after the guarded update. When a document/comment is the task owner, use \`corvio agent closeout\` to return verified work to that same collaboration surface and read it back.`,
185
190
  projects: `Usage:\n corvio projects list [--limit <n>]\n corvio projects create --title <title> [--idempotency-key <key>]\n\nProjects are durable root-level grouping owners in the Corvio Docs tree and cannot be nested under another Project. Reuse a matching Project instead of creating one ceremonial Project per file; use semantic branch Pages and leaves for deeper Work Models. 'corvio folders' is an alias.`,
186
- files: `Usage:\n corvio files list [--limit <n>]\n corvio files get <id> [--content]\n corvio files download <id> [--output <path>]\n corvio files upload --file <path> [--mime-type <type>] [--organize --instruction <text> --additional-asset-ids <id,id> --yes]\n corvio files organize <id> --instruction <text> --yes [--additional-asset-ids <id,id>] [--target-root-node-id <project-node-id>] [--processing-profile auto|economy|standard|deep] [--scan-mode auto|always|off] [--skills-extraction-mode auto|always|off]\n corvio files operation <operation-id>\n corvio files resume <operation-id> --yes\n corvio files cancel <operation-id> --yes\n corvio files open <id>\n\nUse --content only when source facts are needed. It returns one bounded AI-safe projection with hash, completeness, and truncation receipts; it does not rewrite or materialize the original. Upload alone preserves the exact original, provenance, hash, policy, and stable Asset ID. Organization is a separate asynchronous value step: one coherent source set can produce reader-facing structure, source reconciliation, Memory candidates, and qualifying Project Skills. Pass --instruction a weak natural goal plus explicit user constraints and only authority facts needed to prevent wrong identity or scope. Keep source-derived facts in the source; do not precompute an outline, edit checklist, taxonomy, titles, artifact count, or sole leaf target from current visibility. For a newly finalized Asset that should enter a Work Model or Skill evaluation, use one organize operation as the sole semantic owner; do not open ask before or after it for the same Asset set. --target-root-node-id is optional and accepts only a Project node_id returned by projects list, never a Page/document UUID or leaf node; omit it when the Project is not known. Use 'files operation' to reach terminal and inspect output_document plus skills_evaluation; always requires evaluation but may correctly return evaluated_no_qualifying_skill. Resume reuses the same durable operation after resolving its blocker; cancel is idempotent.`,
191
+ files: `Usage:\n corvio files list [--limit <n>]\n corvio files get <id> [--content]\n corvio files download <id> [--output <path>]\n corvio files upload --file <path> [--mime-type <type>] [--organize --instruction <text> --additional-asset-ids <id,id> --yes]\n corvio files organize <id> --instruction <text> --yes [--additional-asset-ids <id,id>] [--target-root-node-id <project-node-id>] [--processing-profile auto|economy|standard|deep] [--scan-mode auto|always|off] [--skills-extraction-mode auto|always|off]\n corvio files operation <operation-id>\n corvio files resume <operation-id> --yes\n corvio files cancel <operation-id> --yes\n corvio files open <id>\n\nUse --content only when source facts are needed. It returns one bounded AI-safe projection with hash, completeness, and truncation receipts; it does not rewrite or materialize the original. Upload alone preserves the exact original, provenance, hash, policy, and stable Asset ID. Organization is a separate asynchronous value step: one coherent source set can produce reader-facing structure, source reconciliation, Memory candidates, and qualifying Project Skills. Pass --instruction a weak natural goal plus explicit user constraints and only authority facts needed to prevent wrong identity or scope. Keep source-derived facts in the source; do not precompute an outline, edit checklist, taxonomy, titles, artifact count, or sole leaf target from current visibility. A heterogeneous source may update several real Projects while its provenance carrier stays a standalone document; do not direct Corvio to make the source Page an umbrella Project. For a newly finalized Asset that should enter a Work Model or Skill evaluation, use one organize operation as the sole semantic owner; do not open ask before or after it for the same Asset set. --target-root-node-id is optional and accepts only a Project node_id returned by projects list, never a Page/document UUID or leaf node; omit it when the Project is not known. Use 'files operation' to reach terminal and inspect output_document plus skills_evaluation; always requires evaluation but may correctly return evaluated_no_qualifying_skill. Resume reuses the same durable operation after resolving its blocker; cancel is idempotent.`,
187
192
  sync: `Usage:\n corvio sync init --root-node-id <id> [--dir <path>] [--name <name>]\n corvio sync status|plan|pull [--dir <path>]\n corvio sync push --yes [--dir <path>]\n corvio sync resolve --conflict-id <id> --strategy use-remote|keep-local --yes [--dir <path>]`,
188
193
  update: `Usage: corvio update check [--json]\n\nCompare this executable with the reviewed API policy and the npm beta dist-tag.`,
189
194
  });
@@ -238,6 +243,8 @@ function validateInvocation(options, positionals) {
238
243
  "questions:get",
239
244
  "conversations:get",
240
245
  "docs:get",
246
+ "docs:read",
247
+ "docs:patch",
241
248
  "docs:table-read",
242
249
  "docs:table-mutate",
243
250
  "docs:update",
@@ -2977,8 +2984,108 @@ async function docs(options, action, id) {
2977
2984
  };
2978
2985
  }
2979
2986
  if (options.output) {
2980
- await writeTextFile(options.output, String(result.markdown || ""));
2981
- result = { ...result, output: options.output };
2987
+ const markdown = String(result.markdown || "");
2988
+ await writeTextFile(options.output, markdown);
2989
+ const { markdown: _omittedMarkdown, ...metadata } = result;
2990
+ result = {
2991
+ ...metadata,
2992
+ output: options.output,
2993
+ body_returned: false,
2994
+ written_chars: markdown.length,
2995
+ content_sha256: createHash("sha256").update(markdown).digest("hex"),
2996
+ };
2997
+ }
2998
+ } else if (action === "read") {
2999
+ const targetId = resolveDocumentId(documentId, selection);
3000
+ const mode = String(options.mode || "auto").trim().toLowerCase().replaceAll("-", "_");
3001
+ if (!new Set(["auto", "overview", "line_range", "section", "search", "full"]).has(mode)) {
3002
+ throw new CliError("--mode must be auto, overview, line-range, section, search, or full.", {
3003
+ code: "document_read_mode_invalid",
3004
+ });
3005
+ }
3006
+ result = await api.request(`/documents/${resourcePath(targetId)}/content`, {
3007
+ query: {
3008
+ mode,
3009
+ start_line: options["start-line"] === undefined
3010
+ ? undefined
3011
+ : numberOption(options, "start-line", undefined, { minimum: 1, maximum: 2_000_000 }),
3012
+ end_line: options["end-line"] === undefined
3013
+ ? undefined
3014
+ : numberOption(options, "end-line", undefined, { minimum: 1, maximum: 2_000_000 }),
3015
+ section_ref: options["section-ref"] || undefined,
3016
+ heading: options.heading || undefined,
3017
+ query: options.query || undefined,
3018
+ max_chars: numberOption(options, "max-chars", 6000, { minimum: 200, maximum: 60000 }),
3019
+ max_sections: numberOption(options, "max-sections", 240, { minimum: 1, maximum: 400 }),
3020
+ context_lines: numberOption(options, "context-lines", 2, { minimum: 0, maximum: 12 }),
3021
+ max_matches: numberOption(options, "max-matches", 12, { minimum: 1, maximum: 30 }),
3022
+ case_sensitive: Boolean(options["case-sensitive"]),
3023
+ },
3024
+ });
3025
+ if (executionIdentity === "agent") {
3026
+ result = {
3027
+ ...result,
3028
+ collaboration_follow_up: "If this document or one of its comments owns the task, return verified results to the originating collaboration surface after the work. A read-only citation needs no ceremonial comment.",
3029
+ };
3030
+ }
3031
+ } else if (action === "patch") {
3032
+ requireConfirmation(options, "Patching document line ranges");
3033
+ const targetId = resolveDocumentId(documentId, selection);
3034
+ const payload = await readJsonObject(option(options, "input", { required: true }), "--input");
3035
+ const changeSummary = String(options["change-summary"] || "").trim();
3036
+ if (executionIdentity === "agent" && !changeSummary) {
3037
+ throw new CliError(
3038
+ "Agent document patches require --change-summary so collaborators can see what changed and why.",
3039
+ { code: "agent_document_change_summary_required" },
3040
+ );
3041
+ }
3042
+ const operationId = String(options["operation-id"] || payload.operation_id || randomUUID());
3043
+ result = await api.request(`/documents/${resourcePath(targetId)}/content`, {
3044
+ method: "PATCH",
3045
+ retrySafe: true,
3046
+ body: { ...payload, operation_id: operationId },
3047
+ });
3048
+ if (executionIdentity === "agent" && result?.status !== "no_op") {
3049
+ const commentIdempotencyKey = `document-patch:${createHash("sha256")
3050
+ .update(JSON.stringify({ document_id: targetId, operation_id: operationId, body: changeSummary }))
3051
+ .digest("hex")}`;
3052
+ try {
3053
+ const comment = await api.request(`/documents/${resourcePath(targetId)}/comments`, {
3054
+ method: "POST",
3055
+ headers: { "idempotency-key": commentIdempotencyKey },
3056
+ body: {
3057
+ body: changeSummary,
3058
+ mention_targets: [],
3059
+ selection: { target_scope: "document" },
3060
+ entry_point: "external_agent_cli_document_line_patch",
3061
+ start_new_chain: true,
3062
+ },
3063
+ });
3064
+ const entry = Array.isArray(comment?.entries) ? comment.entries.at(-1) : null;
3065
+ result = {
3066
+ ...result,
3067
+ change_comment: {
3068
+ thread_id: comment?.id || null,
3069
+ entry_id: entry?.id || null,
3070
+ body: changeSummary,
3071
+ },
3072
+ };
3073
+ } catch (error) {
3074
+ throw new CliError(
3075
+ "The line patch succeeded, but its required change comment could not be created. Add the comment before reporting completion.",
3076
+ {
3077
+ code: "document_patched_comment_failed",
3078
+ exitCode: error instanceof CliError ? error.exitCode : EXIT.REMOTE,
3079
+ status: error instanceof CliError ? error.status : null,
3080
+ details: {
3081
+ document_id: targetId,
3082
+ operation_id: operationId,
3083
+ mutation: result,
3084
+ recovery_command: `corvio agent comment --document-id ${targetId} --body <change-summary> --start-new-chain --idempotency-key ${commentIdempotencyKey}`,
3085
+ },
3086
+ },
3087
+ );
3088
+ }
2982
3089
  }
2983
3090
  } else if (action === "table-read") {
2984
3091
  const targetId = resolveDocumentId(documentId, selection);
@@ -3053,6 +3160,7 @@ async function docs(options, action, id) {
3053
3160
  const markdown = options.file ? await readTextFile(options.file) : String(options.markdown || "");
3054
3161
  result = await api.request("/documents", {
3055
3162
  method: "POST",
3163
+ query: { response_mode: "compact" },
3056
3164
  headers: { "idempotency-key": idempotencyKey(options) },
3057
3165
  body: {
3058
3166
  title: option(options, "title", { required: true }),
@@ -3081,7 +3189,9 @@ async function docs(options, action, id) {
3081
3189
  if (options["expected-revision"] !== undefined) {
3082
3190
  expectedRevision = numberOption(options, "expected-revision", undefined, { minimum: 0 });
3083
3191
  } else {
3084
- const current = await api.request(`/documents/${resourcePath(targetId)}`);
3192
+ const current = await api.request(`/documents/${resourcePath(targetId)}/content`, {
3193
+ query: { mode: "overview", max_chars: 1000, max_sections: 1 },
3194
+ });
3085
3195
  if (!Number.isSafeInteger(current?.content_revision) || current.content_revision < 0) {
3086
3196
  throw new CliError("Corvio did not return a valid document content revision.", {
3087
3197
  code: "document_revision_missing",
@@ -3092,6 +3202,7 @@ async function docs(options, action, id) {
3092
3202
  }
3093
3203
  result = await api.request(`/documents/${resourcePath(targetId)}`, {
3094
3204
  method: "PUT",
3205
+ query: { response_mode: "compact" },
3095
3206
  body: {
3096
3207
  ...(options.title !== undefined ? { title: options.title } : {}),
3097
3208
  ...(markdown !== undefined ? { markdown } : {}),
@@ -3176,7 +3287,7 @@ async function docs(options, action, id) {
3176
3287
  const opened = options["no-input"] ? false : await openBrowser(target);
3177
3288
  result = { document_id: targetId, url: target, opened };
3178
3289
  } else {
3179
- throw new CliError("docs action must be list, get, table-read, table-mutate, create, update, move, archive, restore, share, or open.");
3290
+ throw new CliError("docs action must be list, get, read, patch, table-read, table-mutate, create, update, move, archive, restore, share, or open.");
3180
3291
  }
3181
3292
  if (!new Set(["list", "create"]).has(action)) {
3182
3293
  result = withCanonicalDocumentId(result, selection, resolveDocumentId(documentId, selection));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corvio/cli",
3
- "version": "0.1.0-beta.33",
3
+ "version": "0.1.0-beta.35",
4
4
  "description": "Official Corvio Workspace CLI for questions, knowledge search, documents, and Agent workflows.",
5
5
  "type": "module",
6
6
  "bin": {