@roackb2/heddle 0.0.5 → 0.0.7
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 +39 -6
- package/dist/src/__tests__/chat-compaction.test.js +39 -0
- package/dist/src/__tests__/chat-compaction.test.js.map +1 -1
- package/dist/src/__tests__/chat-format.test.js +14 -1
- package/dist/src/__tests__/chat-format.test.js.map +1 -1
- package/dist/src/__tests__/local-commands.test.js +65 -101
- package/dist/src/__tests__/local-commands.test.js.map +1 -1
- package/dist/src/__tests__/prompts.test.js +3 -0
- package/dist/src/__tests__/prompts.test.js.map +1 -1
- package/dist/src/__tests__/tools.test.js +78 -0
- package/dist/src/__tests__/tools.test.js.map +1 -1
- package/dist/src/cli/ask.d.ts.map +1 -1
- package/dist/src/cli/ask.js +5 -1
- package/dist/src/cli/ask.js.map +1 -1
- package/dist/src/cli/chat/App.d.ts.map +1 -1
- package/dist/src/cli/chat/App.js +5 -5
- package/dist/src/cli/chat/App.js.map +1 -1
- package/dist/src/cli/chat/components/SlashHintPanel.js +2 -30
- package/dist/src/cli/chat/components/SlashHintPanel.js.map +1 -1
- package/dist/src/cli/chat/hooks/useAgentRun.d.ts.map +1 -1
- package/dist/src/cli/chat/hooks/useAgentRun.js +28 -8
- package/dist/src/cli/chat/hooks/useAgentRun.js.map +1 -1
- package/dist/src/cli/chat/state/compaction.d.ts +4 -0
- package/dist/src/cli/chat/state/compaction.d.ts.map +1 -1
- package/dist/src/cli/chat/state/compaction.js +21 -5
- package/dist/src/cli/chat/state/compaction.js.map +1 -1
- package/dist/src/cli/chat/state/local-commands.d.ts +6 -0
- package/dist/src/cli/chat/state/local-commands.d.ts.map +1 -1
- package/dist/src/cli/chat/state/local-commands.js +38 -45
- package/dist/src/cli/chat/state/local-commands.js.map +1 -1
- package/dist/src/cli/chat/state/storage.js +1 -0
- package/dist/src/cli/chat/state/storage.js.map +1 -1
- package/dist/src/cli/chat/state/types.d.ts +1 -0
- package/dist/src/cli/chat/state/types.d.ts.map +1 -1
- package/dist/src/cli/chat/submit.d.ts.map +1 -1
- package/dist/src/cli/chat/submit.js +27 -1
- package/dist/src/cli/chat/submit.js.map +1 -1
- package/dist/src/cli/chat/utils/format.d.ts +5 -0
- package/dist/src/cli/chat/utils/format.d.ts.map +1 -1
- package/dist/src/cli/chat/utils/format.js +23 -0
- package/dist/src/cli/chat/utils/format.js.map +1 -1
- package/dist/src/cli/chat/utils/runtime.d.ts +1 -0
- package/dist/src/cli/chat/utils/runtime.d.ts.map +1 -1
- package/dist/src/cli/chat/utils/runtime.js +1 -0
- package/dist/src/cli/chat/utils/runtime.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/prompts/system-prompt.d.ts.map +1 -1
- package/dist/src/prompts/system-prompt.js +10 -0
- package/dist/src/prompts/system-prompt.js.map +1 -1
- package/dist/src/tools/edit-file.d.ts +3 -7
- package/dist/src/tools/edit-file.d.ts.map +1 -1
- package/dist/src/tools/edit-file.js +16 -222
- package/dist/src/tools/edit-file.js.map +1 -1
- package/dist/src/tools/file-edit-core.d.ts +31 -0
- package/dist/src/tools/file-edit-core.d.ts.map +1 -0
- package/dist/src/tools/file-edit-core.js +231 -0
- package/dist/src/tools/file-edit-core.js.map +1 -0
- package/dist/src/tools/memory-notes.d.ts +13 -0
- package/dist/src/tools/memory-notes.d.ts.map +1 -0
- package/dist/src/tools/memory-notes.js +382 -0
- package/dist/src/tools/memory-notes.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Heddle is a terminal coding agent runtime and CLI.
|
|
4
4
|
|
|
5
|
-
It is
|
|
5
|
+
It is built to feel like a terminal partner that understands your project, keeps continuity across real work, and becomes more useful over time.
|
|
6
|
+
|
|
7
|
+
It is open source, provider-agnostic, supports OpenAI and Anthropic models, and can build memory across sessions.
|
|
6
8
|
|
|
7
9
|
## How Heddle Helps
|
|
8
10
|
|
|
@@ -16,11 +18,12 @@ It is open source, provider-agnostic, and currently supports OpenAI and Anthropi
|
|
|
16
18
|
## Advanced Capabilities
|
|
17
19
|
|
|
18
20
|
- provider-agnostic model support across OpenAI and Anthropic
|
|
19
|
-
- hosted web search through `web_search`
|
|
21
|
+
- provider-backed hosted web search through `web_search`
|
|
20
22
|
- local image viewing from referenced file paths through `view_image`
|
|
21
23
|
- inline `@file` mentions that tell the agent which workspace files to inspect first
|
|
22
24
|
- multi-turn sessions with save, switch, continue, rename, and close flows
|
|
23
|
-
- automatic conversation compaction for longer chats
|
|
25
|
+
- automatic conversation compaction for longer chats, plus manual `/compact` when needed
|
|
26
|
+
- persistent workspace knowledge through `.heddle/memory/`
|
|
24
27
|
- lightweight working-plan tracking through `update_plan`
|
|
25
28
|
- approval-gated shell execution with remembered per-project approvals
|
|
26
29
|
- trace logs, persistent chat state, and project instruction loading under `.heddle/`
|
|
@@ -73,16 +76,19 @@ Heddle currently supports:
|
|
|
73
76
|
|
|
74
77
|
- repository inspection with `list_files`, `read_file`, and `search_files`
|
|
75
78
|
- code and doc changes with `edit_file`
|
|
76
|
-
- hosted web search through `web_search`
|
|
79
|
+
- provider-backed hosted web search through `web_search`
|
|
77
80
|
- local screenshot and image inspection through `view_image`
|
|
78
81
|
- inline `@file` mentions for file-priority context without pasting file contents into the prompt
|
|
79
82
|
- shell execution with inspect vs approval-gated mutate behavior
|
|
80
83
|
- multi-turn chat sessions with saved history under `.heddle/`
|
|
81
84
|
- session management with create, switch, continue, rename, and close flows
|
|
82
85
|
- automatic conversation compaction so longer chats preserve context instead of growing unbounded
|
|
86
|
+
- manual `/compact` to shrink the current session transcript on demand
|
|
87
|
+
- persistent workspace memory notes under `.heddle/memory/`
|
|
83
88
|
- short working-plan support through `update_plan` for substantial multi-step tasks
|
|
84
89
|
- remembered per-project approvals for repeated commands and edits
|
|
85
90
|
- interrupt and resume support for longer-running coding workflows
|
|
91
|
+
- request-size aware context tracking in chat so the footer reflects model input usage, not only raw history size
|
|
86
92
|
|
|
87
93
|
The image workflow is intentionally simple for now: users can reference a local image path in chat, and the agent can decide whether to inspect it with `view_image`. Heddle does not require a full multimodal attachment model for this first version.
|
|
88
94
|
|
|
@@ -90,6 +96,30 @@ The file-mention workflow is also intentionally lightweight: `@path/to/file` tel
|
|
|
90
96
|
|
|
91
97
|
The planning workflow is also intentionally lightweight: Heddle does not force a heavyweight planner or a separate "plan mode," but it can automatically record and update a short plan when a task is substantial enough to benefit from visible progress tracking.
|
|
92
98
|
|
|
99
|
+
The web-search workflow is provider-backed rather than crawler-backed: OpenAI models use OpenAI-hosted web search, and Anthropic models use Anthropic-hosted web search when available through the selected model/tool path.
|
|
100
|
+
|
|
101
|
+
## Knowledge Persistence
|
|
102
|
+
|
|
103
|
+
Heddle can maintain durable workspace knowledge under `.heddle/memory/`.
|
|
104
|
+
|
|
105
|
+
The goal is to help Heddle learn from real project work over time instead of rediscovering the same stable facts every session.
|
|
106
|
+
|
|
107
|
+
Typical examples:
|
|
108
|
+
|
|
109
|
+
- architecture notes that future sessions should reuse
|
|
110
|
+
- recurring build, test, or environment quirks
|
|
111
|
+
- important repo conventions and command patterns
|
|
112
|
+
- durable findings from completed implementation work
|
|
113
|
+
|
|
114
|
+
The memory model is intentionally simple:
|
|
115
|
+
|
|
116
|
+
- memory is stored as readable markdown files in the project state directory
|
|
117
|
+
- Heddle can list, read, search, and edit those notes
|
|
118
|
+
- shell tools are still available when flexible retrieval or editing is needed
|
|
119
|
+
- memory is meant for stable, reusable knowledge, not scratch notes or speculative plans
|
|
120
|
+
|
|
121
|
+
This is one of Heddle's more distinctive host-side capabilities: the aim is not just to answer the current prompt, but to let the runtime accumulate project understanding from your operations and become more useful across sessions.
|
|
122
|
+
|
|
93
123
|
## What Heddle Does
|
|
94
124
|
|
|
95
125
|
Heddle runs an agent loop against your workspace:
|
|
@@ -125,9 +155,9 @@ Typical chat use cases:
|
|
|
125
155
|
- ask Heddle to explain architecture, code paths, tests, or build setup
|
|
126
156
|
- iterate on a fix over multiple prompts instead of fitting everything into one request
|
|
127
157
|
- inspect files, search the repo, and edit code inside one persistent session
|
|
128
|
-
- keep a long coding conversation usable through saved sessions, `/continue`,
|
|
158
|
+
- keep a long coding conversation usable through saved sessions, `/continue`, automatic history compaction, and manual `/compact`
|
|
129
159
|
- let the agent create and update a short working plan for a multi-step implementation
|
|
130
|
-
- search official docs or other current external references with `web_search`
|
|
160
|
+
- search official docs or other current external references with provider-backed `web_search`
|
|
131
161
|
- mention important repo files with `@path/to/file` so the agent treats them as first-pass context
|
|
132
162
|
- reference a local screenshot path and have the agent inspect it with `view_image`
|
|
133
163
|
- run direct shell commands from chat with `!<command>`
|
|
@@ -149,6 +179,7 @@ Useful chat commands:
|
|
|
149
179
|
- `/session rename <name>`: rename the current session
|
|
150
180
|
- `/session close <id>`: remove a saved session
|
|
151
181
|
- `/clear`: clear the current transcript
|
|
182
|
+
- `/compact`: compact older session history immediately
|
|
152
183
|
- `!<command>`: run a shell command directly in chat
|
|
153
184
|
|
|
154
185
|
Direct shell in chat:
|
|
@@ -161,6 +192,8 @@ Direct shell in chat:
|
|
|
161
192
|
|
|
162
193
|
Read-oriented commands stay in inspect mode when possible. Workspace-changing or unclassified commands fall back to approval-gated execution.
|
|
163
194
|
|
|
195
|
+
Chat state is stored under `.heddle/`, including saved sessions, traces, approvals, and memory notes. The footer context indicator is an estimate of total request input against the active model's context window, not only the raw chat history length.
|
|
196
|
+
|
|
164
197
|
## CLI Usage
|
|
165
198
|
|
|
166
199
|
Supported commands:
|
|
@@ -20,5 +20,44 @@ describe('chat history compaction', () => {
|
|
|
20
20
|
const visibleMessages = buildConversationMessages(compacted.history);
|
|
21
21
|
expect(visibleMessages[0]?.text).toContain('Earlier conversation history was compacted');
|
|
22
22
|
});
|
|
23
|
+
it('can force a single manual compaction pass even before the auto threshold is exceeded', () => {
|
|
24
|
+
const history = Array.from({ length: 6 }).flatMap((_, index) => [
|
|
25
|
+
{ role: 'user', content: `User prompt ${index}: ${'u'.repeat(60)}` },
|
|
26
|
+
{ role: 'assistant', content: `Assistant reply ${index}: ${'a'.repeat(60)}` },
|
|
27
|
+
]);
|
|
28
|
+
const autoCompacted = compactChatHistory({
|
|
29
|
+
history,
|
|
30
|
+
model: 'gpt-5.1',
|
|
31
|
+
});
|
|
32
|
+
const manuallyCompacted = compactChatHistory({
|
|
33
|
+
history,
|
|
34
|
+
model: 'gpt-5.1',
|
|
35
|
+
force: true,
|
|
36
|
+
});
|
|
37
|
+
expect(autoCompacted.history).toEqual(history);
|
|
38
|
+
expect(isCompactedHistorySummary(manuallyCompacted.history[0])).toBe(true);
|
|
39
|
+
expect(manuallyCompacted.history.length).toBeLessThan(history.length);
|
|
40
|
+
expect(manuallyCompacted.context.compactedMessages).toBeGreaterThan(0);
|
|
41
|
+
});
|
|
42
|
+
it('can re-compact an already compacted short session when forced manually', () => {
|
|
43
|
+
const history = [
|
|
44
|
+
{
|
|
45
|
+
role: 'system',
|
|
46
|
+
content: 'Heddle compacted earlier conversation history.\n\nMore recent archived turns:\nAssistant: Earlier summary.',
|
|
47
|
+
},
|
|
48
|
+
{ role: 'system', content: 'Host reminder: use the evidence you already gathered.' },
|
|
49
|
+
{ role: 'tool', toolCallId: 'tool-1', content: '{"ok":true,"output":"git diff --stat HEAD"}' },
|
|
50
|
+
{ role: 'user', content: 'can you try again' },
|
|
51
|
+
{ role: 'user', content: 'try again' },
|
|
52
|
+
];
|
|
53
|
+
const compacted = compactChatHistory({
|
|
54
|
+
history,
|
|
55
|
+
model: 'gpt-5.1',
|
|
56
|
+
force: true,
|
|
57
|
+
});
|
|
58
|
+
expect(compacted.history.length).toBeLessThan(history.length);
|
|
59
|
+
expect(isCompactedHistorySummary(compacted.history[0])).toBe(true);
|
|
60
|
+
expect(compacted.context.compactedMessages).toBeGreaterThan(0);
|
|
61
|
+
});
|
|
23
62
|
});
|
|
24
63
|
//# sourceMappingURL=chat-compaction.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-compaction.test.js","sourceRoot":"","sources":["../../../src/__tests__/chat-compaction.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;QACrF,MAAM,OAAO,GAAkB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;YAC9E,EAAE,IAAI,EAAE,MAAe,EAAE,OAAO,EAAE,eAAe,KAAK,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE;YAC/E,EAAE,IAAI,EAAE,WAAoB,EAAE,OAAO,EAAE,mBAAmB,KAAK,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE;SACzF,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,kBAAkB,CAAC;YACnC,OAAO;YACP,KAAK,EAAE,SAAS;SACjB,CAAC,CAAC;QAEH,MAAM,CAAC,yBAAyB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9D,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,C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AU,EAAE,QAAQ,EAAE,OAAO,EAAE,6CAA6C,EAAE;YAC9F,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE;YAC9C,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE;SACvC,CAAC;QAEF,MAAM,SAAS,GAAG,kBAAkB,CAAC;YACnC,OAAO;YACP,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QAEH,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9D,MAAM,CAAC,yBAAyB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { buildConversationMessages, formatEditPreviewHistoryMessage, formatPlanHistoryMessage } from '../cli/chat/utils/format.js';
|
|
2
|
+
import { buildConversationMessages, formatChatFailureMessage, formatEditPreviewHistoryMessage, formatPlanHistoryMessage, } from '../cli/chat/utils/format.js';
|
|
3
3
|
describe('buildConversationMessages', () => {
|
|
4
4
|
it('renders successful edit_file tool results into visible conversation history', () => {
|
|
5
5
|
const history = [
|
|
@@ -121,4 +121,17 @@ describe('buildConversationMessages', () => {
|
|
|
121
121
|
expect(rendered).toContain('- [ ] Verify with tests');
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
|
+
describe('formatChatFailureMessage', () => {
|
|
125
|
+
it('adds manual compaction guidance for likely input-size TPM failures', () => {
|
|
126
|
+
const formatted = formatChatFailureMessage(`429 {"type":"error","error":{"type":"rate_limit_error","message":"This request would exceed your organization's rate limit of 30,000 input tokens per minute. Please reduce the prompt length or the maximum tokens requested."}}`, { model: 'claude-sonnet-4-6', estimatedHistoryTokens: 18234 });
|
|
127
|
+
expect(formatted).toContain('input-token-per-minute limit');
|
|
128
|
+
expect(formatted).toContain('18,234 tokens');
|
|
129
|
+
expect(formatted).toContain('/compact, /clear, or /session new');
|
|
130
|
+
});
|
|
131
|
+
it('distinguishes OpenAI quota exhaustion from prompt-size issues', () => {
|
|
132
|
+
const formatted = formatChatFailureMessage('You exceeded your current quota, please check your plan and billing details.', { model: 'gpt-5.4' });
|
|
133
|
+
expect(formatted).toContain('quota or billing limit');
|
|
134
|
+
expect(formatted).toContain('not a transient prompt-size issue');
|
|
135
|
+
});
|
|
136
|
+
});
|
|
124
137
|
//# sourceMappingURL=chat-format.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-format.test.js","sourceRoot":"","sources":["../../../src/__tests__/chat-format.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"chat-format.test.js","sourceRoot":"","sources":["../../../src/__tests__/chat-format.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AAGrC,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;QACrF,MAAM,OAAO,GAAkB;YAC7B,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE;YAC7C;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,yBAAyB;gBACl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;QAC7D,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;QACtD,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,oEAAoE,EAAE,GAAG,EAAE;QAC5E,MAAM,SAAS,GAAG,wBAAwB,CACxC,mOAAmO,EACnO,EAAE,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAC9D,CAAC;QAEF,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC;QAC5D,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QAC7C,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,mCAAmC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,MAAM,SAAS,GAAG,wBAAwB,CACxC,8EAA8E,EAC9E,EAAE,KAAK,EAAE,SAAS,EAAE,CACrB,CAAC;QAEF,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;QACtD,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,mCAAmC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { isLikelyLocalCommand, runLocalCommand } from '../cli/chat/state/local-commands.js';
|
|
2
|
+
import { getLocalCommandHints, isLikelyLocalCommand, runLocalCommand } from '../cli/chat/state/local-commands.js';
|
|
3
|
+
function createCommandArgs(overrides = {}) {
|
|
4
|
+
return {
|
|
5
|
+
prompt: '/help',
|
|
6
|
+
activeModel: 'gpt-5.1-codex',
|
|
7
|
+
setActiveModel: vi.fn(),
|
|
8
|
+
sessions: [],
|
|
9
|
+
recentSessions: [],
|
|
10
|
+
activeSessionId: 'session-1',
|
|
11
|
+
switchSession: vi.fn(),
|
|
12
|
+
createSession: vi.fn(),
|
|
13
|
+
renameSession: vi.fn(),
|
|
14
|
+
removeSession: vi.fn(),
|
|
15
|
+
clearConversation: vi.fn(),
|
|
16
|
+
compactConversation: vi.fn(() => 'Compacted earlier session history to reduce context size.'),
|
|
17
|
+
listRecentSessionsMessage: [],
|
|
18
|
+
...overrides,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
3
21
|
describe('runLocalCommand', () => {
|
|
4
22
|
it('treats bare and partial slash command roots as local commands for hints', () => {
|
|
5
23
|
expect(isLikelyLocalCommand('/')).toBe(true);
|
|
6
24
|
expect(isLikelyLocalCommand('/h')).toBe(true);
|
|
7
25
|
expect(isLikelyLocalCommand('/mo')).toBe(true);
|
|
8
26
|
expect(isLikelyLocalCommand('/sess')).toBe(true);
|
|
27
|
+
expect(isLikelyLocalCommand('/comp')).toBe(true);
|
|
9
28
|
});
|
|
10
29
|
it('does not treat absolute unix paths as slash commands', () => {
|
|
11
30
|
expect(isLikelyLocalCommand('/Users/roackb2/Desktop/screenshot.png')).toBe(false);
|
|
12
31
|
});
|
|
13
32
|
it('lists grouped common built-in model choices with multi-line formatting', () => {
|
|
14
|
-
const result = runLocalCommand({
|
|
15
|
-
prompt: '/model list',
|
|
16
|
-
activeModel: 'gpt-5.1-codex',
|
|
17
|
-
setActiveModel: vi.fn(),
|
|
18
|
-
sessions: [],
|
|
19
|
-
recentSessions: [],
|
|
20
|
-
activeSessionId: 'session-1',
|
|
21
|
-
switchSession: vi.fn(),
|
|
22
|
-
createSession: vi.fn(),
|
|
23
|
-
renameSession: vi.fn(),
|
|
24
|
-
removeSession: vi.fn(),
|
|
25
|
-
clearConversation: vi.fn(),
|
|
26
|
-
listRecentSessionsMessage: [],
|
|
27
|
-
});
|
|
33
|
+
const result = runLocalCommand(createCommandArgs({ prompt: '/model list' }));
|
|
28
34
|
expect(result).toMatchObject({
|
|
29
35
|
handled: true,
|
|
30
36
|
kind: 'message',
|
|
@@ -40,20 +46,7 @@ describe('runLocalCommand', () => {
|
|
|
40
46
|
expect(result.message).toContain('Anthropic · Claude 3.5\n - claude-3-5-sonnet-latest\n - claude-3-5-haiku-latest');
|
|
41
47
|
});
|
|
42
48
|
it('keeps /models as a compatibility alias for /model list', () => {
|
|
43
|
-
const result = runLocalCommand({
|
|
44
|
-
prompt: '/models',
|
|
45
|
-
activeModel: 'gpt-5.1-codex',
|
|
46
|
-
setActiveModel: vi.fn(),
|
|
47
|
-
sessions: [],
|
|
48
|
-
recentSessions: [],
|
|
49
|
-
activeSessionId: 'session-1',
|
|
50
|
-
switchSession: vi.fn(),
|
|
51
|
-
createSession: vi.fn(),
|
|
52
|
-
renameSession: vi.fn(),
|
|
53
|
-
removeSession: vi.fn(),
|
|
54
|
-
clearConversation: vi.fn(),
|
|
55
|
-
listRecentSessionsMessage: [],
|
|
56
|
-
});
|
|
49
|
+
const result = runLocalCommand(createCommandArgs({ prompt: '/models' }));
|
|
57
50
|
expect(result).toMatchObject({
|
|
58
51
|
handled: true,
|
|
59
52
|
kind: 'message',
|
|
@@ -67,20 +60,10 @@ describe('runLocalCommand', () => {
|
|
|
67
60
|
});
|
|
68
61
|
it('recognizes supported shortlist models when switching', () => {
|
|
69
62
|
const setActiveModel = vi.fn();
|
|
70
|
-
const result = runLocalCommand({
|
|
63
|
+
const result = runLocalCommand(createCommandArgs({
|
|
71
64
|
prompt: '/model gpt-5.4-mini',
|
|
72
|
-
activeModel: 'gpt-5.1-codex',
|
|
73
65
|
setActiveModel,
|
|
74
|
-
|
|
75
|
-
recentSessions: [],
|
|
76
|
-
activeSessionId: 'session-1',
|
|
77
|
-
switchSession: vi.fn(),
|
|
78
|
-
createSession: vi.fn(),
|
|
79
|
-
renameSession: vi.fn(),
|
|
80
|
-
removeSession: vi.fn(),
|
|
81
|
-
clearConversation: vi.fn(),
|
|
82
|
-
listRecentSessionsMessage: [],
|
|
83
|
-
});
|
|
66
|
+
}));
|
|
84
67
|
expect(setActiveModel).toHaveBeenCalledWith('gpt-5.4-mini');
|
|
85
68
|
expect(result).toEqual({
|
|
86
69
|
handled: true,
|
|
@@ -90,20 +73,10 @@ describe('runLocalCommand', () => {
|
|
|
90
73
|
});
|
|
91
74
|
it('does not treat /model set as a literal model name', () => {
|
|
92
75
|
const setActiveModel = vi.fn();
|
|
93
|
-
const result = runLocalCommand({
|
|
76
|
+
const result = runLocalCommand(createCommandArgs({
|
|
94
77
|
prompt: '/model set',
|
|
95
|
-
activeModel: 'gpt-5.1-codex',
|
|
96
78
|
setActiveModel,
|
|
97
|
-
|
|
98
|
-
recentSessions: [],
|
|
99
|
-
activeSessionId: 'session-1',
|
|
100
|
-
switchSession: vi.fn(),
|
|
101
|
-
createSession: vi.fn(),
|
|
102
|
-
renameSession: vi.fn(),
|
|
103
|
-
removeSession: vi.fn(),
|
|
104
|
-
clearConversation: vi.fn(),
|
|
105
|
-
listRecentSessionsMessage: [],
|
|
106
|
-
});
|
|
79
|
+
}));
|
|
107
80
|
expect(setActiveModel).not.toHaveBeenCalled();
|
|
108
81
|
expect(result).toEqual({
|
|
109
82
|
handled: true,
|
|
@@ -113,26 +86,17 @@ describe('runLocalCommand', () => {
|
|
|
113
86
|
});
|
|
114
87
|
it('allows switching sessions by recent-session index', () => {
|
|
115
88
|
const switchSession = vi.fn();
|
|
116
|
-
const
|
|
89
|
+
const sessions = [
|
|
90
|
+
{ id: 'session-a', name: 'A', history: [], messages: [], turns: [], createdAt: '2024-01-01', updatedAt: '2024-01-01' },
|
|
91
|
+
{ id: 'session-b', name: 'B', history: [], messages: [], turns: [], createdAt: '2024-01-02', updatedAt: '2024-01-02' },
|
|
92
|
+
];
|
|
93
|
+
const result = runLocalCommand(createCommandArgs({
|
|
117
94
|
prompt: '/session switch 2',
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
sessions: [
|
|
121
|
-
{ id: 'session-a', name: 'A', history: [], messages: [], turns: [], createdAt: '2024-01-01', updatedAt: '2024-01-01' },
|
|
122
|
-
{ id: 'session-b', name: 'B', history: [], messages: [], turns: [], createdAt: '2024-01-02', updatedAt: '2024-01-02' },
|
|
123
|
-
],
|
|
124
|
-
recentSessions: [
|
|
125
|
-
{ id: 'session-a', name: 'A', history: [], messages: [], turns: [], createdAt: '2024-01-01', updatedAt: '2024-01-01' },
|
|
126
|
-
{ id: 'session-b', name: 'B', history: [], messages: [], turns: [], createdAt: '2024-01-02', updatedAt: '2024-01-02' },
|
|
127
|
-
],
|
|
95
|
+
sessions,
|
|
96
|
+
recentSessions: sessions,
|
|
128
97
|
activeSessionId: 'session-a',
|
|
129
98
|
switchSession,
|
|
130
|
-
|
|
131
|
-
renameSession: vi.fn(),
|
|
132
|
-
removeSession: vi.fn(),
|
|
133
|
-
clearConversation: vi.fn(),
|
|
134
|
-
listRecentSessionsMessage: [],
|
|
135
|
-
});
|
|
99
|
+
}));
|
|
136
100
|
expect(switchSession).toHaveBeenCalledWith('session-b');
|
|
137
101
|
expect(result).toEqual({
|
|
138
102
|
handled: true,
|
|
@@ -141,26 +105,16 @@ describe('runLocalCommand', () => {
|
|
|
141
105
|
});
|
|
142
106
|
});
|
|
143
107
|
it('allows continuing sessions by recent-session index', () => {
|
|
144
|
-
const
|
|
108
|
+
const sessions = [
|
|
109
|
+
{ id: 'session-a', name: 'A', history: [], messages: [], turns: [], createdAt: '2024-01-01', updatedAt: '2024-01-01' },
|
|
110
|
+
{ id: 'session-b', name: 'B', history: [], messages: [], turns: [], createdAt: '2024-01-02', updatedAt: '2024-01-02' },
|
|
111
|
+
];
|
|
112
|
+
const result = runLocalCommand(createCommandArgs({
|
|
145
113
|
prompt: '/session continue 2',
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
sessions: [
|
|
149
|
-
{ id: 'session-a', name: 'A', history: [], messages: [], turns: [], createdAt: '2024-01-01', updatedAt: '2024-01-01' },
|
|
150
|
-
{ id: 'session-b', name: 'B', history: [], messages: [], turns: [], createdAt: '2024-01-02', updatedAt: '2024-01-02' },
|
|
151
|
-
],
|
|
152
|
-
recentSessions: [
|
|
153
|
-
{ id: 'session-a', name: 'A', history: [], messages: [], turns: [], createdAt: '2024-01-01', updatedAt: '2024-01-01' },
|
|
154
|
-
{ id: 'session-b', name: 'B', history: [], messages: [], turns: [], createdAt: '2024-01-02', updatedAt: '2024-01-02' },
|
|
155
|
-
],
|
|
114
|
+
sessions,
|
|
115
|
+
recentSessions: sessions,
|
|
156
116
|
activeSessionId: 'session-a',
|
|
157
|
-
|
|
158
|
-
createSession: vi.fn(),
|
|
159
|
-
renameSession: vi.fn(),
|
|
160
|
-
removeSession: vi.fn(),
|
|
161
|
-
clearConversation: vi.fn(),
|
|
162
|
-
listRecentSessionsMessage: [],
|
|
163
|
-
});
|
|
117
|
+
}));
|
|
164
118
|
expect(result).toEqual({
|
|
165
119
|
handled: true,
|
|
166
120
|
kind: 'continue',
|
|
@@ -169,21 +123,31 @@ describe('runLocalCommand', () => {
|
|
|
169
123
|
});
|
|
170
124
|
});
|
|
171
125
|
it('passes through absolute unix paths as normal prompts', () => {
|
|
172
|
-
const result = runLocalCommand({
|
|
126
|
+
const result = runLocalCommand(createCommandArgs({
|
|
173
127
|
prompt: '/Users/roackb2/Desktop/screenshot.png can you describe this image',
|
|
174
|
-
|
|
175
|
-
setActiveModel: vi.fn(),
|
|
176
|
-
sessions: [],
|
|
177
|
-
recentSessions: [],
|
|
178
|
-
activeSessionId: 'session-1',
|
|
179
|
-
switchSession: vi.fn(),
|
|
180
|
-
createSession: vi.fn(),
|
|
181
|
-
renameSession: vi.fn(),
|
|
182
|
-
removeSession: vi.fn(),
|
|
183
|
-
clearConversation: vi.fn(),
|
|
184
|
-
listRecentSessionsMessage: [],
|
|
185
|
-
});
|
|
128
|
+
}));
|
|
186
129
|
expect(result).toEqual({ handled: false });
|
|
187
130
|
});
|
|
131
|
+
it('runs manual compaction when requested', () => {
|
|
132
|
+
const compactConversation = vi.fn(() => 'Compacted earlier session history to reduce context size (24 messages summarized).');
|
|
133
|
+
const result = runLocalCommand(createCommandArgs({
|
|
134
|
+
prompt: '/compact',
|
|
135
|
+
activeModel: 'claude-sonnet-4-6',
|
|
136
|
+
compactConversation,
|
|
137
|
+
}));
|
|
138
|
+
expect(compactConversation).toHaveBeenCalledTimes(1);
|
|
139
|
+
expect(result).toEqual({
|
|
140
|
+
handled: true,
|
|
141
|
+
kind: 'message',
|
|
142
|
+
message: 'Compacted earlier session history to reduce context size (24 messages summarized).',
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
it('includes /compact in shared slash-command hints', () => {
|
|
146
|
+
const hints = getLocalCommandHints('/', 'session-1', []);
|
|
147
|
+
expect(hints).toContainEqual({
|
|
148
|
+
command: '/compact',
|
|
149
|
+
description: 'compact earlier session history for the next run',
|
|
150
|
+
});
|
|
151
|
+
});
|
|
188
152
|
});
|
|
189
153
|
//# sourceMappingURL=local-commands.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-commands.test.js","sourceRoot":"","sources":["../../../src/__tests__/local-commands.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"local-commands.test.js","sourceRoot":"","sources":["../../../src/__tests__/local-commands.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAElH,SAAS,iBAAiB,CAAC,YA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AAE,oFAAoF;SAC9F,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,KAAK,GAAG,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;QAEzD,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC;YAC3B,OAAO,EAAE,UAAU;YACnB,WAAW,EAAE,kDAAkD;SAChE,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -21,6 +21,9 @@ describe('buildSystemPrompt', () => {
|
|
|
21
21
|
expect(prompt).toContain('prefer carrying the task through implementation and verification instead of stopping at analysis or a plan unless you are blocked');
|
|
22
22
|
expect(prompt).toContain('If the user asks to improve tests or coverage');
|
|
23
23
|
expect(prompt).toContain('Prefer the first-class file editing tool for creating or changing file contents');
|
|
24
|
+
expect(prompt).toContain('## Knowledge Persistence');
|
|
25
|
+
expect(prompt).toContain('Maintain useful memory proactively');
|
|
26
|
+
expect(prompt).toContain('Memory writes do not require user approval');
|
|
24
27
|
expect(prompt).toContain('If a shell command is arbitrary, uses inline scripts, needs redirects/heredocs, or inspect rejects it, switch to run_shell_mutate');
|
|
25
28
|
expect(prompt).toContain('do not stop at "inspect is blocked."');
|
|
26
29
|
expect(prompt).toContain('Do not ask unnecessary questions when the answer can be discovered from the workspace');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.test.js","sourceRoot":"","sources":["../../../src/__tests__/prompts.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,6EAA6E,EAAE,GAAG,EAAE;QACrF,MAAM,MAAM,GAAG,i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CAAC;QAClK,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,sCAAsC,CAAC,CAAC;QACjE,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,gEAAgE,CAAC,CAAC;QAC3F,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,uCAAuC,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,MAAM,GAAG,iBAAiB,CAAC,oBAAoB,EAAE,CAAC,YAAY,CAAC,EAAE,uDAAuD,CAAC,CAAC;QAEhI,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;QAC/C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,oCAAoC,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -11,6 +11,7 @@ import { classifyShellCommandPolicy, createRunShellInspectTool, createRunShellMu
|
|
|
11
11
|
import { createSearchFilesTool, searchFilesTool } from '../tools/search-files.js';
|
|
12
12
|
import { webSearchTool } from '../tools/web-search.js';
|
|
13
13
|
import { viewImageTool } from '../tools/view-image.js';
|
|
14
|
+
import { createListMemoryNotesTool, createReadMemoryNoteTool, createSearchMemoryNotesTool, createEditMemoryNoteTool, } from '../tools/memory-notes.js';
|
|
14
15
|
describe('tool input validation', () => {
|
|
15
16
|
it('rejects unexpected fields for list_files', async () => {
|
|
16
17
|
const result = await listFilesTool.execute({ path: '.', maxLines: 20 });
|
|
@@ -61,6 +62,16 @@ describe('tool input validation', () => {
|
|
|
61
62
|
expect(webSearchTool.description).toContain('{ "query": "OpenAI Responses API web search tool" }');
|
|
62
63
|
expect(viewImageTool.description).toContain('Inspect a local image file');
|
|
63
64
|
expect(viewImageTool.description).toContain('{ "path": "/absolute/path/to/screenshot.png" }');
|
|
65
|
+
const listMemoryTool = createListMemoryNotesTool();
|
|
66
|
+
const readMemoryTool = createReadMemoryNoteTool();
|
|
67
|
+
const searchMemoryTool = createSearchMemoryNotesTool();
|
|
68
|
+
const editMemoryTool = createEditMemoryNoteTool();
|
|
69
|
+
expect(listMemoryTool.description).toContain('List markdown notes inside Heddle persistent memory');
|
|
70
|
+
expect(readMemoryTool.description).toContain('Read a persistent memory note');
|
|
71
|
+
expect(searchMemoryTool.description).toContain('mature command-line search tools');
|
|
72
|
+
expect(editMemoryTool.description).toContain('Create or edit a persistent markdown note');
|
|
73
|
+
expect(editMemoryTool.description).toContain('does not require approval');
|
|
74
|
+
expect(editMemoryTool.requiresApproval).toBeUndefined();
|
|
64
75
|
expect(reportStateTool.description).toContain('Use this when you are blocked, uncertain');
|
|
65
76
|
expect(reportStateTool.description).toContain('tell the library author what capability, input, or support was missing');
|
|
66
77
|
expect(reportStateTool.description).toContain('Returns the same structured report back');
|
|
@@ -234,6 +245,73 @@ describe('viewImageTool', () => {
|
|
|
234
245
|
}
|
|
235
246
|
});
|
|
236
247
|
});
|
|
248
|
+
describe('memory note tools', () => {
|
|
249
|
+
it('lists markdown notes recursively inside the memory root', async () => {
|
|
250
|
+
const root = await mkdtemp(join(tmpdir(), 'heddle-memory-list-'));
|
|
251
|
+
await mkdir(join(root, 'architecture'), { recursive: true });
|
|
252
|
+
await writeFile(join(root, 'project-summary.md'), '# Summary\n');
|
|
253
|
+
await writeFile(join(root, 'architecture', 'auth.md'), '# Auth\n');
|
|
254
|
+
await writeFile(join(root, 'architecture', 'notes.txt'), 'ignore\n');
|
|
255
|
+
const tool = createListMemoryNotesTool({ memoryRoot: root });
|
|
256
|
+
const result = await tool.execute({});
|
|
257
|
+
expect(result).toEqual({
|
|
258
|
+
ok: true,
|
|
259
|
+
output: ['architecture/auth.md', 'project-summary.md'].join('\n'),
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
it('reads memory notes with paging support', async () => {
|
|
263
|
+
const root = await mkdtemp(join(tmpdir(), 'heddle-memory-read-'));
|
|
264
|
+
await writeFile(join(root, 'project-summary.md'), ['zero', 'one', 'two'].join('\n'));
|
|
265
|
+
const tool = createReadMemoryNoteTool({ memoryRoot: root });
|
|
266
|
+
const result = await tool.execute({ path: 'project-summary.md', offset: 1, maxLines: 1 });
|
|
267
|
+
expect(result).toEqual({
|
|
268
|
+
ok: true,
|
|
269
|
+
output: 'one',
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
it('searches memory notes with grep-style output', async () => {
|
|
273
|
+
const root = await mkdtemp(join(tmpdir(), 'heddle-memory-search-'));
|
|
274
|
+
await writeFile(join(root, 'known-issues.md'), ['first line', 'test command is yarn test', 'another'].join('\n'));
|
|
275
|
+
const tool = createSearchMemoryNotesTool({ memoryRoot: root });
|
|
276
|
+
const result = await tool.execute({ query: 'test command' });
|
|
277
|
+
expect(result).toEqual({
|
|
278
|
+
ok: true,
|
|
279
|
+
output: 'known-issues.md:2:test command is yarn test',
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
it('edits memory notes inside the memory root without approval gating', async () => {
|
|
283
|
+
const root = await mkdtemp(join(tmpdir(), 'heddle-memory-write-'));
|
|
284
|
+
await writeFile(join(root, 'project-summary.md'), '# Summary\nKnown fact');
|
|
285
|
+
const tool = createEditMemoryNoteTool({ memoryRoot: root });
|
|
286
|
+
const replaced = await tool.execute({
|
|
287
|
+
path: 'project-summary.md',
|
|
288
|
+
oldText: 'Known fact',
|
|
289
|
+
newText: 'Updated fact',
|
|
290
|
+
});
|
|
291
|
+
expect(replaced).toEqual({
|
|
292
|
+
ok: true,
|
|
293
|
+
output: {
|
|
294
|
+
path: 'project-summary.md',
|
|
295
|
+
action: 'replaced',
|
|
296
|
+
matchCount: 1,
|
|
297
|
+
bytesWritten: Buffer.byteLength('# Summary\nUpdated fact', 'utf8'),
|
|
298
|
+
diff: {
|
|
299
|
+
path: 'project-summary.md',
|
|
300
|
+
action: 'replaced',
|
|
301
|
+
diff: ['--- a/project-summary.md', '+++ b/project-summary.md', '@@ -1,2 +1,2 @@', ' # Summary', '-Known fact', '+Updated fact'].join('\n'),
|
|
302
|
+
truncated: false,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
it('refuses to access paths outside the memory root', async () => {
|
|
308
|
+
const root = await mkdtemp(join(tmpdir(), 'heddle-memory-scope-'));
|
|
309
|
+
const tool = createReadMemoryNoteTool({ memoryRoot: root });
|
|
310
|
+
const result = await tool.execute({ path: '../outside.md' });
|
|
311
|
+
expect(result.ok).toBe(false);
|
|
312
|
+
expect(result.error).toContain('Memory note paths must stay inside');
|
|
313
|
+
});
|
|
314
|
+
});
|
|
237
315
|
describe('editFileTool', () => {
|
|
238
316
|
it('creates a new file when explicitly allowed', async () => {
|
|
239
317
|
const root = await mkdtemp(join(tmpdir(), 'heddle-edit-create-'));
|