@doist/twist-cli 2.2.0 → 2.4.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 +19 -0
- package/dist/__mocks__/chalk.d.ts +3 -0
- package/dist/__mocks__/chalk.d.ts.map +1 -0
- package/dist/__mocks__/chalk.js +8 -0
- package/dist/__mocks__/chalk.js.map +1 -0
- package/dist/__tests__/auth.test.js +1 -9
- package/dist/__tests__/auth.test.js.map +1 -1
- package/dist/__tests__/channel.test.js +1 -9
- package/dist/__tests__/channel.test.js.map +1 -1
- package/dist/__tests__/completion.test.d.ts +2 -0
- package/dist/__tests__/completion.test.d.ts.map +1 -0
- package/dist/__tests__/completion.test.js +106 -0
- package/dist/__tests__/completion.test.js.map +1 -0
- package/dist/__tests__/conversation.test.js +1 -9
- package/dist/__tests__/conversation.test.js.map +1 -1
- package/dist/__tests__/inbox.test.js +1 -9
- package/dist/__tests__/inbox.test.js.map +1 -1
- package/dist/__tests__/msg.test.js +1 -9
- package/dist/__tests__/msg.test.js.map +1 -1
- package/dist/__tests__/search.test.js +1 -6
- package/dist/__tests__/search.test.js.map +1 -1
- package/dist/__tests__/skill.test.js +1 -8
- package/dist/__tests__/skill.test.js.map +1 -1
- package/dist/__tests__/spinner.test.js +1 -11
- package/dist/__tests__/spinner.test.js.map +1 -1
- package/dist/__tests__/thread.test.js +1 -9
- package/dist/__tests__/thread.test.js.map +1 -1
- package/dist/__tests__/update.test.d.ts +2 -0
- package/dist/__tests__/update.test.d.ts.map +1 -0
- package/dist/__tests__/update.test.js +166 -0
- package/dist/__tests__/update.test.js.map +1 -0
- package/dist/__tests__/user.test.js +1 -6
- package/dist/__tests__/user.test.js.map +1 -1
- package/dist/commands/completion.d.ts +3 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +121 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +3 -1
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/thread.d.ts.map +1 -1
- package/dist/commands/thread.js +3 -1
- package/dist/commands/thread.js.map +1 -1
- package/dist/commands/update.d.ts +11 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +83 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/index.js +85 -65
- package/dist/index.js.map +1 -1
- package/dist/lib/completion.d.ts +31 -0
- package/dist/lib/completion.d.ts.map +1 -0
- package/dist/lib/completion.js +173 -0
- package/dist/lib/completion.js.map +1 -0
- package/dist/lib/oauth.d.ts.map +1 -1
- package/dist/lib/oauth.js +1 -1
- package/dist/lib/oauth.js.map +1 -1
- package/dist/lib/skills/content.d.ts +2 -2
- package/dist/lib/skills/content.d.ts.map +1 -1
- package/dist/lib/skills/content.js +19 -0
- package/dist/lib/skills/content.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -2,55 +2,38 @@
|
|
|
2
2
|
import { program } from 'commander';
|
|
3
3
|
import pkg from '../package.json' with { type: 'json' };
|
|
4
4
|
import { startEarlySpinner, stopEarlySpinner } from './lib/spinner.js';
|
|
5
|
+
const loadWorkspaceCommand = async () => (await import('./commands/workspace.js')).registerWorkspaceCommand;
|
|
6
|
+
const loadUserCommand = async () => (await import('./commands/user.js')).registerUserCommand;
|
|
7
|
+
const loadChannelCommand = async () => (await import('./commands/channel.js')).registerChannelCommand;
|
|
8
|
+
const loadInboxCommand = async () => (await import('./commands/inbox.js')).registerInboxCommand;
|
|
9
|
+
const loadThreadCommand = async () => (await import('./commands/thread.js')).registerThreadCommand;
|
|
10
|
+
const loadConversationCommand = async () => (await import('./commands/conversation.js')).registerConversationCommand;
|
|
11
|
+
const loadMsgCommand = async () => (await import('./commands/msg.js')).registerMsgCommand;
|
|
12
|
+
const loadSearchCommand = async () => (await import('./commands/search.js')).registerSearchCommand;
|
|
13
|
+
const loadReactCommand = async () => (await import('./commands/react.js')).registerReactCommand;
|
|
14
|
+
const loadAuthCommand = async () => (await import('./commands/auth.js')).registerAuthCommand;
|
|
15
|
+
const loadSkillCommand = async () => (await import('./commands/skill.js')).registerSkillCommand;
|
|
16
|
+
const loadViewCommand = async () => (await import('./commands/view.js')).registerViewCommand;
|
|
17
|
+
const loadCompletionCommand = async () => (await import('./commands/completion.js')).registerCompletionCommand;
|
|
18
|
+
const loadUpdateCommand = async () => (await import('./commands/update.js')).registerUpdateCommand;
|
|
5
19
|
const commands = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
],
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
],
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
],
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
],
|
|
22
|
-
|
|
23
|
-
'Thread operations',
|
|
24
|
-
async () => (await import('./commands/thread.js')).registerThreadCommand,
|
|
25
|
-
],
|
|
26
|
-
conversation: [
|
|
27
|
-
'Conversation (DM/group) operations',
|
|
28
|
-
async () => (await import('./commands/conversation.js')).registerConversationCommand,
|
|
29
|
-
],
|
|
30
|
-
msg: [
|
|
31
|
-
'Conversation message operations (view, update, delete)',
|
|
32
|
-
async () => (await import('./commands/msg.js')).registerMsgCommand,
|
|
33
|
-
],
|
|
34
|
-
search: [
|
|
35
|
-
'Search content across a workspace',
|
|
36
|
-
async () => (await import('./commands/search.js')).registerSearchCommand,
|
|
37
|
-
],
|
|
38
|
-
react: [
|
|
39
|
-
'Add an emoji reaction (target-type: thread, comment, message)',
|
|
40
|
-
async () => (await import('./commands/react.js')).registerReactCommand,
|
|
41
|
-
],
|
|
42
|
-
auth: [
|
|
43
|
-
'Manage authentication',
|
|
44
|
-
async () => (await import('./commands/auth.js')).registerAuthCommand,
|
|
45
|
-
],
|
|
46
|
-
skill: [
|
|
47
|
-
'Manage agent skill integrations',
|
|
48
|
-
async () => (await import('./commands/skill.js')).registerSkillCommand,
|
|
49
|
-
],
|
|
50
|
-
view: [
|
|
51
|
-
'View a Twist entity by URL',
|
|
52
|
-
async () => (await import('./commands/view.js')).registerViewCommand,
|
|
53
|
-
],
|
|
20
|
+
workspaces: ['List all workspaces', loadWorkspaceCommand],
|
|
21
|
+
workspace: ['Manage workspace', loadWorkspaceCommand],
|
|
22
|
+
user: ['Show current user info', loadUserCommand],
|
|
23
|
+
users: ['List users in a workspace', loadUserCommand],
|
|
24
|
+
channels: ['List channels in a workspace', loadChannelCommand],
|
|
25
|
+
inbox: ['Show inbox threads', loadInboxCommand],
|
|
26
|
+
thread: ['Thread operations', loadThreadCommand],
|
|
27
|
+
conversation: ['Conversation (DM/group) operations', loadConversationCommand],
|
|
28
|
+
msg: ['Conversation message operations (view, update, delete)', loadMsgCommand],
|
|
29
|
+
search: ['Search content across a workspace', loadSearchCommand],
|
|
30
|
+
react: ['Add an emoji reaction (target-type: thread, comment, message)', loadReactCommand],
|
|
31
|
+
unreact: ['Remove an emoji reaction (target-type: thread, comment, message)', loadReactCommand],
|
|
32
|
+
auth: ['Manage authentication', loadAuthCommand],
|
|
33
|
+
skill: ['Manage agent skill integrations', loadSkillCommand],
|
|
34
|
+
view: ['View a Twist entity by URL', loadViewCommand],
|
|
35
|
+
completion: ['Manage shell completions', loadCompletionCommand],
|
|
36
|
+
update: ['Update the CLI to the latest version', loadUpdateCommand],
|
|
54
37
|
};
|
|
55
38
|
const commandAliases = {
|
|
56
39
|
convo: 'conversation',
|
|
@@ -76,25 +59,62 @@ for (const [name, [description]] of Object.entries(commands)) {
|
|
|
76
59
|
cmd.alias(alias);
|
|
77
60
|
}
|
|
78
61
|
}
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
62
|
+
// completion-server needs the command tree to walk for completions.
|
|
63
|
+
// Only load the completion module + the specific command being completed
|
|
64
|
+
// (extracted from COMP_LINE) to keep startup fast.
|
|
65
|
+
if (process.argv[2] === 'completion-server') {
|
|
66
|
+
const { parseCompLine } = await import('./lib/completion.js');
|
|
67
|
+
const compWords = parseCompLine(process.env.COMP_LINE ?? '');
|
|
68
|
+
const compCmd = compWords.find((w) => !w.startsWith('-') && (w in commands || w in commandAliases));
|
|
69
|
+
const resolvedCompCmd = compCmd ? (commandAliases[compCmd] ?? compCmd) : undefined;
|
|
70
|
+
const completionLoader = commands.completion[1];
|
|
71
|
+
// Build loader set so command aliases that share a module only register once.
|
|
72
|
+
const loadersToRun = resolvedCompCmd
|
|
73
|
+
? [
|
|
74
|
+
completionLoader,
|
|
75
|
+
...(commands[resolvedCompCmd][1] !== completionLoader
|
|
76
|
+
? [commands[resolvedCompCmd][1]]
|
|
77
|
+
: []),
|
|
78
|
+
]
|
|
79
|
+
: [...new Set(Object.values(commands).map(([, loader]) => loader))];
|
|
80
|
+
for (const [name, [, loader]] of Object.entries(commands)) {
|
|
81
|
+
if (!loadersToRun.includes(loader))
|
|
82
|
+
continue;
|
|
83
|
+
const idx = program.commands.findIndex((c) => c.name() === name);
|
|
84
|
+
if (idx !== -1)
|
|
85
|
+
program.commands.splice(idx, 1);
|
|
86
|
+
}
|
|
87
|
+
await Promise.all(loadersToRun.map(async (loader) => {
|
|
92
88
|
const register = await loader();
|
|
93
89
|
register(program);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// Detect which command is being invoked (resolve aliases first)
|
|
94
|
+
const commandArg = process.argv
|
|
95
|
+
.slice(2)
|
|
96
|
+
.find((a) => !a.startsWith('-') && (a in commands || a in commandAliases));
|
|
97
|
+
const commandName = commandArg ? (commandAliases[commandArg] ?? commandArg) : undefined;
|
|
98
|
+
if (commandName && commands[commandName]) {
|
|
99
|
+
const loader = commands[commandName][1];
|
|
100
|
+
// Remove all placeholders that map to the same loader to avoid
|
|
101
|
+
// duplicate command registration from alias entries.
|
|
102
|
+
for (const [name, [, entryLoader]] of Object.entries(commands)) {
|
|
103
|
+
if (entryLoader !== loader)
|
|
104
|
+
continue;
|
|
105
|
+
const idx = program.commands.findIndex((c) => c.name() === name);
|
|
106
|
+
if (idx !== -1)
|
|
107
|
+
program.commands.splice(idx, 1);
|
|
108
|
+
}
|
|
109
|
+
startEarlySpinner();
|
|
110
|
+
try {
|
|
111
|
+
const register = await loader();
|
|
112
|
+
register(program);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
stopEarlySpinner();
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
98
118
|
}
|
|
99
119
|
}
|
|
100
120
|
try {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAgB,OAAO,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEtE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAgB,OAAO,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEtE,MAAM,oBAAoB,GAAG,KAAK,IAAI,EAAE,CACpC,CAAC,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,wBAAwB,CAAA;AACtE,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,oBAAoB,CAAC,C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AC,CAAA;QACrB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,gBAAgB,EAAE,CAAA;YAClB,MAAM,GAAG,CAAA;QACb,CAAC;IACL,CAAC;AACL,CAAC;AAED,IAAI,CAAC;IACD,MAAM,OAAO,CAAC,UAAU,EAAE,CAAA;AAC9B,CAAC;QAAS,CAAC;IACP,gBAAgB,EAAE,CAAA;AACtB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Command, Option } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Set argChoices on an option without enabling Commander's built-in
|
|
4
|
+
* validation. The choices are surfaced for shell completions but the
|
|
5
|
+
* option still accepts any value at parse time.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withUnvalidatedChoices(opt: Option, values: string[]): Option;
|
|
8
|
+
export declare function withCaseInsensitiveChoices(opt: Option, values: string[]): Option;
|
|
9
|
+
/**
|
|
10
|
+
* Parse COMP_LINE into words, stripping the binary name and the
|
|
11
|
+
* 'completion-server' token that tabtab injects.
|
|
12
|
+
*
|
|
13
|
+
* FIXME: This splits on whitespace and does not handle quoted arguments.
|
|
14
|
+
* This is acceptable for command/flag traversal. It can be improved once
|
|
15
|
+
* tabtab exposes shell-provided tokenized words.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseCompLine(compLine: string): string[];
|
|
18
|
+
export interface CompletionItem {
|
|
19
|
+
name: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get completions for the current command line context.
|
|
24
|
+
*
|
|
25
|
+
* @param program - The root Commander program with all commands registered
|
|
26
|
+
* @param words - The words on the command line (excluding the binary name)
|
|
27
|
+
* @param current - The current word being typed (may be empty string)
|
|
28
|
+
* @returns Array of completion items
|
|
29
|
+
*/
|
|
30
|
+
export declare function getCompletions(program: Command, words: string[], current: string): CompletionItem[];
|
|
31
|
+
//# sourceMappingURL=completion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/lib/completion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEhD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAG5E;AAED,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAWhF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAIxD;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACvB;AAoBD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC1B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,EAAE,MAAM,GAChB,cAAc,EAAE,CAsGlB"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set argChoices on an option without enabling Commander's built-in
|
|
3
|
+
* validation. The choices are surfaced for shell completions but the
|
|
4
|
+
* option still accepts any value at parse time.
|
|
5
|
+
*/
|
|
6
|
+
export function withUnvalidatedChoices(opt, values) {
|
|
7
|
+
opt.argChoices = values;
|
|
8
|
+
return opt;
|
|
9
|
+
}
|
|
10
|
+
export function withCaseInsensitiveChoices(opt, values) {
|
|
11
|
+
opt.choices(values);
|
|
12
|
+
// choices() sets parseArg internally. Assert so we catch upstream changes.
|
|
13
|
+
const original = opt.parseArg;
|
|
14
|
+
if (!original) {
|
|
15
|
+
throw new Error('Expected Commander choices() to set parseArg');
|
|
16
|
+
}
|
|
17
|
+
opt.parseArg = (arg, prev) => original(arg.toLowerCase(), prev);
|
|
18
|
+
return opt;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parse COMP_LINE into words, stripping the binary name and the
|
|
22
|
+
* 'completion-server' token that tabtab injects.
|
|
23
|
+
*
|
|
24
|
+
* FIXME: This splits on whitespace and does not handle quoted arguments.
|
|
25
|
+
* This is acceptable for command/flag traversal. It can be improved once
|
|
26
|
+
* tabtab exposes shell-provided tokenized words.
|
|
27
|
+
*/
|
|
28
|
+
export function parseCompLine(compLine) {
|
|
29
|
+
const words = compLine.split(/\s+/).slice(1); // remove binary name (tw)
|
|
30
|
+
if (words[0] === 'completion-server')
|
|
31
|
+
words.shift();
|
|
32
|
+
return words;
|
|
33
|
+
}
|
|
34
|
+
/** Names to exclude from completion results (internal commands) */
|
|
35
|
+
const HIDDEN_COMMAND_NAMES = new Set(['completion-server']);
|
|
36
|
+
/**
|
|
37
|
+
* Check if a Commander Option expects a value argument (not a boolean flag).
|
|
38
|
+
*/
|
|
39
|
+
function optionExpectsValue(opt) {
|
|
40
|
+
// required means <value>, optional means [value] — both expect a value
|
|
41
|
+
return opt.required || opt.optional;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Find an option by its long or short flag in a command.
|
|
45
|
+
*/
|
|
46
|
+
function findOption(cmd, flag) {
|
|
47
|
+
return cmd.options.find((o) => o.long === flag || o.short === flag);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get completions for the current command line context.
|
|
51
|
+
*
|
|
52
|
+
* @param program - The root Commander program with all commands registered
|
|
53
|
+
* @param words - The words on the command line (excluding the binary name)
|
|
54
|
+
* @param current - The current word being typed (may be empty string)
|
|
55
|
+
* @returns Array of completion items
|
|
56
|
+
*/
|
|
57
|
+
export function getCompletions(program, words, current) {
|
|
58
|
+
let activeCmd = program;
|
|
59
|
+
let seenDoubleDash = false;
|
|
60
|
+
const usedOptions = new Set();
|
|
61
|
+
// Walk the words to find the active command context
|
|
62
|
+
let i = 0;
|
|
63
|
+
while (i < words.length) {
|
|
64
|
+
const word = words[i];
|
|
65
|
+
// If we hit the current word (last position), stop walking
|
|
66
|
+
if (i === words.length - 1 && word === current) {
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
if (word === '--') {
|
|
70
|
+
seenDoubleDash = true;
|
|
71
|
+
i++;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (!seenDoubleDash && word.startsWith('-')) {
|
|
75
|
+
// Handle --flag=value syntax
|
|
76
|
+
const eqIdx = word.indexOf('=');
|
|
77
|
+
const flag = eqIdx > 0 ? word.slice(0, eqIdx) : word;
|
|
78
|
+
usedOptions.add(flag);
|
|
79
|
+
// If this option expects a value and no = was used, consume the next word
|
|
80
|
+
if (eqIdx < 0) {
|
|
81
|
+
const opt = findOption(activeCmd, flag);
|
|
82
|
+
if (opt && optionExpectsValue(opt)) {
|
|
83
|
+
i++; // skip the value word
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
i++;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
// Try to descend into a subcommand
|
|
90
|
+
const sub = activeCmd.commands.find((c) => c.name() === word || c.aliases().includes(word));
|
|
91
|
+
if (sub) {
|
|
92
|
+
activeCmd = sub;
|
|
93
|
+
usedOptions.clear();
|
|
94
|
+
}
|
|
95
|
+
i++;
|
|
96
|
+
}
|
|
97
|
+
// Check if previous word was an option expecting a value
|
|
98
|
+
if (words.length >= 2) {
|
|
99
|
+
const prevWord = words[words.length - 2];
|
|
100
|
+
if (prevWord?.startsWith('-') && prevWord !== '--') {
|
|
101
|
+
const eqIdx = prevWord.indexOf('=');
|
|
102
|
+
const flag = eqIdx > 0 ? prevWord.slice(0, eqIdx) : prevWord;
|
|
103
|
+
const opt = findOption(activeCmd, flag);
|
|
104
|
+
if (opt && optionExpectsValue(opt) && eqIdx < 0) {
|
|
105
|
+
const enumValues = opt.argChoices;
|
|
106
|
+
if (enumValues) {
|
|
107
|
+
return enumValues.filter((v) => v.startsWith(current)).map((v) => ({ name: v }));
|
|
108
|
+
}
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Handle --flag=<TAB> — suggest values after =
|
|
114
|
+
if (current.includes('=')) {
|
|
115
|
+
const eqIdx = current.indexOf('=');
|
|
116
|
+
const flag = current.slice(0, eqIdx);
|
|
117
|
+
const partial = current.slice(eqIdx + 1);
|
|
118
|
+
const opt = findOption(activeCmd, flag);
|
|
119
|
+
if (opt) {
|
|
120
|
+
const enumValues = opt.argChoices;
|
|
121
|
+
if (enumValues) {
|
|
122
|
+
return enumValues
|
|
123
|
+
.filter((v) => v.startsWith(partial))
|
|
124
|
+
.map((v) => ({ name: `${flag}=${v}` }));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
// After --, everything is positional — no more commands or options
|
|
130
|
+
if (seenDoubleDash) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
// If current word starts with -, suggest options
|
|
134
|
+
if (current.startsWith('-')) {
|
|
135
|
+
return getOptionCompletions(activeCmd, current, usedOptions);
|
|
136
|
+
}
|
|
137
|
+
// Suggest subcommands, and if there are none, suggest options instead
|
|
138
|
+
const subcommands = getSubcommandCompletions(activeCmd, current);
|
|
139
|
+
if (subcommands.length > 0) {
|
|
140
|
+
return subcommands;
|
|
141
|
+
}
|
|
142
|
+
return getOptionCompletions(activeCmd, current, usedOptions);
|
|
143
|
+
}
|
|
144
|
+
function getSubcommandCompletions(cmd, prefix) {
|
|
145
|
+
return cmd.commands
|
|
146
|
+
.filter((c) => !c._hidden &&
|
|
147
|
+
!HIDDEN_COMMAND_NAMES.has(c.name()))
|
|
148
|
+
.filter((c) => c.name().startsWith(prefix))
|
|
149
|
+
.map((c) => ({
|
|
150
|
+
name: c.name(),
|
|
151
|
+
description: c.description(),
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
function getOptionCompletions(cmd, prefix, usedOptions) {
|
|
155
|
+
return cmd.options
|
|
156
|
+
.filter((o) => {
|
|
157
|
+
if (!o.long)
|
|
158
|
+
return false;
|
|
159
|
+
if (o.hidden)
|
|
160
|
+
return false;
|
|
161
|
+
// Exclude already-used options
|
|
162
|
+
if (usedOptions.has(o.long))
|
|
163
|
+
return false;
|
|
164
|
+
if (o.short && usedOptions.has(o.short))
|
|
165
|
+
return false;
|
|
166
|
+
return o.long.startsWith(prefix);
|
|
167
|
+
})
|
|
168
|
+
.map((o) => ({
|
|
169
|
+
name: o.long,
|
|
170
|
+
description: o.description,
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=completion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../../src/lib/completion.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAW,EAAE,MAAgB;IAChE,GAAG,CAAC,UAAU,GAAG,MAAM,CAAA;IACvB,OAAO,GAAG,CAAA;AACd,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,GAAW,EAAE,MAAgB;IACpE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAEnB,2EAA2E;IAC3E,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAA;IAC7B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;IACnE,CAAC;IAED,GAAG,CAAC,QAAQ,GAAG,CAAI,GAAW,EAAE,IAAO,EAAK,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,CAAA;IAChF,OAAO,GAAG,CAAA;AACd,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC1C,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,CAAC,0BAA0B;I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,MAAc,EACd,WAAwB;IAExB,OAAO,GAAG,CAAC,OAAO;SACb,MAAM,CAAC,CAAC,CAAS,EAAE,EAAE;QAClB,IAAI,CAAC,CAAC,CAAC,IAAI;YAAE,OAAO,KAAK,CAAA;QACzB,IAAI,CAAC,CAAC,MAAM;YAAE,OAAO,KAAK,CAAA;QAC1B,+BAA+B;QAC/B,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAA;QACzC,IAAI,CAAC,CAAC,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAA;QACrD,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IACpC,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC;QACjB,IAAI,EAAE,CAAC,CAAC,IAAc;QACtB,WAAW,EAAE,CAAC,CAAC,WAAW;KAC7B,CAAC,CAAC,CAAA;AACX,CAAC"}
|
package/dist/lib/oauth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/lib/oauth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,iBAAiB,sCAAsC,CAAA;AACpE,eAAO,MAAM,SAAS,yCAAyC,CAAA;AAC/D,eAAO,MAAM,gBAAgB,qCAAqC,CAAA;AAClE,eAAO,MAAM,kBAAkB,mCAAmC,CAAA;AAGlE,eAAO,MAAM,YAAY,QAcd,CAAA;AAEX;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;CACxB;AAED;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../src/lib/oauth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,eAAO,MAAM,iBAAiB,sCAAsC,CAAA;AACpE,eAAO,MAAM,SAAS,yCAAyC,CAAA;AAC/D,eAAO,MAAM,gBAAgB,qCAAqC,CAAA;AAClE,eAAO,MAAM,kBAAkB,mCAAmC,CAAA;AAGlE,eAAO,MAAM,YAAY,QAcd,CAAA;AAEX;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;CACxB;AAED;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,WAAW,CAAC,CAgDlE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,GACd,MAAM,CAYR;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACtC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC,CAiDjB"}
|
package/dist/lib/oauth.js
CHANGED
|
@@ -34,7 +34,7 @@ export async function registerDynamicClient() {
|
|
|
34
34
|
response_types: ['code'],
|
|
35
35
|
token_endpoint_auth_method: 'client_secret_basic', // Use Basic auth for token exchange
|
|
36
36
|
application_type: 'native', // CLI is a native application
|
|
37
|
-
logo_uri: 'https://
|
|
37
|
+
logo_uri: 'https://raw.githubusercontent.com/Doist/twist-cli/d65c447ff453eb36af585044c2f5f2f602bcdb34/icons/twist-cli.png',
|
|
38
38
|
};
|
|
39
39
|
try {
|
|
40
40
|
const response = await fetch(REGISTRATION_URL, {
|
package/dist/lib/oauth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/lib/oauth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,8FAA8F;AAC9F,MAAM,CAAC,MAAM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CAAC,OAAO,EAAE,CAAC,CAAA;QAC1E,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;IACvE,CAAC;AACL,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const SKILL_NAME = "twist-cli";
|
|
2
2
|
export declare const SKILL_DESCRIPTION = "Twist messaging CLI for team communication";
|
|
3
|
-
export declare const SKILL_CONTENT = "# Twist CLI Skill\n\nAccess Twist messaging via the `tw` CLI. Use when the user asks about their Twist workspaces, threads, messages, or wants to interact with Twist in any way.\n\n## Setup\n\n```bash\ntw auth login # OAuth login (opens browser)\ntw auth token <your-api-token> # Save API token manually\ntw auth status # Verify authentication\ntw auth logout # Remove saved token\ntw workspaces # List available workspaces\ntw workspace use <ref> # Set current workspace\n```\n\n## View by URL\n\n```bash\ntw view <url> # View any Twist entity by URL\n```\n\nRoutes automatically based on URL structure:\n- Message URL \u2192 `tw msg view`\n- Conversation URL \u2192 `tw conversation view`\n- Thread+comment URL \u2192 `tw thread view` (comment ID extracted from URL)\n- Thread URL \u2192 `tw thread view`\n\nAll target command flags pass through (e.g. `--json`, `--raw`, `--full`).\n\n## Inbox\n\n```bash\ntw inbox # Show inbox threads\ntw inbox --unread # Only unread threads\ntw inbox --channel <filter> # Filter by channel name (fuzzy)\ntw inbox --since <date> # Filter by date (ISO format)\ntw inbox --limit <n> # Max items (default: 50)\n```\n\n## Threads\n\n```bash\ntw thread <thread-ref> # View thread (shorthand for view)\ntw thread view <thread-ref> # View thread with comments\ntw thread view <ref> --comment <id> # View a specific comment\ntw thread view <url-with-/c/id> # Comment ID extracted from URL\ntw thread view <ref> --unread # Show only unread comments\ntw thread view <ref> --context 3 # Include 3 read comments before unread\ntw thread view <ref> --limit 20 # Limit number of comments\ntw thread view <ref> --since <date> # Comments newer than date\ntw thread view <ref> --raw # Show raw markdown\ntw thread reply <ref> \"content\" # Post a comment\ntw thread reply <ref> \"content\" --notify EVERYONE # Notify all workspace members\ntw thread reply <ref> \"content\" --notify 123,id:456 # Notify specific user IDs\ntw thread done <ref> # Archive thread (mark done)\n```\n\nDefault `--notify` is EVERYONE_IN_THREAD. Options: EVERYONE, EVERYONE_IN_THREAD, or comma-separated user ID refs.\n\n## Conversations (DMs/Groups)\n\n```bash\ntw conversation unread # List unread conversations\ntw conversation <conversation-ref> # View conversation (shorthand for view)\ntw conversation view <conversation-ref> # View conversation messages\ntw conversation reply <ref> \"content\" # Send a message\ntw conversation done <ref> # Archive conversation\n```\n\nAlias: `tw convo` works the same as `tw conversation`.\n\n## Conversation Messages\n\n```bash\ntw msg <message-ref> # View a message (shorthand for view)\ntw msg view <message-ref> # View a single conversation message\ntw msg update <ref> \"content\" # Edit a conversation message\ntw msg delete <ref> # Delete a conversation message\n```\n\nAlias: `tw message` works the same as `tw msg`.\n\n## Search\n\n```bash\ntw search \"query\" # Search content\ntw search \"query\" --type threads # Filter: threads, messages, or all\ntw search \"query\" --author <ref> # Filter by author\ntw search \"query\" --to <ref> # Messages sent to user\ntw search \"query\" --title-only # Search thread titles only\ntw search \"query\" --mention-me # Results mentioning current user\ntw search \"query\" --conversation <refs> # Limit to conversations (comma-separated refs)\ntw search \"query\" --since <date> # Content from date\ntw search \"query\" --until <date> # Content until date\ntw search \"query\" --channel <refs> # Filter by channel refs (comma-separated)\ntw search \"query\" --limit <n> # Max results (default: 50)\ntw search \"query\" --cursor <cur> # Pagination cursor\n```\n\n## Users & Channels\n\n```bash\ntw user # Show current user info\ntw users # List workspace users\ntw users --search <text> # Filter by name/email\ntw channels # List workspace channels\n```\n\n## Reactions\n\n```bash\ntw react thread <ref> \uD83D\uDC4D # Add reaction to thread\ntw react comment <ref> +1 # Add reaction (shortcode)\ntw react message <ref> heart # Add reaction to DM message\ntw unreact thread <ref> \uD83D\uDC4D # Remove reaction\n```\n\nSupported shortcodes: +1, -1, heart, tada, smile, laughing, thinking, fire, check, x, eyes, pray, clap, rocket, wave\n\n## Global Options\n\n```bash\n--no-spinner # Disable loading animations\n--progress-jsonl # Machine-readable progress events (JSONL to stderr)\n```\n\n## Output Formats\n\nAll list/view commands support:\n\n```bash\n--json # Output as JSON\n--ndjson # Output as newline-delimited JSON (for streaming)\n--full # Include all fields (default shows essential fields only)\n```\n\n## Reference System\n\nCommands accept flexible references:\n- **Numeric IDs**: `123` or `id:123`\n- **Twist URLs**: Full `https://twist.com/...` URLs (parsed automatically)\n- **Fuzzy names**: For workspaces/users - `\"My Workspace\"` or partial matches\n\n## Common Workflows\n\n**View by URL (auto-routes to the right command):**\n```bash\ntw view https://twist.com/a/1585/ch/100/t/200 # View thread\ntw view https://twist.com/a/1585/ch/100/t/200/c/300 # View comment\ntw view https://twist.com/a/1585/msg/400 # View conversation\ntw view https://twist.com/a/1585/msg/400/m/500 --json # View message as JSON\n```\n\n**Check inbox and respond:**\n```bash\ntw inbox --unread --json\ntw thread view <id> --unread\ntw thread reply <id> \"Thanks, I'll look into this.\"\ntw thread done <id>\n```\n\n**Search and review:**\n```bash\ntw search \"deployment\" --type threads --json\ntw thread view <thread-id>\n```\n\n**Check DMs:**\n```bash\ntw conversation unread --json\ntw conversation view <conversation-id>\ntw conversation reply <id> \"Got it, thanks!\"\n```\n";
|
|
4
|
-
export declare const SKILL_FILE_CONTENT = "---\nname: twist-cli\ndescription: Twist messaging CLI for team communication\n---\n\n# Twist CLI Skill\n\nAccess Twist messaging via the `tw` CLI. Use when the user asks about their Twist workspaces, threads, messages, or wants to interact with Twist in any way.\n\n## Setup\n\n```bash\ntw auth login # OAuth login (opens browser)\ntw auth token <your-api-token> # Save API token manually\ntw auth status # Verify authentication\ntw auth logout # Remove saved token\ntw workspaces # List available workspaces\ntw workspace use <ref> # Set current workspace\n```\n\n## View by URL\n\n```bash\ntw view <url> # View any Twist entity by URL\n```\n\nRoutes automatically based on URL structure:\n- Message URL \u2192 `tw msg view`\n- Conversation URL \u2192 `tw conversation view`\n- Thread+comment URL \u2192 `tw thread view` (comment ID extracted from URL)\n- Thread URL \u2192 `tw thread view`\n\nAll target command flags pass through (e.g. `--json`, `--raw`, `--full`).\n\n## Inbox\n\n```bash\ntw inbox # Show inbox threads\ntw inbox --unread # Only unread threads\ntw inbox --channel <filter> # Filter by channel name (fuzzy)\ntw inbox --since <date> # Filter by date (ISO format)\ntw inbox --limit <n> # Max items (default: 50)\n```\n\n## Threads\n\n```bash\ntw thread <thread-ref> # View thread (shorthand for view)\ntw thread view <thread-ref> # View thread with comments\ntw thread view <ref> --comment <id> # View a specific comment\ntw thread view <url-with-/c/id> # Comment ID extracted from URL\ntw thread view <ref> --unread # Show only unread comments\ntw thread view <ref> --context 3 # Include 3 read comments before unread\ntw thread view <ref> --limit 20 # Limit number of comments\ntw thread view <ref> --since <date> # Comments newer than date\ntw thread view <ref> --raw # Show raw markdown\ntw thread reply <ref> \"content\" # Post a comment\ntw thread reply <ref> \"content\" --notify EVERYONE # Notify all workspace members\ntw thread reply <ref> \"content\" --notify 123,id:456 # Notify specific user IDs\ntw thread done <ref> # Archive thread (mark done)\n```\n\nDefault `--notify` is EVERYONE_IN_THREAD. Options: EVERYONE, EVERYONE_IN_THREAD, or comma-separated user ID refs.\n\n## Conversations (DMs/Groups)\n\n```bash\ntw conversation unread # List unread conversations\ntw conversation <conversation-ref> # View conversation (shorthand for view)\ntw conversation view <conversation-ref> # View conversation messages\ntw conversation reply <ref> \"content\" # Send a message\ntw conversation done <ref> # Archive conversation\n```\n\nAlias: `tw convo` works the same as `tw conversation`.\n\n## Conversation Messages\n\n```bash\ntw msg <message-ref> # View a message (shorthand for view)\ntw msg view <message-ref> # View a single conversation message\ntw msg update <ref> \"content\" # Edit a conversation message\ntw msg delete <ref> # Delete a conversation message\n```\n\nAlias: `tw message` works the same as `tw msg`.\n\n## Search\n\n```bash\ntw search \"query\" # Search content\ntw search \"query\" --type threads # Filter: threads, messages, or all\ntw search \"query\" --author <ref> # Filter by author\ntw search \"query\" --to <ref> # Messages sent to user\ntw search \"query\" --title-only # Search thread titles only\ntw search \"query\" --mention-me # Results mentioning current user\ntw search \"query\" --conversation <refs> # Limit to conversations (comma-separated refs)\ntw search \"query\" --since <date> # Content from date\ntw search \"query\" --until <date> # Content until date\ntw search \"query\" --channel <refs> # Filter by channel refs (comma-separated)\ntw search \"query\" --limit <n> # Max results (default: 50)\ntw search \"query\" --cursor <cur> # Pagination cursor\n```\n\n## Users & Channels\n\n```bash\ntw user # Show current user info\ntw users # List workspace users\ntw users --search <text> # Filter by name/email\ntw channels # List workspace channels\n```\n\n## Reactions\n\n```bash\ntw react thread <ref> \uD83D\uDC4D # Add reaction to thread\ntw react comment <ref> +1 # Add reaction (shortcode)\ntw react message <ref> heart # Add reaction to DM message\ntw unreact thread <ref> \uD83D\uDC4D # Remove reaction\n```\n\nSupported shortcodes: +1, -1, heart, tada, smile, laughing, thinking, fire, check, x, eyes, pray, clap, rocket, wave\n\n## Global Options\n\n```bash\n--no-spinner # Disable loading animations\n--progress-jsonl # Machine-readable progress events (JSONL to stderr)\n```\n\n## Output Formats\n\nAll list/view commands support:\n\n```bash\n--json # Output as JSON\n--ndjson # Output as newline-delimited JSON (for streaming)\n--full # Include all fields (default shows essential fields only)\n```\n\n## Reference System\n\nCommands accept flexible references:\n- **Numeric IDs**: `123` or `id:123`\n- **Twist URLs**: Full `https://twist.com/...` URLs (parsed automatically)\n- **Fuzzy names**: For workspaces/users - `\"My Workspace\"` or partial matches\n\n## Common Workflows\n\n**View by URL (auto-routes to the right command):**\n```bash\ntw view https://twist.com/a/1585/ch/100/t/200 # View thread\ntw view https://twist.com/a/1585/ch/100/t/200/c/300 # View comment\ntw view https://twist.com/a/1585/msg/400 # View conversation\ntw view https://twist.com/a/1585/msg/400/m/500 --json # View message as JSON\n```\n\n**Check inbox and respond:**\n```bash\ntw inbox --unread --json\ntw thread view <id> --unread\ntw thread reply <id> \"Thanks, I'll look into this.\"\ntw thread done <id>\n```\n\n**Search and review:**\n```bash\ntw search \"deployment\" --type threads --json\ntw thread view <thread-id>\n```\n\n**Check DMs:**\n```bash\ntw conversation unread --json\ntw conversation view <conversation-id>\ntw conversation reply <id> \"Got it, thanks!\"\n```\n";
|
|
3
|
+
export declare const SKILL_CONTENT = "# Twist CLI Skill\n\nAccess Twist messaging via the `tw` CLI. Use when the user asks about their Twist workspaces, threads, messages, or wants to interact with Twist in any way.\n\n## Setup\n\n```bash\ntw auth login # OAuth login (opens browser)\ntw auth token <your-api-token> # Save API token manually\ntw auth status # Verify authentication\ntw auth logout # Remove saved token\ntw workspaces # List available workspaces\ntw workspace use <ref> # Set current workspace\ntw completion install # Install shell completions\ntw update # Update CLI to latest version\n```\n\n## View by URL\n\n```bash\ntw view <url> # View any Twist entity by URL\n```\n\nRoutes automatically based on URL structure:\n- Message URL \u2192 `tw msg view`\n- Conversation URL \u2192 `tw conversation view`\n- Thread+comment URL \u2192 `tw thread view` (comment ID extracted from URL)\n- Thread URL \u2192 `tw thread view`\n\nAll target command flags pass through (e.g. `--json`, `--raw`, `--full`).\n\n## Inbox\n\n```bash\ntw inbox # Show inbox threads\ntw inbox --unread # Only unread threads\ntw inbox --channel <filter> # Filter by channel name (fuzzy)\ntw inbox --since <date> # Filter by date (ISO format)\ntw inbox --limit <n> # Max items (default: 50)\n```\n\n## Threads\n\n```bash\ntw thread <thread-ref> # View thread (shorthand for view)\ntw thread view <thread-ref> # View thread with comments\ntw thread view <ref> --comment <id> # View a specific comment\ntw thread view <url-with-/c/id> # Comment ID extracted from URL\ntw thread view <ref> --unread # Show only unread comments\ntw thread view <ref> --context 3 # Include 3 read comments before unread\ntw thread view <ref> --limit 20 # Limit number of comments\ntw thread view <ref> --since <date> # Comments newer than date\ntw thread view <ref> --raw # Show raw markdown\ntw thread reply <ref> \"content\" # Post a comment\ntw thread reply <ref> \"content\" --notify EVERYONE # Notify all workspace members\ntw thread reply <ref> \"content\" --notify 123,id:456 # Notify specific user IDs\ntw thread done <ref> # Archive thread (mark done)\n```\n\nDefault `--notify` is EVERYONE_IN_THREAD. Options: EVERYONE, EVERYONE_IN_THREAD, or comma-separated user ID refs.\n\n## Conversations (DMs/Groups)\n\n```bash\ntw conversation unread # List unread conversations\ntw conversation <conversation-ref> # View conversation (shorthand for view)\ntw conversation view <conversation-ref> # View conversation messages\ntw conversation reply <ref> \"content\" # Send a message\ntw conversation done <ref> # Archive conversation\n```\n\nAlias: `tw convo` works the same as `tw conversation`.\n\n## Conversation Messages\n\n```bash\ntw msg <message-ref> # View a message (shorthand for view)\ntw msg view <message-ref> # View a single conversation message\ntw msg update <ref> \"content\" # Edit a conversation message\ntw msg delete <ref> # Delete a conversation message\n```\n\nAlias: `tw message` works the same as `tw msg`.\n\n## Search\n\n```bash\ntw search \"query\" # Search content\ntw search \"query\" --type threads # Filter: threads, messages, or all\ntw search \"query\" --author <ref> # Filter by author\ntw search \"query\" --to <ref> # Messages sent to user\ntw search \"query\" --title-only # Search thread titles only\ntw search \"query\" --mention-me # Results mentioning current user\ntw search \"query\" --conversation <refs> # Limit to conversations (comma-separated refs)\ntw search \"query\" --since <date> # Content from date\ntw search \"query\" --until <date> # Content until date\ntw search \"query\" --channel <refs> # Filter by channel refs (comma-separated)\ntw search \"query\" --limit <n> # Max results (default: 50)\ntw search \"query\" --cursor <cur> # Pagination cursor\n```\n\n## Users & Channels\n\n```bash\ntw user # Show current user info\ntw users # List workspace users\ntw users --search <text> # Filter by name/email\ntw channels # List workspace channels\n```\n\n## Reactions\n\n```bash\ntw react thread <ref> \uD83D\uDC4D # Add reaction to thread\ntw react comment <ref> +1 # Add reaction (shortcode)\ntw react message <ref> heart # Add reaction to DM message\ntw unreact thread <ref> \uD83D\uDC4D # Remove reaction\n```\n\nSupported shortcodes: +1, -1, heart, tada, smile, laughing, thinking, fire, check, x, eyes, pray, clap, rocket, wave\n\n## Shell Completions\n\n```bash\ntw completion install # Install tab completions (prompts for shell)\ntw completion install bash # Install for specific shell\ntw completion install zsh\ntw completion install fish\ntw completion uninstall # Remove completions\n```\n\n### Update\n\n```bash\ntw update # Update CLI to latest version\ntw update --check # Check for updates without installing\n```\n\n## Global Options\n\n```bash\n--no-spinner # Disable loading animations\n--progress-jsonl # Machine-readable progress events (JSONL to stderr)\n```\n\n## Output Formats\n\nAll list/view commands support:\n\n```bash\n--json # Output as JSON\n--ndjson # Output as newline-delimited JSON (for streaming)\n--full # Include all fields (default shows essential fields only)\n```\n\n## Reference System\n\nCommands accept flexible references:\n- **Numeric IDs**: `123` or `id:123`\n- **Twist URLs**: Full `https://twist.com/...` URLs (parsed automatically)\n- **Fuzzy names**: For workspaces/users - `\"My Workspace\"` or partial matches\n\n## Common Workflows\n\n**View by URL (auto-routes to the right command):**\n```bash\ntw view https://twist.com/a/1585/ch/100/t/200 # View thread\ntw view https://twist.com/a/1585/ch/100/t/200/c/300 # View comment\ntw view https://twist.com/a/1585/msg/400 # View conversation\ntw view https://twist.com/a/1585/msg/400/m/500 --json # View message as JSON\n```\n\n**Check inbox and respond:**\n```bash\ntw inbox --unread --json\ntw thread view <id> --unread\ntw thread reply <id> \"Thanks, I'll look into this.\"\ntw thread done <id>\n```\n\n**Search and review:**\n```bash\ntw search \"deployment\" --type threads --json\ntw thread view <thread-id>\n```\n\n**Check DMs:**\n```bash\ntw conversation unread --json\ntw conversation view <conversation-id>\ntw conversation reply <id> \"Got it, thanks!\"\n```\n";
|
|
4
|
+
export declare const SKILL_FILE_CONTENT = "---\nname: twist-cli\ndescription: Twist messaging CLI for team communication\n---\n\n# Twist CLI Skill\n\nAccess Twist messaging via the `tw` CLI. Use when the user asks about their Twist workspaces, threads, messages, or wants to interact with Twist in any way.\n\n## Setup\n\n```bash\ntw auth login # OAuth login (opens browser)\ntw auth token <your-api-token> # Save API token manually\ntw auth status # Verify authentication\ntw auth logout # Remove saved token\ntw workspaces # List available workspaces\ntw workspace use <ref> # Set current workspace\ntw completion install # Install shell completions\ntw update # Update CLI to latest version\n```\n\n## View by URL\n\n```bash\ntw view <url> # View any Twist entity by URL\n```\n\nRoutes automatically based on URL structure:\n- Message URL \u2192 `tw msg view`\n- Conversation URL \u2192 `tw conversation view`\n- Thread+comment URL \u2192 `tw thread view` (comment ID extracted from URL)\n- Thread URL \u2192 `tw thread view`\n\nAll target command flags pass through (e.g. `--json`, `--raw`, `--full`).\n\n## Inbox\n\n```bash\ntw inbox # Show inbox threads\ntw inbox --unread # Only unread threads\ntw inbox --channel <filter> # Filter by channel name (fuzzy)\ntw inbox --since <date> # Filter by date (ISO format)\ntw inbox --limit <n> # Max items (default: 50)\n```\n\n## Threads\n\n```bash\ntw thread <thread-ref> # View thread (shorthand for view)\ntw thread view <thread-ref> # View thread with comments\ntw thread view <ref> --comment <id> # View a specific comment\ntw thread view <url-with-/c/id> # Comment ID extracted from URL\ntw thread view <ref> --unread # Show only unread comments\ntw thread view <ref> --context 3 # Include 3 read comments before unread\ntw thread view <ref> --limit 20 # Limit number of comments\ntw thread view <ref> --since <date> # Comments newer than date\ntw thread view <ref> --raw # Show raw markdown\ntw thread reply <ref> \"content\" # Post a comment\ntw thread reply <ref> \"content\" --notify EVERYONE # Notify all workspace members\ntw thread reply <ref> \"content\" --notify 123,id:456 # Notify specific user IDs\ntw thread done <ref> # Archive thread (mark done)\n```\n\nDefault `--notify` is EVERYONE_IN_THREAD. Options: EVERYONE, EVERYONE_IN_THREAD, or comma-separated user ID refs.\n\n## Conversations (DMs/Groups)\n\n```bash\ntw conversation unread # List unread conversations\ntw conversation <conversation-ref> # View conversation (shorthand for view)\ntw conversation view <conversation-ref> # View conversation messages\ntw conversation reply <ref> \"content\" # Send a message\ntw conversation done <ref> # Archive conversation\n```\n\nAlias: `tw convo` works the same as `tw conversation`.\n\n## Conversation Messages\n\n```bash\ntw msg <message-ref> # View a message (shorthand for view)\ntw msg view <message-ref> # View a single conversation message\ntw msg update <ref> \"content\" # Edit a conversation message\ntw msg delete <ref> # Delete a conversation message\n```\n\nAlias: `tw message` works the same as `tw msg`.\n\n## Search\n\n```bash\ntw search \"query\" # Search content\ntw search \"query\" --type threads # Filter: threads, messages, or all\ntw search \"query\" --author <ref> # Filter by author\ntw search \"query\" --to <ref> # Messages sent to user\ntw search \"query\" --title-only # Search thread titles only\ntw search \"query\" --mention-me # Results mentioning current user\ntw search \"query\" --conversation <refs> # Limit to conversations (comma-separated refs)\ntw search \"query\" --since <date> # Content from date\ntw search \"query\" --until <date> # Content until date\ntw search \"query\" --channel <refs> # Filter by channel refs (comma-separated)\ntw search \"query\" --limit <n> # Max results (default: 50)\ntw search \"query\" --cursor <cur> # Pagination cursor\n```\n\n## Users & Channels\n\n```bash\ntw user # Show current user info\ntw users # List workspace users\ntw users --search <text> # Filter by name/email\ntw channels # List workspace channels\n```\n\n## Reactions\n\n```bash\ntw react thread <ref> \uD83D\uDC4D # Add reaction to thread\ntw react comment <ref> +1 # Add reaction (shortcode)\ntw react message <ref> heart # Add reaction to DM message\ntw unreact thread <ref> \uD83D\uDC4D # Remove reaction\n```\n\nSupported shortcodes: +1, -1, heart, tada, smile, laughing, thinking, fire, check, x, eyes, pray, clap, rocket, wave\n\n## Shell Completions\n\n```bash\ntw completion install # Install tab completions (prompts for shell)\ntw completion install bash # Install for specific shell\ntw completion install zsh\ntw completion install fish\ntw completion uninstall # Remove completions\n```\n\n### Update\n\n```bash\ntw update # Update CLI to latest version\ntw update --check # Check for updates without installing\n```\n\n## Global Options\n\n```bash\n--no-spinner # Disable loading animations\n--progress-jsonl # Machine-readable progress events (JSONL to stderr)\n```\n\n## Output Formats\n\nAll list/view commands support:\n\n```bash\n--json # Output as JSON\n--ndjson # Output as newline-delimited JSON (for streaming)\n--full # Include all fields (default shows essential fields only)\n```\n\n## Reference System\n\nCommands accept flexible references:\n- **Numeric IDs**: `123` or `id:123`\n- **Twist URLs**: Full `https://twist.com/...` URLs (parsed automatically)\n- **Fuzzy names**: For workspaces/users - `\"My Workspace\"` or partial matches\n\n## Common Workflows\n\n**View by URL (auto-routes to the right command):**\n```bash\ntw view https://twist.com/a/1585/ch/100/t/200 # View thread\ntw view https://twist.com/a/1585/ch/100/t/200/c/300 # View comment\ntw view https://twist.com/a/1585/msg/400 # View conversation\ntw view https://twist.com/a/1585/msg/400/m/500 --json # View message as JSON\n```\n\n**Check inbox and respond:**\n```bash\ntw inbox --unread --json\ntw thread view <id> --unread\ntw thread reply <id> \"Thanks, I'll look into this.\"\ntw thread done <id>\n```\n\n**Search and review:**\n```bash\ntw search \"deployment\" --type threads --json\ntw thread view <thread-id>\n```\n\n**Check DMs:**\n```bash\ntw conversation unread --json\ntw conversation view <conversation-id>\ntw conversation reply <id> \"Got it, thanks!\"\n```\n";
|
|
5
5
|
//# sourceMappingURL=content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,cAAc,CAAA;AAErC,eAAO,MAAM,iBAAiB,+CAA+C,CAAA;AAE7E,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,cAAc,CAAA;AAErC,eAAO,MAAM,iBAAiB,+CAA+C,CAAA;AAE7E,eAAO,MAAM,aAAa,skNAgMzB,CAAA;AAED,eAAO,MAAM,kBAAkB,4pNAKd,CAAA"}
|
|
@@ -13,6 +13,8 @@ tw auth status # Verify authentication
|
|
|
13
13
|
tw auth logout # Remove saved token
|
|
14
14
|
tw workspaces # List available workspaces
|
|
15
15
|
tw workspace use <ref> # Set current workspace
|
|
16
|
+
tw completion install # Install shell completions
|
|
17
|
+
tw update # Update CLI to latest version
|
|
16
18
|
\`\`\`
|
|
17
19
|
|
|
18
20
|
## View by URL
|
|
@@ -119,6 +121,23 @@ tw unreact thread <ref> 👍 # Remove reaction
|
|
|
119
121
|
|
|
120
122
|
Supported shortcodes: +1, -1, heart, tada, smile, laughing, thinking, fire, check, x, eyes, pray, clap, rocket, wave
|
|
121
123
|
|
|
124
|
+
## Shell Completions
|
|
125
|
+
|
|
126
|
+
\`\`\`bash
|
|
127
|
+
tw completion install # Install tab completions (prompts for shell)
|
|
128
|
+
tw completion install bash # Install for specific shell
|
|
129
|
+
tw completion install zsh
|
|
130
|
+
tw completion install fish
|
|
131
|
+
tw completion uninstall # Remove completions
|
|
132
|
+
\`\`\`
|
|
133
|
+
|
|
134
|
+
### Update
|
|
135
|
+
|
|
136
|
+
\`\`\`bash
|
|
137
|
+
tw update # Update CLI to latest version
|
|
138
|
+
tw update --check # Check for updates without installing
|
|
139
|
+
\`\`\`
|
|
140
|
+
|
|
122
141
|
## Global Options
|
|
123
142
|
|
|
124
143
|
\`\`\`bash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAA;AAErC,MAAM,CAAC,MAAM,iBAAiB,GAAG,4CAA4C,CAAA;AAE7E,MAAM,CAAC,MAAM,aAAa,GAAG
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/lib/skills/content.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAA;AAErC,MAAM,CAAC,MAAM,iBAAiB,GAAG,4CAA4C,CAAA;AAE7E,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgM5B,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;QAC1B,UAAU;eACH,iBAAiB;;;EAG9B,aAAa,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doist/twist-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "TypeScript CLI for Twist",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@doist/twist-sdk": "2.0.2",
|
|
51
|
+
"@pnpm/tabtab": "0.5.4",
|
|
51
52
|
"chalk": "5.6.2",
|
|
52
53
|
"commander": "14.0.2",
|
|
53
54
|
"marked": "15.0.12",
|