@leemour/max-cli 0.2.0 → 0.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 +10 -3
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +3 -0
- package/dist/cache/index.js.map +1 -1
- package/dist/cache/schema.d.ts +4 -1
- package/dist/cache/schema.d.ts.map +1 -1
- package/dist/cache/schema.js +89 -2
- package/dist/cache/schema.js.map +1 -1
- package/dist/cache/store.d.ts +38 -11
- package/dist/cache/store.d.ts.map +1 -1
- package/dist/cache/store.js +123 -17
- package/dist/cache/store.js.map +1 -1
- package/dist/client.d.ts +41 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +188 -49
- package/dist/client.js.map +1 -1
- package/dist/commands/account.js +1 -1
- package/dist/commands/account.js.map +1 -1
- package/dist/commands/body.d.ts +23 -0
- package/dist/commands/body.d.ts.map +1 -0
- package/dist/commands/body.js +36 -0
- package/dist/commands/body.js.map +1 -0
- package/dist/commands/cache.js +2 -2
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/chats.d.ts.map +1 -1
- package/dist/commands/chats.js +24 -3
- package/dist/commands/chats.js.map +1 -1
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +55 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/contacts.d.ts.map +1 -1
- package/dist/commands/contacts.js +8 -3
- package/dist/commands/contacts.js.map +1 -1
- package/dist/commands/context.d.ts +27 -3
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +45 -8
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/doctor.d.ts +18 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +72 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/messages.d.ts.map +1 -1
- package/dist/commands/messages.js +129 -5
- package/dist/commands/messages.js.map +1 -1
- package/dist/commands/paging.d.ts +6 -3
- package/dist/commands/paging.d.ts.map +1 -1
- package/dist/commands/paging.js +14 -3
- package/dist/commands/paging.js.map +1 -1
- package/dist/commands/runs.d.ts.map +1 -1
- package/dist/commands/runs.js +4 -6
- package/dist/commands/runs.js.map +1 -1
- package/dist/commands/session.js +2 -2
- package/dist/commands/session.js.map +1 -1
- package/dist/commands/skill.d.ts +3 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +23 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/config.d.ts +46 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +103 -9
- package/dist/config.js.map +1 -1
- package/dist/deadline.d.ts +30 -0
- package/dist/deadline.d.ts.map +1 -0
- package/dist/deadline.js +45 -0
- package/dist/deadline.js.map +1 -0
- package/dist/diagnose.d.ts +68 -0
- package/dist/diagnose.d.ts.map +1 -0
- package/dist/diagnose.js +115 -0
- package/dist/diagnose.js.map +1 -0
- package/dist/domain/map.d.ts.map +1 -1
- package/dist/domain/map.js +42 -3
- package/dist/domain/map.js.map +1 -1
- package/dist/domain/models.d.ts +46 -0
- package/dist/domain/models.d.ts.map +1 -1
- package/dist/domain/models.js +11 -1
- package/dist/domain/models.js.map +1 -1
- package/dist/output.d.ts +7 -4
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +8 -11
- package/dist/output.js.map +1 -1
- package/dist/program.d.ts +2 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +15 -2
- package/dist/program.js.map +1 -1
- package/dist/protocol/connection.d.ts +10 -0
- package/dist/protocol/connection.d.ts.map +1 -1
- package/dist/protocol/connection.js +20 -3
- package/dist/protocol/connection.js.map +1 -1
- package/dist/rendering/messages.d.ts +19 -0
- package/dist/rendering/messages.d.ts.map +1 -0
- package/dist/rendering/messages.js +138 -0
- package/dist/rendering/messages.js.map +1 -0
- package/dist/runs/events.d.ts +1 -1
- package/dist/runs/recording.d.ts +2 -2
- package/dist/runs/recording.d.ts.map +1 -1
- package/dist/runs/recording.js +3 -3
- package/dist/runs/recording.js.map +1 -1
- package/dist/testing/mock-max.d.ts.map +1 -1
- package/dist/testing/mock-max.js +16 -2
- package/dist/testing/mock-max.js.map +1 -1
- package/dist/testing/sandbox.d.ts +2 -0
- package/dist/testing/sandbox.d.ts.map +1 -0
- package/dist/testing/sandbox.js +31 -0
- package/dist/testing/sandbox.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -3
- package/skills/max-cli/SKILL.md +83 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { CliError } from "@leemour/cli-core";
|
|
1
2
|
import { Command } from "commander";
|
|
2
3
|
import { openProfileCache } from "../cache/index.js";
|
|
4
|
+
import { renderMessages } from "../rendering/messages.js";
|
|
5
|
+
import { readBody } from "./body.js";
|
|
3
6
|
import { forCommand } from "./context.js";
|
|
4
7
|
import { renderPage } from "./paging.js";
|
|
5
8
|
export const messagesCommand = () => {
|
|
@@ -19,7 +22,7 @@ export const messagesCommand = () => {
|
|
|
19
22
|
.option("--before <id-or-time>", "read what came before this message id, or this ISO 8601 time")
|
|
20
23
|
.action(async function (chat) {
|
|
21
24
|
const options = this.optsWithGlobals();
|
|
22
|
-
const context = forCommand(
|
|
25
|
+
const context = forCommand(this);
|
|
23
26
|
const { renderer, settings, createClient, run } = context;
|
|
24
27
|
const cache = await openProfileCache(settings.profile, { onProblem: (message) => renderer.note(message) });
|
|
25
28
|
await run("messages list", async (events) => {
|
|
@@ -27,7 +30,7 @@ export const messagesCommand = () => {
|
|
|
27
30
|
try {
|
|
28
31
|
const chatId = await client.chats.resolve(chat);
|
|
29
32
|
const before = options.before === undefined ? {} : { before: client.messages.before(String(options.before)) };
|
|
30
|
-
renderPage(context, await client.messages.list(chatId, { limit: settings.limit, ...before }));
|
|
33
|
+
renderPage(context, await client.messages.list(chatId, { limit: settings.limit, ...before }), feed(context), ([oldest]) => `older ones: \`--before ${oldest?.id}\``);
|
|
31
34
|
}
|
|
32
35
|
finally {
|
|
33
36
|
await client.close();
|
|
@@ -35,17 +38,82 @@ export const messagesCommand = () => {
|
|
|
35
38
|
}
|
|
36
39
|
});
|
|
37
40
|
});
|
|
41
|
+
/**
|
|
42
|
+
* **Search reads this machine's copy and never asks MAX.**
|
|
43
|
+
*
|
|
44
|
+
* There is no search operation in MAX's protocol as we know it, so there is nothing to send.
|
|
45
|
+
* That makes this command the opposite of every other read here — it opens no socket, spends no
|
|
46
|
+
* login, and can only find what `max messages list` has already brought down.
|
|
47
|
+
*
|
|
48
|
+
* ⚠ **A short result is therefore ambiguous**, and the note on stderr is what resolves it: not
|
|
49
|
+
* "there are no such messages", but "there are none in what has been read". Saying so costs one
|
|
50
|
+
* line and is the difference between an answer and a misleading one.
|
|
51
|
+
*/
|
|
52
|
+
command
|
|
53
|
+
.command("search")
|
|
54
|
+
.argument("<text>", "what to look for; at least 3 characters")
|
|
55
|
+
.description("find messages in what this machine has already read")
|
|
56
|
+
.option("--chat <id>", "only this chat; an id, because searching never connects to resolve a name")
|
|
57
|
+
.option("--limit <n>", "how many to show", (value) => Number.parseInt(value, 10))
|
|
58
|
+
.action(async function (text) {
|
|
59
|
+
const options = this.optsWithGlobals();
|
|
60
|
+
const context = forCommand(this);
|
|
61
|
+
const { renderer, settings, createClient, run } = context;
|
|
62
|
+
const cache = await openProfileCache(settings.profile, { onProblem: (message) => renderer.note(message) });
|
|
63
|
+
await run("messages search", async (events) => {
|
|
64
|
+
const client = createClient({ events, ...(cache ? { cache } : {}), offline: true });
|
|
65
|
+
try {
|
|
66
|
+
// Resolving a chat by name would need the chat list, which needs a login — and this
|
|
67
|
+
// command promises not to. An id works offline; a name is refused with the reason.
|
|
68
|
+
const chatId = options.chat === undefined ? undefined : offlineChat(String(options.chat));
|
|
69
|
+
const found = await client.messages.search(text, {
|
|
70
|
+
...(chatId === undefined ? {} : { chatId }),
|
|
71
|
+
limit: settings.limit,
|
|
72
|
+
});
|
|
73
|
+
renderer.note(found.items.length === 0
|
|
74
|
+
? "nothing matched what this machine has read — `max messages list <chat>` reads more"
|
|
75
|
+
: "searched the local copy only; a chat nobody has opened is not in it");
|
|
76
|
+
renderPage(context, found, feed(context), () => "more matched — raise `--limit`");
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
await client.close();
|
|
80
|
+
cache?.close();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
command
|
|
85
|
+
.command("show")
|
|
86
|
+
.argument("<chat>", "chat id, or part of a chat name")
|
|
87
|
+
.argument("<message>", "message id")
|
|
88
|
+
.description("one message by its id")
|
|
89
|
+
.action(async function (chat, messageId) {
|
|
90
|
+
await readWindow(this, chat, messageId, { before: 0, after: 0 }, "messages show");
|
|
91
|
+
});
|
|
92
|
+
command
|
|
93
|
+
.command("context")
|
|
94
|
+
.argument("<chat>", "chat id, or part of a chat name")
|
|
95
|
+
.argument("<message>", "message id")
|
|
96
|
+
.description("a message and what came either side of it, oldest first")
|
|
97
|
+
.option("--before <n>", "how many before it", count, 5)
|
|
98
|
+
.option("--after <n>", "how many after it", count, 5)
|
|
99
|
+
.action(async function (chat, messageId) {
|
|
100
|
+
const { before, after } = this.opts();
|
|
101
|
+
await readWindow(this, chat, messageId, { before, after }, "messages context");
|
|
102
|
+
});
|
|
38
103
|
/**
|
|
39
104
|
* One message, one command, no retry.
|
|
40
105
|
*
|
|
41
106
|
* There is no `--dry-run` here: the target and the text are both in the line the person typed, so
|
|
42
107
|
* a preview would restate the command back at them (REQUIREMENTS §21). What this command does owe
|
|
43
108
|
* the caller is honesty about an outcome it does not know — see `MaxClient.messages.send`.
|
|
109
|
+
*
|
|
110
|
+
* **The body may come from a pipe instead**, by leaving the argument off — `readBody` says why
|
|
111
|
+
* argv is the wrong place for it and why omission is the signal rather than a flag.
|
|
44
112
|
*/
|
|
45
113
|
command
|
|
46
114
|
.command("send")
|
|
47
115
|
.argument("<chat>", "chat id, or part of a chat name")
|
|
48
|
-
.argument("
|
|
116
|
+
.argument("[text]", "what to say; leave it off to read the message from stdin")
|
|
49
117
|
.description("send one text message")
|
|
50
118
|
.option("--cid <n>", "reuse a client id from an earlier ambiguous send; MAX collapses the duplicate", (value) => Number.parseInt(value, 10))
|
|
51
119
|
// `notify` is part of MSG_SEND and has always been sent as `true`. It is the one send option
|
|
@@ -54,13 +122,16 @@ export const messagesCommand = () => {
|
|
|
54
122
|
.option("--silent", "deliver without a notification")
|
|
55
123
|
.action(async function (chat, text) {
|
|
56
124
|
const options = this.optsWithGlobals();
|
|
57
|
-
const { renderer, settings, createClient, run } = forCommand(
|
|
125
|
+
const { renderer, settings, createClient, run } = forCommand(this);
|
|
126
|
+
// Before the run directory and before the socket: a body we cannot read is a command that
|
|
127
|
+
// never attempted anything, so there is nothing to record and nothing to close.
|
|
128
|
+
const body = text ?? (await readBody());
|
|
58
129
|
const cache = await openProfileCache(settings.profile, { onProblem: (message) => renderer.note(message) });
|
|
59
130
|
await run("messages send", async (events) => {
|
|
60
131
|
const client = createClient({ events, ...(cache ? { cache } : {}) });
|
|
61
132
|
try {
|
|
62
133
|
const chatId = await client.chats.resolve(chat);
|
|
63
|
-
const sent = await client.messages.send(chatId,
|
|
134
|
+
const sent = await client.messages.send(chatId, body, {
|
|
64
135
|
...(options.cid === undefined ? {} : { cid: options.cid }),
|
|
65
136
|
...(options.silent === true ? { notify: false } : {}),
|
|
66
137
|
});
|
|
@@ -74,4 +145,57 @@ export const messagesCommand = () => {
|
|
|
74
145
|
});
|
|
75
146
|
return command;
|
|
76
147
|
};
|
|
148
|
+
const feed = ({ color, settings }) => (messages) => renderMessages(messages, {
|
|
149
|
+
color,
|
|
150
|
+
senderColors: settings.senderColors,
|
|
151
|
+
verbosity: settings.detail,
|
|
152
|
+
width: process.stdout.columns ?? 80,
|
|
153
|
+
profile: settings.profile,
|
|
154
|
+
});
|
|
155
|
+
/**
|
|
156
|
+
* `--chat` on a search takes an id, because resolving a name needs the chat list and the chat list
|
|
157
|
+
* needs a login — which this command promises not to spend. Refused by name rather than silently
|
|
158
|
+
* searching every chat, since "I asked for one chat and got all of them" is a wrong answer.
|
|
159
|
+
*/
|
|
160
|
+
const offlineChat = (reference) => {
|
|
161
|
+
const trimmed = reference.trim();
|
|
162
|
+
if (/^-?\d+$/.test(trimmed))
|
|
163
|
+
return trimmed;
|
|
164
|
+
throw new CliError("validation_error", `\`messages search --chat\` takes a chat id, not a name — searching never connects, and a name ` +
|
|
165
|
+
`can only be resolved by asking MAX. \`max chats list --search ${trimmed}\` gives you the id.`);
|
|
166
|
+
};
|
|
167
|
+
const count = (value) => {
|
|
168
|
+
const parsed = Number.parseInt(value, 10);
|
|
169
|
+
if (!Number.isInteger(parsed) || parsed < 0 || parsed > 100) {
|
|
170
|
+
throw new CliError("validation_error", `expected a number from 0 to 100, not "${value}"`);
|
|
171
|
+
}
|
|
172
|
+
return parsed;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* `show` is a window of none either side. **In JSON the one asked for carries `anchor: true`**
|
|
176
|
+
* (`NEED-131`); `show` answers the bare message, `context` an object holding the window.
|
|
177
|
+
*/
|
|
178
|
+
const readWindow = async (command, chat, messageId, window, name) => {
|
|
179
|
+
const context = forCommand(command);
|
|
180
|
+
const { renderer, settings, createClient, run, format, streams } = context;
|
|
181
|
+
const cache = await openProfileCache(settings.profile, { onProblem: (message) => renderer.note(message) });
|
|
182
|
+
await run(name, async (events) => {
|
|
183
|
+
const client = createClient({ events, ...(cache ? { cache } : {}) });
|
|
184
|
+
try {
|
|
185
|
+
const chatId = await client.chats.resolve(chat);
|
|
186
|
+
const found = await client.messages.around(chatId, messageId.trim(), window);
|
|
187
|
+
const single = window.before === 0 && window.after === 0;
|
|
188
|
+
if (format === "pretty")
|
|
189
|
+
streams.data(feed(context)(found));
|
|
190
|
+
else if (format === "jsonl")
|
|
191
|
+
renderer.stream(found);
|
|
192
|
+
else
|
|
193
|
+
renderer.result(single ? found[0] : { items: found });
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
await client.close();
|
|
197
|
+
cache?.close();
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
};
|
|
77
201
|
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/commands/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/commands/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAuB,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAY,EAAE;IAC3C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,kCAAkC,CAAC,CAAA;IAEvF;;;OAGG;IACH,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,QAAQ,EAAE,iCAAiC,CAAC;SACrD,WAAW,CAAC,yCAAyC,CAAC;SACtD,MAAM,CAAC,aAAa,EAAE,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACjF,0FAA0F;QAC1F,6FAA6F;QAC7F,mFAAmF;SAClF,MAAM,CAAC,uBAAuB,EAA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import type { Renderer, RenderFormat } from "@leemour/cli-core";
|
|
1
|
+
import type { Renderer, RenderFormat, Streams } from "@leemour/cli-core";
|
|
2
2
|
import type { Command } from "commander";
|
|
3
3
|
import type { Settings } from "../config.js";
|
|
4
4
|
import type { Page } from "../domain/models.js";
|
|
@@ -30,9 +30,12 @@ export declare const window: ({ limit, page, all }: Settings) => {
|
|
|
30
30
|
* It is a helper each command calls rather than something inside `renderer.result`, because
|
|
31
31
|
* `account show` and `session start` are not lists and keep answering a bare object.
|
|
32
32
|
*/
|
|
33
|
-
export declare const renderPage: <T>({ renderer, format, settings }: {
|
|
33
|
+
export declare const renderPage: <T>({ renderer, format, settings, streams, }: {
|
|
34
34
|
renderer: Renderer;
|
|
35
35
|
format: RenderFormat;
|
|
36
36
|
settings: Settings;
|
|
37
|
-
|
|
37
|
+
streams: Streams;
|
|
38
|
+
}, { items, hasMore }: Page<T>, view?: (items: T[]) => string,
|
|
39
|
+
/** What to type for the rest, when the listing is not paged by `--page`. */
|
|
40
|
+
more?: (items: T[]) => string) => void;
|
|
38
41
|
//# sourceMappingURL=paging.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../../src/commands/paging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../../src/commands/paging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,OAAO,KAAG,OAIF,CAAA;AAE5C;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GAAI,sBAAsB,QAAQ,KAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAC3B,CAAA;AAE7D;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAC1B,0CAKG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,EACrF,oBAAoB,IAAI,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,MAAM;AAC7B,4EAA4E;AAC5E,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,MAAM,KAC5B,IAsBF,CAAA"}
|
package/dist/commands/paging.js
CHANGED
|
@@ -26,7 +26,15 @@ export const window = ({ limit, page, all }) => all ? { offset: 0 } : { limit, o
|
|
|
26
26
|
* It is a helper each command calls rather than something inside `renderer.result`, because
|
|
27
27
|
* `account show` and `session start` are not lists and keep answering a bare object.
|
|
28
28
|
*/
|
|
29
|
-
export const renderPage = ({ renderer, format, settings }, { items, hasMore }
|
|
29
|
+
export const renderPage = ({ renderer, format, settings, streams, }, { items, hasMore }, view,
|
|
30
|
+
/** What to type for the rest, when the listing is not paged by `--page`. */
|
|
31
|
+
more) => {
|
|
32
|
+
if (format === "jsonl") {
|
|
33
|
+
renderer.stream(items);
|
|
34
|
+
if (!settings.all && hasMore)
|
|
35
|
+
renderer.note(more ? more(items) : `more — \`--page ${settings.page + 1}\` for the next`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
30
38
|
if (format !== "pretty") {
|
|
31
39
|
renderer.result({
|
|
32
40
|
items,
|
|
@@ -36,8 +44,11 @@ export const renderPage = ({ renderer, format, settings }, { items, hasMore }) =
|
|
|
36
44
|
});
|
|
37
45
|
return;
|
|
38
46
|
}
|
|
39
|
-
|
|
47
|
+
if (view)
|
|
48
|
+
streams.data(view(items));
|
|
49
|
+
else
|
|
50
|
+
renderer.result(items);
|
|
40
51
|
if (!settings.all && hasMore)
|
|
41
|
-
renderer.note(`page ${settings.page} of more — \`--page ${settings.page + 1}\` for the next`);
|
|
52
|
+
renderer.note(more ? more(items) : `page ${settings.page} of more — \`--page ${settings.page + 1}\` for the next`);
|
|
42
53
|
};
|
|
43
54
|
//# sourceMappingURL=paging.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paging.js","sourceRoot":"","sources":["../../src/commands/paging.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAW,EAAE,CACtD,OAAO;KACJ,MAAM,CAAC,aAAa,EAAE,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;KAChF,MAAM,CAAC,YAAY,EAAE,2BAA2B,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;KACxF,MAAM,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAY,EAAsC,EAAE,CAC3F,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,CAAA;AAE7D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,
|
|
1
|
+
{"version":3,"file":"paging.js","sourceRoot":"","sources":["../../src/commands/paging.ts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AI,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxB,QAAQ,CAAC,MAAM,CAAC;YACd,KAAK;YACL,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI;YACtC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK;YACnD,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;SACxC,CAAC,CAAA;QACF,OAAM;IACR,CAAC;IAED,IAAI,IAAI;QAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;;QAC9B,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC3B,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO;QAC1B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,QAAQ,CAAC,IAAI,uBAAuB,QAAQ,CAAC,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAA;AACtH,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/commands/runs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAO,
|
|
1
|
+
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/commands/runs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAO,OA8C9B,CAAA"}
|
package/dist/commands/runs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@leemour/cli-core";
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
-
import { resolveOutput } from "../output.js";
|
|
4
3
|
import { findRun, listRuns, readEvents, runsDirFor } from "../runs/run.js";
|
|
4
|
+
import { outputFor } from "./context.js";
|
|
5
5
|
/**
|
|
6
6
|
* What this tool did, when it was asked to keep the record.
|
|
7
7
|
*
|
|
@@ -16,7 +16,7 @@ export const runsCommand = () => {
|
|
|
16
16
|
.option("--limit <n>", "how many to show", (value) => Number.parseInt(value, 10), 20)
|
|
17
17
|
.action(function () {
|
|
18
18
|
const options = this.optsWithGlobals();
|
|
19
|
-
const { renderer } =
|
|
19
|
+
const { renderer } = outputFor(this);
|
|
20
20
|
const runs = listRuns(runsDirFor());
|
|
21
21
|
renderer.result(runs.slice(0, options.limit));
|
|
22
22
|
// An empty list reads as broken otherwise, and the reason is that nothing asked for a
|
|
@@ -30,8 +30,7 @@ export const runsCommand = () => {
|
|
|
30
30
|
.argument("<run-id>", "an id from `max runs list`")
|
|
31
31
|
.description("one run: what it was, and one line per request")
|
|
32
32
|
.action(function (id) {
|
|
33
|
-
const
|
|
34
|
-
const { renderer } = resolveOutput(options);
|
|
33
|
+
const { renderer } = outputFor(this);
|
|
35
34
|
const found = runOrRefuse(id);
|
|
36
35
|
// Both, because neither answers the question on its own: the metadata says how it ended and
|
|
37
36
|
// the events say where it went.
|
|
@@ -42,8 +41,7 @@ export const runsCommand = () => {
|
|
|
42
41
|
.argument("<run-id>", "an id from `max runs list`")
|
|
43
42
|
.description("the directory holding one run")
|
|
44
43
|
.action(function (id) {
|
|
45
|
-
const
|
|
46
|
-
const { renderer } = resolveOutput(options);
|
|
44
|
+
const { renderer } = outputFor(this);
|
|
47
45
|
// One JSON value on stdout here too, with no exception for convenience (`NEED-88`): a script
|
|
48
46
|
// reads `--json | jq -r .path`, and a terminal prints the bare path as a labelled line.
|
|
49
47
|
renderer.result({ path: runOrRefuse(id).dir });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/commands/runs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/commands/runs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAY,EAAE;IACvC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,8CAA8C,CAAC,CAAA;IAE/F,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,6BAA6B,CAAC;SAC1C,MAAM,CAAC,aAAa,EAAE,kBAAkB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;SACpF,MAAM,CAAC;QACN,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,EAAE,CAAA;QACtC,MAAM,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;QACpC,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;QAEnC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;QAE7C,sFAAsF;QACtF,qFAAqF;QACrF,uE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AAEjG,MAAM,WAAW,GAAG,CAAC,EAAU,EAAE,EAAE;IACjC,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,EAAE,EAAE,EAAE,CAAC,CAAA;IACvC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,QAAQ,CAAC,WAAW,EAAE,oBAAoB,EAAE,2CAA2C,CAAC,CAAA;IAC9G,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
package/dist/commands/session.js
CHANGED
|
@@ -21,7 +21,7 @@ export const sessionCommand = () => {
|
|
|
21
21
|
.command("start")
|
|
22
22
|
.description("store a MAX session for this profile")
|
|
23
23
|
.action(async function () {
|
|
24
|
-
const { renderer, settings, store, createClient, run } = forCommand(this
|
|
24
|
+
const { renderer, settings, store, createClient, run } = forCommand(this);
|
|
25
25
|
// Creation is the only moment the collision can still be explained; after this the name is
|
|
26
26
|
// written down and `max <name>` would silently be a command instead.
|
|
27
27
|
refuseCommandName(settings.profile, commandWords(rootOf(this)));
|
|
@@ -57,7 +57,7 @@ export const sessionCommand = () => {
|
|
|
57
57
|
.command("end")
|
|
58
58
|
.description("forget the stored session for this profile")
|
|
59
59
|
.action(async function () {
|
|
60
|
-
const { renderer, store, run } = forCommand(this
|
|
60
|
+
const { renderer, store, run } = forCommand(this);
|
|
61
61
|
// It contacts nobody, so the run holds no events — but forgetting a session is an action, and
|
|
62
62
|
// "when did this profile stop working" is a question the record is kept to answer.
|
|
63
63
|
await run("session end", async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,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;YAClC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAA;YAE1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,CAAA;YACnF,IAAI,GAAG;gBAAE,QAAQ,CAAC,OAAO,CAAC,2BAA2B,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;;gBACjF,QAAQ,CAAC,IAAI,CAAC,6BAA6B,KAAK,CAAC,OAAO,GAAG,CAAC,CAAA;QACnE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEJ,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../src/commands/skill.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMnC,eAAO,MAAM,YAAY,QAAO,OAgB/B,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { forCommand } from "./context.js";
|
|
4
|
+
/** Beside `dist/` in the package and in a checkout alike, so the skill is always this version's. */
|
|
5
|
+
const SKILL = new URL("../../skills/max-cli/SKILL.md", import.meta.url);
|
|
6
|
+
export const skillCommand = () => {
|
|
7
|
+
const command = new Command("skill").description("the instructions an agent is given for this tool");
|
|
8
|
+
command
|
|
9
|
+
.command("show")
|
|
10
|
+
.description("print SKILL.md — `max skill show > ~/.claude/skills/max-cli/SKILL.md` installs it")
|
|
11
|
+
.action(function () {
|
|
12
|
+
const { settings, renderer, streams } = forCommand(this);
|
|
13
|
+
const content = readFileSync(SKILL, "utf8").trimEnd();
|
|
14
|
+
// The file itself even into a pipe: installing it *is* a redirect, and a redirect is where
|
|
15
|
+
// every other command switches to JSON. Asked for by name, it is JSON like the rest.
|
|
16
|
+
if (settings.json || settings.jsonl)
|
|
17
|
+
renderer.result({ name: "max-cli", content });
|
|
18
|
+
else
|
|
19
|
+
streams.data(content);
|
|
20
|
+
});
|
|
21
|
+
return command;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=skill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.js","sourceRoot":"","sources":["../../src/commands/skill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,oGAAoG;AACpG,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,+BAA+B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAEvE,MAAM,CAAC,MAAM,YAAY,GAAG,GAAY,EAAE;IACxC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAA;IAEpG,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,mFAAmF,CAAC;SAChG,MAAM,CAAC;QACN,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;QACxD,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,CAAA;QACrD,2FAA2F;QAC3F,qFAAqF;QACrF,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,KAAK;YAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAA;;YAC7E,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEJ,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/dist/config.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const configSchema: v.StrictObjectSchema<{
|
|
|
5
5
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>;
|
|
6
6
|
readonly timeoutMs: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>;
|
|
7
7
|
readonly color: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
8
|
+
readonly senderColors: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
8
9
|
/** The run log reads these two; nothing records anything until it exists. */
|
|
9
10
|
readonly record: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
10
11
|
readonly keepRunsForDays: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>;
|
|
@@ -15,20 +16,30 @@ export type Config = v.InferOutput<typeof configSchema>;
|
|
|
15
16
|
export interface GlobalFlags {
|
|
16
17
|
profile?: string;
|
|
17
18
|
json?: boolean;
|
|
19
|
+
jsonl?: boolean;
|
|
18
20
|
quiet?: boolean;
|
|
19
|
-
verbose?:
|
|
21
|
+
verbose?: number;
|
|
22
|
+
trace?: boolean;
|
|
20
23
|
limit?: number;
|
|
21
24
|
page?: number;
|
|
22
25
|
all?: boolean;
|
|
23
26
|
record?: boolean;
|
|
27
|
+
/** Raw text from `--timeout`, parsed here so the unit rule lives in one place. */
|
|
28
|
+
timeout?: string;
|
|
24
29
|
}
|
|
25
30
|
export interface Settings {
|
|
26
31
|
profile: string;
|
|
32
|
+
/** Where the profile came from, decided here so nothing has to re-derive the order. */
|
|
27
33
|
json: boolean;
|
|
34
|
+
jsonl: boolean;
|
|
28
35
|
quiet: boolean;
|
|
29
|
-
|
|
36
|
+
/** How much of what the model knows a human view shows: `-v`, `-vv`. */
|
|
37
|
+
detail: 0 | 1 | 2;
|
|
38
|
+
trace: boolean;
|
|
30
39
|
/** Unset means "decide from the terminal", which is `resolveOutput`'s job, not this one's. */
|
|
31
40
|
color: boolean | undefined;
|
|
41
|
+
/** A colour per sender in `messages` — a matter of taste, so off until the profile asks. */
|
|
42
|
+
senderColors: boolean;
|
|
32
43
|
limit: number;
|
|
33
44
|
/** Which page, 1-based. Per invocation only — a page number in a configuration file is a setting nobody wants twice. */
|
|
34
45
|
page: number;
|
|
@@ -36,11 +47,31 @@ export interface Settings {
|
|
|
36
47
|
all: boolean;
|
|
37
48
|
/** Unset means the transport's own default; the number lives in `protocol/connection.ts`. */
|
|
38
49
|
timeoutMs: number | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* How long the **whole command** may take, or `undefined` for no bound.
|
|
52
|
+
*
|
|
53
|
+
* ⚠ Not the same thing as `timeoutMs`, which is one request's wait. One read is a connect, an
|
|
54
|
+
* INIT, a LOGIN, a name to resolve and then the request itself, so the wall clock is a multiple
|
|
55
|
+
* of `timeoutMs` and never equal to it. An agent given thirty seconds needs to say *thirty
|
|
56
|
+
* seconds*, and this is the only setting that means that.
|
|
57
|
+
*
|
|
58
|
+
* They are spelled differently on purpose — a number of milliseconds in the file, a duration
|
|
59
|
+
* with a unit on the command line — because two settings called "timeout" that mean different
|
|
60
|
+
* things are otherwise a trap.
|
|
61
|
+
*/
|
|
62
|
+
commandTimeoutMs: number | undefined;
|
|
39
63
|
record: boolean;
|
|
40
64
|
keepRunsForDays: number;
|
|
41
65
|
/** Named in errors and in `max --help`, so a person can find the file that decided this. */
|
|
42
66
|
configPath: string;
|
|
67
|
+
configFound: boolean;
|
|
68
|
+
/** Profiles the configuration file names, whether or not anyone has logged in to them. */
|
|
69
|
+
configuredProfiles: string[];
|
|
70
|
+
/** Where each value came from — `max config show` prints it. */
|
|
71
|
+
sources: Record<SourcedSetting, Source>;
|
|
43
72
|
}
|
|
73
|
+
export type Source = "first word" | "flag" | "MAX_PROFILE" | "MAX_TIMEOUT" | "config file" | "default";
|
|
74
|
+
export type SourcedSetting = "profile" | "limit" | "timeoutMs" | "commandTimeoutMs" | "color" | "senderColors" | "record" | "keepRunsForDays";
|
|
44
75
|
export interface ResolveOptions {
|
|
45
76
|
env?: NodeJS.ProcessEnv;
|
|
46
77
|
/** Tests pass a temporary directory; nothing else should need this. */
|
|
@@ -50,10 +81,23 @@ export interface ResolveOptions {
|
|
|
50
81
|
* **Flag, then environment, then the configuration file, then the built-in default.** One place,
|
|
51
82
|
* so no command can decide the order differently from another.
|
|
52
83
|
*
|
|
84
|
+
* ⚠ **Only two settings actually have the middle step** — `MAX_PROFILE` and `MAX_TIMEOUT` — and
|
|
85
|
+
* that is deliberate rather than unfinished (`NEED-119`). They are the two an agent sets once for
|
|
86
|
+
* a whole process. A variable for `--json` or `--color` would be worse than missing: one left set
|
|
87
|
+
* in a shell silently changes the output of a command that never asked for it.
|
|
88
|
+
*
|
|
53
89
|
* Two things already jump this queue and are documented rather than re-litigated here:
|
|
54
90
|
* `MAX_TOKEN` outranks the keyring (`cli-core`'s `Credentials.read`), and `MAX_CONFIG_DIR`,
|
|
55
91
|
* `MAX_STATE_DIR` or `MAX_CACHE_DIR` move the whole installation — including which keyring entry
|
|
56
92
|
* a profile means (`ARCHITECTURE.md` §13).
|
|
57
93
|
*/
|
|
58
94
|
export declare const resolveSettings: (flags?: GlobalFlags, { env, configDir }?: ResolveOptions) => Settings;
|
|
95
|
+
/**
|
|
96
|
+
* The profile names written in the configuration file.
|
|
97
|
+
*
|
|
98
|
+
* ⚠ **This is not every profile that works.** `max <name> session start` stores a token under any
|
|
99
|
+
* name without writing anything to the file, so a profile can be in daily use and absent here.
|
|
100
|
+
* Whoever prints this has to say so, or it reads as a complete list and quietly is not.
|
|
101
|
+
*/
|
|
102
|
+
export declare const configuredProfiles: ({ env, configDir }?: ResolveOptions) => string[];
|
|
59
103
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AA8B5B,eAAO,MAAM,YAAY;;;;;;;QALvB,6EAA6E;;;;aAQ7E,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,YAAY,CAAC,CAAA;AAEvD,gGAAgG;AAChG,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,uFAAuF;IACvF,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,OAAO,CAAA;IACd,wEAAwE;IACxE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,8FAA8F;IAC9F,KAAK,EAAE,OAAO,GAAG,SAAS,CAAA;IAC1B,4FAA4F;IAC5F,YAAY,EAAE,OAAO,CAAA;IACrB,KAAK,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