reasonally 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -12
- package/dist/agent/bundled-commands.js +24 -0
- package/dist/agent/command-files.js +334 -0
- package/dist/agent/command-template.js +179 -0
- package/dist/agent/compact.js +58 -8
- package/dist/agent/context.js +82 -0
- package/dist/agent/loop.js +128 -31
- package/dist/agent/permissions.js +91 -0
- package/dist/agent/session.js +73 -5
- package/dist/browser/guards.js +15 -0
- package/dist/browser/messages.js +61 -0
- package/dist/browser/sessions.js +2 -60
- package/dist/tui/app.js +164 -38
- package/dist/tui/commands.js +71 -15
- package/package.json +1 -1
package/dist/tui/commands.js
CHANGED
|
@@ -1,24 +1,65 @@
|
|
|
1
1
|
export const COMMANDS = [
|
|
2
|
-
{ name: "model", description: "Switch model" },
|
|
2
|
+
{ name: "model", description: "Switch model", argumentHint: "[name]" },
|
|
3
3
|
{
|
|
4
4
|
name: "mode",
|
|
5
5
|
description: "Switch between asking, auto-accepting edits, planning first, and not asking",
|
|
6
|
+
argumentHint: "[ask|auto|plan|full]",
|
|
6
7
|
},
|
|
7
|
-
{
|
|
8
|
+
{
|
|
9
|
+
name: "plan",
|
|
10
|
+
description: "Plan first; nothing changes until you approve",
|
|
11
|
+
argumentHint: "[task]",
|
|
12
|
+
},
|
|
13
|
+
{ name: "new", description: "Start a new conversation", aliases: ["clear"] },
|
|
8
14
|
{ name: "resume", description: "Continue an earlier conversation in this folder" },
|
|
9
|
-
{
|
|
10
|
-
|
|
15
|
+
{
|
|
16
|
+
name: "compact",
|
|
17
|
+
description: "Summarize the conversation so far to free up context",
|
|
18
|
+
argumentHint: "[focus]",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "usage",
|
|
22
|
+
description: "Show this session's cost, the context used and your balance",
|
|
23
|
+
aliases: ["cost", "context"],
|
|
24
|
+
},
|
|
11
25
|
{ name: "mcp", description: "Show MCP servers and their tools" },
|
|
12
26
|
{ name: "login", description: "Log in again (e.g. after a key was revoked)" },
|
|
13
27
|
{ name: "help", description: "Show commands and keys" },
|
|
14
|
-
{ name: "exit", description: "Quit" },
|
|
28
|
+
{ name: "exit", description: "Quit", aliases: ["quit"] },
|
|
15
29
|
];
|
|
16
|
-
/**
|
|
17
|
-
export function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
/** The command a name or alias runs, or null when it isn't one of the app's own. */
|
|
31
|
+
export function appCommand(name) {
|
|
32
|
+
return COMMANDS.find((c) => c.name === name || c.aliases?.includes(name)) ?? null;
|
|
33
|
+
}
|
|
34
|
+
/** Where a saved command came from, as the help and the menu label it. */
|
|
35
|
+
export const SOURCE_LABELS = {
|
|
36
|
+
bundled: "Reasonally",
|
|
37
|
+
project: "Project",
|
|
38
|
+
personal: "Personal",
|
|
39
|
+
claude: "Claude Code",
|
|
40
|
+
codex: "Codex",
|
|
41
|
+
};
|
|
42
|
+
/** Saved commands named like what was typed, for "did you mean". */
|
|
43
|
+
export function closeMatches(name, names) {
|
|
44
|
+
return names
|
|
45
|
+
.map((n) => ({ n, d: distance(name, n) }))
|
|
46
|
+
.filter(({ n, d }) => d <= 2 || (name.length > 1 && n.startsWith(name)))
|
|
47
|
+
.sort((a, b) => a.d - b.d)
|
|
48
|
+
.slice(0, 3)
|
|
49
|
+
.map(({ n }) => n);
|
|
50
|
+
}
|
|
51
|
+
function distance(a, b) {
|
|
52
|
+
const row = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
53
|
+
for (let i = 1; i <= a.length; i++) {
|
|
54
|
+
let prev = row[0];
|
|
55
|
+
row[0] = i;
|
|
56
|
+
for (let j = 1; j <= b.length; j++) {
|
|
57
|
+
const next = row[j];
|
|
58
|
+
row[j] = Math.min(row[j] + 1, row[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
59
|
+
prev = next;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return row[b.length];
|
|
22
63
|
}
|
|
23
64
|
export const KEYS = [
|
|
24
65
|
["Enter", "send · Shift+Enter or Ctrl+J for a new line"],
|
|
@@ -28,15 +69,30 @@ export const KEYS = [
|
|
|
28
69
|
["Ctrl+G", "edit a waiting plan in your editor"],
|
|
29
70
|
["Ctrl+C", "clear the input · twice to quit"],
|
|
30
71
|
["@", "mention a file"],
|
|
72
|
+
["/", "a command, at the start of a message"],
|
|
31
73
|
["↑ ↓", "earlier messages"],
|
|
32
74
|
];
|
|
33
|
-
|
|
34
|
-
|
|
75
|
+
const usage = (c) => `/${c.name}${c.argumentHint ? ` ${c.argumentHint}` : ""}`;
|
|
76
|
+
export function helpText(saved = [], problems = [], home = "") {
|
|
77
|
+
const prompts = saved.filter((c) => c.source === "bundled");
|
|
78
|
+
const yours = saved.filter((c) => c.source !== "bundled");
|
|
79
|
+
const rows = [...COMMANDS.map((c) => usage(c)), ...saved.map(usage)];
|
|
80
|
+
const width = Math.max(...rows.map((r) => r.length)) + 2;
|
|
81
|
+
const short = (path) => home && path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
35
82
|
return [
|
|
36
83
|
"Commands",
|
|
37
|
-
...COMMANDS.map((c) => `
|
|
84
|
+
...COMMANDS.map((c) => ` ${usage(c).padEnd(width)}${c.description}`),
|
|
85
|
+
...prompts.map((c) => ` ${usage(c).padEnd(width)}${c.description}`),
|
|
86
|
+
...(yours.length
|
|
87
|
+
? [
|
|
88
|
+
"",
|
|
89
|
+
"Your commands",
|
|
90
|
+
...yours.map((c) => ` ${usage(c).padEnd(width)}${c.description ? `${c.description} · ` : ""}${SOURCE_LABELS[c.source]}`),
|
|
91
|
+
]
|
|
92
|
+
: ["", "Save a prompt as .reasonally/commands/<name>.md to run it as /<name>."]),
|
|
93
|
+
...problems.map((p) => ` Skipped ${short(p.path)}: ${p.reason}.`),
|
|
38
94
|
"",
|
|
39
95
|
"Keys",
|
|
40
|
-
...KEYS.map(([key, what]) => ` ${key.padEnd(width
|
|
96
|
+
...KEYS.map(([key, what]) => ` ${key.padEnd(width)}${what}`),
|
|
41
97
|
].join("\n");
|
|
42
98
|
}
|