thepopebot 1.2.76-beta.7 → 1.2.76-beta.8
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/lib/ai/index.js
CHANGED
|
@@ -182,10 +182,10 @@ async function* chatStream(threadId, message, attachments = [], options = {}) {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
try {
|
|
185
|
-
await ensureWorkspaceRepo({ workspaceDir: repoDir, repo, branch, featureBranch });
|
|
185
|
+
const setupOutput = await ensureWorkspaceRepo({ workspaceDir: repoDir, repo, branch, featureBranch });
|
|
186
186
|
ensureSkills(repoDir, isCodeMode ? 'code' : 'agent');
|
|
187
187
|
if (needsSetup) {
|
|
188
|
-
const result = `Workspace ready on ${featureBranch || branch}`;
|
|
188
|
+
const result = setupOutput || `Workspace ready on ${featureBranch || branch}`;
|
|
189
189
|
yield { type: 'tool-result', toolCallId: setupToolCallId, result };
|
|
190
190
|
persistMessage(threadId, 'assistant', JSON.stringify({
|
|
191
191
|
type: 'tool-invocation',
|
|
@@ -32,20 +32,24 @@ export async function ensureWorkspaceRepo({ workspaceDir, repo, branch, featureB
|
|
|
32
32
|
if (ghToken) env.GH_TOKEN = ghToken;
|
|
33
33
|
|
|
34
34
|
const execOpts = { cwd: workspaceDir, env };
|
|
35
|
+
const log = [];
|
|
35
36
|
|
|
36
37
|
// 1. Create workspace directory
|
|
37
38
|
mkdirSync(workspaceDir, { recursive: true });
|
|
38
39
|
|
|
39
40
|
// 2. Configure git to use GH_TOKEN for GitHub HTTPS URLs (mirrors setup-git.sh)
|
|
40
41
|
if (ghToken) {
|
|
41
|
-
await run('gh', ['auth', 'setup-git'], execOpts);
|
|
42
|
+
const out = await run('gh', ['auth', 'setup-git'], execOpts);
|
|
43
|
+
if (out) log.push(out);
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
// 3. Clone if not already a git repo
|
|
45
47
|
const hasGit = existsSync(path.join(workspaceDir, '.git'));
|
|
46
48
|
if (!hasGit) {
|
|
47
49
|
if (!repo) throw new Error('ensureWorkspaceRepo: repo is required for initial clone');
|
|
48
|
-
await run('git', ['clone', '--branch', branch || 'main', `https://github.com/${repo}`, '.'], execOpts);
|
|
50
|
+
const out = await run('git', ['clone', '--branch', branch || 'main', `https://github.com/${repo}`, '.'], execOpts);
|
|
51
|
+
log.push(`Cloned ${repo} (branch: ${branch || 'main'})`);
|
|
52
|
+
if (out) log.push(out);
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
// 3. Git identity (only if not already configured)
|
|
@@ -61,6 +65,7 @@ export async function ensureWorkspaceRepo({ workspaceDir, repo, branch, featureB
|
|
|
61
65
|
const email = user.email || `${user.id}+${user.login}@users.noreply.github.com`;
|
|
62
66
|
await run('git', ['config', 'user.name', name], execOpts);
|
|
63
67
|
await run('git', ['config', 'user.email', email], execOpts);
|
|
68
|
+
log.push(`Git identity: ${name} <${email}>`);
|
|
64
69
|
} catch (err) {
|
|
65
70
|
console.error('[workspace-setup] Failed to set git identity:', err.message);
|
|
66
71
|
}
|
|
@@ -68,7 +73,7 @@ export async function ensureWorkspaceRepo({ workspaceDir, repo, branch, featureB
|
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
// 4. Feature branch checkout
|
|
71
|
-
if (!featureBranch) return;
|
|
76
|
+
if (!featureBranch) return log.join('\n');
|
|
72
77
|
|
|
73
78
|
// Already on the right branch locally?
|
|
74
79
|
try {
|
|
@@ -77,8 +82,11 @@ export async function ensureWorkspaceRepo({ workspaceDir, repo, branch, featureB
|
|
|
77
82
|
const current = await run('git', ['rev-parse', '--abbrev-ref', 'HEAD'], execOpts);
|
|
78
83
|
if (current !== featureBranch) {
|
|
79
84
|
await run('git', ['checkout', featureBranch], execOpts);
|
|
85
|
+
log.push(`Checked out ${featureBranch}`);
|
|
86
|
+
} else {
|
|
87
|
+
log.push(`Already on ${featureBranch}`);
|
|
80
88
|
}
|
|
81
|
-
return;
|
|
89
|
+
return log.join('\n');
|
|
82
90
|
} catch {
|
|
83
91
|
// Branch doesn't exist locally — check remote
|
|
84
92
|
}
|
|
@@ -88,15 +96,20 @@ export async function ensureWorkspaceRepo({ workspaceDir, repo, branch, featureB
|
|
|
88
96
|
if (remoteCheck) {
|
|
89
97
|
// Remote branch exists — checkout tracking it
|
|
90
98
|
await run('git', ['checkout', '-B', featureBranch, `origin/${featureBranch}`], execOpts);
|
|
99
|
+
log.push(`Checked out ${featureBranch} (tracking origin)`);
|
|
91
100
|
} else {
|
|
92
101
|
// Create new branch and push
|
|
93
102
|
await run('git', ['checkout', '-b', featureBranch], execOpts);
|
|
94
|
-
await run('git', ['push', '-u', 'origin', featureBranch], execOpts);
|
|
103
|
+
const pushOut = await run('git', ['push', '-u', 'origin', featureBranch], execOpts);
|
|
104
|
+
log.push(`Created and pushed ${featureBranch}`);
|
|
105
|
+
if (pushOut) log.push(pushOut);
|
|
95
106
|
}
|
|
96
107
|
} catch (err) {
|
|
97
108
|
console.error('[workspace-setup] Feature branch error:', err.message);
|
|
98
109
|
throw err;
|
|
99
110
|
}
|
|
111
|
+
|
|
112
|
+
return log.join('\n');
|
|
100
113
|
}
|
|
101
114
|
|
|
102
115
|
/**
|
|
@@ -200,7 +200,7 @@ function WorkspaceBar({
|
|
|
200
200
|
repoName && /* @__PURE__ */ jsx("span", { className: "shrink-0 cursor-default hidden md:inline", title: repo, children: repoName }),
|
|
201
201
|
branch && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
202
202
|
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-muted-foreground/30 hidden md:inline", children: "/" }),
|
|
203
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
203
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 max-w-[120px] md:max-w-[160px]", children: /* @__PURE__ */ jsx(
|
|
204
204
|
Combobox,
|
|
205
205
|
{
|
|
206
206
|
options: branches.map((b) => ({ value: b.name, label: b.name })),
|
|
@@ -225,7 +225,7 @@ export function WorkspaceBar({
|
|
|
225
225
|
{branch && (
|
|
226
226
|
<>
|
|
227
227
|
<span className="shrink-0 text-muted-foreground/30 hidden md:inline">/</span>
|
|
228
|
-
<div className="
|
|
228
|
+
<div className="min-w-0 max-w-[120px] md:max-w-[160px]">
|
|
229
229
|
<Combobox
|
|
230
230
|
options={branches.map((b) => ({ value: b.name, label: b.name }))}
|
|
231
231
|
value={branch}
|