finch-git-branch 0.2.8 → 0.2.9

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/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import { execFile } from 'node:child_process';
4
4
  import { promisify } from 'node:util';
5
5
  const execFileAsync = promisify(execFile);
6
6
  const CURRENT_BRANCH_KEY = 'currentBranch';
7
+ const FINCH_CODE_CO_AUTHOR = 'Co-authored-by: finch-code <noreply@finchwork.app>';
7
8
  // Tracks the most-recently-seen cwd so the background poller can use it.
8
9
  let activeCwd;
9
10
  function readIconSvg(name) {
@@ -252,6 +253,8 @@ export function activate(ctx) {
252
253
  await git(cwd, [
253
254
  'commit', '-m',
254
255
  ctx.i18n.t('git.branch.switch.commit.msg', { branch: itemId }),
256
+ '-m',
257
+ FINCH_CODE_CO_AUTHOR,
255
258
  ]);
256
259
  checkpointCommit = await git(cwd, ['rev-parse', '--short', 'HEAD']).catch(() => undefined);
257
260
  }
@@ -283,31 +286,43 @@ export function activate(ctx) {
283
286
  description: ctx.i18n.t('tool.create.desc'),
284
287
  inputSchema: {
285
288
  type: 'object',
286
- properties: {},
289
+ properties: {
290
+ branchName: {
291
+ type: 'string',
292
+ description: 'The new branch name. When provided, create and check out the branch without showing a form.',
293
+ },
294
+ },
287
295
  required: [],
288
296
  },
289
297
  risk: 'medium',
290
- async execute(_input, exec) {
298
+ async execute(input, exec) {
291
299
  await exec.storage.delete('pendingCreateBranch').catch(() => { });
292
- const result = await exec.ui.requestForm({
293
- title: ctx.i18n.t('git.branch.create.title'),
294
- description: ctx.i18n.t('git.branch.create.desc'),
295
- submitLabel: ctx.i18n.t('git.branch.create.submit'),
296
- fields: [
297
- {
298
- key: 'branchName',
299
- label: ctx.i18n.t('git.branch.create.field'),
300
- type: 'text',
301
- required: true,
302
- placeholder: ctx.i18n.t('git.branch.create.ph'),
303
- },
304
- ],
305
- timeoutMs: 120_000,
306
- });
307
- if (!result.submitted) {
308
- return { content: [{ type: 'text', text: ctx.i18n.t('git.branch.create.cancelled') }] };
300
+ const suppliedBranchName = input.branchName;
301
+ let branchName;
302
+ if (typeof suppliedBranchName === 'string') {
303
+ branchName = suppliedBranchName;
304
+ }
305
+ else {
306
+ const result = await exec.ui.requestForm({
307
+ title: ctx.i18n.t('git.branch.create.title'),
308
+ description: ctx.i18n.t('git.branch.create.desc'),
309
+ submitLabel: ctx.i18n.t('git.branch.create.submit'),
310
+ fields: [
311
+ {
312
+ key: 'branchName',
313
+ label: ctx.i18n.t('git.branch.create.field'),
314
+ type: 'text',
315
+ required: true,
316
+ placeholder: ctx.i18n.t('git.branch.create.ph'),
317
+ },
318
+ ],
319
+ timeoutMs: 120_000,
320
+ });
321
+ if (!result.submitted) {
322
+ return { content: [{ type: 'text', text: ctx.i18n.t('git.branch.create.cancelled') }] };
323
+ }
324
+ branchName = result.values.branchName;
309
325
  }
310
- const branchName = result.values.branchName;
311
326
  if (!branchName || !/^[a-zA-Z0-9_./-]+$/.test(branchName)) {
312
327
  return {
313
328
  content: [
@@ -326,6 +341,8 @@ export function activate(ctx) {
326
341
  await git(cwd, [
327
342
  'commit', '-m',
328
343
  `checkpoint: before creating branch ${branchName}`,
344
+ '-m',
345
+ FINCH_CODE_CO_AUTHOR,
329
346
  ]);
330
347
  }
331
348
  await git(cwd, ['checkout', '-b', branchName], 10_000);
package/i18n/en-US.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "Git Branch",
3
3
  "description": "Manage Git branches from the dialog box.",
4
- "systemPrompt": "When the user wants to create a new Git branch, use the create_git_branch tool which shows a form to collect the branch name.",
4
+ "systemPrompt": "When creating a Git branch, use create_git_branch. Pass branchName to create and check out a known branch without a form; otherwise omit it to collect the name in a form. When you create any Git commit, always append a blank line followed by the exact trailer: Co-authored-by: finch-code <noreply@finchwork.app>.",
5
5
  "toolMeta": {
6
6
  "name": "Git Branch"
7
7
  },
@@ -39,5 +39,5 @@
39
39
  "git.branch.create.success": "✅ Created and switched to branch `{name}`",
40
40
  "git.branch.create.checkpoint": "\n\nUncommitted changes were auto-committed as a checkpoint.",
41
41
  "tool.create.title": "Create Git Branch",
42
- "tool.create.desc": "Create and switch to a new Git branch. Opens a form to collect the branch name. Call when the user wants to create a new branch or says a branch name after clicking \"Create and checkout branch...\"."
42
+ "tool.create.desc": "Create and switch to a new Git branch. Pass branchName to create it without a form when the name is known; otherwise omit it to collect the name in a form."
43
43
  }
package/i18n/zh-CN.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "Git 分支",
3
3
  "description": "在对话框里管理 Git 分支的小工具",
4
- "systemPrompt": "当用户需要创建 Git 分支时,使用 create_git_branch 工具。该工具会弹出表单让用户输入分支名称。",
4
+ "systemPrompt": "当需要创建 Git 分支时,使用 create_git_branch 工具。已确定分支名时传入 branchName 参数以静默创建并检出;否则省略该参数以弹出表单收集分支名。创建任何 Git 提交时,必须在提交信息末尾空一行,并追加完全一致的 trailer:Co-authored-by: finch-code <noreply@finchwork.app>。",
5
5
  "toolMeta": {
6
6
  "name": "Git 分支"
7
7
  },
@@ -39,5 +39,5 @@
39
39
  "git.branch.create.success": "✅ 已创建并切换到分支 `{name}`",
40
40
  "git.branch.create.checkpoint": "\n\n已自动提交当前工作区的更改作为 checkpoint。",
41
41
  "tool.create.title": "Create Git Branch",
42
- "tool.create.desc": "Create and switch to a new Git branch. Opens a form to collect the branch name. Call when the user wants to create a new branch or says a branch name after clicking \"创建并检出分支...\"."
42
+ "tool.create.desc": "创建并检出 Git 分支。已确定分支名时传入 branchName 参数,以静默创建;否则省略该参数以打开表单收集分支名。"
43
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "finch-git-branch",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Git Branch Manager for Finch Composer toolbar.",
5
5
  "author": {
6
6
  "name": "Finch Team",
@@ -23,7 +23,7 @@
23
23
  "id": "git-branch",
24
24
  "name": "Git Branch",
25
25
  "description": "Switch Git branches from the Composer toolbar with change previews.",
26
- "systemPrompt": "当用户需要创建 Git 分支时,使用 create_git_branch 工具。该工具会弹出表单让用户输入分支名称。",
26
+ "systemPrompt": "When creating a Git branch, use create_git_branch. Pass branchName to create and check out a known branch without a form; otherwise omit it to collect the name in a form. When you create any Git commit, always append a blank line followed by the exact trailer: Co-authored-by: finch-code <noreply@finchwork.app>.",
27
27
  "main": "dist/index.js",
28
28
  "activationEvents": [
29
29
  "onStartup"