monday-cli 0.3.0 → 0.5.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/CHANGELOG.md +719 -0
- package/README.md +208 -36
- package/dist/api/assets.d.ts +326 -0
- package/dist/api/assets.d.ts.map +1 -0
- package/dist/api/assets.js +519 -0
- package/dist/api/assets.js.map +1 -0
- package/dist/api/column-types.d.ts +13 -7
- package/dist/api/column-types.d.ts.map +1 -1
- package/dist/api/column-types.js +7 -3
- package/dist/api/column-types.js.map +1 -1
- package/dist/api/column-values.d.ts +8 -1
- package/dist/api/column-values.d.ts.map +1 -1
- package/dist/api/column-values.js +16 -6
- package/dist/api/column-values.js.map +1 -1
- package/dist/api/documents.d.ts +1652 -0
- package/dist/api/documents.d.ts.map +1 -0
- package/dist/api/documents.js +2411 -0
- package/dist/api/documents.js.map +1 -0
- package/dist/api/item-watch.d.ts +263 -0
- package/dist/api/item-watch.d.ts.map +1 -0
- package/dist/api/item-watch.js +709 -0
- package/dist/api/item-watch.js.map +1 -0
- package/dist/api/multipart-transport.d.ts +223 -0
- package/dist/api/multipart-transport.d.ts.map +1 -0
- package/dist/api/multipart-transport.js +274 -0
- package/dist/api/multipart-transport.js.map +1 -0
- package/dist/api/parallel-dispatch.d.ts +155 -0
- package/dist/api/parallel-dispatch.d.ts.map +1 -0
- package/dist/api/parallel-dispatch.js +243 -0
- package/dist/api/parallel-dispatch.js.map +1 -0
- package/dist/api/partial-success-bulk.d.ts +118 -60
- package/dist/api/partial-success-bulk.d.ts.map +1 -1
- package/dist/api/partial-success-bulk.js +137 -79
- package/dist/api/partial-success-bulk.js.map +1 -1
- package/dist/api/partial-success-mutation.d.ts +13 -1
- package/dist/api/partial-success-mutation.d.ts.map +1 -1
- package/dist/api/partial-success-mutation.js +5 -1
- package/dist/api/partial-success-mutation.js.map +1 -1
- package/dist/api/raw-write.d.ts +13 -4
- package/dist/api/raw-write.d.ts.map +1 -1
- package/dist/api/raw-write.js +22 -11
- package/dist/api/raw-write.js.map +1 -1
- package/dist/api/resolve-client.d.ts +11 -0
- package/dist/api/resolve-client.d.ts.map +1 -1
- package/dist/api/resolve-client.js +9 -1
- package/dist/api/resolve-client.js.map +1 -1
- package/dist/api/teams.d.ts +657 -0
- package/dist/api/teams.d.ts.map +1 -0
- package/dist/api/teams.js +880 -0
- package/dist/api/teams.js.map +1 -0
- package/dist/cli/run.d.ts +20 -0
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +1 -0
- package/dist/cli/run.js.map +1 -1
- package/dist/commands/board/column-create.d.ts +6 -5
- package/dist/commands/board/column-create.d.ts.map +1 -1
- package/dist/commands/board/column-create.js +9 -6
- package/dist/commands/board/column-create.js.map +1 -1
- package/dist/commands/completion.d.ts +188 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +418 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/doc/append-markdown.d.ts +117 -0
- package/dist/commands/doc/append-markdown.d.ts.map +1 -0
- package/dist/commands/doc/append-markdown.js +253 -0
- package/dist/commands/doc/append-markdown.js.map +1 -0
- package/dist/commands/doc/block-create.d.ts +114 -0
- package/dist/commands/doc/block-create.d.ts.map +1 -0
- package/dist/commands/doc/block-create.js +206 -0
- package/dist/commands/doc/block-create.js.map +1 -0
- package/dist/commands/doc/block-delete.d.ts +72 -0
- package/dist/commands/doc/block-delete.d.ts.map +1 -0
- package/dist/commands/doc/block-delete.js +161 -0
- package/dist/commands/doc/block-delete.js.map +1 -0
- package/dist/commands/doc/block-update.d.ts +75 -0
- package/dist/commands/doc/block-update.d.ts.map +1 -0
- package/dist/commands/doc/block-update.js +162 -0
- package/dist/commands/doc/block-update.js.map +1 -0
- package/dist/commands/doc/create-in-workspace.d.ts +76 -0
- package/dist/commands/doc/create-in-workspace.d.ts.map +1 -0
- package/dist/commands/doc/create-in-workspace.js +164 -0
- package/dist/commands/doc/create-in-workspace.js.map +1 -0
- package/dist/commands/doc/create-on-column.d.ts +71 -0
- package/dist/commands/doc/create-on-column.d.ts.map +1 -0
- package/dist/commands/doc/create-on-column.js +146 -0
- package/dist/commands/doc/create-on-column.js.map +1 -0
- package/dist/commands/doc/delete.d.ts +68 -0
- package/dist/commands/doc/delete.d.ts.map +1 -0
- package/dist/commands/doc/delete.js +146 -0
- package/dist/commands/doc/delete.js.map +1 -0
- package/dist/commands/doc/duplicate.d.ts +101 -0
- package/dist/commands/doc/duplicate.d.ts.map +1 -0
- package/dist/commands/doc/duplicate.js +191 -0
- package/dist/commands/doc/duplicate.js.map +1 -0
- package/dist/commands/doc/get.d.ts +46 -0
- package/dist/commands/doc/get.d.ts.map +1 -0
- package/dist/commands/doc/get.js +95 -0
- package/dist/commands/doc/get.js.map +1 -0
- package/dist/commands/doc/import-html.d.ts +125 -0
- package/dist/commands/doc/import-html.d.ts.map +1 -0
- package/dist/commands/doc/import-html.js +273 -0
- package/dist/commands/doc/import-html.js.map +1 -0
- package/dist/commands/doc/list.d.ts +86 -0
- package/dist/commands/doc/list.d.ts.map +1 -0
- package/dist/commands/doc/list.js +217 -0
- package/dist/commands/doc/list.js.map +1 -0
- package/dist/commands/doc/rename.d.ts +60 -0
- package/dist/commands/doc/rename.d.ts.map +1 -0
- package/dist/commands/doc/rename.js +135 -0
- package/dist/commands/doc/rename.js.map +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +162 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/item/create.js +2 -2
- package/dist/commands/item/update.d.ts +1 -0
- package/dist/commands/item/update.d.ts.map +1 -1
- package/dist/commands/item/update.js +61 -0
- package/dist/commands/item/update.js.map +1 -1
- package/dist/commands/item/upload.d.ts +108 -0
- package/dist/commands/item/upload.d.ts.map +1 -0
- package/dist/commands/item/upload.js +370 -0
- package/dist/commands/item/upload.js.map +1 -0
- package/dist/commands/item/watch.d.ts +90 -0
- package/dist/commands/item/watch.d.ts.map +1 -0
- package/dist/commands/item/watch.js +342 -0
- package/dist/commands/item/watch.js.map +1 -0
- package/dist/commands/update/create.d.ts.map +1 -1
- package/dist/commands/update/create.js +6 -4
- package/dist/commands/update/create.js.map +1 -1
- package/dist/commands/update/edit.d.ts +4 -2
- package/dist/commands/update/edit.d.ts.map +1 -1
- package/dist/commands/update/edit.js +10 -6
- package/dist/commands/update/edit.js.map +1 -1
- package/dist/commands/update/reply.d.ts +4 -2
- package/dist/commands/update/reply.d.ts.map +1 -1
- package/dist/commands/update/reply.js +10 -6
- package/dist/commands/update/reply.js.map +1 -1
- package/dist/commands/update/upload.d.ts +69 -0
- package/dist/commands/update/upload.d.ts.map +1 -0
- package/dist/commands/update/upload.js +235 -0
- package/dist/commands/update/upload.js.map +1 -0
- package/dist/commands/user/_team-membership.d.ts +10 -0
- package/dist/commands/user/_team-membership.d.ts.map +1 -0
- package/dist/commands/user/_team-membership.js +88 -0
- package/dist/commands/user/_team-membership.js.map +1 -0
- package/dist/commands/user/team-add-members.d.ts +81 -0
- package/dist/commands/user/team-add-members.d.ts.map +1 -0
- package/dist/commands/user/team-add-members.js +186 -0
- package/dist/commands/user/team-add-members.js.map +1 -0
- package/dist/commands/user/team-create.d.ts +82 -0
- package/dist/commands/user/team-create.d.ts.map +1 -0
- package/dist/commands/user/team-create.js +206 -0
- package/dist/commands/user/team-create.js.map +1 -0
- package/dist/commands/user/team-delete.d.ts +56 -0
- package/dist/commands/user/team-delete.d.ts.map +1 -0
- package/dist/commands/user/team-delete.js +137 -0
- package/dist/commands/user/team-delete.js.map +1 -0
- package/dist/commands/user/team-get.d.ts +41 -0
- package/dist/commands/user/team-get.d.ts.map +1 -0
- package/dist/commands/user/team-get.js +87 -0
- package/dist/commands/user/team-get.js.map +1 -0
- package/dist/commands/user/team-list.d.ts +39 -0
- package/dist/commands/user/team-list.d.ts.map +1 -0
- package/dist/commands/user/team-list.js +90 -0
- package/dist/commands/user/team-list.js.map +1 -0
- package/dist/commands/user/team-remove-members.d.ts +71 -0
- package/dist/commands/user/team-remove-members.d.ts.map +1 -0
- package/dist/commands/user/team-remove-members.js +176 -0
- package/dist/commands/user/team-remove-members.js.map +1 -0
- package/dist/types/ids.d.ts +8 -0
- package/dist/types/ids.d.ts.map +1 -1
- package/dist/types/ids.js +53 -5
- package/dist/types/ids.js.map +1 -1
- package/dist/utils/mime.d.ts +24 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +64 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/output/envelope.d.ts +30 -0
- package/dist/utils/output/envelope.d.ts.map +1 -1
- package/dist/utils/output/envelope.js +26 -0
- package/dist/utils/output/envelope.js.map +1 -1
- package/dist/utils/output/ndjson.d.ts +25 -0
- package/dist/utils/output/ndjson.d.ts.map +1 -1
- package/dist/utils/output/ndjson.js +12 -0
- package/dist/utils/output/ndjson.js.map +1 -1
- package/dist/utils/parse-brand-list.d.ts +95 -0
- package/dist/utils/parse-brand-list.d.ts.map +1 -0
- package/dist/utils/parse-brand-list.js +96 -0
- package/dist/utils/parse-brand-list.js.map +1 -0
- package/dist/utils/signal.d.ts +42 -0
- package/dist/utils/signal.d.ts.map +1 -0
- package/dist/utils/signal.js +45 -0
- package/dist/utils/signal.js.map +1 -0
- package/dist/utils/source-content.d.ts +93 -0
- package/dist/utils/source-content.d.ts.map +1 -0
- package/dist/utils/source-content.js +120 -0
- package/dist/utils/source-content.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comma-separated branded-ID list argv parser (R-NEW-70 lift,
|
|
3
|
+
* v0.5-M34 pre-flight kickoff — ahead-of-feat per R-NEW-29 M25
|
|
4
|
+
* cadence; `v0.5-plan.md` §22 R-NEW-70 entry).
|
|
5
|
+
*
|
|
6
|
+
* Three sites in `src/commands/*` consume a `--<flag> <id,...>`
|
|
7
|
+
* comma-separated list of branded IDs at the argv-parse boundary +
|
|
8
|
+
* reject malformed entries as `usage_error`:
|
|
9
|
+
*
|
|
10
|
+
* - `monday workspace add-users` / `workspace remove-users` /
|
|
11
|
+
* `board add-users` already use the mixed numeric-or-email
|
|
12
|
+
* {@link parseUsersArg} helper (different shape — accepts
|
|
13
|
+
* emails + numeric IDs; NOT a consumer of this helper).
|
|
14
|
+
* - `monday doc list --workspace <wid,...>`
|
|
15
|
+
* (`src/commands/doc/list.ts`, M32 pre-flight — 1st pure-brand-list
|
|
16
|
+
* consumer; pre-lift `parseWorkspaceListArg` inline copy).
|
|
17
|
+
* - `monday user team-create --users <id,...>` / `team-add-members
|
|
18
|
+
* <tid> --users <id,...>` / `team-remove-members <tid> --users
|
|
19
|
+
* <id,...>` (`src/commands/user/team-*.ts`, M34 pre-flight —
|
|
20
|
+
* 3rd-5th consumers; would each duplicate the ~35-line inline
|
|
21
|
+
* pattern without this lift).
|
|
22
|
+
*
|
|
23
|
+
* Each pre-lift site shared the outer-split + trim + empty-entry +
|
|
24
|
+
* per-entry brand-validation outline; the per-call sites carried
|
|
25
|
+
* verb-specific error-message strings + detail keys + hint text. M34
|
|
26
|
+
* pre-flight pushed the count to 4 (1 migrated + 3 new), crossing the
|
|
27
|
+
* R7/R8 3-consumer threshold; this lift ships AHEAD of the M34
|
|
28
|
+
* pre-flight feat commit mirroring R-NEW-29's M25 cadence (lift
|
|
29
|
+
* commit lands first, feat commit consumes the lifted helper, Codex
|
|
30
|
+
* review then sees the lifted shape).
|
|
31
|
+
*
|
|
32
|
+
* **Why this is NOT folded into {@link parseUsersArg}.** The mixed
|
|
33
|
+
* numeric-or-email shape inflates the helper's signature with an
|
|
34
|
+
* `email_kind` discriminator + a directory-cache leg's source-
|
|
35
|
+
* aggregator coupling that's load-bearing in the fan-out path but
|
|
36
|
+
* irrelevant to a pure brand-list parse. Keeping the two shapes as
|
|
37
|
+
* sibling helpers keeps the pure-brand-list call sites readable and
|
|
38
|
+
* the mixed-mode fan-out call sites tightly typed.
|
|
39
|
+
*/
|
|
40
|
+
import type { z } from 'zod';
|
|
41
|
+
export interface ParseBrandedListArgOptions {
|
|
42
|
+
/**
|
|
43
|
+
* The argv flag name including the leading dashes (e.g.
|
|
44
|
+
* `'--workspace'`, `'--users'`). Surfaces verbatim into
|
|
45
|
+
* `error.message` so the agent sees which flag rejected.
|
|
46
|
+
*/
|
|
47
|
+
readonly flagName: string;
|
|
48
|
+
/**
|
|
49
|
+
* Short noun phrase describing one entry (e.g. `'numeric workspace
|
|
50
|
+
* ID'`, `'numeric user ID'`). Surfaces into the per-entry
|
|
51
|
+
* rejection message: `"--<flag> entry "<token>" is not a
|
|
52
|
+
* <entryDescription>"`.
|
|
53
|
+
*/
|
|
54
|
+
readonly entryDescription: string;
|
|
55
|
+
/**
|
|
56
|
+
* Free-form hint surfaced into `error.details.hint` on per-entry
|
|
57
|
+
* brand-validation failure (e.g. `'workspace IDs are numeric
|
|
58
|
+
* (e.g. 12345)'`). Same hint used for both the empty-entry
|
|
59
|
+
* rejection (where it falls back to a generic "no leading,
|
|
60
|
+
* trailing, or duplicate commas" message if {@link emptyEntryHint}
|
|
61
|
+
* is unset) and the per-entry rejection.
|
|
62
|
+
*/
|
|
63
|
+
readonly hint: string;
|
|
64
|
+
/**
|
|
65
|
+
* Optional hint override for the empty-entry rejection path
|
|
66
|
+
* (trailing comma / leading comma / double comma). Defaults to
|
|
67
|
+
* `"e.g. ${flagName} <id-or-token>,<id-or-token> — no leading,
|
|
68
|
+
* trailing, or duplicate commas"` when unset, which matches the
|
|
69
|
+
* pre-lift `parseWorkspaceListArg` shape verbatim.
|
|
70
|
+
*/
|
|
71
|
+
readonly emptyEntryHint?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Splits a comma-separated argv string into an array of brand-
|
|
75
|
+
* validated typed IDs. Whitespace around commas is trimmed. Empty
|
|
76
|
+
* entries (trailing comma, leading comma, double comma) reject
|
|
77
|
+
* with `usage_error.details.hint`; non-conforming entries reject
|
|
78
|
+
* via the supplied zod brand schema (`details.issues[]` carries
|
|
79
|
+
* the per-issue path/message + `details.argv_value` echoes the
|
|
80
|
+
* raw input so agents can correlate retries against the original
|
|
81
|
+
* argv).
|
|
82
|
+
*
|
|
83
|
+
* The brand-validation step uses `safeParse` so the zod error
|
|
84
|
+
* doesn't bubble through the runner's catch-all as
|
|
85
|
+
* `internal_error` (per `validation.md`'s "Never bubble raw
|
|
86
|
+
* ZodError out of a parse boundary" rule). Caller wraps with the
|
|
87
|
+
* verb's outer `parseArgv` for the rest of the argv surface.
|
|
88
|
+
*
|
|
89
|
+
* Empty input strings (`raw === ''`) reject at the per-verb input
|
|
90
|
+
* schema's `.min(1)` check BEFORE reaching this helper — the
|
|
91
|
+
* helper assumes a non-empty raw string. The empty-`raw` defensive
|
|
92
|
+
* branch is c8-ignored as unreachable from production.
|
|
93
|
+
*/
|
|
94
|
+
export declare const parseBrandedListArg: <T>(raw: string, brandSchema: z.ZodType<T>, options: ParseBrandedListArgOptions) => readonly T[];
|
|
95
|
+
//# sourceMappingURL=parse-brand-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-brand-list.d.ts","sourceRoot":"","sources":["../../src/utils/parse-brand-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,EACnC,KAAK,MAAM,EACX,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EACzB,SAAS,0BAA0B,KAClC,SAAS,CAAC,EAwCZ,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comma-separated branded-ID list argv parser (R-NEW-70 lift,
|
|
3
|
+
* v0.5-M34 pre-flight kickoff — ahead-of-feat per R-NEW-29 M25
|
|
4
|
+
* cadence; `v0.5-plan.md` §22 R-NEW-70 entry).
|
|
5
|
+
*
|
|
6
|
+
* Three sites in `src/commands/*` consume a `--<flag> <id,...>`
|
|
7
|
+
* comma-separated list of branded IDs at the argv-parse boundary +
|
|
8
|
+
* reject malformed entries as `usage_error`:
|
|
9
|
+
*
|
|
10
|
+
* - `monday workspace add-users` / `workspace remove-users` /
|
|
11
|
+
* `board add-users` already use the mixed numeric-or-email
|
|
12
|
+
* {@link parseUsersArg} helper (different shape — accepts
|
|
13
|
+
* emails + numeric IDs; NOT a consumer of this helper).
|
|
14
|
+
* - `monday doc list --workspace <wid,...>`
|
|
15
|
+
* (`src/commands/doc/list.ts`, M32 pre-flight — 1st pure-brand-list
|
|
16
|
+
* consumer; pre-lift `parseWorkspaceListArg` inline copy).
|
|
17
|
+
* - `monday user team-create --users <id,...>` / `team-add-members
|
|
18
|
+
* <tid> --users <id,...>` / `team-remove-members <tid> --users
|
|
19
|
+
* <id,...>` (`src/commands/user/team-*.ts`, M34 pre-flight —
|
|
20
|
+
* 3rd-5th consumers; would each duplicate the ~35-line inline
|
|
21
|
+
* pattern without this lift).
|
|
22
|
+
*
|
|
23
|
+
* Each pre-lift site shared the outer-split + trim + empty-entry +
|
|
24
|
+
* per-entry brand-validation outline; the per-call sites carried
|
|
25
|
+
* verb-specific error-message strings + detail keys + hint text. M34
|
|
26
|
+
* pre-flight pushed the count to 4 (1 migrated + 3 new), crossing the
|
|
27
|
+
* R7/R8 3-consumer threshold; this lift ships AHEAD of the M34
|
|
28
|
+
* pre-flight feat commit mirroring R-NEW-29's M25 cadence (lift
|
|
29
|
+
* commit lands first, feat commit consumes the lifted helper, Codex
|
|
30
|
+
* review then sees the lifted shape).
|
|
31
|
+
*
|
|
32
|
+
* **Why this is NOT folded into {@link parseUsersArg}.** The mixed
|
|
33
|
+
* numeric-or-email shape inflates the helper's signature with an
|
|
34
|
+
* `email_kind` discriminator + a directory-cache leg's source-
|
|
35
|
+
* aggregator coupling that's load-bearing in the fan-out path but
|
|
36
|
+
* irrelevant to a pure brand-list parse. Keeping the two shapes as
|
|
37
|
+
* sibling helpers keeps the pure-brand-list call sites readable and
|
|
38
|
+
* the mixed-mode fan-out call sites tightly typed.
|
|
39
|
+
*/
|
|
40
|
+
import { UsageError } from './errors.js';
|
|
41
|
+
/**
|
|
42
|
+
* Splits a comma-separated argv string into an array of brand-
|
|
43
|
+
* validated typed IDs. Whitespace around commas is trimmed. Empty
|
|
44
|
+
* entries (trailing comma, leading comma, double comma) reject
|
|
45
|
+
* with `usage_error.details.hint`; non-conforming entries reject
|
|
46
|
+
* via the supplied zod brand schema (`details.issues[]` carries
|
|
47
|
+
* the per-issue path/message + `details.argv_value` echoes the
|
|
48
|
+
* raw input so agents can correlate retries against the original
|
|
49
|
+
* argv).
|
|
50
|
+
*
|
|
51
|
+
* The brand-validation step uses `safeParse` so the zod error
|
|
52
|
+
* doesn't bubble through the runner's catch-all as
|
|
53
|
+
* `internal_error` (per `validation.md`'s "Never bubble raw
|
|
54
|
+
* ZodError out of a parse boundary" rule). Caller wraps with the
|
|
55
|
+
* verb's outer `parseArgv` for the rest of the argv surface.
|
|
56
|
+
*
|
|
57
|
+
* Empty input strings (`raw === ''`) reject at the per-verb input
|
|
58
|
+
* schema's `.min(1)` check BEFORE reaching this helper — the
|
|
59
|
+
* helper assumes a non-empty raw string. The empty-`raw` defensive
|
|
60
|
+
* branch is c8-ignored as unreachable from production.
|
|
61
|
+
*/
|
|
62
|
+
export const parseBrandedListArg = (raw, brandSchema, options) => {
|
|
63
|
+
const tokens = raw.split(',').map((t) => t.trim());
|
|
64
|
+
const ids = [];
|
|
65
|
+
for (const token of tokens) {
|
|
66
|
+
if (token === '') {
|
|
67
|
+
throw new UsageError(`${options.flagName} contains an empty entry (trailing comma ` +
|
|
68
|
+
`or double comma); pass a comma-separated list of ` +
|
|
69
|
+
`${options.entryDescription}s.`, {
|
|
70
|
+
details: {
|
|
71
|
+
hint: options.emptyEntryHint ??
|
|
72
|
+
`e.g. ${options.flagName} <id>,<id> — no leading, ` +
|
|
73
|
+
`trailing, or duplicate commas`,
|
|
74
|
+
argv_value: raw,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const parsed = brandSchema.safeParse(token);
|
|
79
|
+
if (!parsed.success) {
|
|
80
|
+
throw new UsageError(`${options.flagName} entry ${JSON.stringify(token)} is not a ${options.entryDescription}`, {
|
|
81
|
+
cause: parsed.error,
|
|
82
|
+
details: {
|
|
83
|
+
issues: parsed.error.issues.map((i) => ({
|
|
84
|
+
path: i.path.map((p) => String(p)).join('.'),
|
|
85
|
+
message: i.message,
|
|
86
|
+
})),
|
|
87
|
+
argv_value: raw,
|
|
88
|
+
hint: options.hint,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
ids.push(parsed.data);
|
|
93
|
+
}
|
|
94
|
+
return ids;
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=parse-brand-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-brand-list.js","sourceRoot":"","sources":["../../src/utils/parse-brand-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAmCzC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,GAAW,EACX,WAAyB,EACzB,OAAmC,EACrB,EAAE;IAChB,MAAM,MAAM,GAAG,GAAG,CAAC,KA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CAAC;QACD,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AbortSignal utilities shared across dispatchers + streaming verbs
|
|
3
|
+
* (R-NEW-55).
|
|
4
|
+
*
|
|
5
|
+
* Three consumers today share the "extract `signal.reason` as an
|
|
6
|
+
* Error, fall back to a fresh `Error('aborted')`" pattern:
|
|
7
|
+
*
|
|
8
|
+
* 1. `src/api/partial-success-mutation.ts:dispatchSequential` —
|
|
9
|
+
* iteration-boundary signal check; re-throws the reason
|
|
10
|
+
* whole-call.
|
|
11
|
+
* 2. `src/api/parallel-dispatch.ts:dispatchParallel` — worker-
|
|
12
|
+
* loop signal check; re-throws + sets the pool's `aborted`
|
|
13
|
+
* flag so other workers stop scheduling new dispatches.
|
|
14
|
+
* 3. `src/api/item-watch.ts:sleepWithSignal` — both the
|
|
15
|
+
* race-window guard (sync `signal.aborted` check before
|
|
16
|
+
* listener registration) and the abort-listener path
|
|
17
|
+
* reject the sleep promise with the extracted reason.
|
|
18
|
+
*
|
|
19
|
+
* `src/api/retry.ts:signalAbortError` is semantically adjacent but
|
|
20
|
+
* DELIBERATELY divergent: retry.ts assigns `name = 'AbortError'` to
|
|
21
|
+
* match the Web Platform's DOMException-style surface so callers
|
|
22
|
+
* can branch on `err.name === 'AbortError'`. Stays inline to
|
|
23
|
+
* preserve the DOMException naming. {@link extractSignalReason}
|
|
24
|
+
* below matches the dispatcher / sleep-helper semantics (no
|
|
25
|
+
* `AbortError` rename); retry.ts carries its own naming-preserving
|
|
26
|
+
* variant.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Reads `signal.reason` and returns it as an `Error` instance the
|
|
30
|
+
* caller can `throw` directly. When the abort reason is already an
|
|
31
|
+
* `Error`, return it verbatim — preserves cause chains, error
|
|
32
|
+
* classes (`UsageError`, `ApiError`, etc.), and any
|
|
33
|
+
* caller-attached details. When the reason is anything else (a
|
|
34
|
+
* bare string, `undefined`, a non-Error object), wrap in a fresh
|
|
35
|
+
* `Error('aborted')` so the caller always has a throwable shape.
|
|
36
|
+
*
|
|
37
|
+
* Used by `dispatchSequential` + `dispatchParallel` (iteration /
|
|
38
|
+
* worker-loop signal check) and `sleepWithSignal` (race-window
|
|
39
|
+
* abort + listener-fired abort).
|
|
40
|
+
*/
|
|
41
|
+
export declare const extractSignalReason: (signal: AbortSignal) => Error;
|
|
42
|
+
//# sourceMappingURL=signal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/utils/signal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,WAAW,KAAG,KAGzD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AbortSignal utilities shared across dispatchers + streaming verbs
|
|
3
|
+
* (R-NEW-55).
|
|
4
|
+
*
|
|
5
|
+
* Three consumers today share the "extract `signal.reason` as an
|
|
6
|
+
* Error, fall back to a fresh `Error('aborted')`" pattern:
|
|
7
|
+
*
|
|
8
|
+
* 1. `src/api/partial-success-mutation.ts:dispatchSequential` —
|
|
9
|
+
* iteration-boundary signal check; re-throws the reason
|
|
10
|
+
* whole-call.
|
|
11
|
+
* 2. `src/api/parallel-dispatch.ts:dispatchParallel` — worker-
|
|
12
|
+
* loop signal check; re-throws + sets the pool's `aborted`
|
|
13
|
+
* flag so other workers stop scheduling new dispatches.
|
|
14
|
+
* 3. `src/api/item-watch.ts:sleepWithSignal` — both the
|
|
15
|
+
* race-window guard (sync `signal.aborted` check before
|
|
16
|
+
* listener registration) and the abort-listener path
|
|
17
|
+
* reject the sleep promise with the extracted reason.
|
|
18
|
+
*
|
|
19
|
+
* `src/api/retry.ts:signalAbortError` is semantically adjacent but
|
|
20
|
+
* DELIBERATELY divergent: retry.ts assigns `name = 'AbortError'` to
|
|
21
|
+
* match the Web Platform's DOMException-style surface so callers
|
|
22
|
+
* can branch on `err.name === 'AbortError'`. Stays inline to
|
|
23
|
+
* preserve the DOMException naming. {@link extractSignalReason}
|
|
24
|
+
* below matches the dispatcher / sleep-helper semantics (no
|
|
25
|
+
* `AbortError` rename); retry.ts carries its own naming-preserving
|
|
26
|
+
* variant.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Reads `signal.reason` and returns it as an `Error` instance the
|
|
30
|
+
* caller can `throw` directly. When the abort reason is already an
|
|
31
|
+
* `Error`, return it verbatim — preserves cause chains, error
|
|
32
|
+
* classes (`UsageError`, `ApiError`, etc.), and any
|
|
33
|
+
* caller-attached details. When the reason is anything else (a
|
|
34
|
+
* bare string, `undefined`, a non-Error object), wrap in a fresh
|
|
35
|
+
* `Error('aborted')` so the caller always has a throwable shape.
|
|
36
|
+
*
|
|
37
|
+
* Used by `dispatchSequential` + `dispatchParallel` (iteration /
|
|
38
|
+
* worker-loop signal check) and `sleepWithSignal` (race-window
|
|
39
|
+
* abort + listener-fired abort).
|
|
40
|
+
*/
|
|
41
|
+
export const extractSignalReason = (signal) => {
|
|
42
|
+
const reason = signal.reason;
|
|
43
|
+
return reason instanceof Error ? reason : new Error('aborted');
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=signal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal.js","sourceRoot":"","sources":["../../src/utils/signal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAmB,EAAS,EAAE;IAChE,MAAM,MAAM,GAAY,MAAM,CAAC,MAAM,CAAC;IACtC,OAAO,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;AACjE,CAAC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic file-or-stdin-or-inline-string source-content reader
|
|
3
|
+
* (R-v0.5-NEW-18 lift, v0.5-M37 IMPL kickoff — ahead-of-feat per
|
|
4
|
+
* R-NEW-29 M25 + R-NEW-70 M34 cadence; `v0.5-plan.md` §22 R-v0.5-NEW-18
|
|
5
|
+
* entry).
|
|
6
|
+
*
|
|
7
|
+
* Five sites consume the same shape post-lift:
|
|
8
|
+
*
|
|
9
|
+
* - `src/commands/update/create.ts` (M13; `--body <md>` /
|
|
10
|
+
* `--body-file <path|->`).
|
|
11
|
+
* - `src/commands/update/reply.ts` (M13).
|
|
12
|
+
* - `src/commands/update/edit.ts` (M13).
|
|
13
|
+
* - `src/commands/doc/import-html.ts` (M37; `--html-string <s>` /
|
|
14
|
+
* `--html <file|->`).
|
|
15
|
+
* - `src/commands/doc/append-markdown.ts` (M37; `--markdown-string
|
|
16
|
+
* <s>` / `--markdown <file|->`).
|
|
17
|
+
*
|
|
18
|
+
* All five materialise a content payload from one of three mutually-
|
|
19
|
+
* exclusive sources:
|
|
20
|
+
*
|
|
21
|
+
* 1. `inline` — literal content via an inline-string flag (e.g.
|
|
22
|
+
* `--body <md>`, `--html-string <s>`, `--markdown-string <s>`).
|
|
23
|
+
* 2. `file` — file path via a file-source flag (e.g.
|
|
24
|
+
* `--body-file <path>`, `--html <file>`, `--markdown <file>`).
|
|
25
|
+
* 3. `file === '-'` — stdin (requires the `stdin` slot wired by
|
|
26
|
+
* the runner).
|
|
27
|
+
*
|
|
28
|
+
* Mutex of (1) vs (2) is typically enforced at the parse boundary via
|
|
29
|
+
* a cross-field `.refine()` on the argv schema (see R-v0.5-NEW-20);
|
|
30
|
+
* the helper rejects the both-set case defensively. Inline byte-length
|
|
31
|
+
* cap is enforced at the parse boundary via `.refine()` (see
|
|
32
|
+
* R-v0.5-NEW-21); when {@link ReadSourceContentInputs.maxBytes} is
|
|
33
|
+
* supplied here, the same cap is applied at the runtime read boundary
|
|
34
|
+
* for the file / stdin path (file content size isn't known at argv-
|
|
35
|
+
* parse time).
|
|
36
|
+
*
|
|
37
|
+
* Throws `UsageError` for:
|
|
38
|
+
* - Both `inline` and `file` set (pre-parse-boundary drift).
|
|
39
|
+
* - Neither set (no source).
|
|
40
|
+
* - `file === '-'` with no `stdin` (programmer wiring bug).
|
|
41
|
+
* - Empty (or whitespace-only) result after read.
|
|
42
|
+
* - File-read failure (ENOENT / EACCES / etc.) wrapped with the
|
|
43
|
+
* underlying error message.
|
|
44
|
+
* - Oversized payload (when `maxBytes` is set) with
|
|
45
|
+
* `details.size_bytes` + `details.limit_bytes` + `details.source`
|
|
46
|
+
* ('inline' / 'file' / 'stdin') for agent introspection.
|
|
47
|
+
*/
|
|
48
|
+
export interface ReadSourceContentInputs {
|
|
49
|
+
/** Inline-string flag value (e.g. `--body <md>` / `--html-string`). */
|
|
50
|
+
readonly inline: string | undefined;
|
|
51
|
+
/** File-source flag value (e.g. `--body-file <path>` / `--html <file>`). */
|
|
52
|
+
readonly file: string | undefined;
|
|
53
|
+
/** stdin slot wired by the runner — required for `<file-flag> -`. */
|
|
54
|
+
readonly stdin: NodeJS.ReadableStream | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Inline-flag display name for error messages (e.g. `'--body'`,
|
|
57
|
+
* `'--html-string'`). Surfaces verbatim into `error.message`.
|
|
58
|
+
*/
|
|
59
|
+
readonly inlineFlagName: string;
|
|
60
|
+
/**
|
|
61
|
+
* File-source flag display name for error messages (e.g.
|
|
62
|
+
* `'--body-file'`, `'--html'`).
|
|
63
|
+
*/
|
|
64
|
+
readonly fileFlagName: string;
|
|
65
|
+
/**
|
|
66
|
+
* Verb-specific "neither set" error message. Omit for a generic
|
|
67
|
+
* `${inlineFlagName} or ${fileFlagName}` phrasing. Callers usually
|
|
68
|
+
* supply a verb-named hint (e.g. "monday update create requires
|
|
69
|
+
* either --body <md> or --body-file <path>. Use --body-file - to
|
|
70
|
+
* read from stdin.").
|
|
71
|
+
*/
|
|
72
|
+
readonly verbHint?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Optional UTF-8 byte-length cap applied to the resolved content.
|
|
75
|
+
* When set, the helper rejects oversized payloads as `usage_error`
|
|
76
|
+
* with structured `details.size_bytes` / `details.limit_bytes` /
|
|
77
|
+
* `details.source`. M37 supplies `MAX_DOC_IMPORT_PAYLOAD_BYTES`
|
|
78
|
+
* (`256_000`) per D13 closure; M13 supplies nothing (no wire-side
|
|
79
|
+
* cap on `update` body payloads).
|
|
80
|
+
*/
|
|
81
|
+
readonly maxBytes?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Trim trailing whitespace from file / stdin content. Default
|
|
84
|
+
* `true` (matches M13 behaviour — a trailing newline from `cat
|
|
85
|
+
* foo.md` doesn't surface as a literal `\n` in the posted
|
|
86
|
+
* comment / doc payload). Inline content is always returned
|
|
87
|
+
* verbatim (post empty-trim rejection); the parameter only
|
|
88
|
+
* affects file / stdin paths.
|
|
89
|
+
*/
|
|
90
|
+
readonly trimTrailingWhitespace?: boolean;
|
|
91
|
+
}
|
|
92
|
+
export declare const readSourceContent: (inputs: ReadSourceContentInputs) => Promise<string>;
|
|
93
|
+
//# sourceMappingURL=source-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-content.d.ts","sourceRoot":"","sources":["../../src/utils/source-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAKH,MAAM,WAAW,uBAAuB;IACtC,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,cAAc,GAAG,SAAS,CAAC;IAClD;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;OAOG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAC3C;AA8BD,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,uBAAuB,KAC9B,OAAO,CAAC,MAAM,CA+EhB,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic file-or-stdin-or-inline-string source-content reader
|
|
3
|
+
* (R-v0.5-NEW-18 lift, v0.5-M37 IMPL kickoff — ahead-of-feat per
|
|
4
|
+
* R-NEW-29 M25 + R-NEW-70 M34 cadence; `v0.5-plan.md` §22 R-v0.5-NEW-18
|
|
5
|
+
* entry).
|
|
6
|
+
*
|
|
7
|
+
* Five sites consume the same shape post-lift:
|
|
8
|
+
*
|
|
9
|
+
* - `src/commands/update/create.ts` (M13; `--body <md>` /
|
|
10
|
+
* `--body-file <path|->`).
|
|
11
|
+
* - `src/commands/update/reply.ts` (M13).
|
|
12
|
+
* - `src/commands/update/edit.ts` (M13).
|
|
13
|
+
* - `src/commands/doc/import-html.ts` (M37; `--html-string <s>` /
|
|
14
|
+
* `--html <file|->`).
|
|
15
|
+
* - `src/commands/doc/append-markdown.ts` (M37; `--markdown-string
|
|
16
|
+
* <s>` / `--markdown <file|->`).
|
|
17
|
+
*
|
|
18
|
+
* All five materialise a content payload from one of three mutually-
|
|
19
|
+
* exclusive sources:
|
|
20
|
+
*
|
|
21
|
+
* 1. `inline` — literal content via an inline-string flag (e.g.
|
|
22
|
+
* `--body <md>`, `--html-string <s>`, `--markdown-string <s>`).
|
|
23
|
+
* 2. `file` — file path via a file-source flag (e.g.
|
|
24
|
+
* `--body-file <path>`, `--html <file>`, `--markdown <file>`).
|
|
25
|
+
* 3. `file === '-'` — stdin (requires the `stdin` slot wired by
|
|
26
|
+
* the runner).
|
|
27
|
+
*
|
|
28
|
+
* Mutex of (1) vs (2) is typically enforced at the parse boundary via
|
|
29
|
+
* a cross-field `.refine()` on the argv schema (see R-v0.5-NEW-20);
|
|
30
|
+
* the helper rejects the both-set case defensively. Inline byte-length
|
|
31
|
+
* cap is enforced at the parse boundary via `.refine()` (see
|
|
32
|
+
* R-v0.5-NEW-21); when {@link ReadSourceContentInputs.maxBytes} is
|
|
33
|
+
* supplied here, the same cap is applied at the runtime read boundary
|
|
34
|
+
* for the file / stdin path (file content size isn't known at argv-
|
|
35
|
+
* parse time).
|
|
36
|
+
*
|
|
37
|
+
* Throws `UsageError` for:
|
|
38
|
+
* - Both `inline` and `file` set (pre-parse-boundary drift).
|
|
39
|
+
* - Neither set (no source).
|
|
40
|
+
* - `file === '-'` with no `stdin` (programmer wiring bug).
|
|
41
|
+
* - Empty (or whitespace-only) result after read.
|
|
42
|
+
* - File-read failure (ENOENT / EACCES / etc.) wrapped with the
|
|
43
|
+
* underlying error message.
|
|
44
|
+
* - Oversized payload (when `maxBytes` is set) with
|
|
45
|
+
* `details.size_bytes` + `details.limit_bytes` + `details.source`
|
|
46
|
+
* ('inline' / 'file' / 'stdin') for agent introspection.
|
|
47
|
+
*/
|
|
48
|
+
import { readFile } from 'node:fs/promises';
|
|
49
|
+
import { UsageError, errorMessage } from './errors.js';
|
|
50
|
+
const enforceMaxBytes = (content, source, maxBytes, inputs) => {
|
|
51
|
+
const size = Buffer.byteLength(content, 'utf8');
|
|
52
|
+
if (size <= maxBytes)
|
|
53
|
+
return;
|
|
54
|
+
const flagName = source === 'inline' ? inputs.inlineFlagName : inputs.fileFlagName;
|
|
55
|
+
const details = {
|
|
56
|
+
source,
|
|
57
|
+
size_bytes: size,
|
|
58
|
+
limit_bytes: maxBytes,
|
|
59
|
+
};
|
|
60
|
+
if (source === 'file' && inputs.file !== undefined) {
|
|
61
|
+
details.file_path = inputs.file;
|
|
62
|
+
}
|
|
63
|
+
throw new UsageError(`${flagName}: payload (${String(size)} bytes) exceeds the ${String(maxBytes)}-byte wire-side limit. Pass a smaller payload, or split the call.`, { details });
|
|
64
|
+
};
|
|
65
|
+
export const readSourceContent = async (inputs) => {
|
|
66
|
+
const { inline, file, stdin, inlineFlagName, fileFlagName, maxBytes, } = inputs;
|
|
67
|
+
const trimTrailing = inputs.trimTrailingWhitespace ?? true;
|
|
68
|
+
if (inline !== undefined && file !== undefined) {
|
|
69
|
+
throw new UsageError(`${inlineFlagName} and ${fileFlagName} are mutually exclusive; pick one.`, { details: { [`has_inline_value`]: true, file_path: file } });
|
|
70
|
+
}
|
|
71
|
+
if (inline !== undefined) {
|
|
72
|
+
if (inline.trim().length === 0) {
|
|
73
|
+
throw new UsageError(`${inlineFlagName} cannot be empty (or whitespace-only). Pass content or use ${fileFlagName} <path> to read from disk / stdin.`);
|
|
74
|
+
}
|
|
75
|
+
if (maxBytes !== undefined) {
|
|
76
|
+
enforceMaxBytes(inline, 'inline', maxBytes, inputs);
|
|
77
|
+
}
|
|
78
|
+
return inline;
|
|
79
|
+
}
|
|
80
|
+
if (file === undefined) {
|
|
81
|
+
const verbHint = inputs.verbHint ??
|
|
82
|
+
`requires either ${inlineFlagName} <s> or ${fileFlagName} <file>. Use ${fileFlagName} - to read from stdin.`;
|
|
83
|
+
throw new UsageError(verbHint);
|
|
84
|
+
}
|
|
85
|
+
if (file === '-') {
|
|
86
|
+
if (stdin === undefined) {
|
|
87
|
+
throw new UsageError(`${fileFlagName} - requested stdin, but no stdin is wired into the runner. This is a programmer wiring bug.`);
|
|
88
|
+
}
|
|
89
|
+
const chunks = [];
|
|
90
|
+
for await (const chunk of stdin) {
|
|
91
|
+
chunks.push(Buffer.from(chunk));
|
|
92
|
+
}
|
|
93
|
+
const raw = Buffer.concat(chunks).toString('utf8');
|
|
94
|
+
const body = trimTrailing ? raw.trimEnd() : raw;
|
|
95
|
+
if (body.length === 0) {
|
|
96
|
+
throw new UsageError(`stdin produced an empty payload. Pipe non-empty content into ${fileFlagName} - or pass ${inlineFlagName} <s> inline.`, { details: { source: 'stdin' } });
|
|
97
|
+
}
|
|
98
|
+
if (maxBytes !== undefined) {
|
|
99
|
+
enforceMaxBytes(body, 'stdin', maxBytes, inputs);
|
|
100
|
+
}
|
|
101
|
+
return body;
|
|
102
|
+
}
|
|
103
|
+
// File on disk. UTF-8 always; binary content would corrupt the
|
|
104
|
+
// markdown / HTML payload anyway.
|
|
105
|
+
const raw = await readFile(file, 'utf8').catch((err) => {
|
|
106
|
+
throw new UsageError(`${fileFlagName}: failed to read ${JSON.stringify(file)} (${errorMessage(err)}).`, {
|
|
107
|
+
cause: err,
|
|
108
|
+
details: { file_path: file },
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
const body = trimTrailing ? raw.trimEnd() : raw;
|
|
112
|
+
if (body.length === 0) {
|
|
113
|
+
throw new UsageError(`${fileFlagName}: ${JSON.stringify(file)} is empty (after trim). Pass non-empty content.`, { details: { file_path: file } });
|
|
114
|
+
}
|
|
115
|
+
if (maxBytes !== undefined) {
|
|
116
|
+
enforceMaxBytes(body, 'file', maxBytes, inputs);
|
|
117
|
+
}
|
|
118
|
+
return body;
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=source-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-content.js","sourceRoot":"","sources":["../../src/utils/source-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,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
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Agent-first CLI for Monday.com — read boards, file backlog items, transition statuses, and post comments from the terminal. Built for AI coding agents (Claude Code, Codex) with humans as a welcome second audience.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|