scoutline 0.1.0 → 0.6.0

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 (242) hide show
  1. package/README.md +394 -7
  2. package/bin/scoutline.js +36 -15
  3. package/dist/capabilities/diagnostics.d.ts +135 -0
  4. package/dist/capabilities/diagnostics.d.ts.map +1 -0
  5. package/dist/capabilities/diagnostics.js +139 -0
  6. package/dist/capabilities/diagnostics.js.map +1 -0
  7. package/dist/capabilities/quota.d.ts +99 -0
  8. package/dist/capabilities/quota.d.ts.map +1 -0
  9. package/dist/capabilities/quota.js +129 -0
  10. package/dist/capabilities/quota.js.map +1 -0
  11. package/dist/capabilities/reader.d.ts +227 -0
  12. package/dist/capabilities/reader.d.ts.map +1 -0
  13. package/dist/capabilities/reader.js +100 -0
  14. package/dist/capabilities/reader.js.map +1 -0
  15. package/dist/capabilities/repository.d.ts +221 -0
  16. package/dist/capabilities/repository.d.ts.map +1 -0
  17. package/dist/capabilities/repository.js +172 -0
  18. package/dist/capabilities/repository.js.map +1 -0
  19. package/dist/capabilities/search.d.ts +110 -0
  20. package/dist/capabilities/search.d.ts.map +1 -0
  21. package/dist/capabilities/search.js +21 -0
  22. package/dist/capabilities/search.js.map +1 -0
  23. package/dist/capabilities/vision.d.ts +156 -0
  24. package/dist/capabilities/vision.d.ts.map +1 -0
  25. package/dist/capabilities/vision.js +111 -0
  26. package/dist/capabilities/vision.js.map +1 -0
  27. package/dist/command-invocation.d.ts +58 -0
  28. package/dist/command-invocation.d.ts.map +1 -0
  29. package/dist/command-invocation.js +95 -0
  30. package/dist/command-invocation.js.map +1 -0
  31. package/dist/commands/cache.d.ts +106 -0
  32. package/dist/commands/cache.d.ts.map +1 -0
  33. package/dist/commands/cache.js +203 -0
  34. package/dist/commands/cache.js.map +1 -0
  35. package/dist/commands/code.d.ts +11 -4
  36. package/dist/commands/code.d.ts.map +1 -1
  37. package/dist/commands/code.js +16 -42
  38. package/dist/commands/code.js.map +1 -1
  39. package/dist/commands/doctor.d.ts +69 -3
  40. package/dist/commands/doctor.d.ts.map +1 -1
  41. package/dist/commands/doctor.js +179 -52
  42. package/dist/commands/doctor.js.map +1 -1
  43. package/dist/commands/quota.d.ts +45 -3
  44. package/dist/commands/quota.d.ts.map +1 -1
  45. package/dist/commands/quota.js +116 -60
  46. package/dist/commands/quota.js.map +1 -1
  47. package/dist/commands/read.d.ts +76 -2
  48. package/dist/commands/read.d.ts.map +1 -1
  49. package/dist/commands/read.js +260 -121
  50. package/dist/commands/read.js.map +1 -1
  51. package/dist/commands/repo.d.ts +55 -4
  52. package/dist/commands/repo.d.ts.map +1 -1
  53. package/dist/commands/repo.js +115 -172
  54. package/dist/commands/repo.js.map +1 -1
  55. package/dist/commands/repository-explorer.d.ts +147 -0
  56. package/dist/commands/repository-explorer.d.ts.map +1 -0
  57. package/dist/commands/repository-explorer.js +550 -0
  58. package/dist/commands/repository-explorer.js.map +1 -0
  59. package/dist/commands/search.d.ts +27 -2
  60. package/dist/commands/search.d.ts.map +1 -1
  61. package/dist/commands/search.js +95 -103
  62. package/dist/commands/search.js.map +1 -1
  63. package/dist/commands/tools.d.ts +9 -3
  64. package/dist/commands/tools.d.ts.map +1 -1
  65. package/dist/commands/tools.js +29 -59
  66. package/dist/commands/tools.js.map +1 -1
  67. package/dist/commands/vision.d.ts +35 -9
  68. package/dist/commands/vision.d.ts.map +1 -1
  69. package/dist/commands/vision.js +184 -131
  70. package/dist/commands/vision.js.map +1 -1
  71. package/dist/index.d.ts +62 -1
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +580 -223
  74. package/dist/index.js.map +1 -1
  75. package/dist/lib/cache.d.ts +178 -12
  76. package/dist/lib/cache.d.ts.map +1 -1
  77. package/dist/lib/cache.js +377 -39
  78. package/dist/lib/cache.js.map +1 -1
  79. package/dist/lib/code-mode.d.ts +13 -0
  80. package/dist/lib/code-mode.d.ts.map +1 -1
  81. package/dist/lib/code-mode.js +26 -6
  82. package/dist/lib/code-mode.js.map +1 -1
  83. package/dist/lib/config.d.ts.map +1 -1
  84. package/dist/lib/config.js +15 -18
  85. package/dist/lib/config.js.map +1 -1
  86. package/dist/lib/errors.d.ts +89 -11
  87. package/dist/lib/errors.d.ts.map +1 -1
  88. package/dist/lib/errors.js +168 -21
  89. package/dist/lib/errors.js.map +1 -1
  90. package/dist/lib/execution.d.ts +190 -0
  91. package/dist/lib/execution.d.ts.map +1 -0
  92. package/dist/lib/execution.js +383 -0
  93. package/dist/lib/execution.js.map +1 -0
  94. package/dist/lib/index.d.ts +10 -2
  95. package/dist/lib/index.d.ts.map +1 -1
  96. package/dist/lib/index.js +10 -2
  97. package/dist/lib/index.js.map +1 -1
  98. package/dist/lib/mcp-client.d.ts +75 -16
  99. package/dist/lib/mcp-client.d.ts.map +1 -1
  100. package/dist/lib/mcp-client.js +173 -108
  101. package/dist/lib/mcp-client.js.map +1 -1
  102. package/dist/lib/mcp-config.d.ts +17 -0
  103. package/dist/lib/mcp-config.d.ts.map +1 -1
  104. package/dist/lib/mcp-config.js +29 -0
  105. package/dist/lib/mcp-config.js.map +1 -1
  106. package/dist/lib/monitor-client.d.ts +17 -3
  107. package/dist/lib/monitor-client.d.ts.map +1 -1
  108. package/dist/lib/monitor-client.js +23 -69
  109. package/dist/lib/monitor-client.js.map +1 -1
  110. package/dist/lib/output.d.ts +53 -7
  111. package/dist/lib/output.d.ts.map +1 -1
  112. package/dist/lib/output.js +126 -39
  113. package/dist/lib/output.js.map +1 -1
  114. package/dist/lib/redact.d.ts +62 -3
  115. package/dist/lib/redact.d.ts.map +1 -1
  116. package/dist/lib/redact.js +165 -31
  117. package/dist/lib/redact.js.map +1 -1
  118. package/dist/lib/tool-cache.d.ts +86 -0
  119. package/dist/lib/tool-cache.d.ts.map +1 -0
  120. package/dist/lib/tool-cache.js +123 -0
  121. package/dist/lib/tool-cache.js.map +1 -0
  122. package/dist/lib/tty.d.ts +7 -20
  123. package/dist/lib/tty.d.ts.map +1 -1
  124. package/dist/lib/tty.js +51 -30
  125. package/dist/lib/tty.js.map +1 -1
  126. package/dist/node-command-invocation-adapter.d.ts +28 -0
  127. package/dist/node-command-invocation-adapter.d.ts.map +1 -0
  128. package/dist/node-command-invocation-adapter.js +88 -0
  129. package/dist/node-command-invocation-adapter.js.map +1 -0
  130. package/dist/providers/minimax/adapter.d.ts +49 -0
  131. package/dist/providers/minimax/adapter.d.ts.map +1 -0
  132. package/dist/providers/minimax/adapter.js +450 -0
  133. package/dist/providers/minimax/adapter.js.map +1 -0
  134. package/dist/providers/minimax/coding-plan-client.d.ts +60 -0
  135. package/dist/providers/minimax/coding-plan-client.d.ts.map +1 -0
  136. package/dist/providers/minimax/coding-plan-client.js +204 -0
  137. package/dist/providers/minimax/coding-plan-client.js.map +1 -0
  138. package/dist/providers/minimax/config.d.ts +32 -0
  139. package/dist/providers/minimax/config.d.ts.map +1 -0
  140. package/dist/providers/minimax/config.js +84 -0
  141. package/dist/providers/minimax/config.js.map +1 -0
  142. package/dist/providers/minimax/media.d.ts +88 -0
  143. package/dist/providers/minimax/media.d.ts.map +1 -0
  144. package/dist/providers/minimax/media.js +232 -0
  145. package/dist/providers/minimax/media.js.map +1 -0
  146. package/dist/providers/minimax/quota-client.d.ts +44 -0
  147. package/dist/providers/minimax/quota-client.d.ts.map +1 -0
  148. package/dist/providers/minimax/quota-client.js +83 -0
  149. package/dist/providers/minimax/quota-client.js.map +1 -0
  150. package/dist/providers/minimax/quota.d.ts +48 -0
  151. package/dist/providers/minimax/quota.d.ts.map +1 -0
  152. package/dist/providers/minimax/quota.js +120 -0
  153. package/dist/providers/minimax/quota.js.map +1 -0
  154. package/dist/providers/minimax/sdk-client.d.ts +29 -0
  155. package/dist/providers/minimax/sdk-client.d.ts.map +1 -0
  156. package/dist/providers/minimax/sdk-client.js +50 -0
  157. package/dist/providers/minimax/sdk-client.js.map +1 -0
  158. package/dist/providers/minimax/vision-attestations.d.ts +52 -0
  159. package/dist/providers/minimax/vision-attestations.d.ts.map +1 -0
  160. package/dist/providers/minimax/vision-attestations.js +79 -0
  161. package/dist/providers/minimax/vision-attestations.js.map +1 -0
  162. package/dist/providers/minimax/vision-conformance.d.ts +186 -0
  163. package/dist/providers/minimax/vision-conformance.d.ts.map +1 -0
  164. package/dist/providers/minimax/vision-conformance.js +371 -0
  165. package/dist/providers/minimax/vision-conformance.js.map +1 -0
  166. package/dist/providers/minimax/vision-mappings/chart.d.ts +35 -0
  167. package/dist/providers/minimax/vision-mappings/chart.d.ts.map +1 -0
  168. package/dist/providers/minimax/vision-mappings/chart.js +55 -0
  169. package/dist/providers/minimax/vision-mappings/chart.js.map +1 -0
  170. package/dist/providers/minimax/vision-mappings/common.d.ts +60 -0
  171. package/dist/providers/minimax/vision-mappings/common.d.ts.map +1 -0
  172. package/dist/providers/minimax/vision-mappings/common.js +75 -0
  173. package/dist/providers/minimax/vision-mappings/common.js.map +1 -0
  174. package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts +35 -0
  175. package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts.map +1 -0
  176. package/dist/providers/minimax/vision-mappings/diagnose-error.js +55 -0
  177. package/dist/providers/minimax/vision-mappings/diagnose-error.js.map +1 -0
  178. package/dist/providers/minimax/vision-mappings/diagram.d.ts +35 -0
  179. package/dist/providers/minimax/vision-mappings/diagram.d.ts.map +1 -0
  180. package/dist/providers/minimax/vision-mappings/diagram.js +55 -0
  181. package/dist/providers/minimax/vision-mappings/diagram.js.map +1 -0
  182. package/dist/providers/minimax/vision-mappings/extract-text.d.ts +35 -0
  183. package/dist/providers/minimax/vision-mappings/extract-text.d.ts.map +1 -0
  184. package/dist/providers/minimax/vision-mappings/extract-text.js +55 -0
  185. package/dist/providers/minimax/vision-mappings/extract-text.js.map +1 -0
  186. package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts +35 -0
  187. package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts.map +1 -0
  188. package/dist/providers/minimax/vision-mappings/ui-artifact.js +69 -0
  189. package/dist/providers/minimax/vision-mappings/ui-artifact.js.map +1 -0
  190. package/dist/providers/minimax/vision-mappings.generated.d.ts +29 -0
  191. package/dist/providers/minimax/vision-mappings.generated.d.ts.map +1 -0
  192. package/dist/providers/minimax/vision-mappings.generated.js +29 -0
  193. package/dist/providers/minimax/vision-mappings.generated.js.map +1 -0
  194. package/dist/providers/minimax/vision-revisions.d.ts +29 -0
  195. package/dist/providers/minimax/vision-revisions.d.ts.map +1 -0
  196. package/dist/providers/minimax/vision-revisions.js +34 -0
  197. package/dist/providers/minimax/vision-revisions.js.map +1 -0
  198. package/dist/providers/registry.d.ts +36 -0
  199. package/dist/providers/registry.d.ts.map +1 -0
  200. package/dist/providers/registry.js +45 -0
  201. package/dist/providers/registry.js.map +1 -0
  202. package/dist/providers/selection.d.ts +44 -0
  203. package/dist/providers/selection.d.ts.map +1 -0
  204. package/dist/providers/selection.js +85 -0
  205. package/dist/providers/selection.js.map +1 -0
  206. package/dist/providers/types.d.ts +281 -0
  207. package/dist/providers/types.d.ts.map +1 -0
  208. package/dist/providers/types.js +127 -0
  209. package/dist/providers/types.js.map +1 -0
  210. package/dist/providers/zai/adapter.d.ts +35 -0
  211. package/dist/providers/zai/adapter.d.ts.map +1 -0
  212. package/dist/providers/zai/adapter.js +685 -0
  213. package/dist/providers/zai/adapter.js.map +1 -0
  214. package/dist/providers/zai/credentials.d.ts +38 -0
  215. package/dist/providers/zai/credentials.d.ts.map +1 -0
  216. package/dist/providers/zai/credentials.js +60 -0
  217. package/dist/providers/zai/credentials.js.map +1 -0
  218. package/dist/providers/zai/encoded-error.d.ts +90 -0
  219. package/dist/providers/zai/encoded-error.d.ts.map +1 -0
  220. package/dist/providers/zai/encoded-error.js +169 -0
  221. package/dist/providers/zai/encoded-error.js.map +1 -0
  222. package/dist/providers/zai/media.d.ts +38 -0
  223. package/dist/providers/zai/media.d.ts.map +1 -0
  224. package/dist/providers/zai/media.js +107 -0
  225. package/dist/providers/zai/media.js.map +1 -0
  226. package/dist/providers/zai/monitor-client.d.ts +53 -0
  227. package/dist/providers/zai/monitor-client.d.ts.map +1 -0
  228. package/dist/providers/zai/monitor-client.js +117 -0
  229. package/dist/providers/zai/monitor-client.js.map +1 -0
  230. package/dist/providers/zai/quota.d.ts +47 -0
  231. package/dist/providers/zai/quota.d.ts.map +1 -0
  232. package/dist/providers/zai/quota.js +127 -0
  233. package/dist/providers/zai/quota.js.map +1 -0
  234. package/dist/providers/zai/reader.d.ts +82 -0
  235. package/dist/providers/zai/reader.d.ts.map +1 -0
  236. package/dist/providers/zai/reader.js +490 -0
  237. package/dist/providers/zai/reader.js.map +1 -0
  238. package/dist/providers/zai/repository.d.ts +76 -0
  239. package/dist/providers/zai/repository.d.ts.map +1 -0
  240. package/dist/providers/zai/repository.js +715 -0
  241. package/dist/providers/zai/repository.js.map +1 -0
  242. package/package.json +11 -6
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/commands/read.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAwDD,wBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,I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CA6CxB;AAaD,eAAO,MAAM,SAAS,QAwFd,CAAC"}
@@ -1,166 +1,305 @@
1
1
  /**
2
- * Web reader command using Z.AI WebReader MCP
2
+ * Web reader command — thin handler over the Reader Capability
3
+ * (DESIGN.md §18, reader-migration-core-flows, reader-migration-tech-plan
4
+ * Ticket 04).
5
+ *
6
+ * The handler applies parse-level validation only (URL scheme, --extract
7
+ * mode), delegates to `capability.fetch(request)` through shared
8
+ * execution, then projects the normalized `ReaderFetchResult` into the
9
+ * public v1 envelope(s) (content read vs extract read). The Adapter
10
+ * (providers/zai/reader.ts) owns URL rewrite, credentials, transport,
11
+ * raw response parsing, cache identity, and retry/terminal
12
+ * classification; the handler owns projection (`--max-chars` truncation,
13
+ * `--extract` slicing), output-mode presentation, and the
14
+ * schema-version-1 envelope migration.
15
+ *
16
+ * Provider selection, capability support, configuration, Adapter
17
+ * construction, and adapter.reader agreement live in `src/index.ts`.
18
+ *
19
+ * Handler interface (P6-07A pattern): `deps: ReadHandlerDependencies`
20
+ * is REQUIRED — production and direct tests cross the same compile-
21
+ * checked Interface. An optional trailing `CommandContext` follows when
22
+ * a caller wants to surface per-invocation context; the handler does
23
+ * not currently read it. A `CommandContext` is NOT a valid substitute
24
+ * for `deps`.
25
+ *
26
+ * Output-mode behavior (core-flows table):
27
+ *
28
+ * - data: the envelope object (content or extract).
29
+ * - json / pretty: standard `{success, data, timestamp}` envelope.
30
+ * - compact / markdown / refs / tty:
31
+ * * content read → the `content` string directly (presentations).
32
+ * * extract read → JSON fallback (the extract envelope object);
33
+ * no presentation override because extracted items are data,
34
+ * not prose.
35
+ *
36
+ * `--full-envelope` is silently accepted and ignored (D3): the v1
37
+ * envelope is always returned.
3
38
  */
4
- import { ZaiMcpClient } from "../lib/mcp-client.js";
5
- import { outputSuccess, getOutputMode } from "../lib/output.js";
6
- import { formatErrorOutput, ValidationError } from "../lib/errors.js";
7
- import { silenceConsole, restoreConsole } from "../lib/silence.js";
39
+ import { executeReaderOperation } from "../lib/execution.js";
40
+ import { OUTPUT_MODES } from "../lib/output.js";
41
+ import { ValidationError } from "../lib/errors.js";
8
42
  import { extract, isExtractMode } from "../lib/extract.js";
43
+ // ---------------------------------------------------------------------------
44
+ // Parse-level validation
45
+ // ---------------------------------------------------------------------------
9
46
  /**
10
- * Rewrite rendered GitHub gist/file URLs to their raw form so Z.AI's reader
11
- * returns pure file content instead of the rendered HTML page chrome
12
- * (Sign in / Star / Fork / Embed / etc.).
13
- *
14
- * gist.github.com/<user>/<id> -> gist.github.com/<user>/<id>/raw
15
- * gist.github.com/<user>/<id>#file-... -> gist.github.com/<user>/<id>/raw
16
- *
17
- * Leaves alone: URLs that already end in /raw, /raw/<rev>, or have a query string.
47
+ * Validate the URL at parse time. Only `http://` and `https://` schemes
48
+ * are accepted; everything else is a terminal `ValidationError` that
49
+ * fires BEFORE Provider resolution. Mirrors the v0.2 contract so direct
50
+ * handler tests keep their assertion shape.
18
51
  */
19
- function maybeRewriteToRaw(url) {
20
- // Already raw? Leave alone.
21
- if (/\/raw(\/|$|\?|#)/.test(url))
22
- return url;
23
- // Only rewrite gist.github.com (not github.com/owner/repo — that's different)
24
- const m = url.match(/^(https?:\/\/gist\.github\.com\/[^/]+\/[^/#?]+)(?:[/?#]|$)/);
25
- if (!m)
26
- return url;
27
- const base = m[1];
28
- // Append /raw, preserve any fragment (file anchor still meaningful)
29
- const frag = url.indexOf("#") >= 0 ? url.slice(url.indexOf("#")) : "";
30
- return `${base}/raw${frag}`;
52
+ function validateUrl(url) {
53
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
54
+ throw new ValidationError("URL must start with http:// or https://");
55
+ }
31
56
  }
32
57
  /**
33
- * Pull just the content string out of a Z.AI reader response. The full envelope
34
- * (title, url, metadata, external) is rarely useful for agents — it just bloats
35
- * output and makes truncation limits harder to reason about.
58
+ * Validate `--extract` mode at parse time. An invalid value is a
59
+ * terminal `ValidationError` that fires BEFORE Provider resolution.
36
60
  */
37
- function extractContent(response) {
38
- if (typeof response === "string")
39
- return { content: response, original: response };
40
- if (response && typeof response === "object") {
41
- const obj = response;
42
- if (typeof obj.content === "string") {
43
- return { content: obj.content, original: response };
44
- }
61
+ function validateExtractMode(mode) {
62
+ if (mode !== undefined && !isExtractMode(mode)) {
63
+ throw new ValidationError(`Invalid --extract mode: ${mode}. Use one of: code, links, tables, headings`);
45
64
  }
46
- // Fallback: stringify whatever we got
47
- return { content: JSON.stringify(response), original: response };
48
65
  }
66
+ // ---------------------------------------------------------------------------
67
+ // Projection helpers
68
+ // ---------------------------------------------------------------------------
49
69
  /**
50
- * Truncate to max chars. Returns the (possibly truncated) content plus the
51
- * original length so the caller can warn about truncation.
70
+ * Apply `--max-chars` truncation to content. Mirrors the v0.2 contract:
71
+ * slice to `max - 1`, trim trailing whitespace, and append `…`. Returns
72
+ * the original text and `truncated: false` when no truncation occurs.
52
73
  */
53
- function truncate(content, max) {
74
+ function truncateContent(content, max) {
54
75
  const originalLen = content.length;
55
76
  if (!max || max <= 0 || originalLen <= max) {
56
77
  return { text: content, originalLen, truncated: false };
57
78
  }
58
79
  return { text: content.slice(0, max - 1).trimEnd() + "…", originalLen, truncated: true };
59
80
  }
60
- export async function read(url, options = {}) {
61
- // Validate URL first (before silencing)
62
- if (!url.startsWith("http://") && !url.startsWith("https://")) {
63
- console.error(formatErrorOutput(new ValidationError("URL must start with http:// or https://")));
64
- process.exit(1);
65
- }
66
- if (options.extract && !isExtractMode(options.extract)) {
67
- console.error(formatErrorOutput(new ValidationError(`Invalid --extract mode: ${options.extract}. Use one of: code, links, tables, headings`)));
68
- process.exit(1);
69
- }
70
- const finalUrl = maybeRewriteToRaw(url);
71
- if (finalUrl !== url) {
72
- process.stderr.write(`ℹ️ rewrote gist URL to raw form: ${finalUrl}\n`);
73
- }
74
- silenceConsole();
75
- const client = new ZaiMcpClient({ enableVision: false, noCache: options.noCache });
76
- try {
77
- try {
78
- const response = await client.webRead({
79
- url: finalUrl,
80
- format: options.format || "markdown",
81
- retainImages: !options.noImages,
82
- withLinksSummary: options.withLinks,
83
- timeout: options.timeout,
84
- noCache: options.noCache,
85
- noGfm: options.noGfm,
86
- keepImgDataUrl: options.keepImgDataUrl,
87
- withImagesSummary: options.withImagesSummary,
88
- });
89
- const { content: rawContent } = extractContent(response);
90
- // --extract short-circuits: returns the extracted slice as a JSON array,
91
- // bypassing truncation and envelope logic.
92
- if (options.extract) {
93
- const extracted = extract(rawContent, options.extract);
94
- process.stderr.write(`ℹ️ extracted ${extracted.length} ${options.extract}\n`);
95
- outputSuccess(extracted);
96
- return;
97
- }
98
- const { text, originalLen, truncated } = truncate(rawContent, options.maxChars);
99
- if (truncated) {
100
- process.stderr.write(`⚠️ content truncated from ${originalLen.toLocaleString()} to ${text.length.toLocaleString()} chars; use a higher --max-chars or omit it for full content\n`);
101
- }
102
- // Default: content-only (drops title/metadata/external envelope).
103
- // --full-envelope or --output-format json/pretty keeps the structured object.
104
- const wantEnvelope = options.fullEnvelope || getOutputMode() === "json" || getOutputMode() === "pretty";
105
- if (wantEnvelope) {
106
- const envelope = response && typeof response === "object"
107
- ? { ...response, content: text }
108
- : { content: text };
109
- outputSuccess(envelope);
110
- }
111
- else {
112
- outputSuccess(text);
113
- }
114
- }
115
- finally {
116
- await client.close().catch(() => { });
117
- restoreConsole();
118
- }
81
+ /**
82
+ * Build the Provider-neutral ReaderFetchRequest from ReadOptions. Built
83
+ * as a single fresh object so the readonly invariants on
84
+ * `ReaderFetchRequest` are honored. `--max-chars`, `--extract`,
85
+ * `--full-envelope`, `--no-cache`, and output mode NEVER appear here —
86
+ * they are projections applied after the cached normalized result.
87
+ */
88
+ function buildReaderRequest(url, options) {
89
+ const request = { url };
90
+ if (options.format)
91
+ request.format = options.format;
92
+ if (options.noImages !== undefined)
93
+ request.retainImages = !options.noImages;
94
+ if (options.withLinks !== undefined)
95
+ request.withLinksSummary = options.withLinks;
96
+ if (options.noGfm !== undefined)
97
+ request.noGfm = options.noGfm;
98
+ if (options.keepImgDataUrl !== undefined)
99
+ request.keepImgDataUrl = options.keepImgDataUrl;
100
+ if (options.withImagesSummary !== undefined) {
101
+ request.withImagesSummary = options.withImagesSummary;
119
102
  }
120
- catch (error) {
121
- console.error(formatErrorOutput(error));
122
- process.exit(1);
103
+ if (options.timeout !== undefined)
104
+ request.timeout = options.timeout;
105
+ return request;
106
+ }
107
+ /**
108
+ * Build the v1 content-read envelope. `truncated` and
109
+ * `originalContentLength` are projection state recomputed on every read;
110
+ * the cache stores the full content.
111
+ */
112
+ function buildContentEnvelope(result, text, originalLen, truncated) {
113
+ // Preserve metadata/external verbatim when present on the cached
114
+ // result. Built as a fresh object so the readonly invariants on
115
+ // `ReaderFetchResult` are honored.
116
+ const envelope = {
117
+ schemaVersion: 1,
118
+ url: result.url,
119
+ finalUrl: result.finalUrl,
120
+ title: result.title,
121
+ content: text,
122
+ contentFormat: result.contentFormat,
123
+ truncated,
124
+ originalContentLength: originalLen,
125
+ };
126
+ if (result.metadata !== undefined)
127
+ envelope.metadata = result.metadata;
128
+ if (result.external !== undefined)
129
+ envelope.external = result.external;
130
+ return envelope;
131
+ }
132
+ /**
133
+ * Build the v1 extract-read envelope. `items` carry the extracted
134
+ * slice; `originalItemCount` and `truncated` report projection state.
135
+ * `--max-chars` is intentionally IGNORED for extract reads
136
+ * (truncating a code block or link list mid-item is harmful).
137
+ */
138
+ function buildExtractEnvelope(result, mode, items) {
139
+ return {
140
+ schemaVersion: 1,
141
+ url: result.url,
142
+ finalUrl: result.finalUrl,
143
+ mode,
144
+ items,
145
+ truncated: false,
146
+ originalItemCount: items.length,
147
+ };
148
+ }
149
+ // ---------------------------------------------------------------------------
150
+ // Handler
151
+ // ---------------------------------------------------------------------------
152
+ /**
153
+ * Read web page content through the injected Reader Capability.
154
+ *
155
+ * Ordering:
156
+ * 1. Parse-level validation (URL scheme, --extract mode). Throws
157
+ * `ValidationError` BEFORE the Adapter or shared execution is
158
+ * reached.
159
+ * 2. Build the Provider-neutral request and delegate to
160
+ * `executeProviderOperation` with shared cache + retry policy.
161
+ * 3. Project the normalized result:
162
+ * - `--extract` slicing into the extract envelope (sets `mode`,
163
+ * `items`, `originalItemCount`); `--max-chars` is IGNORED.
164
+ * - Otherwise, `--max-chars` truncation on `content` (sets
165
+ * `truncated`, `originalContentLength`).
166
+ * 4. Set presentations so text-oriented modes (compact/markdown/
167
+ * refs/tty) emit `content` directly for content reads. Extract
168
+ * reads omit presentations; text modes then fall back to JSON
169
+ * (the extract envelope), matching the core-flows table.
170
+ */
171
+ export async function read(url, options = {}, deps, _context) {
172
+ // 1. Parse-level validation BEFORE Provider/Adapter work.
173
+ validateUrl(url);
174
+ validateExtractMode(options.extract);
175
+ // 2. Build the Provider-neutral request. Only fields that affect
176
+ // the Provider request or the cache identity appear here;
177
+ // --max-chars, --extract, --full-envelope, --no-cache, and
178
+ // output mode never enter the request.
179
+ const request = buildReaderRequest(url, options);
180
+ const result = await executeReaderOperation(deps.capability.fetch, request, { noCache: options.noCache === true }, deps.execution);
181
+ // 3. Projection.
182
+ if (options.extract) {
183
+ const items = extract(result.content, options.extract);
184
+ const envelope = buildExtractEnvelope(result, options.extract, items);
185
+ // No presentation override for extract reads: text modes fall
186
+ // back to JSON (the envelope) because extracted items are data,
187
+ // not prose.
188
+ return { kind: "data", data: envelope };
123
189
  }
190
+ const { text, originalLen, truncated } = truncateContent(result.content, options.maxChars);
191
+ const envelope = buildContentEnvelope(result, text, originalLen, truncated);
192
+ // 4. Presentations: text-oriented modes emit `content` directly for
193
+ // content reads (D4 — Reader content is naturally prose). All
194
+ // four text modes share the same value because the page body is
195
+ // the same prose regardless of mode.
196
+ return {
197
+ kind: "data",
198
+ data: envelope,
199
+ presentations: {
200
+ compact: text,
201
+ markdown: text,
202
+ refs: text,
203
+ tty: text,
204
+ },
205
+ };
124
206
  }
125
- // Help text
207
+ // ---------------------------------------------------------------------------
208
+ // Help
209
+ // ---------------------------------------------------------------------------
210
+ /**
211
+ * Canonical output-mode list for `--output-format`. Derived from the
212
+ * shared `OUTPUT_MODES` contract so the help text cannot drift from
213
+ * the accepted set.
214
+ */
215
+ const OUTPUT_MODE_LIST = OUTPUT_MODES.join(" | ");
126
216
  export const READ_HELP = `
127
- Read Command - Fetch and parse web page content using Z.AI WebReader MCP
217
+ Read Command - Fetch and parse web pages (Provider Capability)
128
218
 
129
219
  Usage: scoutline read <url> [options]
130
220
 
131
221
  URL handling:
132
- gist.github.com/<user>/<id> URLs are auto-rewritten to /raw so you get pure
133
- file content instead of rendered HTML chrome (Sign in / Star / Fork / Embed).
222
+ gist.github.com/<user>/<id> URLs are auto-rewritten to /raw by the
223
+ Z.AI Adapter so you get pure file content instead of rendered HTML
224
+ chrome (Sign in / Star / Fork / Embed). The rewritten URL surfaces
225
+ as finalUrl in the v1 result.
226
+
227
+ Provider selection (precedence: --provider, then SCOUTLINE_PROVIDER,
228
+ then zai):
229
+ - The 'read' command participates in Provider selection.
230
+ - Z.AI advertises the reader Capability and supplies the Adapter;
231
+ selecting zai routes Read through it.
232
+ - MiniMax does NOT advertise reader. Selecting minimax (explicitly
233
+ or via SCOUTLINE_PROVIDER) returns UNSUPPORTED_CAPABILITY with
234
+ no fallback to Z.AI.
134
235
 
135
236
  Options:
136
237
  --format <f> Output format: markdown (default), text
137
238
  --no-images Remove images from output
138
- --no-cache Disable server-side caching
239
+ --no-cache Bypass the response cache for this invocation
139
240
  --with-links Include links summary
140
241
  --with-images-summary Include images summary
141
242
  --no-gfm Disable GitHub Flavored Markdown
142
243
  --keep-img-data-url Keep image data URLs in output
143
244
  --timeout <s> Request timeout in seconds (default: 20)
144
- --max-chars <n> Truncate content to <n> chars (warns on stderr when it kicks in)
145
- --full-envelope Include title/url/metadata/external fields (default: content-only)
146
- --extract <m> Pull a specific slice out as JSON array: code | links | tables | headings
245
+ --max-chars <n> Truncate content to <n> chars (content reads only)
246
+ --full-envelope Silently accepted and ignored. The envelope is always
247
+ returned at schema-version-1 (deprecation: D3).
248
+ --extract <m> Pull a specific slice out as a typed envelope with
249
+ mode/items/originalItemCount. Mode is one of:
250
+ code | links | tables | headings
251
+
252
+ Common Options:
253
+ --provider <id> Override the active Provider (zai | minimax)
254
+ --output-format <mode> One of: ${OUTPUT_MODE_LIST} (default: data)
255
+ -O <mode> Alias for --output-format
147
256
 
148
- By default the command outputs just the page content (string). Use --full-envelope
149
- or --output-format json/pretty to get the full structured response object. Use
150
- --extract to return only matching elements (e.g. all code blocks, all links).
257
+ Output format (schema-version-1 migration):
258
+ Content read (default):
259
+ {
260
+ "schemaVersion": 1,
261
+ "url": "<the URL you passed>",
262
+ "finalUrl": "<the URL the Adapter fetched>",
263
+ "title": "<page title or null>",
264
+ "content": "<page body as markdown/text>",
265
+ "contentFormat": "markdown" | "text",
266
+ "truncated": false,
267
+ "originalContentLength": <number>
268
+ }
269
+ Extract read (--extract <mode>):
270
+ {
271
+ "schemaVersion": 1,
272
+ "url": "<the URL you passed>",
273
+ "finalUrl": "<the URL the Adapter fetched>",
274
+ "mode": "code" | "links" | "tables" | "headings",
275
+ "items": [<typed items per mode>],
276
+ "truncated": false,
277
+ "originalItemCount": <number>
278
+ }
279
+ --max-chars applies ONLY to content reads (sets truncated:true and
280
+ originalContentLength). --max-chars is IGNORED for extract reads —
281
+ truncating a code block or link list mid-item is harmful.
282
+
283
+ Output modes for read results:
284
+ - data: raw schema-version-1 envelope object.
285
+ - json / pretty: standard {success, data, timestamp} envelope
286
+ (indent 0 for json, indent 2 for pretty).
287
+ - compact / markdown / refs / tty:
288
+ * content read → the content string is emitted directly (Reader
289
+ content is naturally prose).
290
+ * extract read → JSON fallback (the extract envelope object).
291
+ Extracted items are data, not prose, so the text-oriented modes
292
+ do not synthesize a presentation for them.
151
293
 
152
294
  Examples:
153
295
  scoutline read https://docs.example.com/api
154
296
  scoutline read https://github.com/owner/repo --format text
155
- scoutline read https://gist.github.com/user/abc123 # auto-rewritten to /raw
297
+ scoutline read https://gist.github.com/user/abc123 # finalUrl shows /raw
156
298
  scoutline read https://blog.example.com/post --no-images --with-links
157
299
  scoutline read https://example.com/long-article --max-chars 2000
158
- scoutline read https://react.dev/learn/hooks --extract code # just code blocks
159
- scoutline read https://example.com/page --extract links # just URLs
300
+ scoutline read https://react.dev/learn/hooks --extract code # code blocks
301
+ scoutline read https://example.com/page --extract links # links
160
302
  scoutline read https://en.wikipedia.org/wiki/X --extract headings # section outline
161
-
162
- Output format:
163
- Content string by default; structured object with --full-envelope or -O json;
164
- JSON array of extracted elements with --extract.
303
+ scoutline --provider minimax read https://example.com/ # UNSUPPORTED_CAPABILITY
165
304
  `.trim();
166
305
  //# sourceMappingURL=read.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/commands/read.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AAgB7E;;;;;;;;;GASG;AACH,SAAS,iBAAiB,CAAC,GAAW;IACpC,4BAA4B;IAC5B,IAAI,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAC7C,8EAA8E;IAC9E,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAClF,IAAI,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IACnB,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClB,oEAAoE;IACpE,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC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E,QAAQ;QACd,aAAa,EAAE;YACb,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,IAAI;YACV,GAAG,EAAE,IAAI;SACV;KACF,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,OAAO;AACP,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCAsCc,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDtD,CAAC,IAAI,EAAE,CAAC"}
@@ -1,6 +1,30 @@
1
1
  /**
2
- * Repo commands for GitHub repository exploration (ZRead)
2
+ * Repo commands — thin handlers over the Repository Explorer (P6-07,
3
+ * DESIGN.md §18, §11, PRD FR-080–FR-088).
4
+ *
5
+ * Each handler applies parse-level defaults/validation, builds the
6
+ * Explorer request, and returns the normalized Explorer result as
7
+ * base data. The handlers own NO Provider client, raw MCP name,
8
+ * ZRead parser, traversal transport, cache policy, retry, or close.
9
+ *
10
+ * Provider selection, capability support, configuration, Adapter
11
+ * construction, and adapter.repository agreement live in
12
+ * `src/index.ts`. The Explorer receives a `RepositoryCapability`
13
+ * plus shared `ExecutionDependencies` and owns path canonicalization,
14
+ * BFS, maxChars projection, and result projection.
15
+ *
16
+ * Handler interface (P6-07A): mirrors the shared Search command
17
+ * pattern. `deps: RepoHandlerDependencies` is REQUIRED — production
18
+ * and direct tests cross the same compile-checked Interface. An
19
+ * optional trailing `CommandContext` follows when a caller wants to
20
+ * surface per-invocation context; the handlers do not currently read
21
+ * it. A `CommandContext` is NOT a valid substitute for `deps`: a
22
+ * direct caller who omits `deps` fails loudly with a TypeError
23
+ * before reaching the Explorer rather than silently degrading.
3
24
  */
25
+ import type { CommandContext, CommandResult } from "../command-invocation.js";
26
+ import type { RepositoryCapability } from "../capabilities/repository.js";
27
+ import type { ExecutionDependencies } from "../lib/execution.js";
4
28
  export interface RepoSearchOptions {
5
29
  language?: "en" | "zh";
6
30
  maxChars?: number;
@@ -15,8 +39,35 @@ export interface RepoReadOptions {
15
39
  maxChars?: number;
16
40
  noCache?: boolean;
17
41
  }
18
- export declare function repoSearch(repo: string, query: string, options?: RepoSearchOptions): Promise<void>;
19
- export declare function repoTree(repo: string, options?: RepoTreeOptions): Promise<void>;
20
- export declare function repoRead(repo: string, path: string, options?: RepoReadOptions): Promise<void>;
42
+ /**
43
+ * Dependencies injected by `src/index.ts` after Provider selection,
44
+ * capability support check, configuration check, Adapter
45
+ * construction, and adapter.repository agreement. The handlers
46
+ * never resolve a Provider descriptor themselves. Required — a
47
+ * caller that omits `deps` is malformed and fails loudly.
48
+ */
49
+ export interface RepoHandlerDependencies {
50
+ readonly capability: RepositoryCapability;
51
+ readonly execution: ExecutionDependencies;
52
+ }
53
+ /**
54
+ * Repository Search. Validates parse-level request shape, delegates
55
+ * to the Explorer with the injected Repository Capability, and
56
+ * returns the normalized Search result as base data.
57
+ */
58
+ export declare function repoSearch(repo: string, query: string, options: RepoSearchOptions, deps: RepoHandlerDependencies, _context?: CommandContext): Promise<CommandResult>;
59
+ /**
60
+ * Repository Tree. Validates parse-level request shape (including
61
+ * depth), delegates to the Explorer's BFS traversal, and returns
62
+ * the normalized Tree result as base data. Tree is never
63
+ * character-limited; `maxChars` is intentionally not accepted.
64
+ */
65
+ export declare function repoTree(repo: string, options: RepoTreeOptions, deps: RepoHandlerDependencies, _context?: CommandContext): Promise<CommandResult>;
66
+ /**
67
+ * Repository File read. Validates parse-level request shape,
68
+ * delegates to the Explorer with the injected Repository Capability,
69
+ * and returns the normalized File result as base data.
70
+ */
71
+ export declare function repoRead(repo: string, path: string, options: RepoReadOptions, deps: RepoHandlerDependencies, _context?: CommandContext): Promise<CommandResult>;
21
72
  export declare const REPO_HELP: string;
22
73
  //# sourceMappingURL=repo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/commands/repo.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgBH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAiFD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA0Bf;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCzF;AAED,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAsBf;AAGD,eAAO,MAAM,SAAS,QA2Cd,CAAC"}
1
+ {"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/commands/repo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AA2BjE,MA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