@xagent/one-shot 1.1.100 → 1.1.102
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 +1 -1
- package/dist/index.js +68 -799
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7331,10 +7331,10 @@ var init_dependency_analyzer = __esm({
|
|
|
7331
7331
|
const circularDeps = [];
|
|
7332
7332
|
const visited = /* @__PURE__ */ new Set();
|
|
7333
7333
|
const visiting = /* @__PURE__ */ new Set();
|
|
7334
|
-
const dfs = (filePath,
|
|
7334
|
+
const dfs = (filePath, path33) => {
|
|
7335
7335
|
if (visiting.has(filePath)) {
|
|
7336
|
-
const cycleStart =
|
|
7337
|
-
const cycle =
|
|
7336
|
+
const cycleStart = path33.indexOf(filePath);
|
|
7337
|
+
const cycle = path33.slice(cycleStart).concat([filePath]);
|
|
7338
7338
|
circularDeps.push({
|
|
7339
7339
|
cycle: cycle.map((fp) => graph.nodes.get(fp)?.filePath || fp),
|
|
7340
7340
|
severity: cycle.length <= 2 ? "error" : "warning",
|
|
@@ -7350,7 +7350,7 @@ var init_dependency_analyzer = __esm({
|
|
|
7350
7350
|
if (node) {
|
|
7351
7351
|
for (const dependency of node.dependencies) {
|
|
7352
7352
|
if (graph.nodes.has(dependency)) {
|
|
7353
|
-
dfs(dependency, [...
|
|
7353
|
+
dfs(dependency, [...path33, filePath]);
|
|
7354
7354
|
}
|
|
7355
7355
|
}
|
|
7356
7356
|
}
|
|
@@ -12097,131 +12097,6 @@ ${option.id}) ${option.title}`);
|
|
|
12097
12097
|
}
|
|
12098
12098
|
});
|
|
12099
12099
|
|
|
12100
|
-
// src/utils/context-loader.ts
|
|
12101
|
-
var context_loader_exports = {};
|
|
12102
|
-
__export(context_loader_exports, {
|
|
12103
|
-
formatContextStatus: () => formatContextStatus,
|
|
12104
|
-
loadContext: () => loadContext
|
|
12105
|
-
});
|
|
12106
|
-
function loadMarkdownDirectory(dirPath) {
|
|
12107
|
-
if (!fs2__default.existsSync(dirPath)) {
|
|
12108
|
-
return "";
|
|
12109
|
-
}
|
|
12110
|
-
const files = fs2__default.readdirSync(dirPath).filter((file) => file.endsWith(".md")).sort();
|
|
12111
|
-
let content = "";
|
|
12112
|
-
for (const file of files) {
|
|
12113
|
-
const filePath = path8__default.join(dirPath, file);
|
|
12114
|
-
try {
|
|
12115
|
-
const fileContent = fs2__default.readFileSync(filePath, "utf-8");
|
|
12116
|
-
content += `
|
|
12117
|
-
|
|
12118
|
-
=== ${file} ===
|
|
12119
|
-
|
|
12120
|
-
${fileContent}`;
|
|
12121
|
-
} catch (error) {
|
|
12122
|
-
console.warn(`Failed to read ${filePath}:`, error);
|
|
12123
|
-
}
|
|
12124
|
-
}
|
|
12125
|
-
return content;
|
|
12126
|
-
}
|
|
12127
|
-
function extractDateFromFilename(filename) {
|
|
12128
|
-
const match = filename.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
12129
|
-
if (match) {
|
|
12130
|
-
return new Date(match[1]);
|
|
12131
|
-
}
|
|
12132
|
-
return /* @__PURE__ */ new Date(0);
|
|
12133
|
-
}
|
|
12134
|
-
function summarizeContent(content, maxLength = MAX_SUMMARY_LENGTH) {
|
|
12135
|
-
if (content.length <= maxLength) {
|
|
12136
|
-
return content;
|
|
12137
|
-
}
|
|
12138
|
-
const truncated = content.substring(0, maxLength);
|
|
12139
|
-
const lastNewline = truncated.lastIndexOf("\n\n");
|
|
12140
|
-
if (lastNewline > maxLength * 0.8) {
|
|
12141
|
-
return truncated.substring(0, lastNewline);
|
|
12142
|
-
}
|
|
12143
|
-
return truncated + "\n\n[...content truncated for context budget...]";
|
|
12144
|
-
}
|
|
12145
|
-
function loadTaskFiles(tasksDir, maxBudget) {
|
|
12146
|
-
if (!fs2__default.existsSync(tasksDir)) {
|
|
12147
|
-
return [];
|
|
12148
|
-
}
|
|
12149
|
-
const files = fs2__default.readdirSync(tasksDir).filter((file) => file.endsWith(".md")).map((filename) => {
|
|
12150
|
-
const filePath = path8__default.join(tasksDir, filename);
|
|
12151
|
-
const content = fs2__default.readFileSync(filePath, "utf-8");
|
|
12152
|
-
return {
|
|
12153
|
-
filename,
|
|
12154
|
-
content,
|
|
12155
|
-
size: Buffer.byteLength(content, "utf-8"),
|
|
12156
|
-
date: extractDateFromFilename(filename),
|
|
12157
|
-
isSummarized: false
|
|
12158
|
-
};
|
|
12159
|
-
}).sort((a, b) => b.date.getTime() - a.date.getTime());
|
|
12160
|
-
const result = [];
|
|
12161
|
-
let usedBudget = 0;
|
|
12162
|
-
for (const file of files) {
|
|
12163
|
-
let finalContent = file.content;
|
|
12164
|
-
let isSummarized = false;
|
|
12165
|
-
if (usedBudget + file.size > maxBudget) {
|
|
12166
|
-
finalContent = summarizeContent(file.content);
|
|
12167
|
-
const summarizedSize = Buffer.byteLength(finalContent, "utf-8");
|
|
12168
|
-
if (usedBudget + summarizedSize > maxBudget) {
|
|
12169
|
-
continue;
|
|
12170
|
-
}
|
|
12171
|
-
usedBudget += summarizedSize;
|
|
12172
|
-
isSummarized = true;
|
|
12173
|
-
} else {
|
|
12174
|
-
usedBudget += file.size;
|
|
12175
|
-
}
|
|
12176
|
-
result.push({
|
|
12177
|
-
...file,
|
|
12178
|
-
content: finalContent,
|
|
12179
|
-
isSummarized
|
|
12180
|
-
});
|
|
12181
|
-
}
|
|
12182
|
-
return result;
|
|
12183
|
-
}
|
|
12184
|
-
function loadContext(agentDir = ".agent") {
|
|
12185
|
-
const systemContent = loadMarkdownDirectory(path8__default.join(agentDir, "system"));
|
|
12186
|
-
const sopContent = loadMarkdownDirectory(path8__default.join(agentDir, "sop"));
|
|
12187
|
-
const systemSize = Buffer.byteLength(systemContent, "utf-8");
|
|
12188
|
-
const sopSize = Buffer.byteLength(sopContent, "utf-8");
|
|
12189
|
-
const taskBudget = Math.max(0, CONTEXT_BUDGET_BYTES - systemSize - sopSize);
|
|
12190
|
-
const tasks = loadTaskFiles(path8__default.join(agentDir, "tasks"), taskBudget);
|
|
12191
|
-
const totalSize = systemSize + sopSize + tasks.reduce((sum, task) => sum + Buffer.byteLength(task.content, "utf-8"), 0);
|
|
12192
|
-
const warnings = [];
|
|
12193
|
-
if (totalSize > CONTEXT_BUDGET_BYTES) {
|
|
12194
|
-
warnings.push(`Context size (${(totalSize / 1024).toFixed(1)}KB) exceeds budget (${CONTEXT_BUDGET_BYTES / 1024}KB)`);
|
|
12195
|
-
}
|
|
12196
|
-
return {
|
|
12197
|
-
system: systemContent,
|
|
12198
|
-
sop: sopContent,
|
|
12199
|
-
tasks,
|
|
12200
|
-
totalSize,
|
|
12201
|
-
warnings
|
|
12202
|
-
};
|
|
12203
|
-
}
|
|
12204
|
-
function formatContextStatus(pack) {
|
|
12205
|
-
const taskCount = pack.tasks.length;
|
|
12206
|
-
const summarizedCount = pack.tasks.filter((t) => t.isSummarized).length;
|
|
12207
|
-
const sizeKB = (pack.totalSize / 1024).toFixed(1);
|
|
12208
|
-
let status = `[x-cli] Context: loaded system docs, sop docs, ${taskCount} task docs (~${sizeKB} KB).`;
|
|
12209
|
-
if (summarizedCount > 0) {
|
|
12210
|
-
status += ` Summarized ${summarizedCount} older tasks for context budget.`;
|
|
12211
|
-
}
|
|
12212
|
-
if (pack.warnings.length > 0) {
|
|
12213
|
-
status += ` Warnings: ${pack.warnings.join("; ")}`;
|
|
12214
|
-
}
|
|
12215
|
-
return status;
|
|
12216
|
-
}
|
|
12217
|
-
var CONTEXT_BUDGET_BYTES, MAX_SUMMARY_LENGTH;
|
|
12218
|
-
var init_context_loader = __esm({
|
|
12219
|
-
"src/utils/context-loader.ts"() {
|
|
12220
|
-
CONTEXT_BUDGET_BYTES = 280 * 1024;
|
|
12221
|
-
MAX_SUMMARY_LENGTH = 2e3;
|
|
12222
|
-
}
|
|
12223
|
-
});
|
|
12224
|
-
|
|
12225
12100
|
// src/agent/grok-agent.ts
|
|
12226
12101
|
var grok_agent_exports = {};
|
|
12227
12102
|
__export(grok_agent_exports, {
|
|
@@ -12256,6 +12131,7 @@ var init_grok_agent = __esm({
|
|
|
12256
12131
|
const savedModel = manager.getCurrentModel();
|
|
12257
12132
|
const modelToUse = model || savedModel || "grok-code-fast-1";
|
|
12258
12133
|
this.maxToolRounds = maxToolRounds || 400;
|
|
12134
|
+
this.contextPack = contextPack;
|
|
12259
12135
|
this.sessionLogPath = process.env.GROK_SESSION_LOG || `${process.env.HOME}/.grok/session.log`;
|
|
12260
12136
|
this.grokClient = new GrokClient(apiKey2, modelToUse, baseURL);
|
|
12261
12137
|
this.textEditor = new TextEditorTool();
|
|
@@ -12285,16 +12161,16 @@ CUSTOM INSTRUCTIONS:
|
|
|
12285
12161
|
${customInstructions}
|
|
12286
12162
|
|
|
12287
12163
|
The above custom instructions should be followed alongside the standard instructions below.` : "";
|
|
12288
|
-
const contextSection = contextPack ? `
|
|
12164
|
+
const contextSection = this.contextPack ? `
|
|
12289
12165
|
|
|
12290
12166
|
PROJECT CONTEXT:
|
|
12291
|
-
${contextPack.system}
|
|
12167
|
+
${this.contextPack.system}
|
|
12292
12168
|
|
|
12293
12169
|
SOP:
|
|
12294
|
-
${contextPack.sop}
|
|
12170
|
+
${this.contextPack.sop}
|
|
12295
12171
|
|
|
12296
12172
|
TASKS:
|
|
12297
|
-
${contextPack.tasks.map((t) => `- ${t.filename}: ${t.content}`).join("\n")}
|
|
12173
|
+
${this.contextPack.tasks.map((t) => `- ${t.filename}: ${t.content}`).join("\n")}
|
|
12298
12174
|
|
|
12299
12175
|
The above project context should inform your responses and decision making.` : "";
|
|
12300
12176
|
this.messages.push({
|
|
@@ -12452,14 +12328,12 @@ Current working directory: ${process.cwd()}`
|
|
|
12452
12328
|
this.logEntry(userEntry);
|
|
12453
12329
|
this.messages.push({ role: "user", content: message });
|
|
12454
12330
|
try {
|
|
12455
|
-
const contextPack = await this.loadContextPack();
|
|
12456
12331
|
const workflowService = new ResearchRecommendService(this);
|
|
12457
12332
|
const request = {
|
|
12458
|
-
userTask: message
|
|
12459
|
-
context: contextPack ? "Project context loaded" : void 0
|
|
12333
|
+
userTask: message
|
|
12460
12334
|
};
|
|
12461
12335
|
console.log("\u{1F50D} Researching and analyzing...");
|
|
12462
|
-
const { output, approval, revisions } = await workflowService.researchAndGetApproval(request, contextPack);
|
|
12336
|
+
const { output, approval, revisions } = await workflowService.researchAndGetApproval(request, this.contextPack);
|
|
12463
12337
|
if (!approval.approved) {
|
|
12464
12338
|
const rejectionEntry = {
|
|
12465
12339
|
type: "assistant",
|
|
@@ -12863,10 +12737,10 @@ Current working directory: ${process.cwd()}`
|
|
|
12863
12737
|
return await this.textEditor.view(args.path, range);
|
|
12864
12738
|
} catch (error) {
|
|
12865
12739
|
console.warn(`view_file tool failed, falling back to bash: ${error.message}`);
|
|
12866
|
-
const
|
|
12867
|
-
let command = `cat "${
|
|
12740
|
+
const path33 = args.path;
|
|
12741
|
+
let command = `cat "${path33}"`;
|
|
12868
12742
|
if (args.start_line && args.end_line) {
|
|
12869
|
-
command = `sed -n '${args.start_line},${args.end_line}p' "${
|
|
12743
|
+
command = `sed -n '${args.start_line},${args.end_line}p' "${path33}"`;
|
|
12870
12744
|
}
|
|
12871
12745
|
return await this.bash.execute(command);
|
|
12872
12746
|
}
|
|
@@ -13130,18 +13004,6 @@ EOF`;
|
|
|
13130
13004
|
console.warn("Failed to log session entry:", error);
|
|
13131
13005
|
}
|
|
13132
13006
|
}
|
|
13133
|
-
/**
|
|
13134
|
-
* Load .agent context pack for enhanced recommendations
|
|
13135
|
-
*/
|
|
13136
|
-
async loadContextPack() {
|
|
13137
|
-
try {
|
|
13138
|
-
const contextLoader = await Promise.resolve().then(() => (init_context_loader(), context_loader_exports));
|
|
13139
|
-
return await contextLoader.loadContext(".agent");
|
|
13140
|
-
} catch (error) {
|
|
13141
|
-
console.warn("[Workflow] Failed to load context pack:", error);
|
|
13142
|
-
return void 0;
|
|
13143
|
-
}
|
|
13144
|
-
}
|
|
13145
13007
|
/**
|
|
13146
13008
|
* Convert workflow results to chat entries for display
|
|
13147
13009
|
*/
|
|
@@ -18638,7 +18500,7 @@ var init_package = __esm({
|
|
|
18638
18500
|
package_default = {
|
|
18639
18501
|
type: "module",
|
|
18640
18502
|
name: "@xagent/one-shot",
|
|
18641
|
-
version: "1.1.
|
|
18503
|
+
version: "1.1.102",
|
|
18642
18504
|
description: "An open-source AI agent that brings advanced AI capabilities directly into your terminal with automatic documentation updates.",
|
|
18643
18505
|
main: "dist/index.js",
|
|
18644
18506
|
module: "dist/index.js",
|
|
@@ -20682,514 +20544,23 @@ ${pushResult.error || "Git push failed"}
|
|
|
20682
20544
|
setChatHistory((prev) => [...prev, userEntry]);
|
|
20683
20545
|
setIsProcessing(true);
|
|
20684
20546
|
try {
|
|
20685
|
-
const
|
|
20686
|
-
const
|
|
20687
|
-
const qualityCheckEntry = {
|
|
20688
|
-
type: "assistant",
|
|
20689
|
-
content: "\u{1F50D} **Running pre-push quality checks...**",
|
|
20690
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20691
|
-
};
|
|
20692
|
-
setChatHistory((prev) => [...prev, qualityCheckEntry]);
|
|
20693
|
-
const tsCheckEntry = {
|
|
20694
|
-
type: "assistant",
|
|
20695
|
-
content: "\u{1F4DD} Checking TypeScript...",
|
|
20696
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20697
|
-
};
|
|
20698
|
-
setChatHistory((prev) => [...prev, tsCheckEntry]);
|
|
20699
|
-
const tsResult = await agent.executeBashCommand("npm run typecheck");
|
|
20700
|
-
if (tsResult.success) {
|
|
20701
|
-
const tsSuccessEntry = {
|
|
20702
|
-
type: "tool_result",
|
|
20703
|
-
content: "\u2705 TypeScript check passed",
|
|
20704
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
20705
|
-
toolCall: {
|
|
20706
|
-
id: `ts_check_${Date.now()}`,
|
|
20707
|
-
type: "function",
|
|
20708
|
-
function: {
|
|
20709
|
-
name: "bash",
|
|
20710
|
-
arguments: JSON.stringify({ command: "npm run typecheck" })
|
|
20711
|
-
}
|
|
20712
|
-
},
|
|
20713
|
-
toolResult: tsResult
|
|
20714
|
-
};
|
|
20715
|
-
setChatHistory((prev) => [...prev, tsSuccessEntry]);
|
|
20716
|
-
} else {
|
|
20717
|
-
const tsFailEntry = {
|
|
20718
|
-
type: "assistant",
|
|
20719
|
-
content: `\u274C **TypeScript check failed**
|
|
20720
|
-
|
|
20721
|
-
${tsResult.error || tsResult.output}`,
|
|
20722
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20723
|
-
};
|
|
20724
|
-
setChatHistory((prev) => [...prev, tsFailEntry]);
|
|
20725
|
-
setIsProcessing(false);
|
|
20726
|
-
clearInput();
|
|
20727
|
-
return true;
|
|
20728
|
-
}
|
|
20729
|
-
const lintCheckEntry = {
|
|
20730
|
-
type: "assistant",
|
|
20731
|
-
content: "\u{1F9F9} Running ESLint...",
|
|
20732
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20733
|
-
};
|
|
20734
|
-
setChatHistory((prev) => [...prev, lintCheckEntry]);
|
|
20735
|
-
const lintResult = await agent.executeBashCommand("npm run lint");
|
|
20736
|
-
const lintSuccessEntry = {
|
|
20737
|
-
type: "tool_result",
|
|
20738
|
-
content: "\u2705 ESLint check completed (warnings allowed)",
|
|
20739
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
20740
|
-
toolCall: {
|
|
20741
|
-
id: `lint_check_${Date.now()}`,
|
|
20742
|
-
type: "function",
|
|
20743
|
-
function: {
|
|
20744
|
-
name: "bash",
|
|
20745
|
-
arguments: JSON.stringify({ command: "npm run lint" })
|
|
20746
|
-
}
|
|
20747
|
-
},
|
|
20748
|
-
toolResult: lintResult
|
|
20749
|
-
};
|
|
20750
|
-
setChatHistory((prev) => [...prev, lintSuccessEntry]);
|
|
20751
|
-
const statusResult = await agent.executeBashCommand("git status --porcelain");
|
|
20752
|
-
if (!statusResult.success) {
|
|
20753
|
-
const errorEntry = {
|
|
20754
|
-
type: "assistant",
|
|
20755
|
-
content: "\u274C **Git Error**\n\nUnable to check git status. Are you in a git repository?",
|
|
20756
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20757
|
-
};
|
|
20758
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20759
|
-
setIsProcessing(false);
|
|
20760
|
-
clearInput();
|
|
20761
|
-
return true;
|
|
20762
|
-
}
|
|
20763
|
-
if (!statusResult.output || statusResult.output.trim() === "") {
|
|
20764
|
-
const noChangesEntry = {
|
|
20765
|
-
type: "assistant",
|
|
20766
|
-
content: "\u{1F4CB} **No Changes to Push**\n\nWorking directory is clean. No commits to push.",
|
|
20767
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20768
|
-
};
|
|
20769
|
-
setChatHistory((prev) => [...prev, noChangesEntry]);
|
|
20770
|
-
setIsProcessing(false);
|
|
20771
|
-
clearInput();
|
|
20772
|
-
return true;
|
|
20773
|
-
}
|
|
20774
|
-
const prePullAddResult = await agent.executeBashCommand("git add .");
|
|
20775
|
-
if (!prePullAddResult.success) {
|
|
20776
|
-
const errorEntry = {
|
|
20777
|
-
type: "assistant",
|
|
20778
|
-
content: `\u274C **Failed to stage changes**
|
|
20779
|
-
|
|
20780
|
-
${prePullAddResult.error || "Unknown error"}`,
|
|
20781
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20782
|
-
};
|
|
20783
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20784
|
-
setIsProcessing(false);
|
|
20785
|
-
clearInput();
|
|
20786
|
-
return true;
|
|
20787
|
-
}
|
|
20788
|
-
const stashResult = await agent.executeBashCommand("git stash push --include-untracked --message 'smart-push temporary stash'");
|
|
20789
|
-
if (!stashResult.success) {
|
|
20790
|
-
const errorEntry = {
|
|
20791
|
-
type: "assistant",
|
|
20792
|
-
content: `\u274C **Failed to stash changes**
|
|
20793
|
-
|
|
20794
|
-
${stashResult.error || "Unknown error"}`,
|
|
20795
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20796
|
-
};
|
|
20797
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20798
|
-
setIsProcessing(false);
|
|
20799
|
-
clearInput();
|
|
20800
|
-
return true;
|
|
20801
|
-
}
|
|
20802
|
-
const pullEntry = {
|
|
20803
|
-
type: "assistant",
|
|
20804
|
-
content: "\u{1F504} Pulling latest changes...",
|
|
20805
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20806
|
-
};
|
|
20807
|
-
setChatHistory((prev) => [...prev, pullEntry]);
|
|
20808
|
-
const rebaseCheck = await agent.executeBashCommand("test -d .git/rebase-apply -o -d .git/rebase-merge -o -f .git/MERGE_HEAD && echo 'ongoing' || echo 'clean'");
|
|
20809
|
-
if (rebaseCheck.output?.includes("ongoing")) {
|
|
20810
|
-
const cleanupEntry = {
|
|
20811
|
-
type: "assistant",
|
|
20812
|
-
content: "\u26A0\uFE0F Git operation in progress - cleaning up...",
|
|
20813
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20814
|
-
};
|
|
20815
|
-
setChatHistory((prev) => [...prev, cleanupEntry]);
|
|
20816
|
-
await agent.executeBashCommand("git rebase --abort 2>/dev/null || git merge --abort 2>/dev/null || true");
|
|
20817
|
-
}
|
|
20818
|
-
let pullResult = await agent.executeBashCommand(`git pull --rebase origin ${currentBranch}`);
|
|
20819
|
-
if (!pullResult.success) {
|
|
20820
|
-
pullResult = await agent.executeBashCommand(`git pull origin ${currentBranch}`);
|
|
20821
|
-
if (pullResult.success) {
|
|
20822
|
-
const mergeFallbackEntry = {
|
|
20823
|
-
type: "assistant",
|
|
20824
|
-
content: "\u26A0\uFE0F Rebase failed, fell back to merge",
|
|
20825
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20826
|
-
};
|
|
20827
|
-
setChatHistory((prev) => [...prev, mergeFallbackEntry]);
|
|
20828
|
-
}
|
|
20829
|
-
}
|
|
20830
|
-
if (pullResult.success) {
|
|
20831
|
-
const pullSuccessEntry = {
|
|
20832
|
-
type: "tool_result",
|
|
20833
|
-
content: pullResult.output?.includes("Successfully rebased") ? "\u2705 Successfully rebased local changes" : "\u2705 Successfully pulled latest changes",
|
|
20834
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20835
|
-
};
|
|
20836
|
-
setChatHistory((prev) => [...prev, pullSuccessEntry]);
|
|
20837
|
-
const popStashResult = await agent.executeBashCommand("git stash pop");
|
|
20838
|
-
if (!popStashResult.success) {
|
|
20839
|
-
const errorEntry = {
|
|
20840
|
-
type: "assistant",
|
|
20841
|
-
content: `\u26A0\uFE0F **Failed to restore stashed changes**
|
|
20842
|
-
|
|
20843
|
-
${popStashResult.error || "Unknown error"}
|
|
20844
|
-
|
|
20845
|
-
\u{1F4A1} Your changes may be lost. Check git stash list.`,
|
|
20846
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20847
|
-
};
|
|
20848
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20849
|
-
setIsProcessing(false);
|
|
20850
|
-
clearInput();
|
|
20851
|
-
return true;
|
|
20852
|
-
} else {
|
|
20853
|
-
const popSuccessEntry = {
|
|
20854
|
-
type: "tool_result",
|
|
20855
|
-
content: "\u2705 Changes restored from stash",
|
|
20856
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20857
|
-
};
|
|
20858
|
-
setChatHistory((prev) => [...prev, popSuccessEntry]);
|
|
20859
|
-
}
|
|
20860
|
-
} else {
|
|
20861
|
-
const pullFailEntry = {
|
|
20862
|
-
type: "assistant",
|
|
20863
|
-
content: `\u274C **Pull failed**
|
|
20864
|
-
|
|
20865
|
-
${pullResult.error || pullResult.output}
|
|
20866
|
-
|
|
20867
|
-
\u{1F4A1} Check git status and resolve any conflicts`,
|
|
20868
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20869
|
-
};
|
|
20870
|
-
setChatHistory((prev) => [...prev, pullFailEntry]);
|
|
20871
|
-
setIsProcessing(false);
|
|
20872
|
-
clearInput();
|
|
20873
|
-
return true;
|
|
20874
|
-
}
|
|
20875
|
-
const addResult = await agent.executeBashCommand("git add .");
|
|
20876
|
-
if (!addResult.success) {
|
|
20877
|
-
const errorEntry = {
|
|
20878
|
-
type: "assistant",
|
|
20879
|
-
content: `\u274C **Failed to stage changes**
|
|
20880
|
-
|
|
20881
|
-
${addResult.error || "Unknown error"}`,
|
|
20882
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20883
|
-
};
|
|
20884
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20885
|
-
setIsProcessing(false);
|
|
20886
|
-
clearInput();
|
|
20887
|
-
return true;
|
|
20888
|
-
}
|
|
20889
|
-
const addEntry = {
|
|
20890
|
-
type: "tool_result",
|
|
20891
|
-
content: "\u2705 Changes staged successfully",
|
|
20892
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
20893
|
-
toolCall: {
|
|
20894
|
-
id: `git_add_${Date.now()}`,
|
|
20895
|
-
type: "function",
|
|
20896
|
-
function: {
|
|
20897
|
-
name: "bash",
|
|
20898
|
-
arguments: JSON.stringify({ command: "git add ." })
|
|
20899
|
-
}
|
|
20900
|
-
},
|
|
20901
|
-
toolResult: addResult
|
|
20902
|
-
};
|
|
20903
|
-
setChatHistory((prev) => [...prev, addEntry]);
|
|
20904
|
-
const diffResult = await agent.executeBashCommand("git diff --cached");
|
|
20905
|
-
const maxDiffLength = 5e4;
|
|
20906
|
-
const truncatedDiff = diffResult.output ? diffResult.output.length > maxDiffLength ? diffResult.output.substring(0, maxDiffLength) + "\n... (truncated due to length)" : diffResult.output : "No staged changes shown";
|
|
20907
|
-
const commitPrompt = `Generate a concise, professional git commit message for these changes:
|
|
20908
|
-
|
|
20909
|
-
Git Status:
|
|
20910
|
-
${statusResult.output}
|
|
20911
|
-
|
|
20912
|
-
Git Diff (staged changes):
|
|
20913
|
-
${truncatedDiff}
|
|
20914
|
-
|
|
20915
|
-
Follow conventional commit format (feat:, fix:, docs:, etc.) and keep it under 72 characters.
|
|
20916
|
-
Respond with ONLY the commit message, no additional text.`;
|
|
20917
|
-
let commitMessage = "";
|
|
20918
|
-
let streamingEntry = null;
|
|
20919
|
-
let accumulatedCommitContent = "";
|
|
20920
|
-
let lastCommitUpdateTime = Date.now();
|
|
20921
|
-
try {
|
|
20922
|
-
for await (const chunk of agent.processUserMessageStream(commitPrompt)) {
|
|
20923
|
-
if (chunk.type === "content" && chunk.content) {
|
|
20924
|
-
accumulatedCommitContent += chunk.content;
|
|
20925
|
-
const now = Date.now();
|
|
20926
|
-
if (now - lastCommitUpdateTime >= 150) {
|
|
20927
|
-
commitMessage += accumulatedCommitContent;
|
|
20928
|
-
if (!streamingEntry) {
|
|
20929
|
-
const newEntry = {
|
|
20930
|
-
type: "assistant",
|
|
20931
|
-
content: `\u{1F916} Generating commit message...
|
|
20932
|
-
|
|
20933
|
-
${commitMessage}`,
|
|
20934
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
20935
|
-
isStreaming: true
|
|
20936
|
-
};
|
|
20937
|
-
setChatHistory((prev) => [...prev, newEntry]);
|
|
20938
|
-
streamingEntry = newEntry;
|
|
20939
|
-
} else {
|
|
20940
|
-
setChatHistory(
|
|
20941
|
-
(prev) => prev.map(
|
|
20942
|
-
(entry, idx) => idx === prev.length - 1 && entry.isStreaming ? {
|
|
20943
|
-
...entry,
|
|
20944
|
-
content: `\u{1F916} Generating commit message...
|
|
20945
|
-
|
|
20946
|
-
${commitMessage}`
|
|
20947
|
-
} : entry
|
|
20948
|
-
)
|
|
20949
|
-
);
|
|
20950
|
-
}
|
|
20951
|
-
accumulatedCommitContent = "";
|
|
20952
|
-
lastCommitUpdateTime = now;
|
|
20953
|
-
}
|
|
20954
|
-
} else if (chunk.type === "done") {
|
|
20955
|
-
if (streamingEntry) {
|
|
20956
|
-
setChatHistory(
|
|
20957
|
-
(prev) => prev.map(
|
|
20958
|
-
(entry) => entry.isStreaming ? {
|
|
20959
|
-
...entry,
|
|
20960
|
-
content: `\u2705 Generated commit message: "${commitMessage.trim()}"`,
|
|
20961
|
-
isStreaming: false
|
|
20962
|
-
} : entry
|
|
20963
|
-
)
|
|
20964
|
-
);
|
|
20965
|
-
}
|
|
20966
|
-
break;
|
|
20967
|
-
}
|
|
20968
|
-
}
|
|
20969
|
-
} catch (error) {
|
|
20970
|
-
commitMessage = "feat: update files";
|
|
20971
|
-
const errorEntry = {
|
|
20972
|
-
type: "assistant",
|
|
20973
|
-
content: `\u26A0\uFE0F **AI commit message generation failed**: ${error.message}
|
|
20974
|
-
|
|
20975
|
-
Using fallback message: "${commitMessage}"`,
|
|
20976
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
20977
|
-
};
|
|
20978
|
-
setChatHistory((prev) => [...prev, errorEntry]);
|
|
20979
|
-
if (streamingEntry) {
|
|
20980
|
-
setChatHistory(
|
|
20981
|
-
(prev) => prev.map(
|
|
20982
|
-
(entry) => entry.isStreaming ? { ...entry, isStreaming: false } : entry
|
|
20983
|
-
)
|
|
20984
|
-
);
|
|
20985
|
-
}
|
|
20986
|
-
}
|
|
20987
|
-
const cleanCommitMessage = commitMessage.trim().replace(/^["']|["']$/g, "");
|
|
20988
|
-
const commitCommand = `git commit -m "${cleanCommitMessage}"`;
|
|
20989
|
-
const commitResult = await agent.executeBashCommand(commitCommand);
|
|
20990
|
-
const commitEntry = {
|
|
20547
|
+
const result = await agent.executeBashCommand("npm run smart-push");
|
|
20548
|
+
const resultEntry = {
|
|
20991
20549
|
type: "tool_result",
|
|
20992
|
-
content:
|
|
20550
|
+
content: result.success ? "\u{1F389} Smart Push Completed Successfully!" : `\u274C Smart Push Failed: ${result.error}`,
|
|
20993
20551
|
timestamp: /* @__PURE__ */ new Date(),
|
|
20994
20552
|
toolCall: {
|
|
20995
|
-
id: `
|
|
20553
|
+
id: `smart_push_${Date.now()}`,
|
|
20996
20554
|
type: "function",
|
|
20997
|
-
function: {
|
|
20998
|
-
name: "bash",
|
|
20999
|
-
arguments: JSON.stringify({ command: commitCommand })
|
|
21000
|
-
}
|
|
20555
|
+
function: { name: "bash", arguments: JSON.stringify({ command: "npm run smart-push" }) }
|
|
21001
20556
|
},
|
|
21002
|
-
toolResult:
|
|
20557
|
+
toolResult: result
|
|
21003
20558
|
};
|
|
21004
|
-
setChatHistory((prev) => [...prev,
|
|
21005
|
-
if (commitResult.success) {
|
|
21006
|
-
const pushResult = await agent.executeBashCommand("git push");
|
|
21007
|
-
if (pushResult.success) {
|
|
21008
|
-
const pushEntry = {
|
|
21009
|
-
type: "tool_result",
|
|
21010
|
-
content: `\u{1F680} **Push Successful**: ${pushResult.output?.split("\n")[0] || "Changes pushed to remote"}`,
|
|
21011
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
21012
|
-
toolCall: {
|
|
21013
|
-
id: `git_push_${Date.now()}`,
|
|
21014
|
-
type: "function",
|
|
21015
|
-
function: {
|
|
21016
|
-
name: "bash",
|
|
21017
|
-
arguments: JSON.stringify({ command: "git push" })
|
|
21018
|
-
}
|
|
21019
|
-
},
|
|
21020
|
-
toolResult: pushResult
|
|
21021
|
-
};
|
|
21022
|
-
setChatHistory((prev) => [...prev, pushEntry]);
|
|
21023
|
-
const verificationEntry = {
|
|
21024
|
-
type: "assistant",
|
|
21025
|
-
content: "\u{1F50D} **Running post-push verification...**",
|
|
21026
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21027
|
-
};
|
|
21028
|
-
setChatHistory((prev) => [...prev, verificationEntry]);
|
|
21029
|
-
const statusCheckResult = await agent.executeBashCommand("git status --porcelain");
|
|
21030
|
-
if (statusCheckResult.success && statusCheckResult.output?.trim() === "") {
|
|
21031
|
-
const statusOkEntry = {
|
|
21032
|
-
type: "tool_result",
|
|
21033
|
-
content: "\u2705 **Git Status**: Working directory clean",
|
|
21034
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21035
|
-
};
|
|
21036
|
-
setChatHistory((prev) => [...prev, statusOkEntry]);
|
|
21037
|
-
} else {
|
|
21038
|
-
const statusIssueEntry = {
|
|
21039
|
-
type: "assistant",
|
|
21040
|
-
content: `\u26A0\uFE0F **Git Status Issues Detected**:
|
|
21041
|
-
|
|
21042
|
-
${statusCheckResult.output || "Unknown status"}`,
|
|
21043
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21044
|
-
};
|
|
21045
|
-
setChatHistory((prev) => [...prev, statusIssueEntry]);
|
|
21046
|
-
}
|
|
21047
|
-
const waitEntry = {
|
|
21048
|
-
type: "assistant",
|
|
21049
|
-
content: "\u23F3 **Waiting for CI/NPM publishing...** (10 seconds)",
|
|
21050
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21051
|
-
};
|
|
21052
|
-
setChatHistory((prev) => [...prev, waitEntry]);
|
|
21053
|
-
await new Promise((resolve8) => setTimeout(resolve8, 1e4));
|
|
21054
|
-
const localPackageResult = await agent.executeBashCommand(`node -p "require('./package.json').name" 2>/dev/null || echo 'no-package'`);
|
|
21055
|
-
const localName = localPackageResult.success && localPackageResult.output?.trim() !== "no-package" ? localPackageResult.output?.trim() : null;
|
|
21056
|
-
if (localName) {
|
|
21057
|
-
const localVersionResult = await agent.executeBashCommand(`node -p "require('./package.json').version"`);
|
|
21058
|
-
const localVersion = localVersionResult.success ? localVersionResult.output?.trim() : "unknown";
|
|
21059
|
-
const npmCheckResult = await agent.executeBashCommand(`npm view ${localName} version 2>/dev/null || echo 'not-found'`);
|
|
21060
|
-
if (npmCheckResult.success && npmCheckResult.output?.trim() && npmCheckResult.output?.trim() !== "not-found") {
|
|
21061
|
-
const npmVersion = npmCheckResult.output.trim();
|
|
21062
|
-
if (npmVersion === localVersion) {
|
|
21063
|
-
const npmConfirmEntry = {
|
|
21064
|
-
type: "tool_result",
|
|
21065
|
-
content: `\u2705 **NPM Package Confirmed**: ${localName} v${npmVersion} published successfully`,
|
|
21066
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21067
|
-
};
|
|
21068
|
-
setChatHistory((prev) => [...prev, npmConfirmEntry]);
|
|
21069
|
-
} else {
|
|
21070
|
-
const npmPendingEntry = {
|
|
21071
|
-
type: "assistant",
|
|
21072
|
-
content: `\u23F3 **NPM Status**: Local ${localName} v${localVersion}, NPM v${npmVersion}. Publishing may still be in progress.`,
|
|
21073
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21074
|
-
};
|
|
21075
|
-
setChatHistory((prev) => [...prev, npmPendingEntry]);
|
|
21076
|
-
}
|
|
21077
|
-
} else {
|
|
21078
|
-
const npmSkipEntry = {
|
|
21079
|
-
type: "assistant",
|
|
21080
|
-
content: `\u2139\uFE0F **NPM Check Skipped**: Package ${localName} not found on NPM (may not be published yet)`,
|
|
21081
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21082
|
-
};
|
|
21083
|
-
setChatHistory((prev) => [...prev, npmSkipEntry]);
|
|
21084
|
-
}
|
|
21085
|
-
} else {
|
|
21086
|
-
const npmSkipEntry = {
|
|
21087
|
-
type: "assistant",
|
|
21088
|
-
content: `\u2139\uFE0F **NPM Check Skipped**: No package.json found or not an NPM package`,
|
|
21089
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21090
|
-
};
|
|
21091
|
-
setChatHistory((prev) => [...prev, npmSkipEntry]);
|
|
21092
|
-
}
|
|
21093
|
-
const finalSuccessEntry = {
|
|
21094
|
-
type: "assistant",
|
|
21095
|
-
content: "\u{1F389} **Smart Push Complete**: All verifications passed!",
|
|
21096
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21097
|
-
};
|
|
21098
|
-
setChatHistory((prev) => [...prev, finalSuccessEntry]);
|
|
21099
|
-
} else {
|
|
21100
|
-
const pushError = pushResult.error || pushResult.output || "";
|
|
21101
|
-
if (pushError.includes("protected branch") || pushError.includes("Changes must be made through a pull request") || pushError.includes("GH006")) {
|
|
21102
|
-
const branchProtectionEntry = {
|
|
21103
|
-
type: "assistant",
|
|
21104
|
-
content: "\u{1F6E1}\uFE0F **Branch Protection Detected**: Direct pushes to this branch are blocked.\n\n\u{1F504} **Creating PR workflow...**",
|
|
21105
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21106
|
-
};
|
|
21107
|
-
setChatHistory((prev) => [...prev, branchProtectionEntry]);
|
|
21108
|
-
const featureBranch = `feature/${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/[:-]/g, "").replace("T", "-")}-smart-push`;
|
|
21109
|
-
const createBranchResult = await agent.executeBashCommand(`git checkout -b ${featureBranch}`);
|
|
21110
|
-
if (createBranchResult.success) {
|
|
21111
|
-
const pushBranchResult = await agent.executeBashCommand(`git push -u origin ${featureBranch}`);
|
|
21112
|
-
if (pushBranchResult.success) {
|
|
21113
|
-
const branchSuccessEntry = {
|
|
21114
|
-
type: "tool_result",
|
|
21115
|
-
content: `\u2705 **Feature Branch Created**: \`${featureBranch}\`
|
|
21116
|
-
|
|
21117
|
-
\u{1F4CB} **Attempting to create Pull Request...**`,
|
|
21118
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21119
|
-
};
|
|
21120
|
-
setChatHistory((prev) => [...prev, branchSuccessEntry]);
|
|
21121
|
-
const prResult = await agent.executeBashCommand(`gh pr create --title "${cleanCommitMessage}" --body "Auto-generated PR from smart-push" --head ${featureBranch} --base ${currentBranch}`);
|
|
21122
|
-
if (prResult.success) {
|
|
21123
|
-
const prUrl = prResult.output?.match(/https:\/\/github\.com\/[^\s]+/)?.[0];
|
|
21124
|
-
const prSuccessEntry = {
|
|
21125
|
-
type: "tool_result",
|
|
21126
|
-
content: `\u2705 **Pull Request Created Successfully!**
|
|
21127
|
-
|
|
21128
|
-
\u{1F517} **PR URL**: ${prUrl || "Check GitHub for the link"}
|
|
21129
|
-
|
|
21130
|
-
\u{1F3AF} **Next Steps**:
|
|
21131
|
-
\u2022 Review the PR on GitHub
|
|
21132
|
-
\u2022 Wait for CI checks to pass
|
|
21133
|
-
\u2022 Request approval and merge`,
|
|
21134
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21135
|
-
};
|
|
21136
|
-
setChatHistory((prev) => [...prev, prSuccessEntry]);
|
|
21137
|
-
} else {
|
|
21138
|
-
const prManualEntry = {
|
|
21139
|
-
type: "assistant",
|
|
21140
|
-
content: `\u26A0\uFE0F **PR Creation Failed**: GitHub CLI may not be available.
|
|
21141
|
-
|
|
21142
|
-
\u{1F4A1} **Create PR Manually**:
|
|
21143
|
-
\u2022 Go to GitHub repository
|
|
21144
|
-
\u2022 Create PR from \`${featureBranch}\` \u2192 \`${currentBranch}\`
|
|
21145
|
-
\u2022 Title: \`${cleanCommitMessage}\``,
|
|
21146
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21147
|
-
};
|
|
21148
|
-
setChatHistory((prev) => [...prev, prManualEntry]);
|
|
21149
|
-
}
|
|
21150
|
-
} else {
|
|
21151
|
-
const pushFailEntry = {
|
|
21152
|
-
type: "tool_result",
|
|
21153
|
-
content: `\u274C **Failed to push feature branch**: ${pushBranchResult.error}`,
|
|
21154
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21155
|
-
};
|
|
21156
|
-
setChatHistory((prev) => [...prev, pushFailEntry]);
|
|
21157
|
-
}
|
|
21158
|
-
} else {
|
|
21159
|
-
const branchFailEntry = {
|
|
21160
|
-
type: "tool_result",
|
|
21161
|
-
content: `\u274C **Failed to create feature branch**: ${createBranchResult.error}`,
|
|
21162
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21163
|
-
};
|
|
21164
|
-
setChatHistory((prev) => [...prev, branchFailEntry]);
|
|
21165
|
-
}
|
|
21166
|
-
} else {
|
|
21167
|
-
const pushFailEntry = {
|
|
21168
|
-
type: "tool_result",
|
|
21169
|
-
content: `\u274C **Push Failed**: ${pushResult.error || "Unknown error"}
|
|
21170
|
-
|
|
21171
|
-
Try running \`git push\` manually.`,
|
|
21172
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
21173
|
-
toolCall: {
|
|
21174
|
-
id: `git_push_${Date.now()}`,
|
|
21175
|
-
type: "function",
|
|
21176
|
-
function: {
|
|
21177
|
-
name: "bash",
|
|
21178
|
-
arguments: JSON.stringify({ command: "git push" })
|
|
21179
|
-
}
|
|
21180
|
-
},
|
|
21181
|
-
toolResult: pushResult
|
|
21182
|
-
};
|
|
21183
|
-
setChatHistory((prev) => [...prev, pushFailEntry]);
|
|
21184
|
-
}
|
|
21185
|
-
}
|
|
21186
|
-
}
|
|
20559
|
+
setChatHistory((prev) => [...prev, resultEntry]);
|
|
21187
20560
|
} catch (error) {
|
|
21188
20561
|
const errorEntry = {
|
|
21189
20562
|
type: "assistant",
|
|
21190
|
-
content: `\u274C
|
|
21191
|
-
|
|
21192
|
-
${error instanceof Error ? error.message : String(error)}`,
|
|
20563
|
+
content: `\u274C Smart Push Failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
21193
20564
|
timestamp: /* @__PURE__ */ new Date()
|
|
21194
20565
|
};
|
|
21195
20566
|
setChatHistory((prev) => [...prev, errorEntry]);
|
|
@@ -21693,125 +21064,50 @@ var init_use_context_info = __esm({
|
|
|
21693
21064
|
"src/hooks/use-context-info.ts"() {
|
|
21694
21065
|
}
|
|
21695
21066
|
});
|
|
21696
|
-
function
|
|
21067
|
+
function useCLAUDEmd(setChatHistory) {
|
|
21697
21068
|
useEffect(() => {
|
|
21698
|
-
|
|
21699
|
-
|
|
21700
|
-
|
|
21701
|
-
|
|
21702
|
-
|
|
21703
|
-
|
|
21704
|
-
|
|
21705
|
-
|
|
21706
|
-
|
|
21707
|
-
|
|
21708
|
-
|
|
21709
|
-
|
|
21710
|
-
|
|
21711
|
-
|
|
21712
|
-
|
|
21713
|
-
|
|
21714
|
-
|
|
21715
|
-
|
|
21716
|
-
|
|
21717
|
-
|
|
21718
|
-
|
|
21719
|
-
|
|
21720
|
-
const showSummaryMessage = config2?.showSummaryMessage !== false;
|
|
21721
|
-
const showFileContents = config2?.showFileContents === true;
|
|
21722
|
-
if (!isEnabled) {
|
|
21723
|
-
return;
|
|
21724
|
-
}
|
|
21725
|
-
if (showLoadingMessage) {
|
|
21726
|
-
initialMessages.push({
|
|
21727
|
-
type: "assistant",
|
|
21728
|
-
content: "\u{1F4DA} Reading core documentation into memory...",
|
|
21729
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21730
|
-
});
|
|
21731
|
-
}
|
|
21732
|
-
console.log("\u{1F50D} Auto-reading .agent documentation...");
|
|
21733
|
-
const folders = config2?.folders || [
|
|
21734
|
-
{
|
|
21735
|
-
name: "system",
|
|
21736
|
-
priority: 1,
|
|
21737
|
-
files: [
|
|
21738
|
-
{ name: "architecture.md", title: "System Architecture", icon: "\u{1F4CB}", required: true },
|
|
21739
|
-
{ name: "critical-state.md", title: "Critical State", icon: "\u{1F3D7}\uFE0F", required: false },
|
|
21740
|
-
{ name: "installation.md", title: "Installation", icon: "\u{1F3D7}\uFE0F", required: false },
|
|
21741
|
-
{ name: "api-schema.md", title: "API Schema", icon: "\u{1F3D7}\uFE0F", required: false },
|
|
21742
|
-
{ name: "auto-read-system.md", title: "Auto-Read System", icon: "\u{1F3D7}\uFE0F", required: false }
|
|
21743
|
-
]
|
|
21744
|
-
},
|
|
21745
|
-
{
|
|
21746
|
-
name: "sop",
|
|
21747
|
-
priority: 2,
|
|
21748
|
-
files: [
|
|
21749
|
-
{ name: "git-workflow.md", title: "Git Workflow SOP", icon: "\u{1F527}", required: true },
|
|
21750
|
-
{ name: "release-management.md", title: "Release Management SOP", icon: "\u{1F4D6}", required: false },
|
|
21751
|
-
{ name: "automation-protection.md", title: "Automation Protection SOP", icon: "\u{1F4D6}", required: false },
|
|
21752
|
-
{ name: "npm-publishing-troubleshooting.md", title: "NPM Publishing Troubleshooting", icon: "\u{1F4D6}", required: false }
|
|
21753
|
-
]
|
|
21754
|
-
}
|
|
21755
|
-
];
|
|
21756
|
-
if (config2?.customFolders) {
|
|
21757
|
-
folders.push(...config2.customFolders);
|
|
21758
|
-
}
|
|
21759
|
-
folders.sort((a, b) => (a.priority || 999) - (b.priority || 999));
|
|
21760
|
-
for (const folder of folders) {
|
|
21761
|
-
const folderPath = path8__default.join(".agent", folder.name);
|
|
21762
|
-
if (!fs2__default.existsSync(folderPath)) {
|
|
21763
|
-
continue;
|
|
21069
|
+
const filesToLoad = [
|
|
21070
|
+
{ path: "GROK.md", label: "GROK.md", fallback: "CLAUDE.md" },
|
|
21071
|
+
{ path: "docs-index.md", label: "Documentation Index" }
|
|
21072
|
+
];
|
|
21073
|
+
const loadedDocs = [];
|
|
21074
|
+
let totalChars = 0;
|
|
21075
|
+
for (const file of filesToLoad) {
|
|
21076
|
+
let filePath = file.path;
|
|
21077
|
+
let exists = fs2__default.existsSync(filePath);
|
|
21078
|
+
if (!exists && file.fallback) {
|
|
21079
|
+
filePath = file.fallback;
|
|
21080
|
+
exists = fs2__default.existsSync(filePath);
|
|
21081
|
+
}
|
|
21082
|
+
if (exists) {
|
|
21083
|
+
try {
|
|
21084
|
+
const content = fs2__default.readFileSync(filePath, "utf8");
|
|
21085
|
+
const charCount = content.length;
|
|
21086
|
+
totalChars += charCount;
|
|
21087
|
+
loadedDocs.push(file.label);
|
|
21088
|
+
console.log(`\u{1F4C4} Loaded: ${file.label} (${charCount} chars)`);
|
|
21089
|
+
} catch (error) {
|
|
21090
|
+
console.warn(`\u26A0\uFE0F Failed to load ${file.label}:`, error);
|
|
21764
21091
|
}
|
|
21765
|
-
|
|
21766
|
-
|
|
21767
|
-
|
|
21768
|
-
continue;
|
|
21769
|
-
} else {
|
|
21770
|
-
filePaths = [file.name];
|
|
21771
|
-
}
|
|
21772
|
-
for (const fileName of filePaths) {
|
|
21773
|
-
const filePath = path8__default.join(folderPath, fileName);
|
|
21774
|
-
if (!fs2__default.existsSync(filePath)) {
|
|
21775
|
-
if (file.required) ;
|
|
21776
|
-
continue;
|
|
21777
|
-
}
|
|
21778
|
-
try {
|
|
21779
|
-
const content = fs2__default.readFileSync(filePath, "utf8");
|
|
21780
|
-
const displayTitle = file.title || fileName.replace(".md", "").replace("-", " ").toUpperCase();
|
|
21781
|
-
const icon = file.icon || "\u{1F4C4}";
|
|
21782
|
-
console.log(`\u{1F4C4} Loaded: ${folder.name}/${fileName} (${content.length} chars)`);
|
|
21783
|
-
if (showFileContents) {
|
|
21784
|
-
initialMessages.push({
|
|
21785
|
-
type: "assistant",
|
|
21786
|
-
content: `${icon} **${displayTitle} (from .agent/${folder.name}/${fileName})**
|
|
21787
|
-
|
|
21788
|
-
${content}`,
|
|
21789
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
21790
|
-
});
|
|
21791
|
-
}
|
|
21792
|
-
docsRead++;
|
|
21793
|
-
} catch (_error) {
|
|
21794
|
-
console.log(`\u26A0\uFE0F Failed to read: ${folder.name}/${fileName}`);
|
|
21795
|
-
}
|
|
21796
|
-
}
|
|
21092
|
+
} else {
|
|
21093
|
+
if (process.env.NODE_ENV === "development") {
|
|
21094
|
+
console.log(`\u2139\uFE0F ${file.label} not found - will be created in Sprint 1`);
|
|
21797
21095
|
}
|
|
21798
21096
|
}
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
|
|
21802
|
-
|
|
21803
|
-
|
|
21804
|
-
|
|
21805
|
-
|
|
21806
|
-
}
|
|
21807
|
-
|
|
21808
|
-
setChatHistory(initialMessages);
|
|
21809
|
-
}
|
|
21097
|
+
}
|
|
21098
|
+
if (loadedDocs.length > 0) {
|
|
21099
|
+
const tokenEstimate = Math.round(totalChars / 4);
|
|
21100
|
+
console.log(`\u2705 Context initialized: ${loadedDocs.join(", ")}`);
|
|
21101
|
+
console.log(`\u{1F4CA} Estimated tokens loaded: ~${tokenEstimate} (target: ~700)`);
|
|
21102
|
+
console.log("\u{1F4DA} Additional docs available on-demand via Read tool");
|
|
21103
|
+
} else {
|
|
21104
|
+
console.log("\u{1F4DD} No GROK.md found yet - proceeding without initial context");
|
|
21105
|
+
console.log("\u{1F4A1} Docs will be loaded on-demand via Read tool");
|
|
21810
21106
|
}
|
|
21811
21107
|
}, [setChatHistory]);
|
|
21812
21108
|
}
|
|
21813
|
-
var
|
|
21814
|
-
"src/hooks/use-
|
|
21109
|
+
var init_use_claude_md = __esm({
|
|
21110
|
+
"src/hooks/use-claude-md.ts"() {
|
|
21815
21111
|
}
|
|
21816
21112
|
});
|
|
21817
21113
|
function useStreaming(agent, initialMessage, setChatHistory, streamingState) {
|
|
@@ -24110,9 +23406,7 @@ __export(chat_interface_exports, {
|
|
|
24110
23406
|
function ChatInterfaceWithAgent({
|
|
24111
23407
|
agent,
|
|
24112
23408
|
initialMessage,
|
|
24113
|
-
quiet = false
|
|
24114
|
-
contextPack: _contextPack,
|
|
24115
|
-
contextStatus
|
|
23409
|
+
quiet = false
|
|
24116
23410
|
}) {
|
|
24117
23411
|
const [chatHistory, setChatHistory] = useState([]);
|
|
24118
23412
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
@@ -24122,18 +23416,7 @@ function ChatInterfaceWithAgent({
|
|
|
24122
23416
|
const [confirmationOptions, setConfirmationOptions] = useState(null);
|
|
24123
23417
|
const [showContextTooltip, setShowContextTooltip] = useState(false);
|
|
24124
23418
|
const processingStartTime = useRef(0);
|
|
24125
|
-
|
|
24126
|
-
useEffect(() => {
|
|
24127
|
-
const initialHistory = [];
|
|
24128
|
-
if (contextStatus) {
|
|
24129
|
-
initialHistory.push({
|
|
24130
|
-
type: "assistant",
|
|
24131
|
-
content: `\u{1F527} ${contextStatus}`,
|
|
24132
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
24133
|
-
});
|
|
24134
|
-
}
|
|
24135
|
-
setChatHistory(initialHistory);
|
|
24136
|
-
}, [contextStatus]);
|
|
23419
|
+
useCLAUDEmd(setChatHistory);
|
|
24137
23420
|
useSessionLogging(chatHistory);
|
|
24138
23421
|
const { contextInfo } = useContextInfo(agent);
|
|
24139
23422
|
const handleGlobalShortcuts = (str, key) => {
|
|
@@ -24230,9 +23513,7 @@ function ChatInterfaceWithAgent({
|
|
|
24230
23513
|
function ChatInterface({
|
|
24231
23514
|
agent,
|
|
24232
23515
|
initialMessage,
|
|
24233
|
-
quiet = false
|
|
24234
|
-
contextPack,
|
|
24235
|
-
contextStatus
|
|
23516
|
+
quiet = false
|
|
24236
23517
|
}) {
|
|
24237
23518
|
const [currentAgent, setCurrentAgent] = useState(
|
|
24238
23519
|
agent || null
|
|
@@ -24248,9 +23529,7 @@ function ChatInterface({
|
|
|
24248
23529
|
{
|
|
24249
23530
|
agent: currentAgent,
|
|
24250
23531
|
initialMessage,
|
|
24251
|
-
quiet
|
|
24252
|
-
contextPack,
|
|
24253
|
-
contextStatus
|
|
23532
|
+
quiet
|
|
24254
23533
|
}
|
|
24255
23534
|
);
|
|
24256
23535
|
}
|
|
@@ -24260,7 +23539,7 @@ var init_chat_interface = __esm({
|
|
|
24260
23539
|
init_confirmation_service();
|
|
24261
23540
|
init_api_key_input();
|
|
24262
23541
|
init_use_context_info();
|
|
24263
|
-
|
|
23542
|
+
init_use_claude_md();
|
|
24264
23543
|
init_use_streaming();
|
|
24265
23544
|
init_use_confirmations();
|
|
24266
23545
|
init_use_introduction();
|
|
@@ -24529,7 +23808,7 @@ var require_package = __commonJS({
|
|
|
24529
23808
|
module.exports = {
|
|
24530
23809
|
type: "module",
|
|
24531
23810
|
name: "@xagent/one-shot",
|
|
24532
|
-
version: "1.1.
|
|
23811
|
+
version: "1.1.102",
|
|
24533
23812
|
description: "An open-source AI agent that brings advanced AI capabilities directly into your terminal with automatic documentation updates.",
|
|
24534
23813
|
main: "dist/index.js",
|
|
24535
23814
|
module: "dist/index.js",
|
|
@@ -24714,7 +23993,6 @@ try {
|
|
|
24714
23993
|
const { createToggleConfirmationsCommand: createToggleConfirmationsCommand2 } = await Promise.resolve().then(() => (init_toggle_confirmations(), toggle_confirmations_exports));
|
|
24715
23994
|
const pkg = await Promise.resolve().then(() => __toESM(require_package(), 1));
|
|
24716
23995
|
const { checkForUpdates: checkForUpdates2 } = await Promise.resolve().then(() => (init_version_checker(), version_checker_exports));
|
|
24717
|
-
const { loadContext: loadContext2, formatContextStatus: formatContextStatus2 } = await Promise.resolve().then(() => (init_context_loader(), context_loader_exports));
|
|
24718
23996
|
log("\u2705 All modules imported successfully");
|
|
24719
23997
|
process.on("SIGTERM", () => {
|
|
24720
23998
|
log("\u{1F44B} Gracefully shutting down...");
|
|
@@ -24788,15 +24066,7 @@ try {
|
|
|
24788
24066
|
console.error("\u274C Error: X CLI requires an interactive terminal.");
|
|
24789
24067
|
process.exit(1);
|
|
24790
24068
|
}
|
|
24791
|
-
|
|
24792
|
-
let statusMessage;
|
|
24793
|
-
try {
|
|
24794
|
-
contextPack = loadContext2();
|
|
24795
|
-
statusMessage = formatContextStatus2(contextPack);
|
|
24796
|
-
log("\u{1F4DA} Context loaded successfully");
|
|
24797
|
-
} catch (error) {
|
|
24798
|
-
log(`\u26A0\uFE0F Context loading failed: ${error}`);
|
|
24799
|
-
}
|
|
24069
|
+
log("\u{1F4DA} Documentation available via GROK.md + docs-index.md");
|
|
24800
24070
|
log("\u{1F680} Launching interactive CLI...");
|
|
24801
24071
|
if (!options.quiet) {
|
|
24802
24072
|
printWelcomeBanner2(options.quiet);
|
|
@@ -24805,8 +24075,7 @@ try {
|
|
|
24805
24075
|
const app = render(React4.createElement(ChatInterface2, {
|
|
24806
24076
|
agent,
|
|
24807
24077
|
initialMessage,
|
|
24808
|
-
quiet: options.quiet
|
|
24809
|
-
contextStatus: statusMessage
|
|
24078
|
+
quiet: options.quiet
|
|
24810
24079
|
}));
|
|
24811
24080
|
const cleanup = () => {
|
|
24812
24081
|
log("\u{1F44B} Shutting down...");
|