@travisennis/acai 0.0.11 → 0.0.13
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 +5 -5
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -5
- package/dist/commands/history/types.d.ts +3 -2
- package/dist/commands/history/types.d.ts.map +1 -1
- package/dist/commands/init-project/utils.d.ts +0 -1
- package/dist/commands/init-project/utils.d.ts.map +1 -1
- package/dist/commands/init-project/utils.js +1 -12
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +6 -19
- package/dist/commands/resources/index.d.ts.map +1 -1
- package/dist/commands/resources/index.js +4 -1
- package/dist/commands/session/index.d.ts.map +1 -1
- package/dist/commands/session/index.js +6 -0
- package/dist/commands/session/types.d.ts +1 -0
- package/dist/commands/session/types.d.ts.map +1 -1
- package/dist/commands/share/html-renderer.d.ts.map +1 -1
- package/dist/commands/share/html-renderer.js +54 -48
- package/dist/commands/tools/index.d.ts +3 -0
- package/dist/commands/tools/index.d.ts.map +1 -0
- package/dist/commands/tools/index.js +191 -0
- package/dist/commands/tools/templates.d.ts +6 -0
- package/dist/commands/tools/templates.d.ts.map +1 -0
- package/dist/commands/tools/templates.js +97 -0
- package/dist/config/index.d.ts +5 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +42 -6
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +98 -68
- package/dist/models/anthropic-provider.d.ts +1 -1
- package/dist/models/deepseek-provider.d.ts +3 -3
- package/dist/models/deepseek-provider.js +17 -17
- package/dist/models/google-provider.d.ts +2 -4
- package/dist/models/google-provider.d.ts.map +1 -1
- package/dist/models/google-provider.js +2 -17
- package/dist/models/groq-provider.d.ts +2 -4
- package/dist/models/groq-provider.d.ts.map +1 -1
- package/dist/models/groq-provider.js +3 -21
- package/dist/models/manager.d.ts +1 -10
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +2 -2
- package/dist/models/opencode-go-provider.d.ts +11 -1
- package/dist/models/opencode-go-provider.d.ts.map +1 -1
- package/dist/models/opencode-go-provider.js +130 -0
- package/dist/models/opencode-zen-provider.d.ts +3 -3
- package/dist/models/opencode-zen-provider.d.ts.map +1 -1
- package/dist/models/opencode-zen-provider.js +26 -32
- package/dist/models/openrouter-provider.d.ts +4 -15
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +26 -169
- package/dist/models/providers.d.ts +1 -1
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/models/xai-provider.d.ts +1 -2
- package/dist/models/xai-provider.d.ts.map +1 -1
- package/dist/models/xai-provider.js +0 -13
- package/dist/prompts/manager.d.ts.map +1 -1
- package/dist/prompts/manager.js +5 -1
- package/dist/prompts/system-prompt.d.ts +1 -2
- package/dist/prompts/system-prompt.d.ts.map +1 -1
- package/dist/prompts/system-prompt.js +26 -15
- package/dist/repl/index.d.ts +28 -13
- package/dist/repl/index.d.ts.map +1 -1
- package/dist/repl/index.js +242 -305
- package/dist/skills/activated-tracker.d.ts +11 -0
- package/dist/skills/activated-tracker.d.ts.map +1 -0
- package/dist/skills/activated-tracker.js +16 -0
- package/dist/skills/index.d.ts +12 -2
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +127 -71
- package/dist/terminal/control.d.ts +1 -21
- package/dist/terminal/control.d.ts.map +1 -1
- package/dist/terminal/control.js +1 -32
- package/dist/terminal/formatting.d.ts +0 -33
- package/dist/terminal/formatting.d.ts.map +1 -1
- package/dist/terminal/formatting.js +0 -91
- package/dist/terminal/highlight/theme.d.ts +0 -37
- package/dist/terminal/highlight/theme.d.ts.map +1 -1
- package/dist/terminal/highlight/theme.js +1 -79
- package/dist/terminal/keys.d.ts +0 -97
- package/dist/terminal/keys.d.ts.map +1 -1
- package/dist/terminal/keys.js +0 -194
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +65 -51
- package/dist/terminal/style.d.ts +1 -1
- package/dist/terminal/style.d.ts.map +1 -1
- package/dist/terminal/supports-color.d.ts.map +1 -1
- package/dist/terminal/supports-color.js +38 -20
- package/dist/terminal/supports-hyperlinks.d.ts +3 -0
- package/dist/terminal/supports-hyperlinks.d.ts.map +1 -1
- package/dist/terminal/supports-hyperlinks.js +72 -31
- package/dist/terminal/table/layout-manager.d.ts +0 -20
- package/dist/terminal/table/layout-manager.d.ts.map +1 -1
- package/dist/terminal/table/layout-manager.js +68 -44
- package/dist/terminal/table/utils.d.ts +0 -1
- package/dist/terminal/table/utils.d.ts.map +1 -1
- package/dist/terminal/table/utils.js +2 -4
- package/dist/tools/apply-patch.d.ts +5 -3
- package/dist/tools/apply-patch.d.ts.map +1 -1
- package/dist/tools/apply-patch.js +154 -123
- package/dist/tools/bash.d.ts +4 -4
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +27 -13
- package/dist/tools/dynamic-tool-loader.d.ts +17 -3
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +360 -81
- package/dist/tools/edit-file.d.ts +2 -2
- package/dist/tools/index.d.ts +27 -151
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +16 -21
- package/dist/tools/read-file.d.ts +8 -8
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +32 -13
- package/dist/tools/save-file.d.ts +4 -4
- package/dist/tools/skill.d.ts +2 -1
- package/dist/tools/skill.d.ts.map +1 -1
- package/dist/tools/skill.js +64 -14
- package/dist/tools/types.d.ts +8 -2
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/web-fetch.d.ts +8 -12
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +86 -44
- package/dist/tools/web-search.d.ts +4 -8
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +41 -33
- package/dist/tui/autocomplete/utils.d.ts +0 -15
- package/dist/tui/autocomplete/utils.d.ts.map +1 -1
- package/dist/tui/autocomplete/utils.js +0 -85
- package/dist/tui/autocomplete.d.ts +1 -1
- package/dist/tui/autocomplete.d.ts.map +1 -1
- package/dist/tui/autocomplete.js +1 -1
- package/dist/tui/components/editor.d.ts +12 -0
- package/dist/tui/components/editor.d.ts.map +1 -1
- package/dist/tui/components/editor.js +181 -195
- package/dist/tui/components/footer.d.ts +0 -2
- package/dist/tui/components/footer.d.ts.map +1 -1
- package/dist/tui/components/footer.js +1 -17
- package/dist/tui/components/input.d.ts +4 -0
- package/dist/tui/components/input.d.ts.map +1 -1
- package/dist/tui/components/input.js +33 -31
- package/dist/tui/components/markdown.d.ts +30 -0
- package/dist/tui/components/markdown.d.ts.map +1 -1
- package/dist/tui/components/markdown.js +274 -242
- package/dist/tui/components/modal.d.ts.map +1 -1
- package/dist/tui/components/modal.js +11 -11
- package/dist/tui/components/select-list.d.ts +5 -0
- package/dist/tui/components/select-list.d.ts.map +1 -1
- package/dist/tui/components/select-list.js +69 -98
- package/dist/tui/components/table.d.ts +6 -0
- package/dist/tui/components/table.d.ts.map +1 -1
- package/dist/tui/components/table.js +61 -52
- package/dist/tui/index.d.ts +1 -8
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +0 -8
- package/dist/tui/tui.d.ts +9 -0
- package/dist/tui/tui.d.ts.map +1 -1
- package/dist/tui/tui.js +78 -48
- package/dist/tui/utils.d.ts +7 -0
- package/dist/tui/utils.d.ts.map +1 -1
- package/dist/tui/utils.js +117 -53
- package/dist/utils/bash.d.ts.map +1 -1
- package/dist/utils/bash.js +121 -104
- package/dist/utils/binary-output.d.ts +32 -0
- package/dist/utils/binary-output.d.ts.map +1 -0
- package/dist/utils/binary-output.js +127 -0
- package/dist/utils/command-protection.d.ts +3 -2
- package/dist/utils/command-protection.d.ts.map +1 -1
- package/dist/utils/command-protection.js +121 -29
- package/dist/utils/filesystem/operations.d.ts +0 -15
- package/dist/utils/filesystem/operations.d.ts.map +1 -1
- package/dist/utils/filesystem/operations.js +1 -38
- package/dist/utils/filesystem/security.d.ts.map +1 -1
- package/dist/utils/filesystem/security.js +22 -15
- package/dist/utils/filetype-detection.d.ts +0 -1
- package/dist/utils/filetype-detection.d.ts.map +1 -1
- package/dist/utils/filetype-detection.js +0 -12
- package/dist/utils/formatting.d.ts +0 -30
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils/formatting.js +0 -44
- package/dist/utils/git.d.ts +4 -6
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +36 -46
- package/dist/utils/ignore.d.ts +1 -1
- package/dist/utils/ignore.d.ts.map +1 -1
- package/dist/utils/ignore.js +1 -1
- package/dist/utils/parsing.d.ts +1 -1
- package/dist/utils/parsing.d.ts.map +1 -1
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +77 -79
- package/dist/utils/yaml.d.ts +0 -1
- package/dist/utils/yaml.d.ts.map +1 -1
- package/dist/utils/yaml.js +80 -89
- package/dist/utils/zod.d.ts +0 -3
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +0 -7
- package/package.json +32 -29
- package/dist/agent/sub-agent.d.ts +0 -23
- package/dist/agent/sub-agent.d.ts.map +0 -1
- package/dist/agent/sub-agent.js +0 -109
- package/dist/commands/add-directory/index.d.ts +0 -3
- package/dist/commands/add-directory/index.d.ts.map +0 -1
- package/dist/commands/add-directory/index.js +0 -50
- package/dist/commands/add-directory/utils.d.ts +0 -3
- package/dist/commands/add-directory/utils.d.ts.map +0 -1
- package/dist/commands/add-directory/utils.js +0 -15
- package/dist/commands/clear/index.d.ts +0 -3
- package/dist/commands/clear/index.d.ts.map +0 -1
- package/dist/commands/clear/index.js +0 -13
- package/dist/commands/generate-rules/index.d.ts +0 -3
- package/dist/commands/generate-rules/index.d.ts.map +0 -1
- package/dist/commands/generate-rules/index.js +0 -206
- package/dist/commands/generate-rules/service.d.ts +0 -22
- package/dist/commands/generate-rules/service.d.ts.map +0 -1
- package/dist/commands/generate-rules/service.js +0 -103
- package/dist/commands/generate-rules/utils.d.ts +0 -5
- package/dist/commands/generate-rules/utils.d.ts.map +0 -1
- package/dist/commands/generate-rules/utils.js +0 -25
- package/dist/commands/handoff/index.d.ts +0 -3
- package/dist/commands/handoff/index.d.ts.map +0 -1
- package/dist/commands/handoff/index.js +0 -97
- package/dist/commands/handoff/utils.d.ts +0 -4
- package/dist/commands/handoff/utils.d.ts.map +0 -1
- package/dist/commands/handoff/utils.js +0 -123
- package/dist/commands/list-directories/index.d.ts +0 -3
- package/dist/commands/list-directories/index.d.ts.map +0 -1
- package/dist/commands/list-directories/index.js +0 -35
- package/dist/commands/pickup/index.d.ts +0 -3
- package/dist/commands/pickup/index.d.ts.map +0 -1
- package/dist/commands/pickup/index.js +0 -141
- package/dist/commands/pickup/types.d.ts +0 -6
- package/dist/commands/pickup/types.d.ts.map +0 -1
- package/dist/commands/pickup/types.js +0 -1
- package/dist/commands/pickup/utils.d.ts +0 -7
- package/dist/commands/pickup/utils.d.ts.map +0 -1
- package/dist/commands/pickup/utils.js +0 -56
- package/dist/commands/remove-directory/index.d.ts +0 -3
- package/dist/commands/remove-directory/index.d.ts.map +0 -1
- package/dist/commands/remove-directory/index.js +0 -55
- package/dist/commands/review/index.d.ts +0 -3
- package/dist/commands/review/index.d.ts.map +0 -1
- package/dist/commands/review/index.js +0 -12
- package/dist/commands/review/review-panel.d.ts +0 -3
- package/dist/commands/review/review-panel.d.ts.map +0 -1
- package/dist/commands/review/review-panel.js +0 -186
- package/dist/commands/review/utils.d.ts +0 -18
- package/dist/commands/review/utils.d.ts.map +0 -1
- package/dist/commands/review/utils.js +0 -146
- package/dist/commands/shell/index.d.ts +0 -3
- package/dist/commands/shell/index.d.ts.map +0 -1
- package/dist/commands/shell/index.js +0 -96
- package/dist/modes/manager.d.ts +0 -24
- package/dist/modes/manager.d.ts.map +0 -1
- package/dist/modes/manager.js +0 -77
- package/dist/modes/prompts.d.ts +0 -2
- package/dist/modes/prompts.d.ts.map +0 -1
- package/dist/modes/prompts.js +0 -142
- package/dist/subagents/index.d.ts +0 -16
- package/dist/subagents/index.d.ts.map +0 -1
- package/dist/subagents/index.js +0 -231
- package/dist/terminal/index.d.ts +0 -9
- package/dist/terminal/index.d.ts.map +0 -1
- package/dist/terminal/index.js +0 -8
- package/dist/tools/agent.d.ts +0 -27
- package/dist/tools/agent.d.ts.map +0 -1
- package/dist/tools/agent.js +0 -81
- package/dist/tools/directory-tree.d.ts +0 -28
- package/dist/tools/directory-tree.d.ts.map +0 -1
- package/dist/tools/directory-tree.js +0 -152
- package/dist/tools/glob.d.ts +0 -35
- package/dist/tools/glob.d.ts.map +0 -1
- package/dist/tools/glob.js +0 -159
- package/dist/tools/grep.d.ts +0 -100
- package/dist/tools/grep.d.ts.map +0 -1
- package/dist/tools/grep.js +0 -601
- package/dist/tools/ls.d.ts +0 -26
- package/dist/tools/ls.d.ts.map +0 -1
- package/dist/tools/ls.js +0 -82
- package/dist/tui/components/header.d.ts +0 -21
- package/dist/tui/components/header.d.ts.map +0 -1
- package/dist/tui/components/header.js +0 -63
- package/dist/utils/bash/parse.d.ts +0 -19
- package/dist/utils/bash/parse.d.ts.map +0 -1
- package/dist/utils/bash/parse.js +0 -223
- package/dist/utils/bash/quote.d.ts +0 -6
- package/dist/utils/bash/quote.d.ts.map +0 -1
- package/dist/utils/bash/quote.js +0 -23
- package/dist/utils/generators.d.ts +0 -3
- package/dist/utils/generators.d.ts.map +0 -1
- package/dist/utils/generators.js +0 -25
- package/dist/utils/glob.d.ts +0 -52
- package/dist/utils/glob.d.ts.map +0 -1
- package/dist/utils/glob.js +0 -376
package/dist/agent/sub-agent.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { generateText, stepCountIs } from "ai";
|
|
2
|
-
import { config } from "../config/index.js";
|
|
3
|
-
import { AiConfig } from "../models/ai-config.js";
|
|
4
|
-
import { getLanguageModel, getModelMetadata } from "../models/manager.js";
|
|
5
|
-
import { initTools } from "../tools/index.js";
|
|
6
|
-
import { toAiSdkTools } from "../tools/utils.js";
|
|
7
|
-
export class SubAgent {
|
|
8
|
-
workspace;
|
|
9
|
-
constructor(options) {
|
|
10
|
-
this.workspace = options.workspace;
|
|
11
|
-
}
|
|
12
|
-
async execute({ model, system, prompt, abortSignal, allowedTools, timeout, }) {
|
|
13
|
-
try {
|
|
14
|
-
const { tools, abortSignal: combinedSignal, timeoutId, } = await this.prepareExecution({
|
|
15
|
-
allowedTools,
|
|
16
|
-
timeout,
|
|
17
|
-
abortSignal,
|
|
18
|
-
});
|
|
19
|
-
try {
|
|
20
|
-
const result = await this.runGenerateText({
|
|
21
|
-
model,
|
|
22
|
-
system,
|
|
23
|
-
prompt,
|
|
24
|
-
tools,
|
|
25
|
-
abortSignal: combinedSignal,
|
|
26
|
-
});
|
|
27
|
-
return result.text;
|
|
28
|
-
}
|
|
29
|
-
finally {
|
|
30
|
-
if (timeoutId) {
|
|
31
|
-
clearTimeout(timeoutId);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
throw this.transformError(error);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async prepareExecution({ allowedTools, timeout, abortSignal, }) {
|
|
40
|
-
let tools = await initTools({
|
|
41
|
-
workspace: this.workspace,
|
|
42
|
-
});
|
|
43
|
-
tools = this.filterTools(tools, allowedTools);
|
|
44
|
-
const { signal: timeoutSignal, timeoutId } = this.createTimeoutSignal(timeout);
|
|
45
|
-
const combinedSignal = this.combineAbortSignals(timeoutSignal, abortSignal);
|
|
46
|
-
return { tools, abortSignal: combinedSignal, timeoutId };
|
|
47
|
-
}
|
|
48
|
-
filterTools(tools, allowedTools) {
|
|
49
|
-
if (!allowedTools || allowedTools.length === 0) {
|
|
50
|
-
return tools;
|
|
51
|
-
}
|
|
52
|
-
const filteredTools = {};
|
|
53
|
-
for (const [key, value] of Object.entries(tools)) {
|
|
54
|
-
if (allowedTools.includes(key)) {
|
|
55
|
-
filteredTools[key] = value;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return filteredTools;
|
|
59
|
-
}
|
|
60
|
-
createTimeoutSignal(timeout) {
|
|
61
|
-
if (!timeout || timeout <= 0) {
|
|
62
|
-
return { signal: undefined, timeoutId: undefined };
|
|
63
|
-
}
|
|
64
|
-
const controller = new AbortController();
|
|
65
|
-
const timeoutId = setTimeout(() => {
|
|
66
|
-
controller.abort(new Error(`SubAgent timed out after ${timeout} seconds`));
|
|
67
|
-
}, timeout * 1000);
|
|
68
|
-
return { signal: controller.signal, timeoutId };
|
|
69
|
-
}
|
|
70
|
-
combineAbortSignals(timeoutSignal, abortSignal) {
|
|
71
|
-
const signals = [timeoutSignal, abortSignal].filter((s) => s != null);
|
|
72
|
-
if (signals.length === 0) {
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
if (signals.length === 1) {
|
|
76
|
-
return signals[0];
|
|
77
|
-
}
|
|
78
|
-
return AbortSignal.any(signals);
|
|
79
|
-
}
|
|
80
|
-
async runGenerateText({ model, system, prompt, tools, abortSignal, }) {
|
|
81
|
-
const modelConfig = getModelMetadata({ model });
|
|
82
|
-
const aiConfig = new AiConfig({
|
|
83
|
-
modelMetadata: modelConfig,
|
|
84
|
-
prompt,
|
|
85
|
-
});
|
|
86
|
-
const stateDir = await config.app.ensurePath("audit");
|
|
87
|
-
return generateText({
|
|
88
|
-
model: getLanguageModel({ model, app: "subagent", stateDir }),
|
|
89
|
-
maxOutputTokens: aiConfig.maxOutputTokens(),
|
|
90
|
-
system,
|
|
91
|
-
prompt,
|
|
92
|
-
temperature: aiConfig.temperature(),
|
|
93
|
-
topP: aiConfig.topP(),
|
|
94
|
-
stopWhen: stepCountIs(100),
|
|
95
|
-
providerOptions: aiConfig.providerOptions(),
|
|
96
|
-
tools: toAiSdkTools(tools),
|
|
97
|
-
abortSignal,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
transformError(error) {
|
|
101
|
-
if (error.name === "AbortError" || error.name === "TimeoutError") {
|
|
102
|
-
if (error.message.includes("timed out")) {
|
|
103
|
-
return new Error(error.message);
|
|
104
|
-
}
|
|
105
|
-
return new Error(`SubAgent execution was aborted: ${error.message}`);
|
|
106
|
-
}
|
|
107
|
-
return error;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/add-directory/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/D,eAAO,MAAM,mBAAmB,GAAI,gBAEjC,cAAc,KAAG,WAwFnB,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import style from "../../terminal/style.js";
|
|
2
|
-
import { Text } from "../../tui/index.js";
|
|
3
|
-
import { resolveDirectoryPath, validateDirectory } from "./utils.js";
|
|
4
|
-
export const addDirectoryCommand = ({ workspace, }) => {
|
|
5
|
-
return {
|
|
6
|
-
command: "/add-directory",
|
|
7
|
-
description: "Add a directory to the list of allowed working directories",
|
|
8
|
-
getSubCommands: async () => {
|
|
9
|
-
return [];
|
|
10
|
-
},
|
|
11
|
-
async handle(args, { tui, container, editor, }) {
|
|
12
|
-
const directoryPath = args?.[0];
|
|
13
|
-
if (!directoryPath) {
|
|
14
|
-
container.addChild(new Text(style.red("Usage: /add-directory <path>"), 0, 1));
|
|
15
|
-
tui.requestRender();
|
|
16
|
-
editor.setText("");
|
|
17
|
-
return "continue";
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const resolvedPath = resolveDirectoryPath(directoryPath);
|
|
21
|
-
const isValid = await validateDirectory(resolvedPath);
|
|
22
|
-
if (!isValid) {
|
|
23
|
-
container.addChild(new Text(style.red(`Path is not a directory: ${resolvedPath}`), 1, 0));
|
|
24
|
-
tui.requestRender();
|
|
25
|
-
editor.setText("");
|
|
26
|
-
return "continue";
|
|
27
|
-
}
|
|
28
|
-
if (workspace.allowedDirs.includes(resolvedPath)) {
|
|
29
|
-
container.addChild(new Text(style.yellow(`Directory already in allowed list: ${resolvedPath}`), 1, 0));
|
|
30
|
-
tui.requestRender();
|
|
31
|
-
editor.setText("");
|
|
32
|
-
return "continue";
|
|
33
|
-
}
|
|
34
|
-
workspace.allowedDirs.push(resolvedPath);
|
|
35
|
-
container.addChild(new Text(`Added directory to allowed list: ${style.blue(resolvedPath)}`, 1, 0));
|
|
36
|
-
container.addChild(new Text(`Current allowed directories: ${style.blue(workspace.allowedDirs.join(", "))}`, 2, 0));
|
|
37
|
-
tui.requestRender();
|
|
38
|
-
editor.setText("");
|
|
39
|
-
return "continue";
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
43
|
-
container.addChild(new Text(style.red(`Failed to add directory: ${errorMessage}`), 0, 1));
|
|
44
|
-
tui.requestRender();
|
|
45
|
-
editor.setText("");
|
|
46
|
-
return "continue";
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/add-directory/utils.ts"],"names":[],"mappings":"AAGA,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQzE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
export async function validateDirectory(dirPath) {
|
|
4
|
-
try {
|
|
5
|
-
const resolvedPath = path.resolve(dirPath);
|
|
6
|
-
const stats = await fs.stat(resolvedPath);
|
|
7
|
-
return stats.isDirectory();
|
|
8
|
-
}
|
|
9
|
-
catch {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export function resolveDirectoryPath(dirPath) {
|
|
14
|
-
return path.resolve(dirPath);
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/clear/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/D,eAAO,MAAM,YAAY,GAAI,UAAU,cAAc,KAAG,WAmBvD,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const clearCommand = (_options) => {
|
|
2
|
-
return {
|
|
3
|
-
command: "/clear",
|
|
4
|
-
description: "Clears the terminal screen.",
|
|
5
|
-
getSubCommands: () => Promise.resolve([]),
|
|
6
|
-
async handle(_args, { tui, container, editor, }) {
|
|
7
|
-
container.clear();
|
|
8
|
-
tui.requestRender();
|
|
9
|
-
editor.setText("");
|
|
10
|
-
return "continue";
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/generate-rules/index.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/D,eAAO,MAAM,oBAAoB,GAAI,oEAMlC,cAAc,KAAG,WA4HnB,CAAC"}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { getTerminalSize, isArrowDown, isArrowUp, isEnter, isEscape, isShiftTab, isTab, } from "../../terminal/control.js";
|
|
2
|
-
import style from "../../terminal/style.js";
|
|
3
|
-
import { Container, Input, Spacer, Text, } from "../../tui/index.js";
|
|
4
|
-
import { logger } from "../../utils/logger.js";
|
|
5
|
-
import { generateRulesFromSession } from "./service.js";
|
|
6
|
-
import { hideRuleSelector } from "./utils.js";
|
|
7
|
-
export const generateRulesCommand = ({ sessionManager, modelManager, tokenTracker, config, workspace, }) => {
|
|
8
|
-
return {
|
|
9
|
-
command: "/generate-rules",
|
|
10
|
-
description: "Analyzes the current conversation to generate and save new interaction rules, then displays them.",
|
|
11
|
-
getSubCommands: () => Promise.resolve([]),
|
|
12
|
-
async handle(_args, { tui, container, inputContainer, editor, }) {
|
|
13
|
-
if (sessionManager.isEmpty()) {
|
|
14
|
-
container.addChild(new Text(style.yellow("Cannot generate rules from an empty conversation."), 1, 0));
|
|
15
|
-
tui.requestRender();
|
|
16
|
-
editor.setText("");
|
|
17
|
-
return "continue";
|
|
18
|
-
}
|
|
19
|
-
container.addChild(new Text("Analyzing conversation to generate rules...", 0, 1));
|
|
20
|
-
tui.requestRender();
|
|
21
|
-
try {
|
|
22
|
-
const { rules: newRules } = await generateRulesFromSession({
|
|
23
|
-
modelManager,
|
|
24
|
-
messages: sessionManager.get(),
|
|
25
|
-
tokenTracker,
|
|
26
|
-
config,
|
|
27
|
-
workspace,
|
|
28
|
-
});
|
|
29
|
-
if (newRules == null || newRules.length === 0) {
|
|
30
|
-
container.addChild(new Text(style.yellow("No new generalizable rules were identified."), 2, 0));
|
|
31
|
-
tui.requestRender();
|
|
32
|
-
editor.setText("");
|
|
33
|
-
return "continue";
|
|
34
|
-
}
|
|
35
|
-
const ruleSelector = new RuleSelectorComponent(newRules, async (selectedRules) => {
|
|
36
|
-
if (selectedRules.length === 0) {
|
|
37
|
-
container.addChild(new Text(style.yellow("No rules selected to save."), 2, 0));
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
try {
|
|
41
|
-
const existingRules = await config.readLearnedRulesFile();
|
|
42
|
-
const rulesToAdd = selectedRules.join("\n");
|
|
43
|
-
const updatedRules = existingRules.endsWith("\n") || existingRules.length === 0
|
|
44
|
-
? `${existingRules}${rulesToAdd}`
|
|
45
|
-
: `${existingRules}\n${rulesToAdd}`;
|
|
46
|
-
await config.writeLearnedRulesFile(updatedRules);
|
|
47
|
-
container.addChild(new Text(style.green("Selected rules saved to learned rules."), 2, 0));
|
|
48
|
-
container.addChild(new Text(style.dim("Saved rules:"), 3, 0));
|
|
49
|
-
selectedRules.forEach((rule, index) => {
|
|
50
|
-
container.addChild(new Text(`- ${rule}`, 4 + index, 0));
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
container.addChild(new Text(style.red(`Failed to save rules: ${error}`), 2, 0));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
hideRuleSelector(inputContainer, editor, tui);
|
|
58
|
-
tui.requestRender();
|
|
59
|
-
}, () => {
|
|
60
|
-
hideRuleSelector(inputContainer, editor, tui);
|
|
61
|
-
tui.requestRender();
|
|
62
|
-
});
|
|
63
|
-
inputContainer.clear();
|
|
64
|
-
inputContainer.addChild(ruleSelector);
|
|
65
|
-
tui.setFocus(ruleSelector);
|
|
66
|
-
tui.requestRender();
|
|
67
|
-
return "continue";
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
71
|
-
container.addChild(new Text(style.red(`Error generating rules: ${errorMessage}`), 0, 1));
|
|
72
|
-
logger.error(error, "Error during rule generation:");
|
|
73
|
-
tui.requestRender();
|
|
74
|
-
editor.setText("");
|
|
75
|
-
return "continue";
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
class RuleSelectorComponent extends Container {
|
|
81
|
-
searchInput;
|
|
82
|
-
listContainer;
|
|
83
|
-
allRules = [];
|
|
84
|
-
filteredRules = [];
|
|
85
|
-
selectedIndex = 0;
|
|
86
|
-
selectedRules = new Set();
|
|
87
|
-
onSelectCallback;
|
|
88
|
-
onCancelCallback;
|
|
89
|
-
constructor(rules, onSelect, onCancel) {
|
|
90
|
-
super();
|
|
91
|
-
this.onSelectCallback = onSelect;
|
|
92
|
-
this.onCancelCallback = onCancel;
|
|
93
|
-
this.allRules = rules;
|
|
94
|
-
this.filteredRules = rules;
|
|
95
|
-
const { columns } = getTerminalSize();
|
|
96
|
-
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
97
|
-
this.addChild(new Spacer(1));
|
|
98
|
-
this.searchInput = new Input();
|
|
99
|
-
this.searchInput.onSubmit = () => {
|
|
100
|
-
this.toggleSelection(this.selectedIndex);
|
|
101
|
-
};
|
|
102
|
-
this.addChild(this.searchInput);
|
|
103
|
-
this.addChild(new Spacer(1));
|
|
104
|
-
this.listContainer = new Container();
|
|
105
|
-
this.addChild(this.listContainer);
|
|
106
|
-
this.addChild(new Spacer(1));
|
|
107
|
-
this.addChild(new Text(style.dim("Space: toggle selection, Enter: confirm, Escape: cancel"), 0, 0));
|
|
108
|
-
this.addChild(new Spacer(1));
|
|
109
|
-
this.addChild(new Text(style.blue("─".repeat(columns)), 0, 0));
|
|
110
|
-
this.updateList();
|
|
111
|
-
}
|
|
112
|
-
filterRules(query) {
|
|
113
|
-
if (!query.trim()) {
|
|
114
|
-
this.filteredRules = this.allRules;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
const searchTokens = query
|
|
118
|
-
.toLowerCase()
|
|
119
|
-
.split(/\s+/)
|
|
120
|
-
.filter((t) => t);
|
|
121
|
-
this.filteredRules = this.allRules.filter((rule) => {
|
|
122
|
-
const searchText = rule.toLowerCase();
|
|
123
|
-
return searchTokens.every((token) => searchText.includes(token));
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredRules.length - 1));
|
|
127
|
-
this.updateList();
|
|
128
|
-
}
|
|
129
|
-
updateList() {
|
|
130
|
-
this.listContainer.clear();
|
|
131
|
-
const maxVisible = 10;
|
|
132
|
-
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(maxVisible / 2), this.filteredRules.length - maxVisible));
|
|
133
|
-
const endIndex = Math.min(startIndex + maxVisible, this.filteredRules.length);
|
|
134
|
-
for (let i = startIndex; i < endIndex; i++) {
|
|
135
|
-
const rule = this.filteredRules[i];
|
|
136
|
-
if (!rule)
|
|
137
|
-
continue;
|
|
138
|
-
const isSelected = i === this.selectedIndex;
|
|
139
|
-
const isChecked = this.selectedRules.has(i);
|
|
140
|
-
let line = "";
|
|
141
|
-
if (isSelected) {
|
|
142
|
-
const prefix = style.blue("→ ");
|
|
143
|
-
const checkbox = isChecked ? style.green("[✓] ") : "[ ] ";
|
|
144
|
-
const ruleText = rule;
|
|
145
|
-
line = `${prefix + checkbox + style.blue(ruleText)}`;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
const checkbox = isChecked ? style.green("[✓] ") : "[ ] ";
|
|
149
|
-
const ruleText = ` ${rule}`;
|
|
150
|
-
line = `${checkbox + ruleText}`;
|
|
151
|
-
}
|
|
152
|
-
this.listContainer.addChild(new Text(line, 0, 0));
|
|
153
|
-
}
|
|
154
|
-
if (startIndex > 0 || endIndex < this.filteredRules.length) {
|
|
155
|
-
const scrollInfo = style.gray(` (${this.selectedIndex + 1}/${this.filteredRules.length})`);
|
|
156
|
-
this.listContainer.addChild(new Text(scrollInfo, 0, 0));
|
|
157
|
-
}
|
|
158
|
-
if (this.filteredRules.length === 0) {
|
|
159
|
-
this.listContainer.addChild(new Text(style.gray(" No matching rules"), 0, 0));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
wantsNavigationKeys() {
|
|
163
|
-
return true;
|
|
164
|
-
}
|
|
165
|
-
handleInput(keyData) {
|
|
166
|
-
if (isArrowUp(keyData) || isShiftTab(keyData)) {
|
|
167
|
-
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
168
|
-
this.updateList();
|
|
169
|
-
}
|
|
170
|
-
else if (isArrowDown(keyData) || isTab(keyData)) {
|
|
171
|
-
this.selectedIndex = Math.min(this.filteredRules.length - 1, this.selectedIndex + 1);
|
|
172
|
-
this.updateList();
|
|
173
|
-
}
|
|
174
|
-
else if (keyData === " ") {
|
|
175
|
-
this.toggleSelection(this.selectedIndex);
|
|
176
|
-
}
|
|
177
|
-
else if (isEnter(keyData)) {
|
|
178
|
-
this.handleConfirm();
|
|
179
|
-
}
|
|
180
|
-
else if (isEscape(keyData)) {
|
|
181
|
-
this.onCancelCallback();
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
this.searchInput.handleInput(keyData);
|
|
185
|
-
this.filterRules(this.searchInput.getValue());
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
toggleSelection(index) {
|
|
189
|
-
if (this.selectedRules.has(index)) {
|
|
190
|
-
this.selectedRules.delete(index);
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
this.selectedRules.add(index);
|
|
194
|
-
}
|
|
195
|
-
this.updateList();
|
|
196
|
-
}
|
|
197
|
-
handleConfirm() {
|
|
198
|
-
const selectedRuleTexts = Array.from(this.selectedRules)
|
|
199
|
-
.map((index) => this.filteredRules[index])
|
|
200
|
-
.filter((rule) => rule !== undefined);
|
|
201
|
-
this.onSelectCallback(selectedRuleTexts);
|
|
202
|
-
}
|
|
203
|
-
getSearchInput() {
|
|
204
|
-
return this.searchInput;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type ModelMessage } from "ai";
|
|
2
|
-
import type { ConfigManager } from "../../config/index.ts";
|
|
3
|
-
import type { WorkspaceContext } from "../../index.ts";
|
|
4
|
-
import type { ModelManager } from "../../models/manager.ts";
|
|
5
|
-
import type { TokenTracker } from "../../tokens/tracker.ts";
|
|
6
|
-
interface GenerateRulesOptions {
|
|
7
|
-
modelManager: ModelManager;
|
|
8
|
-
messages: ModelMessage[];
|
|
9
|
-
tokenTracker: TokenTracker;
|
|
10
|
-
config: ConfigManager;
|
|
11
|
-
workspace: WorkspaceContext;
|
|
12
|
-
}
|
|
13
|
-
interface GenerateRulesResult {
|
|
14
|
-
rules: string[];
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Analyzes conversation and generates rules without UI interaction.
|
|
18
|
-
* Returns the list of generated rules.
|
|
19
|
-
*/
|
|
20
|
-
export declare function generateRulesFromSession(options: GenerateRulesOptions): Promise<GenerateRulesResult>;
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../source/commands/generate-rules/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,IAAI,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAG5D,UAAU,oBAAoB;IAC5B,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CA6D9B"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { generateText } from "ai";
|
|
2
|
-
import { systemPrompt } from "../../prompts/system-prompt.js";
|
|
3
|
-
import { createUserMessage } from "../../sessions/manager.js";
|
|
4
|
-
/**
|
|
5
|
-
* Analyzes conversation and generates rules without UI interaction.
|
|
6
|
-
* Returns the list of generated rules.
|
|
7
|
-
*/
|
|
8
|
-
export async function generateRulesFromSession(options) {
|
|
9
|
-
const { modelManager, messages, tokenTracker, config, workspace } = options;
|
|
10
|
-
// Read existing learned rules to avoid duplicates
|
|
11
|
-
const existingRules = await config.readLearnedRulesFile();
|
|
12
|
-
// Add analysis prompt to messages (clone to avoid side effects)
|
|
13
|
-
const analysisMessages = [...messages];
|
|
14
|
-
analysisMessages.push(createUserMessage([
|
|
15
|
-
`Analyze this conversation and identify ONLY rules that are broadly applicable to FUTURE, UNRELATED tasks.
|
|
16
|
-
|
|
17
|
-
**Critical: Most conversations will NOT yield useful generalizable rules.** Only extract a rule if it represents a genuine, reusable principle that would help the agent in completely different contexts.
|
|
18
|
-
|
|
19
|
-
**Key Requirements:**
|
|
20
|
-
- A rule must be *universally* applicable, not just to this project or similar tasks
|
|
21
|
-
- If you're uncertain whether a rule is broadly applicable, DO NOT include it
|
|
22
|
-
- Rules about specific files, functions, or variables are NEVER acceptable
|
|
23
|
-
- Return an EMPTY list if no broadly applicable rules can be inferred
|
|
24
|
-
- Return *only* the Markdown list of rules, with no preamble or explanation
|
|
25
|
-
|
|
26
|
-
<existing-rules>
|
|
27
|
-
${existingRules}
|
|
28
|
-
</existing-rules>`,
|
|
29
|
-
]));
|
|
30
|
-
const systemPromptText = await createAnalysisSystemPrompt(config, workspace);
|
|
31
|
-
const { text, usage } = await generateText({
|
|
32
|
-
model: modelManager.getModel("conversation-analyzer"),
|
|
33
|
-
maxOutputTokens: 8192,
|
|
34
|
-
system: systemPromptText,
|
|
35
|
-
messages: analysisMessages,
|
|
36
|
-
});
|
|
37
|
-
tokenTracker.trackUsage("conversation-analyzer", usage);
|
|
38
|
-
const potentialRulesText = text.trim();
|
|
39
|
-
if (!potentialRulesText || potentialRulesText.length === 0) {
|
|
40
|
-
return { rules: [] };
|
|
41
|
-
}
|
|
42
|
-
const potentialRulesList = potentialRulesText
|
|
43
|
-
.split("\n")
|
|
44
|
-
.map((rule) => rule.trim())
|
|
45
|
-
.filter((rule) => rule.length > 0);
|
|
46
|
-
if (potentialRulesList.length === 0) {
|
|
47
|
-
return { rules: [] };
|
|
48
|
-
}
|
|
49
|
-
// Update learned rules file to avoid duplicates in future analysis
|
|
50
|
-
const updatedRules = existingRules.endsWith("\n") || existingRules.length === 0
|
|
51
|
-
? `${existingRules}${potentialRulesList.join("\n")}`
|
|
52
|
-
: `${existingRules}\n${potentialRulesList.join("\n")}`;
|
|
53
|
-
await config.writeLearnedRulesFile(updatedRules);
|
|
54
|
-
return { rules: potentialRulesList };
|
|
55
|
-
}
|
|
56
|
-
async function createAnalysisSystemPrompt(configManager, workspace) {
|
|
57
|
-
const projectConfig = await configManager.getConfig();
|
|
58
|
-
const sysResult = await systemPrompt({
|
|
59
|
-
activeTools: projectConfig.tools.activeTools,
|
|
60
|
-
includeRules: true,
|
|
61
|
-
allowedDirs: workspace.allowedDirs,
|
|
62
|
-
logsPath: projectConfig.logs?.path,
|
|
63
|
-
});
|
|
64
|
-
const sys = sysResult.prompt;
|
|
65
|
-
return `You are an expert analyst reviewing conversations between a coding agent and a software engineer.
|
|
66
|
-
|
|
67
|
-
**YOUR PRIMARY DIRECTIVE: Be extremely conservative. Most conversations do NOT contain useful generalizable rules.** Your job is to identify ONLY those rare, genuinely universal principles that would help the agent in completely unrelated future tasks.
|
|
68
|
-
|
|
69
|
-
**Your Task:**
|
|
70
|
-
1. Analyze the conversation provided.
|
|
71
|
-
2. Identify corrections or redirections that reveal principles TRUE ACROSS ALMOST ANY CONTEXT.
|
|
72
|
-
3. For each correction, ask yourself: "Would this principle be useful if I were working on a completely different project, with different files, different languages, and different requirements?" If not, DO NOT create a rule.
|
|
73
|
-
4. List only rules that pass this high bar in Markdown bullet points. No preamble.
|
|
74
|
-
|
|
75
|
-
**RULES ABOUT RULES:**
|
|
76
|
-
- When in doubt, EXCLUDE. It is better to generate no rules than to generate specific ones.
|
|
77
|
-
- If a rule references any specific file name, function name, variable name, or project-specific detail, it is INVALID.
|
|
78
|
-
- If a rule is specific to a particular language, framework, or tool without broader applicability, it is INVALID.
|
|
79
|
-
- If the user simply clarified requirements (not corrected a flawed approach), it is NOT a rule-worthy correction.
|
|
80
|
-
|
|
81
|
-
**Valid General Rule Examples:**
|
|
82
|
-
<examples>
|
|
83
|
-
- Always ask for clarification if the user's request is ambiguous.
|
|
84
|
-
- Never make assumptions about file paths without confirmation.
|
|
85
|
-
- Always follow the user's explicitly stated formatting preferences.
|
|
86
|
-
- Never provide incomplete code snippets without indicating they are partial.
|
|
87
|
-
- Always check for potential null or undefined values before accessing properties.
|
|
88
|
-
</examples>
|
|
89
|
-
|
|
90
|
-
**INVALID Examples (Do NOT generate these):**
|
|
91
|
-
<bad-examples>
|
|
92
|
-
- Always use 'const' instead of 'let' for variables (too specific - depends on mutability needs)
|
|
93
|
-
- Never forget to pass the 'config' object to functions (specific to this codebase)
|
|
94
|
-
- Always add a try-catch block around API calls (too specific - depends on error handling strategy)
|
|
95
|
-
- Always run tests after making changes (task-specific workflow, not a general principle)
|
|
96
|
-
- Never modify the .env file (project-specific)
|
|
97
|
-
</bad-examples>
|
|
98
|
-
|
|
99
|
-
This is the original system prompt the agent operated under:
|
|
100
|
-
<systemPrompt>
|
|
101
|
-
${sys}
|
|
102
|
-
</systemPrompt>`;
|
|
103
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Container, Editor, TUI } from "../../tui/index.ts";
|
|
2
|
-
export declare function hideRuleSelector(editorContainer: Container, editor: Editor, tui: TUI): void;
|
|
3
|
-
export declare function parseRulesText(text: string): string[];
|
|
4
|
-
export declare function formatRulesForStorage(existingRules: string, newRules: string[]): string;
|
|
5
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/commands/generate-rules/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAEjE,wBAAgB,gBAAgB,CAC9B,eAAe,EAAE,SAAS,EAC1B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,GACP,IAAI,CAIN;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAUrD;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAAE,GACjB,MAAM,CAUR"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export function hideRuleSelector(editorContainer, editor, tui) {
|
|
2
|
-
editorContainer.clear();
|
|
3
|
-
editorContainer.addChild(editor);
|
|
4
|
-
tui.setFocus(editor);
|
|
5
|
-
}
|
|
6
|
-
export function parseRulesText(text) {
|
|
7
|
-
const trimmed = text.trim();
|
|
8
|
-
if (!trimmed || trimmed.length === 0) {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
return trimmed
|
|
12
|
-
.split("\n")
|
|
13
|
-
.map((rule) => rule.trim())
|
|
14
|
-
.filter((rule) => rule.length > 0);
|
|
15
|
-
}
|
|
16
|
-
export function formatRulesForStorage(existingRules, newRules) {
|
|
17
|
-
if (newRules.length === 0) {
|
|
18
|
-
return existingRules;
|
|
19
|
-
}
|
|
20
|
-
const rulesToAdd = newRules.join("\n");
|
|
21
|
-
if (existingRules.endsWith("\n") || existingRules.length === 0) {
|
|
22
|
-
return `${existingRules}${rulesToAdd}`;
|
|
23
|
-
}
|
|
24
|
-
return `${existingRules}\n${rulesToAdd}`;
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/commands/handoff/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO/D,eAAO,MAAM,cAAc,GAAI,SAAS,cAAc,KAAG,WA2DxD,CAAC"}
|