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,418 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { parseArgv } from './parse-argv.js';
|
|
3
|
+
import { emitSuccess } from './emit.js';
|
|
4
|
+
import { parseGlobalFlags } from '../types/global-flags.js';
|
|
5
|
+
import { UsageError } from '../utils/errors.js';
|
|
6
|
+
/**
|
|
7
|
+
* Closed 3-value enum of shell flavours the CLI knows how to emit a
|
|
8
|
+
* completion script for. Adding a 4th value (e.g. `powershell`,
|
|
9
|
+
* `nushell`) is a SemVer-minor expansion at the M33 contract + a
|
|
10
|
+
* matching hand-rolled template below.
|
|
11
|
+
*/
|
|
12
|
+
export const COMPLETION_SHELLS = ['bash', 'zsh', 'fish'];
|
|
13
|
+
/**
|
|
14
|
+
* zod enum binding for the closed 3-value shell flavour. Exported so
|
|
15
|
+
* downstream `monday schema completion` introspection consumers can
|
|
16
|
+
* pin against the same enum the argv parse boundary uses.
|
|
17
|
+
*/
|
|
18
|
+
export const shellSchema = z.enum(COMPLETION_SHELLS);
|
|
19
|
+
const inputSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
shell: shellSchema,
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
/**
|
|
25
|
+
* `--json` envelope shape. The default mode emits raw script bytes
|
|
26
|
+
* with NO envelope (see module-level carve-out note); this schema
|
|
27
|
+
* applies only when `--json` / `--output json` / `MONDAY_OUTPUT=json`
|
|
28
|
+
* opts into the envelope path.
|
|
29
|
+
*
|
|
30
|
+
* `shell` echoes the input flavour; `script` is the per-shell
|
|
31
|
+
* completion script body as a single string (including trailing
|
|
32
|
+
* newlines). Agents extract via `jq -r '.data.script'`.
|
|
33
|
+
*/
|
|
34
|
+
export const completionOutputSchema = z
|
|
35
|
+
.object({
|
|
36
|
+
shell: shellSchema,
|
|
37
|
+
script: z.string().min(1),
|
|
38
|
+
})
|
|
39
|
+
.strict();
|
|
40
|
+
/**
|
|
41
|
+
* Strip placeholder syntax (`get <itemId>` → `get`, `set <iid>
|
|
42
|
+
* [setExpr]` → `set`) so the completion script enumerates bare
|
|
43
|
+
* verbs. Commander's `Command.name()` already strips this in v14
|
|
44
|
+
* but the defensive helper keeps the templates resilient to any
|
|
45
|
+
* future commander shape change.
|
|
46
|
+
*/
|
|
47
|
+
const stripPlaceholders = (raw) =>
|
|
48
|
+
// `String.prototype.split` always returns at least one element so
|
|
49
|
+
// the `?? raw` arm is unreachable from a non-empty input. The
|
|
50
|
+
// commander `Command.name()` source is non-empty by construction;
|
|
51
|
+
// the defensive guard stays so a future commander shape change
|
|
52
|
+
// doesn't surface as an unhandled `undefined` first-token.
|
|
53
|
+
/* c8 ignore next */
|
|
54
|
+
raw.split(/\s+/u)[0] ?? raw;
|
|
55
|
+
const collectLongOptions = (cmd) => {
|
|
56
|
+
const out = [];
|
|
57
|
+
for (const opt of cmd.options) {
|
|
58
|
+
// Commander v14 stores the long form on `opt.long`. Every option
|
|
59
|
+
// declared via `program.option('--foo …', …)` carries a non-empty
|
|
60
|
+
// long-form string; the `length > 0` guard is defensive against
|
|
61
|
+
// a hypothetical short-only option (not currently used anywhere
|
|
62
|
+
// in `src/cli/program.ts`'s global-flag set or any verb's
|
|
63
|
+
// per-command options).
|
|
64
|
+
/* c8 ignore next */
|
|
65
|
+
if (typeof opt.long === 'string' && opt.long.length > 0) {
|
|
66
|
+
out.push(opt.long);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
};
|
|
71
|
+
const buildCompletionTree = (program) => {
|
|
72
|
+
const visit = (cmd) => ({
|
|
73
|
+
name: stripPlaceholders(cmd.name()),
|
|
74
|
+
children: cmd.commands.map(visit),
|
|
75
|
+
options: collectLongOptions(cmd),
|
|
76
|
+
});
|
|
77
|
+
return visit(program);
|
|
78
|
+
};
|
|
79
|
+
const flattenPaths = (root) => {
|
|
80
|
+
const globalOptions = root.options;
|
|
81
|
+
const acc = [];
|
|
82
|
+
const recur = (node, path) => {
|
|
83
|
+
const merged = new Set([...globalOptions, ...node.options]);
|
|
84
|
+
acc.push({
|
|
85
|
+
path,
|
|
86
|
+
children: node.children.map((c) => c.name).sort(),
|
|
87
|
+
options: [...merged].sort(),
|
|
88
|
+
localOptions: [...node.options].sort(),
|
|
89
|
+
});
|
|
90
|
+
for (const child of node.children) {
|
|
91
|
+
recur(child, [...path, child.name]);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
recur(root, []);
|
|
95
|
+
acc.sort((a, b) => a.path.join(' ').localeCompare(b.path.join(' ')));
|
|
96
|
+
return acc;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Encode a value for safe interpolation inside POSIX-shell
|
|
100
|
+
* single-quoted strings. The only metachar to escape is the
|
|
101
|
+
* single quote itself — close, escape, reopen.
|
|
102
|
+
*/
|
|
103
|
+
const shSingleQuote = (raw) => `'${raw.replace(/'/gu, `'\\''`)}'`;
|
|
104
|
+
const buildBashScript = (paths) => {
|
|
105
|
+
const cases = [];
|
|
106
|
+
for (const entry of paths) {
|
|
107
|
+
const key = entry.path.join(' ');
|
|
108
|
+
const completions = [...entry.children, ...entry.options].join(' ');
|
|
109
|
+
cases.push(` ${shSingleQuote(key)})\n` +
|
|
110
|
+
` COMPREPLY=( $(compgen -W ${shSingleQuote(completions)} -- "$cur") )\n` +
|
|
111
|
+
` return 0\n` +
|
|
112
|
+
` ;;`);
|
|
113
|
+
}
|
|
114
|
+
return [
|
|
115
|
+
'# monday-cli bash completion',
|
|
116
|
+
'# Generated by `monday completion bash` — do not edit by hand.',
|
|
117
|
+
'# Install: append the output to your bashrc, e.g.',
|
|
118
|
+
'# monday completion bash >> ~/.bashrc',
|
|
119
|
+
'',
|
|
120
|
+
'_monday_completion() {',
|
|
121
|
+
' local cur prev words cword',
|
|
122
|
+
' COMPREPLY=()',
|
|
123
|
+
' cur="${COMP_WORDS[COMP_CWORD]}"',
|
|
124
|
+
' prev="${COMP_WORDS[COMP_CWORD-1]}"',
|
|
125
|
+
' words=("${COMP_WORDS[@]}")',
|
|
126
|
+
' cword=$COMP_CWORD',
|
|
127
|
+
'',
|
|
128
|
+
' # Build the command path from the words BEFORE the current',
|
|
129
|
+
' # cursor position. Flags (anything starting with `-`) and the',
|
|
130
|
+
' # binary name itself are skipped — only positional verbs',
|
|
131
|
+
' # contribute to the path lookup.',
|
|
132
|
+
' local path=""',
|
|
133
|
+
' local i=1',
|
|
134
|
+
' while [ $i -lt $cword ]; do',
|
|
135
|
+
' local w="${words[$i]}"',
|
|
136
|
+
' case "$w" in',
|
|
137
|
+
' -*) ;;',
|
|
138
|
+
' *)',
|
|
139
|
+
' if [ -z "$path" ]; then',
|
|
140
|
+
' path="$w"',
|
|
141
|
+
' else',
|
|
142
|
+
' path="$path $w"',
|
|
143
|
+
' fi',
|
|
144
|
+
' ;;',
|
|
145
|
+
' esac',
|
|
146
|
+
' i=$((i+1))',
|
|
147
|
+
' done',
|
|
148
|
+
'',
|
|
149
|
+
' case "$path" in',
|
|
150
|
+
...cases,
|
|
151
|
+
' *)',
|
|
152
|
+
' COMPREPLY=()',
|
|
153
|
+
' return 0',
|
|
154
|
+
' ;;',
|
|
155
|
+
' esac',
|
|
156
|
+
'}',
|
|
157
|
+
'',
|
|
158
|
+
'complete -F _monday_completion monday',
|
|
159
|
+
'',
|
|
160
|
+
].join('\n');
|
|
161
|
+
};
|
|
162
|
+
const buildZshScript = (paths) => {
|
|
163
|
+
// compadd takes one shell word per completion candidate after `--`,
|
|
164
|
+
// so we single-quote each item individually rather than pre-joining
|
|
165
|
+
// into a single space-delimited string. Quoting per-item keeps the
|
|
166
|
+
// emitted compadd line resilient to verb / flag names that ever
|
|
167
|
+
// contain whitespace or quoting metacharacters (none today, but
|
|
168
|
+
// future v0.5+ verbs added by other agents shouldn't have to know
|
|
169
|
+
// the script-emit invariant to stay correct).
|
|
170
|
+
const cases = paths.map((entry) => {
|
|
171
|
+
const key = entry.path.join(' ');
|
|
172
|
+
const items = [...entry.children, ...entry.options]
|
|
173
|
+
.map(shSingleQuote)
|
|
174
|
+
.join(' ');
|
|
175
|
+
return (` ${shSingleQuote(key)})\n` +
|
|
176
|
+
` compadd -- ${items}\n` +
|
|
177
|
+
` return 0\n` +
|
|
178
|
+
` ;;`);
|
|
179
|
+
});
|
|
180
|
+
return [
|
|
181
|
+
'#compdef monday',
|
|
182
|
+
'# monday-cli zsh completion',
|
|
183
|
+
'# Generated by `monday completion zsh` — do not edit by hand.',
|
|
184
|
+
'# Install: append the output to your zshrc, e.g.',
|
|
185
|
+
'# monday completion zsh >> ~/.zshrc',
|
|
186
|
+
'',
|
|
187
|
+
'_monday() {',
|
|
188
|
+
' local -a words_arr',
|
|
189
|
+
' words_arr=("${words[@]}")',
|
|
190
|
+
' local cword=$CURRENT',
|
|
191
|
+
'',
|
|
192
|
+
' # Build the command path from the words BEFORE the current',
|
|
193
|
+
' # cursor position. Flags and the binary name itself are',
|
|
194
|
+
' # skipped — only positional verbs feed the lookup.',
|
|
195
|
+
' local path=""',
|
|
196
|
+
' local i=2',
|
|
197
|
+
' while [ $i -lt $cword ]; do',
|
|
198
|
+
' local w="${words_arr[$i]}"',
|
|
199
|
+
' case "$w" in',
|
|
200
|
+
' -*) ;;',
|
|
201
|
+
' *)',
|
|
202
|
+
' if [ -z "$path" ]; then',
|
|
203
|
+
' path="$w"',
|
|
204
|
+
' else',
|
|
205
|
+
' path="$path $w"',
|
|
206
|
+
' fi',
|
|
207
|
+
' ;;',
|
|
208
|
+
' esac',
|
|
209
|
+
' i=$((i+1))',
|
|
210
|
+
' done',
|
|
211
|
+
'',
|
|
212
|
+
' case "$path" in',
|
|
213
|
+
...cases,
|
|
214
|
+
' *)',
|
|
215
|
+
' return 0',
|
|
216
|
+
' ;;',
|
|
217
|
+
' esac',
|
|
218
|
+
'}',
|
|
219
|
+
'',
|
|
220
|
+
'_monday "$@"',
|
|
221
|
+
'',
|
|
222
|
+
].join('\n');
|
|
223
|
+
};
|
|
224
|
+
const buildFishScript = (paths) => {
|
|
225
|
+
const lines = [
|
|
226
|
+
'# monday-cli fish completion',
|
|
227
|
+
'# Generated by `monday completion fish` — do not edit by hand.',
|
|
228
|
+
'# Install: write the output to your fish completions dir, e.g.',
|
|
229
|
+
'# monday completion fish > ~/.config/fish/completions/monday.fish',
|
|
230
|
+
'',
|
|
231
|
+
'# Disable file completion globally for the monday command; per-',
|
|
232
|
+
'# scope rules below re-enable suggestions where appropriate.',
|
|
233
|
+
'complete -c monday -f',
|
|
234
|
+
'',
|
|
235
|
+
];
|
|
236
|
+
for (const entry of paths) {
|
|
237
|
+
const depth = entry.path.length;
|
|
238
|
+
// The condition predicate enumerates how to detect "we are at',
|
|
239
|
+
// this command depth": at depth 0, no subcommand seen; at depth
|
|
240
|
+
// N, every prior path token has been seen AND the next token
|
|
241
|
+
// has not.
|
|
242
|
+
const seenChain = entry.path
|
|
243
|
+
.map((p) => `__fish_seen_subcommand_from ${p}`)
|
|
244
|
+
.join('; and ');
|
|
245
|
+
const cond = depth === 0
|
|
246
|
+
? '__fish_use_subcommand'
|
|
247
|
+
: seenChain;
|
|
248
|
+
// Emit one `complete -c monday -n '<cond>' -a 'name' -d 'description'`
|
|
249
|
+
// per direct child (sub-noun / sub-verb).
|
|
250
|
+
for (const child of entry.children) {
|
|
251
|
+
const desc = `(${entry.path.length === 0 ? 'top-level' : entry.path.join(' ')} ${child})`;
|
|
252
|
+
lines.push(`complete -c monday -n ${shSingleQuote(cond)} -a ${shSingleQuote(child)} -d ${shSingleQuote(desc)}`);
|
|
253
|
+
}
|
|
254
|
+
// Emit one `complete -c monday -n '<cond>' -l <flag>` per option
|
|
255
|
+
// long-form. The fish completion model is per-condition: globals
|
|
256
|
+
// register at the root (no `-n` predicate so they apply
|
|
257
|
+
// everywhere); per-verb locals register at their specific depth
|
|
258
|
+
// with the matching `__fish_seen_subcommand_from ...` predicate
|
|
259
|
+
// so the suggestion only fires inside the right command scope.
|
|
260
|
+
// Without the per-depth local-flag emission, fish would lose
|
|
261
|
+
// every verb-specific flag (e.g. `doc list --workspace`,
|
|
262
|
+
// `dev sprint list --state`) — Codex IMPL round-1 P2-1 catch.
|
|
263
|
+
const flagsToEmit = depth === 0 ? entry.options : entry.localOptions;
|
|
264
|
+
for (const flag of flagsToEmit) {
|
|
265
|
+
// Strip the leading `--` from the long form for fish's -l.
|
|
266
|
+
// Commander's long-form always starts with `--`; the `: flag`
|
|
267
|
+
// arm is defensive against a hypothetical bare-name input.
|
|
268
|
+
/* c8 ignore next */
|
|
269
|
+
const long = flag.startsWith('--') ? flag.slice(2) : flag;
|
|
270
|
+
if (depth === 0) {
|
|
271
|
+
lines.push(`complete -c monday -l ${shSingleQuote(long)}`);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
lines.push(`complete -c monday -n ${shSingleQuote(cond)} -l ${shSingleQuote(long)}`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
lines.push('');
|
|
279
|
+
return lines.join('\n');
|
|
280
|
+
};
|
|
281
|
+
const buildCompletionScript = (shell, program) => {
|
|
282
|
+
const tree = buildCompletionTree(program);
|
|
283
|
+
const paths = flattenPaths(tree);
|
|
284
|
+
switch (shell) {
|
|
285
|
+
case 'bash':
|
|
286
|
+
return buildBashScript(paths);
|
|
287
|
+
case 'zsh':
|
|
288
|
+
return buildZshScript(paths);
|
|
289
|
+
case 'fish':
|
|
290
|
+
return buildFishScript(paths);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Exposed for unit-test access — lets the test suite build a tree
|
|
295
|
+
* against a synthetic commander program (without spinning the full
|
|
296
|
+
* runner) and assert structural properties.
|
|
297
|
+
*/
|
|
298
|
+
export const _internals = {
|
|
299
|
+
buildCompletionTree,
|
|
300
|
+
flattenPaths,
|
|
301
|
+
buildCompletionScript,
|
|
302
|
+
stripPlaceholders,
|
|
303
|
+
};
|
|
304
|
+
export const completionCommand = {
|
|
305
|
+
name: 'completion',
|
|
306
|
+
summary: 'Emit a shell-completion script (bash | zsh | fish)',
|
|
307
|
+
examples: [
|
|
308
|
+
'monday completion bash >> ~/.bashrc',
|
|
309
|
+
'monday completion zsh >> ~/.zshrc',
|
|
310
|
+
'monday completion fish > ~/.config/fish/completions/monday.fish',
|
|
311
|
+
'monday completion bash --json',
|
|
312
|
+
],
|
|
313
|
+
idempotent: true,
|
|
314
|
+
inputSchema,
|
|
315
|
+
outputSchema: completionOutputSchema,
|
|
316
|
+
attach: (program, ctx) => {
|
|
317
|
+
program
|
|
318
|
+
.command('completion <shell>')
|
|
319
|
+
.description(completionCommand.summary)
|
|
320
|
+
.addHelpText('after', [
|
|
321
|
+
'',
|
|
322
|
+
'Examples:',
|
|
323
|
+
...completionCommand.examples.map((e) => ` ${e}`),
|
|
324
|
+
'',
|
|
325
|
+
'Notes:',
|
|
326
|
+
' - Default output is the raw shell script on stdout (no envelope).',
|
|
327
|
+
' The standard install pipes to your rc file (see examples).',
|
|
328
|
+
' - --json wraps the script in the §6 envelope (data: { shell, script }).',
|
|
329
|
+
' - --table / --output table|text|ndjson are rejected (not applicable to a script).',
|
|
330
|
+
'',
|
|
331
|
+
].join('\n'))
|
|
332
|
+
.action((shellArg) => {
|
|
333
|
+
// Argv parse boundary — validates the positional against
|
|
334
|
+
// the closed 3-value enum BEFORE the output-format dispatch
|
|
335
|
+
// runs, so a premature `monday completion floppy` invocation
|
|
336
|
+
// surfaces `usage_error` from the parse boundary (NOT a
|
|
337
|
+
// confusing "format not applicable" message).
|
|
338
|
+
const parsed = parseArgv(completionCommand.inputSchema, {
|
|
339
|
+
shell: shellArg,
|
|
340
|
+
});
|
|
341
|
+
const globalFlags = parseGlobalFlags(program.opts(), ctx.env);
|
|
342
|
+
// Detect whether the caller explicitly opted into an output
|
|
343
|
+
// format. The cli-design §3.1 #2 raw-bytes carve-out is
|
|
344
|
+
// explicit: default behaviour (no flag, no env) emits raw
|
|
345
|
+
// bytes regardless of TTY / pipe context. Going through
|
|
346
|
+
// `selectOutput` would silently collapse "no opt-in" to
|
|
347
|
+
// either `table` (TTY) or `json` (pipe) — neither matches
|
|
348
|
+
// the carve-out's "raw bytes by default" contract.
|
|
349
|
+
const envOutput = ctx.env.MONDAY_OUTPUT;
|
|
350
|
+
const envOptIn = envOutput !== undefined && envOutput !== '';
|
|
351
|
+
const optedIn = globalFlags.json ||
|
|
352
|
+
globalFlags.table ||
|
|
353
|
+
globalFlags.output !== undefined ||
|
|
354
|
+
envOptIn;
|
|
355
|
+
if (!optedIn) {
|
|
356
|
+
// Default raw-bytes mode. Writes the script directly to
|
|
357
|
+
// stdout with NO envelope wrap — the standard install flow
|
|
358
|
+
// `monday completion bash >> ~/.bashrc` relies on this. No
|
|
359
|
+
// secret-redaction pass is needed: the script bytes are
|
|
360
|
+
// built from `program.commands` + global option names,
|
|
361
|
+
// both compile-time constants with no env interpolation.
|
|
362
|
+
// The integration test suite pins a LEAK_CANARY assertion
|
|
363
|
+
// to catch future drift.
|
|
364
|
+
const script = buildCompletionScript(parsed.shell, program);
|
|
365
|
+
ctx.stdout.write(script);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
// Reject inapplicable formats BEFORE building the script.
|
|
369
|
+
// The cli-design §3.1 #2 carve-out documents three modes:
|
|
370
|
+
// default raw bytes, `--json` envelope, and rejection for
|
|
371
|
+
// every other format. `text` and `ndjson` are accessible
|
|
372
|
+
// only via `--output <fmt>` (NOT as standalone `--text` /
|
|
373
|
+
// `--ndjson` shorthand flags — only `--json` and `--table`
|
|
374
|
+
// are shorthands per §4.4).
|
|
375
|
+
if (globalFlags.table) {
|
|
376
|
+
throw new UsageError('output format not applicable to monday completion: ' +
|
|
377
|
+
'--table is rejected (the verb emits a shell script — ' +
|
|
378
|
+
'raw bytes by default, JSON envelope via --json).');
|
|
379
|
+
}
|
|
380
|
+
if (globalFlags.output === 'table' ||
|
|
381
|
+
globalFlags.output === 'text' ||
|
|
382
|
+
globalFlags.output === 'ndjson') {
|
|
383
|
+
throw new UsageError(`output format not applicable to monday completion: ` +
|
|
384
|
+
`--output ${globalFlags.output} is rejected (the verb emits ` +
|
|
385
|
+
`a shell script — raw bytes by default, JSON envelope via --json).`);
|
|
386
|
+
}
|
|
387
|
+
// Reject MONDAY_OUTPUT=<non-json> on the env path too. The
|
|
388
|
+
// env opt-in is symmetric with the flag opt-in: only
|
|
389
|
+
// MONDAY_OUTPUT=json maps onto the envelope mode; everything
|
|
390
|
+
// else routes through this rejection.
|
|
391
|
+
if (globalFlags.output === undefined &&
|
|
392
|
+
!globalFlags.json &&
|
|
393
|
+
envOptIn &&
|
|
394
|
+
envOutput !== 'json') {
|
|
395
|
+
throw new UsageError(`output format not applicable to monday completion: ` +
|
|
396
|
+
`MONDAY_OUTPUT=${envOutput} is rejected (the verb emits ` +
|
|
397
|
+
`a shell script — raw bytes by default, JSON envelope via --json).`);
|
|
398
|
+
}
|
|
399
|
+
// At this point the caller opted INTO the `--json` envelope
|
|
400
|
+
// path (either `--json`, `--output json`, or
|
|
401
|
+
// `MONDAY_OUTPUT=json`). Build the script + emit through
|
|
402
|
+
// the standard §6 envelope. `source: 'none'` mirrors
|
|
403
|
+
// `monday config show` / `monday config path` cadence for
|
|
404
|
+
// CLI-internal verbs — no Monday API call, no cache, so the
|
|
405
|
+
// data-source field carries the same "no upstream" value.
|
|
406
|
+
const script = buildCompletionScript(parsed.shell, program);
|
|
407
|
+
emitSuccess({
|
|
408
|
+
ctx,
|
|
409
|
+
data: { shell: parsed.shell, script },
|
|
410
|
+
schema: completionCommand.outputSchema,
|
|
411
|
+
programOpts: program.opts(),
|
|
412
|
+
source: 'none',
|
|
413
|
+
cacheAgeSeconds: null,
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
//# sourceMappingURL=completion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAqFA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAU,CAAC;AAGlE;;;;GAIG;AACH,MAAM,CAAC,MAA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C,IACE,WAAW,CAAC,MAAM,KAAK,SAAS;gBAChC,CAAC,WAAW,CAAC,IAAI;gBACjB,QAAQ;gBACR,SAAS,KAAK,MAAM,EACpB,CAAC;gBACD,MAAM,IAAI,UAAU,CAClB,qDAAqD;oBACnD,iBAAiB,SAAS,+BAA+B;oBACzD,mEAAmE,CACtE,CAAC;YACJ,CAAC;YAED,4DAA4D;YAC5D,6CAA6C;YAC7C,yDAAyD;YACzD,qDAAqD;YACrD,0DAA0D;YAC1D,4DAA4D;YAC5D,0DAA0D;YAC1D,MAAM,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC5D,WAAW,CAAC;gBACV,GAAG;gBACH,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE;gBACrC,MAAM,EAAE,iBAAiB,CAAC,YAAY;gBACtC,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE;gBAC3B,MAAM,EAAE,MAAM;gBACd,eAAe,EAAE,IAAI;aACtB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `monday doc append-markdown <doc-id> (--markdown <file|-> |
|
|
3
|
+
* --markdown-string <s>) [--after <bid>] [--dry-run]` — append a
|
|
4
|
+
* parsed-markdown payload as new blocks at the tail of an existing
|
|
5
|
+
* workdoc (`cli-design.md` §4.3 DOC section + §13 v0.5 entry;
|
|
6
|
+
* `v0.5-plan.md` §3 M37 + §8 D12-D13).
|
|
7
|
+
*
|
|
8
|
+
* **Wire shape.** Single `add_content_to_doc_from_markdown(docId,
|
|
9
|
+
* markdown, afterBlockId?) → DocBlocksFromMarkdownResult` round-trip
|
|
10
|
+
* via {@link addContentToDocFromMarkdown} against `mutation
|
|
11
|
+
* AddContentToDocFromMarkdown` with `operationName:
|
|
12
|
+
* 'AddContentToDocFromMarkdown'` (R-NEW-37 W2 audit-point).
|
|
13
|
+
* Custom-OBJECT return shape: `{success!, block_ids?, error?}`.
|
|
14
|
+
*
|
|
15
|
+
* **camelCase wire-arg note.** `add_content_to_doc_from_markdown`
|
|
16
|
+
* uses camelCase `docId` / `afterBlockId` on the wire (Finding 7);
|
|
17
|
+
* CLI argv stays kebab-case (`<doc-id>` positional / `--after <bid>`);
|
|
18
|
+
* error envelope `details.*` keys stay snake_case (`details.doc_id` /
|
|
19
|
+
* `details.after_block_id`). 5th supporting site for R-NEW-41 at the
|
|
20
|
+
* canonical asymmetry note (see `src/api/documents.ts` module header).
|
|
21
|
+
*
|
|
22
|
+
* **Argv shape.**
|
|
23
|
+
*
|
|
24
|
+
* - `<doc-id>` — required positional (Monday's
|
|
25
|
+
* `add_content_to_doc_from_markdown.docId` is `ID!`). Brand-
|
|
26
|
+
* validated via {@link DocIdSchema}.
|
|
27
|
+
* - `--markdown <file|->` OR `--markdown-string <s>` — **mutually-
|
|
28
|
+
* exclusive content source; exactly one required.** Mirrors the
|
|
29
|
+
* `import-html` `--html` / `--html-string` shape verbatim. File
|
|
30
|
+
* path form supports `-` for stdin per cli-design §3.1; inline
|
|
31
|
+
* form caps at {@link MAX_DOC_IMPORT_PAYLOAD_BYTES} bytes UTF-8
|
|
32
|
+
* at parse boundary per D13 closure (same empirical threshold
|
|
33
|
+
* as the HTML side — the wire-side cap is transport-layer-wide,
|
|
34
|
+
* not per-mutation).
|
|
35
|
+
* - `--after <bid>` — optional opaque block ID (maps to wire
|
|
36
|
+
* `afterBlockId: String`). Brand-validated via
|
|
37
|
+
* {@link DocBlockIdSchema}. Absent → markdown blocks land at the
|
|
38
|
+
* document tail (append-end semantics per Monday's probe
|
|
39
|
+
* description: "Use this to append content to the end of a
|
|
40
|
+
* document or insert content after a specific block").
|
|
41
|
+
*
|
|
42
|
+
* **Output envelope.** Custom-OBJECT projection per D12 — `data: {
|
|
43
|
+
* doc_id (echoed input), block_ids, success: true }`. Echoes the
|
|
44
|
+
* input `<doc-id>` so agents piping the envelope into a follow-up
|
|
45
|
+
* `monday doc get <doc-id>` keep the parent doc context inline.
|
|
46
|
+
* `block_ids` is the wire's full list of NEWLY-CREATED block ids
|
|
47
|
+
* preserved in markdown-source order. **Empty `block_ids: []` IS a
|
|
48
|
+
* valid success shape** (non-empty markdown that Monday parses to
|
|
49
|
+
* zero convertible blocks — e.g. comments-only or whitespace-only
|
|
50
|
+
* post-Monday-parse); the CLI does not rewrap empty-blocks as
|
|
51
|
+
* failure. (Note: empty / whitespace-only input is rejected at the
|
|
52
|
+
* parse / read boundary — `--markdown-string` rejects at parse via
|
|
53
|
+
* the schema's `.refine()`; file / stdin rejects at the runtime
|
|
54
|
+
* read boundary via {@link readSourceContent}'s empty-after-trim
|
|
55
|
+
* check — so the empty-`block_ids` success path is only reachable
|
|
56
|
+
* for non-empty input that Monday's parser collapses to zero
|
|
57
|
+
* structural blocks.)
|
|
58
|
+
*
|
|
59
|
+
* **Failure mapping** per D12 closure:
|
|
60
|
+
*
|
|
61
|
+
* - `success: false + populated error` → `validation_failed` with
|
|
62
|
+
* `details: { doc_id, error, hint }`.
|
|
63
|
+
* - `success: false + empty/null error` → `internal_error` with
|
|
64
|
+
* wire-regression hint.
|
|
65
|
+
* - `success: true + null block_ids` → `internal_error` (Monday
|
|
66
|
+
* promises a non-null `block_ids` list on success).
|
|
67
|
+
* - Oversized inline `--markdown-string` at parse boundary →
|
|
68
|
+
* `usage_error.details.issues[{path: 'markdownString', message:
|
|
69
|
+
* '--markdown-string exceeds the 256000-byte wire-side limit
|
|
70
|
+
* ...'}]` from `parseArgv`'s zod-issues envelope (D13 closure).
|
|
71
|
+
* The `usage_error` rejection surfaces ahead of any wire
|
|
72
|
+
* dispatch.
|
|
73
|
+
* - Oversized file payload at runtime →
|
|
74
|
+
* `readSourceContent` rejects with `usage_error` carrying
|
|
75
|
+
* `details: { source: 'file' | 'stdin', size_bytes, limit_bytes,
|
|
76
|
+
* file_path? }`.
|
|
77
|
+
* - Non-existent / inaccessible `<doc-id>` → bubbles via Monday's
|
|
78
|
+
* wire-side `errors[]` → typed `ApiError` (`not_found` or
|
|
79
|
+
* `forbidden`).
|
|
80
|
+
*
|
|
81
|
+
* **Dry-run shape** per cli-design §6.4 mutation-dry-run variant.
|
|
82
|
+
* Minimal envelope listing the planned
|
|
83
|
+
* `add_content_to_doc_from_markdown` operation + resolved input
|
|
84
|
+
* slots (`doc_id`, optional `after_block_id`, `markdown_source`
|
|
85
|
+
* descriptor — file path / `'(stdin)'` / `'(inline)'`). Markdown
|
|
86
|
+
* payload itself omitted (can be hundreds of KB); agents see what
|
|
87
|
+
* would be sent, not the bytes. No preflight read; `meta.source:
|
|
88
|
+
* 'none'`.
|
|
89
|
+
*
|
|
90
|
+
* **Idempotent: false.** Re-running creates a SECOND set of blocks
|
|
91
|
+
* carrying the same markdown content (Monday's wire does not dedupe).
|
|
92
|
+
* Agents that need idempotency must pair with a `monday doc get
|
|
93
|
+
* <doc-id>` lookup first to confirm the content isn't already
|
|
94
|
+
* present, OR use `monday doc block-delete` + `block-create`
|
|
95
|
+
* (M36) for fine-grained per-block control.
|
|
96
|
+
*
|
|
97
|
+
* **Permission-sensitive.** Tokens lacking workdoc-write scope on
|
|
98
|
+
* the target doc surface `forbidden`.
|
|
99
|
+
*
|
|
100
|
+
* **Runtime body landed at v0.5-M37 IMPL.** Same shape as
|
|
101
|
+
* `import-html.ts` — `parseArgv` BEFORE `resolveClient`; lifted
|
|
102
|
+
* {@link readSourceContent} for file/stdin/inline with runtime size
|
|
103
|
+
* guard; dry-run emits minimal planned changes; live path dispatches
|
|
104
|
+
* {@link addContentToDocFromMarkdown} + projects via `emitMutation`.
|
|
105
|
+
*/
|
|
106
|
+
import { z } from 'zod';
|
|
107
|
+
import { type CommandModule } from '../types.js';
|
|
108
|
+
import { type DocAppendMarkdownOutput } from '../../api/documents.js';
|
|
109
|
+
declare const inputSchema: z.ZodObject<{
|
|
110
|
+
docId: z.core.$ZodBranded<z.ZodString, "DocId", "out">;
|
|
111
|
+
markdown: z.ZodOptional<z.ZodString>;
|
|
112
|
+
markdownString: z.ZodOptional<z.ZodString>;
|
|
113
|
+
after: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DocBlockId", "out">>;
|
|
114
|
+
}, z.core.$strict>;
|
|
115
|
+
export declare const docAppendMarkdownCommand: CommandModule<z.infer<typeof inputSchema>, DocAppendMarkdownOutput>;
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=append-markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"append-markdown.d.ts","sourceRoot":"","sources":["../../../src/commands/doc/append-markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAKnE,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,wBAAwB,CAAC;AAGhC,QAAA,MAAM,WAAW;;;;;kBA2Cd,CAAC;AAeJ,eAAO,MAAM,wBAAwB,EAAE,aAAa,CAClD,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,EAC3B,uBAAuB,CAuGxB,CAAC"}
|