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.
- package/README.md +394 -7
- package/bin/scoutline.js +36 -15
- package/dist/capabilities/diagnostics.d.ts +135 -0
- package/dist/capabilities/diagnostics.d.ts.map +1 -0
- package/dist/capabilities/diagnostics.js +139 -0
- package/dist/capabilities/diagnostics.js.map +1 -0
- package/dist/capabilities/quota.d.ts +99 -0
- package/dist/capabilities/quota.d.ts.map +1 -0
- package/dist/capabilities/quota.js +129 -0
- package/dist/capabilities/quota.js.map +1 -0
- package/dist/capabilities/reader.d.ts +227 -0
- package/dist/capabilities/reader.d.ts.map +1 -0
- package/dist/capabilities/reader.js +100 -0
- package/dist/capabilities/reader.js.map +1 -0
- package/dist/capabilities/repository.d.ts +221 -0
- package/dist/capabilities/repository.d.ts.map +1 -0
- package/dist/capabilities/repository.js +172 -0
- package/dist/capabilities/repository.js.map +1 -0
- package/dist/capabilities/search.d.ts +110 -0
- package/dist/capabilities/search.d.ts.map +1 -0
- package/dist/capabilities/search.js +21 -0
- package/dist/capabilities/search.js.map +1 -0
- package/dist/capabilities/vision.d.ts +156 -0
- package/dist/capabilities/vision.d.ts.map +1 -0
- package/dist/capabilities/vision.js +111 -0
- package/dist/capabilities/vision.js.map +1 -0
- package/dist/command-invocation.d.ts +58 -0
- package/dist/command-invocation.d.ts.map +1 -0
- package/dist/command-invocation.js +95 -0
- package/dist/command-invocation.js.map +1 -0
- package/dist/commands/cache.d.ts +106 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +203 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/code.d.ts +11 -4
- package/dist/commands/code.d.ts.map +1 -1
- package/dist/commands/code.js +16 -42
- package/dist/commands/code.js.map +1 -1
- package/dist/commands/doctor.d.ts +69 -3
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +179 -52
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/quota.d.ts +45 -3
- package/dist/commands/quota.d.ts.map +1 -1
- package/dist/commands/quota.js +116 -60
- package/dist/commands/quota.js.map +1 -1
- package/dist/commands/read.d.ts +76 -2
- package/dist/commands/read.d.ts.map +1 -1
- package/dist/commands/read.js +260 -121
- package/dist/commands/read.js.map +1 -1
- package/dist/commands/repo.d.ts +55 -4
- package/dist/commands/repo.d.ts.map +1 -1
- package/dist/commands/repo.js +115 -172
- package/dist/commands/repo.js.map +1 -1
- package/dist/commands/repository-explorer.d.ts +147 -0
- package/dist/commands/repository-explorer.d.ts.map +1 -0
- package/dist/commands/repository-explorer.js +550 -0
- package/dist/commands/repository-explorer.js.map +1 -0
- package/dist/commands/search.d.ts +27 -2
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +95 -103
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/tools.d.ts +9 -3
- package/dist/commands/tools.d.ts.map +1 -1
- package/dist/commands/tools.js +29 -59
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/vision.d.ts +35 -9
- package/dist/commands/vision.d.ts.map +1 -1
- package/dist/commands/vision.js +184 -131
- package/dist/commands/vision.js.map +1 -1
- package/dist/index.d.ts +62 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +580 -223
- package/dist/index.js.map +1 -1
- package/dist/lib/cache.d.ts +178 -12
- package/dist/lib/cache.d.ts.map +1 -1
- package/dist/lib/cache.js +377 -39
- package/dist/lib/cache.js.map +1 -1
- package/dist/lib/code-mode.d.ts +13 -0
- package/dist/lib/code-mode.d.ts.map +1 -1
- package/dist/lib/code-mode.js +26 -6
- package/dist/lib/code-mode.js.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +15 -18
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/errors.d.ts +89 -11
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +168 -21
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/execution.d.ts +190 -0
- package/dist/lib/execution.d.ts.map +1 -0
- package/dist/lib/execution.js +383 -0
- package/dist/lib/execution.js.map +1 -0
- package/dist/lib/index.d.ts +10 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +10 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/mcp-client.d.ts +75 -16
- package/dist/lib/mcp-client.d.ts.map +1 -1
- package/dist/lib/mcp-client.js +173 -108
- package/dist/lib/mcp-client.js.map +1 -1
- package/dist/lib/mcp-config.d.ts +17 -0
- package/dist/lib/mcp-config.d.ts.map +1 -1
- package/dist/lib/mcp-config.js +29 -0
- package/dist/lib/mcp-config.js.map +1 -1
- package/dist/lib/monitor-client.d.ts +17 -3
- package/dist/lib/monitor-client.d.ts.map +1 -1
- package/dist/lib/monitor-client.js +23 -69
- package/dist/lib/monitor-client.js.map +1 -1
- package/dist/lib/output.d.ts +53 -7
- package/dist/lib/output.d.ts.map +1 -1
- package/dist/lib/output.js +126 -39
- package/dist/lib/output.js.map +1 -1
- package/dist/lib/redact.d.ts +62 -3
- package/dist/lib/redact.d.ts.map +1 -1
- package/dist/lib/redact.js +165 -31
- package/dist/lib/redact.js.map +1 -1
- package/dist/lib/tool-cache.d.ts +86 -0
- package/dist/lib/tool-cache.d.ts.map +1 -0
- package/dist/lib/tool-cache.js +123 -0
- package/dist/lib/tool-cache.js.map +1 -0
- package/dist/lib/tty.d.ts +7 -20
- package/dist/lib/tty.d.ts.map +1 -1
- package/dist/lib/tty.js +51 -30
- package/dist/lib/tty.js.map +1 -1
- package/dist/node-command-invocation-adapter.d.ts +28 -0
- package/dist/node-command-invocation-adapter.d.ts.map +1 -0
- package/dist/node-command-invocation-adapter.js +88 -0
- package/dist/node-command-invocation-adapter.js.map +1 -0
- package/dist/providers/minimax/adapter.d.ts +49 -0
- package/dist/providers/minimax/adapter.d.ts.map +1 -0
- package/dist/providers/minimax/adapter.js +450 -0
- package/dist/providers/minimax/adapter.js.map +1 -0
- package/dist/providers/minimax/coding-plan-client.d.ts +60 -0
- package/dist/providers/minimax/coding-plan-client.d.ts.map +1 -0
- package/dist/providers/minimax/coding-plan-client.js +204 -0
- package/dist/providers/minimax/coding-plan-client.js.map +1 -0
- package/dist/providers/minimax/config.d.ts +32 -0
- package/dist/providers/minimax/config.d.ts.map +1 -0
- package/dist/providers/minimax/config.js +84 -0
- package/dist/providers/minimax/config.js.map +1 -0
- package/dist/providers/minimax/media.d.ts +88 -0
- package/dist/providers/minimax/media.d.ts.map +1 -0
- package/dist/providers/minimax/media.js +232 -0
- package/dist/providers/minimax/media.js.map +1 -0
- package/dist/providers/minimax/quota-client.d.ts +44 -0
- package/dist/providers/minimax/quota-client.d.ts.map +1 -0
- package/dist/providers/minimax/quota-client.js +83 -0
- package/dist/providers/minimax/quota-client.js.map +1 -0
- package/dist/providers/minimax/quota.d.ts +48 -0
- package/dist/providers/minimax/quota.d.ts.map +1 -0
- package/dist/providers/minimax/quota.js +120 -0
- package/dist/providers/minimax/quota.js.map +1 -0
- package/dist/providers/minimax/sdk-client.d.ts +29 -0
- package/dist/providers/minimax/sdk-client.d.ts.map +1 -0
- package/dist/providers/minimax/sdk-client.js +50 -0
- package/dist/providers/minimax/sdk-client.js.map +1 -0
- package/dist/providers/minimax/vision-attestations.d.ts +52 -0
- package/dist/providers/minimax/vision-attestations.d.ts.map +1 -0
- package/dist/providers/minimax/vision-attestations.js +79 -0
- package/dist/providers/minimax/vision-attestations.js.map +1 -0
- package/dist/providers/minimax/vision-conformance.d.ts +186 -0
- package/dist/providers/minimax/vision-conformance.d.ts.map +1 -0
- package/dist/providers/minimax/vision-conformance.js +371 -0
- package/dist/providers/minimax/vision-conformance.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/chart.d.ts +35 -0
- package/dist/providers/minimax/vision-mappings/chart.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/chart.js +55 -0
- package/dist/providers/minimax/vision-mappings/chart.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/common.d.ts +60 -0
- package/dist/providers/minimax/vision-mappings/common.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/common.js +75 -0
- package/dist/providers/minimax/vision-mappings/common.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts +35 -0
- package/dist/providers/minimax/vision-mappings/diagnose-error.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/diagnose-error.js +55 -0
- package/dist/providers/minimax/vision-mappings/diagnose-error.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/diagram.d.ts +35 -0
- package/dist/providers/minimax/vision-mappings/diagram.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/diagram.js +55 -0
- package/dist/providers/minimax/vision-mappings/diagram.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/extract-text.d.ts +35 -0
- package/dist/providers/minimax/vision-mappings/extract-text.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/extract-text.js +55 -0
- package/dist/providers/minimax/vision-mappings/extract-text.js.map +1 -0
- package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts +35 -0
- package/dist/providers/minimax/vision-mappings/ui-artifact.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings/ui-artifact.js +69 -0
- package/dist/providers/minimax/vision-mappings/ui-artifact.js.map +1 -0
- package/dist/providers/minimax/vision-mappings.generated.d.ts +29 -0
- package/dist/providers/minimax/vision-mappings.generated.d.ts.map +1 -0
- package/dist/providers/minimax/vision-mappings.generated.js +29 -0
- package/dist/providers/minimax/vision-mappings.generated.js.map +1 -0
- package/dist/providers/minimax/vision-revisions.d.ts +29 -0
- package/dist/providers/minimax/vision-revisions.d.ts.map +1 -0
- package/dist/providers/minimax/vision-revisions.js +34 -0
- package/dist/providers/minimax/vision-revisions.js.map +1 -0
- package/dist/providers/registry.d.ts +36 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +45 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/selection.d.ts +44 -0
- package/dist/providers/selection.d.ts.map +1 -0
- package/dist/providers/selection.js +85 -0
- package/dist/providers/selection.js.map +1 -0
- package/dist/providers/types.d.ts +281 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +127 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/providers/zai/adapter.d.ts +35 -0
- package/dist/providers/zai/adapter.d.ts.map +1 -0
- package/dist/providers/zai/adapter.js +685 -0
- package/dist/providers/zai/adapter.js.map +1 -0
- package/dist/providers/zai/credentials.d.ts +38 -0
- package/dist/providers/zai/credentials.d.ts.map +1 -0
- package/dist/providers/zai/credentials.js +60 -0
- package/dist/providers/zai/credentials.js.map +1 -0
- package/dist/providers/zai/encoded-error.d.ts +90 -0
- package/dist/providers/zai/encoded-error.d.ts.map +1 -0
- package/dist/providers/zai/encoded-error.js +169 -0
- package/dist/providers/zai/encoded-error.js.map +1 -0
- package/dist/providers/zai/media.d.ts +38 -0
- package/dist/providers/zai/media.d.ts.map +1 -0
- package/dist/providers/zai/media.js +107 -0
- package/dist/providers/zai/media.js.map +1 -0
- package/dist/providers/zai/monitor-client.d.ts +53 -0
- package/dist/providers/zai/monitor-client.d.ts.map +1 -0
- package/dist/providers/zai/monitor-client.js +117 -0
- package/dist/providers/zai/monitor-client.js.map +1 -0
- package/dist/providers/zai/quota.d.ts +47 -0
- package/dist/providers/zai/quota.d.ts.map +1 -0
- package/dist/providers/zai/quota.js +127 -0
- package/dist/providers/zai/quota.js.map +1 -0
- package/dist/providers/zai/reader.d.ts +82 -0
- package/dist/providers/zai/reader.d.ts.map +1 -0
- package/dist/providers/zai/reader.js +490 -0
- package/dist/providers/zai/reader.js.map +1 -0
- package/dist/providers/zai/repository.d.ts +76 -0
- package/dist/providers/zai/repository.d.ts.map +1 -0
- package/dist/providers/zai/repository.js +715 -0
- package/dist/providers/zai/repository.js.map +1 -0
- package/package.json +11 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/commands/read.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/commands/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EACV,gBAAgB,EAGjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAIjE,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAM7E,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;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,qBAAqB,CAAC;CAC3C;AAkID;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,IAAI,CACxB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,YAAK,EACzB,IAAI,EAAE,uBAAuB,EAC7B,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,aAAa,CAAC,CA6CxB;AAaD,eAAO,MAAM,SAAS,QAwFd,CAAC"}
|
package/dist/commands/read.js
CHANGED
|
@@ -1,166 +1,305 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Web reader command
|
|
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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
*
|
|
34
|
-
*
|
|
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
|
|
38
|
-
if (
|
|
39
|
-
|
|
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
|
-
*
|
|
51
|
-
*
|
|
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
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
//
|
|
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
|
|
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
|
|
133
|
-
file content instead of rendered HTML
|
|
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
|
|
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 (
|
|
145
|
-
--full-envelope
|
|
146
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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 #
|
|
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 #
|
|
159
|
-
scoutline read https://example.com/page --extract links #
|
|
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
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/commands/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AASH,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AAsC7E,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E;;;;;GAKG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,eAAe,CAAC,yCAAyC,CAAC,CAAC;IACvE,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,IAA6B;IACxD,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,eAAe,CACvB,2BAA2B,IAAI,6CAA6C,CAC7E,CAAC;IACJ,CAAC;AACH,CAAC;AAED,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;;GAIG;AACH,SAAS,eAAe,CACtB,OAAe,EACf,GAAY;IAMZ,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IACnC,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,IAAI,WAAW,IAAI,GAAG,EAAE,CAAC;QAC3C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAA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;;;;;;;;;;;;CAkDtD,CAAC,IAAI,EAAE,CAAC"}
|
package/dist/commands/repo.d.ts
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Repo commands
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
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,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;AAED;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,qBAAqB,CAAC;CAC3C;AAMD;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,uBAAuB,EAC7B,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,aAAa,CAAC,CAaxB;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,EACxB,IA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