heartcode 0.1.45 → 0.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +286 -0
- package/README.md +147 -126
- package/SKILL.md +16 -18
- package/bin/heartcode.js +146 -93
- package/package.json +2 -2
- package/prompts/README.md +1 -1
- package/prompts/agent.md +252 -352
- package/prompts/compact.md +24 -45
- package/prompts/guided.md +43 -67
- package/prompts/tests.md +15 -0
- package/src/acp.js +10 -5
- package/src/agent.js +211 -113
- package/src/check.js +411 -0
- package/src/client.js +25 -42
- package/src/config.js +10 -1
- package/src/guided.js +77 -26
- package/src/headless.js +31 -3
- package/src/log.js +1 -1
- package/src/lsp.js +10 -0
- package/src/mcp.js +30 -21
- package/src/prompts.js +1 -0
- package/src/reset.js +1 -1
- package/src/sessions.js +56 -17
- package/src/settings.html +296 -154
- package/src/settings.js +108 -43
- package/src/skills.js +42 -7
- package/src/tabs.js +6 -2
- package/src/tools.js +185 -56
- package/src/ui.js +449 -110
package/prompts/compact.md
CHANGED
|
@@ -7,48 +7,45 @@ its section into ~/.heart/prompts/compact.md (every project) or .heartcode/promp
|
|
|
7
7
|
|
|
8
8
|
## summarizer
|
|
9
9
|
|
|
10
|
-
<!--
|
|
11
|
-
You
|
|
10
|
+
<!-- The system prompt of the summary request. -->
|
|
11
|
+
You summarize conversations between a user and a coding assistant. Don't continue the work. No tools: write only the summary, as plain text.
|
|
12
12
|
|
|
13
13
|
## findings
|
|
14
14
|
|
|
15
|
-
<!-- Asked of the model doing the task, as the next message of its own conversation, just before the
|
|
16
|
-
conversation
|
|
17
|
-
The earlier part of this conversation is about to be replaced by a summary, and your reasoning so far will be gone. Write down now what you'd need to carry on without reading everything again: what you found and concluded (causes, decisions, what works and what doesn't), where things are (files, lines, names), what's done, and what's next. Plain notes, only what matters. Don't call tools.
|
|
15
|
+
<!-- Asked of the model doing the task, as the next message of its own conversation, just before it's compacted. Its reply leads the summary that replaces the conversation. -->
|
|
16
|
+
The earlier part of this conversation will be replaced by a summary, and your reasoning will be gone. Write down what you need to carry on: what you found and concluded (causes, decisions, what works and what doesn't), where things are (files, lines, names), what's done, and what's next. Plain notes, only what matters. No tools.
|
|
18
17
|
|
|
19
18
|
## summarize-again
|
|
20
19
|
|
|
21
20
|
<!-- Added when the first reply wasn't a summary (empty, or a tool call). -->
|
|
22
|
-
Your last reply was not a summary.
|
|
21
|
+
Your last reply was not a summary. No tools, don't continue the task: write the summary now, as plain notes.
|
|
23
22
|
|
|
24
23
|
## summarize
|
|
25
24
|
|
|
26
|
-
<!-- /compact and auto-compact:
|
|
27
|
-
{{conversation}}: the conversation as text. {{focus}}: what the user asked to keep (may be empty). -->
|
|
25
|
+
<!-- Asks for a summary of a conversation. {{conversation}}: it, as text. {{branch}}: set for /tree, when the user is leaving this part (a branch) for an earlier point; then {{files}}: the files it changed (may be empty). Else /compact and auto-compact, and {{focus}}: what the user asked to keep (may be empty). -->
|
|
28
26
|
<conversation>
|
|
29
27
|
{{conversation}}
|
|
30
28
|
</conversation>
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
{{#if branch}}The user is leaving the conversation above: they went back to an earlier point to try something else. Summarize it for the conversation they go on with:
|
|
31
|
+
- what was tried and how it went (what worked, what failed, why)
|
|
32
|
+
- decisions and findings worth keeping
|
|
33
|
+
- files changed there (with paths){{else}}Summarize the conversation above. Work continues from your summary alone; the original will be gone. Keep:
|
|
34
|
+
- what the user asked for (their words where it matters), and their preferences and decisions
|
|
35
|
+
- what was done: files read, created or changed (with paths) and the key details
|
|
36
|
+
- commands run and what they showed (errors, test results)
|
|
37
|
+
- what is unfinished or next{{/if}}{{#if files}}
|
|
38
|
+
Files it changed: {{files}}{{/if}}{{#if focus}}
|
|
39
|
+
Keep especially: {{focus}}{{/if}}
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
- what the user asked for, in their words where it matters, and any preferences or decisions they stated
|
|
36
|
-
- what has been done: files read, created or changed (with paths) and the important details of those changes
|
|
37
|
-
- commands that were run and what they showed (errors, test results)
|
|
38
|
-
- anything still unfinished or planned next
|
|
39
|
-
{{#if focus}}
|
|
40
|
-
The user asked to keep especially: {{focus}}
|
|
41
|
-
{{/if}}
|
|
42
|
-
Write it as compact notes. No preamble, no tool calls.
|
|
41
|
+
Write compact notes. No preamble, no tool calls.
|
|
43
42
|
|
|
44
43
|
## summary
|
|
45
44
|
|
|
46
|
-
<!-- Replaces the compacted part of the conversation. {{summary}}: the summary
|
|
47
|
-
model's own notes of what it had found, written just before (may be empty).
|
|
48
|
-
{{requests}}: the user's messages so far, word for word ("- …" lines; may be empty). -->
|
|
45
|
+
<!-- Replaces the compacted part of the conversation. {{summary}}: the summary. {{findings}}: the model's own notes, written just before (may be empty). {{requests}}: the user's messages so far, word for word ("- …" lines; may be empty). -->
|
|
49
46
|
This conversation was compacted to save space.{{#if findings}}
|
|
50
47
|
|
|
51
|
-
Your own notes, written just before
|
|
48
|
+
Your own notes, written just before:
|
|
52
49
|
|
|
53
50
|
{{findings}}{{/if}}
|
|
54
51
|
|
|
@@ -59,27 +56,10 @@ Summary of everything before this point:
|
|
|
59
56
|
The user's messages so far, word for word:
|
|
60
57
|
{{requests}}{{/if}}
|
|
61
58
|
|
|
62
|
-
## branch-summarize
|
|
63
|
-
|
|
64
|
-
<!-- /tree: the part of a branch the user is leaving, summarized for the branch they go to.
|
|
65
|
-
{{conversation}}: that part as text. {{files}}: the files it changed (may be empty). -->
|
|
66
|
-
<conversation>
|
|
67
|
-
{{conversation}}
|
|
68
|
-
</conversation>
|
|
69
|
-
|
|
70
|
-
The user is leaving the conversation above (a branch: they went back to an earlier point to try something else). Summarize it for the conversation they go on with, so what was learned isn't lost:
|
|
71
|
-
- what was tried and how it went (what worked, what failed and why)
|
|
72
|
-
- decisions and findings worth keeping
|
|
73
|
-
- files changed there (with paths){{#if files}}: {{files}}{{/if}}
|
|
74
|
-
|
|
75
|
-
Compact notes. No preamble, no tool calls.
|
|
76
|
-
|
|
77
59
|
## branch-note
|
|
78
60
|
|
|
79
|
-
<!-- Goes into the branch the user went to, before their next message. {{summary}}: the summary
|
|
80
|
-
|
|
81
|
-
still on disk (only one is set, and only when it changed files). -->
|
|
82
|
-
(The user went back to this point from another branch of this conversation. What happened on that branch, summarized:
|
|
61
|
+
<!-- Goes into the branch the user went to, before their next message. {{summary}}: the summary. {{files}}: the files the left branch changed. {{kept}} or {{restored}}: whether those changes are still on disk (one is set, only when it changed files). -->
|
|
62
|
+
(The user came back to this point from another branch of this conversation. What happened there:
|
|
83
63
|
|
|
84
64
|
{{summary}}{{#if files}}
|
|
85
65
|
|
|
@@ -92,17 +72,16 @@ That branch changed {{files}}.{{/if}}{{#if kept}} Those changes are still in the
|
|
|
92
72
|
|
|
93
73
|
## summary-lost
|
|
94
74
|
|
|
95
|
-
<!-- Stands in for a summary an older HeartCode lost
|
|
75
|
+
<!-- Stands in for a summary an older HeartCode lost. -->
|
|
96
76
|
(The summary of the earlier conversation was lost. Look at the project files to see where things stand.)
|
|
97
77
|
|
|
98
78
|
## continue
|
|
99
79
|
|
|
100
|
-
<!-- Sent after an automatic compaction in the middle of a task, so the model carries on.
|
|
101
|
-
{{task}}: the user's request it was working on, word for word (may be empty). -->
|
|
80
|
+
<!-- Sent after an automatic compaction in the middle of a task, so the model carries on. {{task}}: the request it was working on, word for word (may be empty). -->
|
|
102
81
|
Continue the task from where you left off.{{#if task}} The request you are working on:
|
|
103
82
|
{{task}}{{/if}}
|
|
104
83
|
|
|
105
84
|
## acknowledged
|
|
106
85
|
|
|
107
|
-
<!-- After a manual /compact
|
|
86
|
+
<!-- After a manual /compact: the model's side of the exchange (keeps user and assistant turns alternating). -->
|
|
108
87
|
Understood. I have the summary and will continue from it.
|
package/prompts/guided.md
CHANGED
|
@@ -7,18 +7,17 @@ its section into ~/.heart/prompts/guided.md (every project) or .heartcode/prompt
|
|
|
7
7
|
|
|
8
8
|
## system
|
|
9
9
|
|
|
10
|
-
<!--
|
|
11
|
-
You are HeartCode, a
|
|
12
|
-
HeartCode
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
<!-- The system prompt in guided mode (models without tool calls: one question at a time). -->
|
|
11
|
+
You are HeartCode, a careful coding agent working in the user's project.
|
|
12
|
+
HeartCode does the work in small steps. Each message asks you ONE thing. Answer exactly that, in the form asked. No explanation, no extra text.
|
|
13
|
+
- Use only what you are shown. Never invent a file path, name, flag or code.
|
|
14
|
+
- Write code complete and correct. No placeholders. Keep what should stay.
|
|
15
|
+
- Your memory of tools, libraries and APIs may be out of date: follow how the project's own files use them.
|
|
16
|
+
- Reuse what the project already has. Clear names. Comments only for what isn't obvious.
|
|
16
17
|
|
|
17
18
|
## context
|
|
18
19
|
|
|
19
|
-
<!-- What comes before every guided question.
|
|
20
|
-
{{task}}: the user's message. {{history}}: earlier messages and answers (may be empty).
|
|
21
|
-
{{files}}: the project's files (or a note that there are none). {{done}}: notes on the steps so far (may be empty). -->
|
|
20
|
+
<!-- What comes before every guided question. {{task}}: the user's message. {{history}}: earlier messages and answers (may be empty). {{files}}: the project's files (or a note that there are none). {{done}}: notes on the steps so far (may be empty). -->
|
|
22
21
|
TASK: {{task}}
|
|
23
22
|
{{#if history}}
|
|
24
23
|
EARLIER IN THIS CONVERSATION:
|
|
@@ -26,69 +25,45 @@ EARLIER IN THIS CONVERSATION:
|
|
|
26
25
|
{{/if}}
|
|
27
26
|
PROJECT FILES:{{files}}
|
|
28
27
|
{{#if done}}
|
|
29
|
-
|
|
28
|
+
DONE SO FAR:
|
|
30
29
|
{{done}}{{/if}}
|
|
31
30
|
|
|
32
31
|
## actions
|
|
33
32
|
|
|
34
|
-
<!-- The steps guided mode can take, one per line as "name: what it does".
|
|
35
|
-
The names are fixed (HeartCode acts on them); the descriptions are what the model sees in the menu. -->
|
|
33
|
+
<!-- The steps guided mode can take, one per line as "name: what it does". The names are fixed (HeartCode acts on them); the descriptions are what the model sees in the menu. -->
|
|
36
34
|
read: look at a file
|
|
37
35
|
search: find text in the project files
|
|
38
36
|
edit: change an existing file
|
|
39
37
|
create: make a new file
|
|
40
38
|
run: run a shell command (tests, build, scripts)
|
|
41
39
|
ask: ask the user a question
|
|
42
|
-
delegate:
|
|
43
|
-
finish: stop and give your final answer
|
|
40
|
+
delegate: give the task to another of your models that can use tools
|
|
41
|
+
finish: stop and give your final answer
|
|
44
42
|
|
|
45
43
|
## next-action
|
|
46
44
|
|
|
47
|
-
<!-- The step menu. {{menu}}: numbered steps, likeliest first. -->
|
|
45
|
+
<!-- The step menu. {{menu}}: numbered steps, likeliest first. {{reply}}: set when the last reply wasn't a number (what it said); {{count}}: how many steps. -->
|
|
48
46
|
What should you do next for the TASK?
|
|
49
47
|
{{menu}}
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
If DONE SO FAR shows the TASK is done, or it was a question you can now answer, choose finish.{{#if reply}}
|
|
50
|
+
"{{reply}}" is not a number from 1 to {{count}}.{{/if}}
|
|
52
51
|
Reply with only the number.
|
|
53
52
|
|
|
54
|
-
## next-action-retry
|
|
55
|
-
|
|
56
|
-
<!-- Added to the step menu when the reply wasn't a number. {{reply}}: what it said. {{count}}: how many steps. -->
|
|
57
|
-
Your reply "{{reply}}" is not a number from 1 to {{count}}. Reply with only the number.
|
|
58
|
-
|
|
59
|
-
## yes-no
|
|
60
|
-
|
|
61
|
-
<!-- A yes/no question. {{question}}: the question. -->
|
|
62
|
-
{{question}}
|
|
63
|
-
Reply with only yes or no.
|
|
64
|
-
|
|
65
53
|
## intent
|
|
66
54
|
|
|
67
55
|
<!-- Asked at the start of each task: does it need changes? -->
|
|
68
|
-
Does the TASK
|
|
56
|
+
Does the TASK need code changed or files created (not just a question answered)?
|
|
57
|
+
Reply with only yes or no.
|
|
69
58
|
|
|
70
59
|
## pick-file
|
|
71
60
|
|
|
72
|
-
<!-- Choosing a file. {{
|
|
73
|
-
{{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
## pick-file-retry
|
|
77
|
-
|
|
78
|
-
<!-- The answer wasn't a project file. {{said}}: the answer. {{choices}}: the closest files, one per line. -->
|
|
79
|
-
{{question}}
|
|
80
|
-
Your answer "{{said}}" is not a file in the project. Choose one of these:
|
|
81
|
-
{{choices}}
|
|
61
|
+
<!-- Choosing a file. {{edit}}: set when it's the file to change (else the file to read). {{said}}: set when the last answer wasn't a project file (what it said); {{choices}}: the closest files, one per line. -->
|
|
62
|
+
{{#if edit}}Which existing file should be changed?{{else}}Which file do you want to read?{{/if}}{{#if said}}
|
|
63
|
+
"{{said}}" is not a file in the project. Choose one of these:
|
|
64
|
+
{{choices}}{{/if}}
|
|
82
65
|
Reply with only the file path.
|
|
83
66
|
|
|
84
|
-
## which-file-to-read
|
|
85
|
-
|
|
86
|
-
Which file do you want to read?
|
|
87
|
-
|
|
88
|
-
## which-file-to-edit
|
|
89
|
-
|
|
90
|
-
Which existing file should be changed?
|
|
91
|
-
|
|
92
67
|
## search
|
|
93
68
|
|
|
94
69
|
What text should be searched for in the project files? Reply with only the search text.
|
|
@@ -96,10 +71,10 @@ What text should be searched for in the project files? Reply with only the searc
|
|
|
96
71
|
## edit-blocks
|
|
97
72
|
|
|
98
73
|
<!-- Editing with SEARCH/REPLACE blocks. {{file}}: path. {{content}}: the file, fenced. -->
|
|
99
|
-
|
|
74
|
+
The current content of {{file}}:
|
|
100
75
|
{{content}}
|
|
101
76
|
|
|
102
|
-
Write one or more SEARCH/REPLACE blocks that make the change
|
|
77
|
+
Write one or more SEARCH/REPLACE blocks that make the change the TASK needs. Use exactly this format:
|
|
103
78
|
<<<<<<< SEARCH
|
|
104
79
|
(lines copied exactly from the file)
|
|
105
80
|
=======
|
|
@@ -110,52 +85,53 @@ Reply with only the blocks.
|
|
|
110
85
|
## rewrite
|
|
111
86
|
|
|
112
87
|
<!-- Rewriting a whole file. {{file}}: path. {{content}}: the file, fenced. {{extra}}: an extra instruction (may be empty). -->
|
|
113
|
-
|
|
88
|
+
The current content of {{file}}:
|
|
114
89
|
{{content}}
|
|
115
90
|
|
|
116
|
-
Rewrite this file with the change
|
|
91
|
+
Rewrite this file with the change the TASK needs. Reply with the COMPLETE new file and nothing else. Keep everything that shouldn't change. Never write placeholders like "rest of code here".{{#if extra}}
|
|
117
92
|
{{extra}}{{/if}}
|
|
118
93
|
|
|
119
94
|
## meant-to-remove
|
|
120
95
|
|
|
121
96
|
<!-- Asked when an edit still removes definitions after a retry. {{names}}: what it removes. -->
|
|
122
|
-
Your edit removes {{names}}. Does the TASK ask
|
|
97
|
+
Your edit removes {{names}}. Does the TASK ask to remove or rename that?
|
|
98
|
+
Reply with only yes or no.
|
|
123
99
|
|
|
124
100
|
## keep-names
|
|
125
101
|
|
|
126
102
|
<!-- An edit deleted definitions the task didn't ask to remove. {{names}}: them. {{them}}: "it" or "them". -->
|
|
127
|
-
Your
|
|
103
|
+
Your last try deleted {{names}}. The TASK doesn't ask for that: keep {{them}} exactly as is.
|
|
128
104
|
|
|
129
105
|
## find-place
|
|
130
106
|
|
|
131
107
|
<!-- The file is too long to show. {{file}}: path. -->
|
|
132
|
-
{{file}} is too long to show whole. What word or text in it marks the place
|
|
108
|
+
{{file}} is too long to show whole. What word or text in it marks the place to change for the TASK? Reply with only that text.
|
|
133
109
|
|
|
134
110
|
## pick-range
|
|
135
111
|
|
|
136
112
|
<!-- Choosing the lines to rewrite in a long file. {{file}}: path. {{part}}: " (lines 10-80 of 400)" or empty. {{view}}: numbered lines, fenced. -->
|
|
137
|
-
|
|
113
|
+
Part of {{file}}{{part}}, with line numbers:
|
|
138
114
|
{{view}}
|
|
139
115
|
|
|
140
|
-
Which lines need to change for the TASK? Reply with only the
|
|
116
|
+
Which lines need to change for the TASK? Reply with only the range, like 12-30.
|
|
141
117
|
|
|
142
118
|
## rewrite-range
|
|
143
119
|
|
|
144
120
|
<!-- Rewriting a line range. {{file}}, {{a}}-{{b}}: the range. {{chunk}}, {{before}}, {{after}}: fenced code. {{extra}}: an extra instruction (may be empty). -->
|
|
145
|
-
In {{file}},
|
|
121
|
+
In {{file}}, lines {{a}}-{{b}}:
|
|
146
122
|
{{chunk}}
|
|
147
123
|
|
|
148
|
-
The lines just before
|
|
124
|
+
The lines just before:
|
|
149
125
|
{{before}}
|
|
150
|
-
The lines just after
|
|
126
|
+
The lines just after:
|
|
151
127
|
{{after}}
|
|
152
128
|
|
|
153
|
-
Write the new code that replaces lines {{a}}-{{b}} for the TASK (
|
|
129
|
+
Write the new code that replaces lines {{a}}-{{b}} for the TASK (more or fewer lines is fine).{{#if extra}}
|
|
154
130
|
{{extra}}{{/if}} Reply with only that code.
|
|
155
131
|
|
|
156
132
|
## new-file-path
|
|
157
133
|
|
|
158
|
-
What is the
|
|
134
|
+
What is the new file's path, relative to the project root? Reply with only the path.
|
|
159
135
|
|
|
160
136
|
## new-file
|
|
161
137
|
|
|
@@ -169,25 +145,25 @@ Which shell command should be run?
|
|
|
169
145
|
{{#if commands}}Commands this project has:
|
|
170
146
|
{{commands}}
|
|
171
147
|
|
|
172
|
-
Reply with a number from the list, or
|
|
148
|
+
Reply with a number from the list, or a different command.{{else}}Reply with only the command.{{/if}}
|
|
173
149
|
|
|
174
150
|
## ask-user
|
|
175
151
|
|
|
176
|
-
What
|
|
152
|
+
What do you want to ask the user? Reply with only the question.
|
|
177
153
|
|
|
178
154
|
## finish
|
|
179
155
|
|
|
180
|
-
Now write your final reply to the user: answer their request, or briefly
|
|
181
|
-
|
|
156
|
+
Now write your final reply to the user: answer their request, or say briefly what was changed.
|
|
157
|
+
Choices for the user: a numbered list (1. 2. 3.). Simple Markdown only (**bold**, `code`, plain lists, code blocks). No tables.
|
|
182
158
|
|
|
183
159
|
## describe-image
|
|
184
160
|
|
|
185
161
|
<!-- For an image attached with @file.png. {{task}}: the user's message. -->
|
|
186
|
-
The user attached this image to the task: "{{task}}". Describe everything in it that matters for the task: text, code,
|
|
162
|
+
The user attached this image to the task: "{{task}}". Describe everything in it that matters for the task: text, code, errors, layout. Thorough but short.
|
|
187
163
|
|
|
188
164
|
## note-repeated
|
|
189
165
|
|
|
190
|
-
You just did the same thing twice
|
|
166
|
+
You just did the same thing twice; again changes nothing. Choose a different step, or finish if the task is done.
|
|
191
167
|
|
|
192
168
|
## note-no-files
|
|
193
169
|
|
|
@@ -195,4 +171,4 @@ There are no files in the project.
|
|
|
195
171
|
|
|
196
172
|
## note-unknown-file
|
|
197
173
|
|
|
198
|
-
Could not
|
|
174
|
+
Could not tell which file was meant.
|
package/prompts/tests.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# tests.md
|
|
2
|
+
|
|
3
|
+
What the settings page's Test asks your models (Test, Test all). Each `## name` below is one prompt.
|
|
4
|
+
A `<!-- … -->` note under a heading explains it and is never sent. To change one, copy its section
|
|
5
|
+
into ~/.heart/prompts/tests.md, or edit it on the settings page.
|
|
6
|
+
|
|
7
|
+
## hello
|
|
8
|
+
|
|
9
|
+
<!-- Does it answer? One short message to the model; any reply in time passes, and its time shows under Works?. -->
|
|
10
|
+
Reply with just the word OK.
|
|
11
|
+
|
|
12
|
+
## tool-check
|
|
13
|
+
|
|
14
|
+
<!-- A model that says it calls tools: can it do a small job with one? It gets HeartCode's write_file tool; it passes when it calls it with a path ending in notes.txt and content containing "hello" (keep those two, or it can't pass). -->
|
|
15
|
+
Create the file notes.txt containing exactly: hello
|
package/src/acp.js
CHANGED
|
@@ -26,16 +26,21 @@ class AcpUI extends HeadlessUI {
|
|
|
26
26
|
update(u) {
|
|
27
27
|
this.conn.notify('session/update', { sessionId: this.sessionId, update: u })
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
// a helper's reply isn't the agent's own thoughts or message: its steps come as tool calls, named
|
|
30
|
+
response(who, { helper = false } = {}) {
|
|
31
|
+
if (helper) return { text() {}, think() {}, end() {} }
|
|
30
32
|
const chunk = (sessionUpdate) => (text) => text && this.update({ sessionUpdate, content: { type: 'text', text } })
|
|
31
33
|
return { text: chunk('agent_message_chunk'), think: chunk('agent_thought_chunk'), end() {} }
|
|
32
34
|
}
|
|
33
35
|
setPermission(mode) {
|
|
36
|
+
if (mode === 'plan' && this.permission !== 'plan') this.beforePlan = this.permission // what plan mode asks like
|
|
34
37
|
super.setPermission(mode)
|
|
35
38
|
if (this.sessionId) this.update({ sessionUpdate: 'current_mode_update', currentModeId: mode })
|
|
36
39
|
}
|
|
37
40
|
async confirm(question, kind = 'edit') {
|
|
38
|
-
if (
|
|
41
|
+
if (kind === 'read' && this.permission === 'plan') return true
|
|
42
|
+
const mode = this.permission === 'plan' ? (this.beforePlan ?? 'ask') : this.permission // plan mode asks as the mode before it did (as the full screen's)
|
|
43
|
+
if (mode === 'all' || (mode === 'commands' && kind === 'edit')) return true
|
|
39
44
|
const toolCallId = runningCall.getStore() ?? this.calls[0] ?? `ask_${Date.now()}` // the call asking
|
|
40
45
|
const r = await this.conn
|
|
41
46
|
.request('session/request_permission', {
|
|
@@ -49,7 +54,7 @@ class AcpUI extends HeadlessUI {
|
|
|
49
54
|
})
|
|
50
55
|
.catch(() => null)
|
|
51
56
|
const id = r?.outcome?.outcome === 'selected' ? r.outcome.optionId : null
|
|
52
|
-
if (id === 'all') this.setPermission('all')
|
|
57
|
+
if (id === 'all') this.permission === 'plan' ? (this.beforePlan = 'all') : this.setPermission('all') // in plan mode: still planning, everything allowed after it
|
|
53
58
|
return id === 'allow' || id === 'all'
|
|
54
59
|
}
|
|
55
60
|
}
|
|
@@ -102,7 +107,7 @@ export async function runAcp({ makeApp, version, permission = 'ask', input = pro
|
|
|
102
107
|
return { sessionId: ui.sessionId, modes: modes(ui.permission) }
|
|
103
108
|
},
|
|
104
109
|
'session/load': async ({ sessionId, cwd, mcpServers }) => {
|
|
105
|
-
const chat = loadChat(sessionId)
|
|
110
|
+
const chat = loadChat(sessionId, cwd)
|
|
106
111
|
if (!chat) throw Object.assign(new Error(`no session ${sessionId}`), { code: -32002 })
|
|
107
112
|
const { ui } = await open(cwd ?? chat.root, mcpServers, chat)
|
|
108
113
|
for (const h of chat.history) {
|
|
@@ -132,7 +137,7 @@ export async function runAcp({ makeApp, version, permission = 'ask', input = pro
|
|
|
132
137
|
if (!s) throw Object.assign(new Error(app.allOff() ? 'the providers of all your models are switched off: switch one on in heart settings' : 'no model set up: run heart settings to add a provider and choose a model'), { code: -32000 })
|
|
133
138
|
s.onEvent ??= (e) => events(it.ui, s, e)
|
|
134
139
|
const k = /^\/(\S+)\s*([\s\S]*)$/.exec(text)
|
|
135
|
-
const skill = k && app.skills.get(k[1])
|
|
140
|
+
const skill = k && app.skills.get(k[1].replace(/^skill:/, '')) // /name or /skill:name, as in the full screen
|
|
136
141
|
await s.run(skill && skill.use !== 'model' ? await app.expandSkill(skill, k[2]) : text, it.ctl.signal, images)
|
|
137
142
|
return { stopReason: 'end_turn' }
|
|
138
143
|
} catch (e) {
|