@co0ontty/wand 1.43.8 → 1.44.0
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/build-info.json +3 -3
- package/dist/git-quick-commit.d.ts +9 -0
- package/dist/git-quick-commit.js +191 -26
- package/dist/server-session-routes.js +3 -0
- package/dist/types.d.ts +2 -0
- package/dist/web-ui/content/scripts.js +33 -33
- package/dist/web-ui/content/styles.css +1 -1
- package/dist/web-ui/embedded-assets.d.ts +1 -1
- package/dist/web-ui/embedded-assets.js +3 -3
- package/package.json +1 -1
package/dist/build-info.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"commit": "
|
|
3
|
-
"builtAt": "2026-05-
|
|
4
|
-
"version": "1.
|
|
2
|
+
"commit": "82bf2e6b3f7f01bbee5ee3213967f3316020601b",
|
|
3
|
+
"builtAt": "2026-05-31T13:20:33.303Z",
|
|
4
|
+
"version": "1.44.0",
|
|
5
5
|
"channel": "stable"
|
|
6
6
|
}
|
|
@@ -10,6 +10,11 @@ interface QuickCommitOptions {
|
|
|
10
10
|
/** When `tag` is empty, ask Claude to generate one based on the diff + commit message. */
|
|
11
11
|
autoTag?: boolean;
|
|
12
12
|
push?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* 是否把 commit / tag / push 递归进入各 submodule 内部。默认 false:
|
|
15
|
+
* 只处理父仓库自身(含已变化的 submodule 指针),不碰 submodule 内部 dirty。
|
|
16
|
+
*/
|
|
17
|
+
submodule?: boolean;
|
|
13
18
|
}
|
|
14
19
|
export declare class QuickCommitError extends Error {
|
|
15
20
|
readonly code: QuickCommitErrorCode;
|
|
@@ -35,6 +40,10 @@ interface PushOptions {
|
|
|
35
40
|
cwd: string;
|
|
36
41
|
pushCommits?: boolean;
|
|
37
42
|
pushTags?: boolean;
|
|
43
|
+
/** 是否同时把各 submodule 的 HEAD(+ 同名 tag)分别推送到各自远端分支。 */
|
|
44
|
+
submodule?: boolean;
|
|
45
|
+
/** `submodule` + `pushTags` 时,要连带推送到 submodule 的同名 tag。 */
|
|
46
|
+
tagName?: string;
|
|
38
47
|
}
|
|
39
48
|
export declare function runPush(opts: PushOptions): Promise<PushResult>;
|
|
40
49
|
export declare function runQuickCommit(opts: QuickCommitOptions): Promise<QuickCommitResult>;
|
package/dist/git-quick-commit.js
CHANGED
|
@@ -241,6 +241,8 @@ export function getGitStatus(cwd) {
|
|
|
241
241
|
behind,
|
|
242
242
|
lastCommit,
|
|
243
243
|
latestTag,
|
|
244
|
+
// 基于全量 allEntries 判定(不受 files 的 200 条 slice 影响),供前端决定是否渲染 Submodule 球。
|
|
245
|
+
hasSubmodule: allEntries.some((e) => e.isSubmodule),
|
|
244
246
|
};
|
|
245
247
|
}
|
|
246
248
|
export class QuickCommitError extends Error {
|
|
@@ -445,6 +447,7 @@ ${diff}`;
|
|
|
445
447
|
*/
|
|
446
448
|
function doPush(opts) {
|
|
447
449
|
const { cwd, pushCommits, pushTags } = opts;
|
|
450
|
+
const recurseFlag = `--recurse-submodules=${opts.recurseSubmodules ?? "check"}`;
|
|
448
451
|
let pushedCommits = false;
|
|
449
452
|
let pushedTags = false;
|
|
450
453
|
let hasUpstream = false;
|
|
@@ -459,10 +462,10 @@ function doPush(opts) {
|
|
|
459
462
|
try {
|
|
460
463
|
if (pushCommits) {
|
|
461
464
|
if (hasUpstream) {
|
|
462
|
-
runGit(["push",
|
|
465
|
+
runGit(["push", recurseFlag], cwd, GIT_PUSH_TIMEOUT_MS);
|
|
463
466
|
}
|
|
464
467
|
else {
|
|
465
|
-
runGit(["push", "-u",
|
|
468
|
+
runGit(["push", "-u", recurseFlag, pushRemote, "HEAD"], cwd, GIT_PUSH_TIMEOUT_MS);
|
|
466
469
|
}
|
|
467
470
|
pushedCommits = true;
|
|
468
471
|
}
|
|
@@ -538,19 +541,63 @@ export async function runTagHead(opts) {
|
|
|
538
541
|
};
|
|
539
542
|
}
|
|
540
543
|
export async function runPush(opts) {
|
|
541
|
-
const { cwd, pushCommits = true, pushTags = false } = opts;
|
|
544
|
+
const { cwd, pushCommits = true, pushTags = false, submodule = false, tagName } = opts;
|
|
542
545
|
assertGitWorkTree(cwd);
|
|
543
546
|
if (!pushCommits && !pushTags) {
|
|
544
547
|
throw new QuickCommitError("没有要推送的内容。", "NOTHING_TO_PUSH");
|
|
545
548
|
}
|
|
546
|
-
|
|
549
|
+
// 纳入 submodule:逐个把声明的 submodule 的 HEAD 推到各自远端分支(已是最新则 git 自身 no-op)。
|
|
550
|
+
// 这覆盖「先 commit(含 submodule)后补 Push & Close」的场景——此时 submodule 已 clean、
|
|
551
|
+
// status 看不到,但本地可能仍领先远端。父仓库随后用 recurse=no 推送。
|
|
552
|
+
let subPushErrors = [];
|
|
553
|
+
if (submodule) {
|
|
554
|
+
const { base, infos } = collectSubmodulesForPush(cwd);
|
|
555
|
+
if (infos.length > 0) {
|
|
556
|
+
const subPush = pushSubmodules(base, infos, { pushTags: !!(pushTags && tagName), tagName });
|
|
557
|
+
subPushErrors = subPush.errors;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
const outcome = doPush({ cwd, pushCommits, pushTags, recurseSubmodules: submodule ? "no" : "check" });
|
|
547
561
|
return {
|
|
548
|
-
ok: !outcome.error,
|
|
562
|
+
ok: !outcome.error && subPushErrors.length === 0,
|
|
549
563
|
pushedCommits: outcome.pushedCommits,
|
|
550
564
|
pushedTags: outcome.pushedTags,
|
|
551
|
-
error: outcome.error,
|
|
565
|
+
error: outcome.error || (subPushErrors.length ? subPushErrors.join(";") : undefined),
|
|
552
566
|
};
|
|
553
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* 解析一个 submodule 当前 HEAD 应推到哪个远端分支。submodule 经 `git submodule update`
|
|
570
|
+
* 后通常处于 detached HEAD,不能直接 `git push`,必须显式 `HEAD:<branch>`,否则父仓库
|
|
571
|
+
* `--recurse-submodules=on-demand` 会以「HEAD does not match the named branch」整体失败。
|
|
572
|
+
* 优先取远端默认分支(`<remote>/HEAD` 指向)→ 当前命名分支 → 回退 main/master。
|
|
573
|
+
*/
|
|
574
|
+
function resolveSubmodulePushBranch(subCwd, remote) {
|
|
575
|
+
const prefix = `${remote}/`;
|
|
576
|
+
try {
|
|
577
|
+
const ref = runGit(["symbolic-ref", "--short", `refs/remotes/${remote}/HEAD`], subCwd);
|
|
578
|
+
const name = (ref.startsWith(prefix) ? ref.slice(prefix.length) : ref).trim();
|
|
579
|
+
if (name)
|
|
580
|
+
return name;
|
|
581
|
+
}
|
|
582
|
+
catch {
|
|
583
|
+
// ignore — fall through
|
|
584
|
+
}
|
|
585
|
+
try {
|
|
586
|
+
const cur = runGit(["branch", "--show-current"], subCwd);
|
|
587
|
+
if (cur)
|
|
588
|
+
return cur;
|
|
589
|
+
}
|
|
590
|
+
catch {
|
|
591
|
+
// ignore
|
|
592
|
+
}
|
|
593
|
+
try {
|
|
594
|
+
runGit(["rev-parse", "--verify", `refs/remotes/${remote}/main`], subCwd);
|
|
595
|
+
return "main";
|
|
596
|
+
}
|
|
597
|
+
catch {
|
|
598
|
+
return "master";
|
|
599
|
+
}
|
|
600
|
+
}
|
|
554
601
|
/**
|
|
555
602
|
* 在 commit 父仓库之前,先在每个内部 dirty / untracked 的 submodule 里
|
|
556
603
|
* 执行一次 `git add -A` + `git commit -m <msg>`,让父仓库的 add -A
|
|
@@ -615,12 +662,109 @@ function commitDirtySubmodules(parentCwd, message) {
|
|
|
615
662
|
hash = runGit(["rev-parse", "--short", "HEAD"], subCwd);
|
|
616
663
|
}
|
|
617
664
|
catch { /* ignore */ }
|
|
618
|
-
|
|
665
|
+
const remote = resolvePushRemote(subCwd);
|
|
666
|
+
const branch = resolveSubmodulePushBranch(subCwd, remote);
|
|
667
|
+
commits.push({ path: entry.path, hash, remote, branch });
|
|
619
668
|
}
|
|
620
669
|
return { commits, errors };
|
|
621
670
|
}
|
|
671
|
+
/** 对刚提交的 submodule 打上与父仓库同名的 tag。已存在同名 tag 则记为非致命跳过。 */
|
|
672
|
+
function tagSubmodules(parentCwd, subInfos, tagName) {
|
|
673
|
+
const tagged = [];
|
|
674
|
+
const errors = [];
|
|
675
|
+
for (const info of subInfos) {
|
|
676
|
+
const subCwd = `${parentCwd}/${info.path}`;
|
|
677
|
+
try {
|
|
678
|
+
runGit(["rev-parse", "--verify", `refs/tags/${tagName}`], subCwd);
|
|
679
|
+
errors.push(`submodule ${info.path} 已存在 tag ${tagName},跳过`);
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
catch {
|
|
683
|
+
// 不存在 → 继续打 tag
|
|
684
|
+
}
|
|
685
|
+
try {
|
|
686
|
+
runGit(["tag", tagName], subCwd);
|
|
687
|
+
tagged.push(info.path);
|
|
688
|
+
}
|
|
689
|
+
catch (error) {
|
|
690
|
+
errors.push(`submodule ${info.path} 打 tag 失败:${getGitErrorMessage(error)}`);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
return { tagged, errors };
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* 对每个 submodule 单独把当前 HEAD 推送到其远端分支(`HEAD:refs/heads/<branch>`),
|
|
697
|
+
* 解决 detached HEAD 无法直接 push 的问题;`pushTags` 时连带把同名 tag 推上去。
|
|
698
|
+
* 单个 submodule 失败收集为非致命错误。
|
|
699
|
+
*/
|
|
700
|
+
function pushSubmodules(parentCwd, subInfos, opts) {
|
|
701
|
+
const pushed = [];
|
|
702
|
+
const errors = [];
|
|
703
|
+
for (const info of subInfos) {
|
|
704
|
+
const subCwd = `${parentCwd}/${info.path}`;
|
|
705
|
+
if (!existsSync(subCwd)) {
|
|
706
|
+
errors.push(`submodule ${info.path} 路径不存在`);
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
try {
|
|
710
|
+
runGit(["push", info.remote, `HEAD:refs/heads/${info.branch}`], subCwd, GIT_PUSH_TIMEOUT_MS);
|
|
711
|
+
}
|
|
712
|
+
catch (error) {
|
|
713
|
+
errors.push(`submodule ${info.path} 推送失败:${getGitErrorMessage(error)}`);
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
if (opts.pushTags && opts.tagName) {
|
|
717
|
+
try {
|
|
718
|
+
runGit(["push", info.remote, `refs/tags/${opts.tagName}`], subCwd, GIT_PUSH_TIMEOUT_MS);
|
|
719
|
+
}
|
|
720
|
+
catch (error) {
|
|
721
|
+
errors.push(`submodule ${info.path} 推送 tag 失败:${getGitErrorMessage(error)}`);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
pushed.push(info.path);
|
|
725
|
+
}
|
|
726
|
+
return { pushed, errors };
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* 枚举仓库声明的全部 submodule(读 repo 根的 .gitmodules),为「单独 push」准备
|
|
730
|
+
* remote + 目标分支。用于结果面板的 Push & Close:此时 submodule 多已 clean,
|
|
731
|
+
* status 里看不到,但本地 HEAD 可能仍领先远端,需要逐个尝试推送(up-to-date 则 no-op)。
|
|
732
|
+
*/
|
|
733
|
+
function collectSubmodulesForPush(cwd) {
|
|
734
|
+
let base;
|
|
735
|
+
try {
|
|
736
|
+
base = runGit(["rev-parse", "--show-toplevel"], cwd);
|
|
737
|
+
}
|
|
738
|
+
catch {
|
|
739
|
+
base = cwd;
|
|
740
|
+
}
|
|
741
|
+
let raw;
|
|
742
|
+
try {
|
|
743
|
+
raw = runGitAllowEmpty(["config", "-f", `${base}/.gitmodules`, "--get-regexp", "\\.path$"], base);
|
|
744
|
+
}
|
|
745
|
+
catch {
|
|
746
|
+
return { base, infos: [] };
|
|
747
|
+
}
|
|
748
|
+
const infos = [];
|
|
749
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
750
|
+
const trimmed = line.trim();
|
|
751
|
+
if (!trimmed)
|
|
752
|
+
continue;
|
|
753
|
+
// 行格式:submodule.<name>.path <relpath>
|
|
754
|
+
const rel = trimmed.split(/\s+/).slice(1).join(" ").trim();
|
|
755
|
+
if (!rel)
|
|
756
|
+
continue;
|
|
757
|
+
const subCwd = `${base}/${rel}`;
|
|
758
|
+
if (!existsSync(subCwd))
|
|
759
|
+
continue;
|
|
760
|
+
const remote = resolvePushRemote(subCwd);
|
|
761
|
+
const branch = resolveSubmodulePushBranch(subCwd, remote);
|
|
762
|
+
infos.push({ path: rel, hash: "", remote, branch });
|
|
763
|
+
}
|
|
764
|
+
return { base, infos };
|
|
765
|
+
}
|
|
622
766
|
export async function runQuickCommit(opts) {
|
|
623
|
-
const { cwd, language, autoMessage, customMessage, tag, autoTag, push } = opts;
|
|
767
|
+
const { cwd, language, autoMessage, customMessage, tag, autoTag, push, submodule } = opts;
|
|
624
768
|
assertGitWorkTree(cwd);
|
|
625
769
|
// 先 add 一次让我们能在 collectStagedDiff 看到完整改动(包含 submodule 指针),
|
|
626
770
|
// AI 生成 message 时也基于这个 staged diff。
|
|
@@ -646,7 +790,11 @@ export async function runQuickCommit(opts) {
|
|
|
646
790
|
submoduleHasDirty = parsePorcelainV2(porcelain).some((e) => e.isSubmodule && (e.submoduleState?.hasTrackedChanges || e.submoduleState?.hasUntracked));
|
|
647
791
|
}
|
|
648
792
|
catch { /* keep submoduleHasDirty=false */ }
|
|
649
|
-
|
|
793
|
+
// 默认不纳入 submodule:只有显式 opts.submodule 时,submodule 内部 dirty 才计入「有改动」。
|
|
794
|
+
if (!parentHasStaged && !(submodule && submoduleHasDirty)) {
|
|
795
|
+
if (submoduleHasDirty && !submodule) {
|
|
796
|
+
throw new QuickCommitError("父仓库没有改动;检测到 submodule 内部有改动,拖入 Submodule 球可一起提交。", "NOTHING_TO_COMMIT");
|
|
797
|
+
}
|
|
650
798
|
throw new QuickCommitError("没有任何改动可以提交。", "NOTHING_TO_COMMIT");
|
|
651
799
|
}
|
|
652
800
|
let message;
|
|
@@ -659,22 +807,25 @@ export async function runQuickCommit(opts) {
|
|
|
659
807
|
throw new QuickCommitError("commit message 不能为空。", "EMPTY_MESSAGE");
|
|
660
808
|
}
|
|
661
809
|
}
|
|
662
|
-
//
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
810
|
+
// 仅当用户显式纳入 submodule 时,才进入各 submodule 内部提交其 dirty 改动;
|
|
811
|
+
// 父仓库随后再 add 一次,picks up 新的 submodule 指针。
|
|
812
|
+
let submoduleOutcome = { commits: [], errors: [] };
|
|
813
|
+
if (submodule) {
|
|
814
|
+
submoduleOutcome = commitDirtySubmodules(cwd, message);
|
|
815
|
+
if (submoduleOutcome.commits.length > 0) {
|
|
816
|
+
try {
|
|
817
|
+
runGit(["add", "-A"], cwd, 5000);
|
|
818
|
+
}
|
|
819
|
+
catch (error) {
|
|
820
|
+
throw new QuickCommitError(`父仓库 add submodule 指针失败:${getGitErrorMessage(error)}`, "GIT_ADD_FAILED");
|
|
821
|
+
}
|
|
822
|
+
// 重新评估父仓库是否有 staged 内容:submodule 指针变了这里应为真。
|
|
823
|
+
try {
|
|
824
|
+
stagedFiles = runGitAllowEmpty(["diff", "--cached", "--name-only"], cwd).trim();
|
|
825
|
+
parentHasStaged = stagedFiles.length > 0;
|
|
826
|
+
}
|
|
827
|
+
catch { /* keep stale value */ }
|
|
676
828
|
}
|
|
677
|
-
catch { /* keep stale value */ }
|
|
678
829
|
}
|
|
679
830
|
if (!parentHasStaged) {
|
|
680
831
|
// submodule 都提交了但父仓库还是没有 staged —— 通常意味着 .gitmodules 没动
|
|
@@ -710,18 +861,32 @@ export async function runQuickCommit(opts) {
|
|
|
710
861
|
catch (error) {
|
|
711
862
|
throw new QuickCommitError(`git tag 失败:${getGitErrorMessage(error)}`, "GIT_TAG_FAILED");
|
|
712
863
|
}
|
|
864
|
+
// 纳入 submodule 时给刚提交的 submodule 打同名 tag(非致命,失败不阻断父仓库流程)。
|
|
865
|
+
if (submodule && submoduleOutcome.commits.length > 0) {
|
|
866
|
+
tagSubmodules(cwd, submoduleOutcome.commits, tagName);
|
|
867
|
+
}
|
|
713
868
|
}
|
|
714
869
|
let pushed = false;
|
|
715
870
|
let pushError;
|
|
716
871
|
if (push) {
|
|
872
|
+
// 纳入 submodule:先把各 submodule 的 HEAD(+ 同名 tag)分别推到各自远端分支,
|
|
873
|
+
// 解决 detached HEAD 无法被父仓库 on-demand 递归推送的问题;父仓库随后用
|
|
874
|
+
// recurse=no 单独推(submodule 已就绪)。否则父仓库用 recurse=check 做安全校验。
|
|
875
|
+
const includeSub = !!submodule && submoduleOutcome.commits.length > 0;
|
|
876
|
+
let subPushErrors = [];
|
|
877
|
+
if (includeSub) {
|
|
878
|
+
const subPush = pushSubmodules(cwd, submoduleOutcome.commits, { pushTags: !!tagName, tagName });
|
|
879
|
+
subPushErrors = subPush.errors;
|
|
880
|
+
}
|
|
717
881
|
const outcome = doPush({
|
|
718
882
|
cwd,
|
|
719
883
|
pushCommits: true,
|
|
720
884
|
// Push only the freshly-created tag — avoids surprising users by pushing stale local tags.
|
|
721
885
|
pushTags: tagName ? [tagName] : false,
|
|
886
|
+
recurseSubmodules: includeSub ? "no" : "check",
|
|
722
887
|
});
|
|
723
|
-
pushed = outcome.pushedCommits && (tagName ? outcome.pushedTags : true);
|
|
724
|
-
pushError = outcome.error;
|
|
888
|
+
pushed = outcome.pushedCommits && (tagName ? outcome.pushedTags : true) && subPushErrors.length === 0;
|
|
889
|
+
pushError = outcome.error || (subPushErrors.length ? subPushErrors.join(";") : undefined);
|
|
725
890
|
}
|
|
726
891
|
return {
|
|
727
892
|
ok: true,
|
|
@@ -426,6 +426,7 @@ export function registerSessionRoutes(app, processes, structured, storage, defau
|
|
|
426
426
|
tag: typeof body.tag === "string" ? body.tag : undefined,
|
|
427
427
|
autoTag: !!body.autoTag,
|
|
428
428
|
push: !!body.push,
|
|
429
|
+
submodule: !!body.submodule,
|
|
429
430
|
});
|
|
430
431
|
res.json(result);
|
|
431
432
|
}
|
|
@@ -506,6 +507,8 @@ export function registerSessionRoutes(app, processes, structured, storage, defau
|
|
|
506
507
|
cwd: snapshot.cwd,
|
|
507
508
|
pushCommits: body.pushCommits !== false,
|
|
508
509
|
pushTags: !!body.pushTags,
|
|
510
|
+
submodule: !!body.submodule,
|
|
511
|
+
tagName: typeof body.tag === "string" ? body.tag : undefined,
|
|
509
512
|
});
|
|
510
513
|
res.json(result);
|
|
511
514
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -198,6 +198,8 @@ export interface GitStatusResult {
|
|
|
198
198
|
};
|
|
199
199
|
/** Most recent tag reachable from HEAD (`git describe --tags --abbrev=0`), if any. */
|
|
200
200
|
latestTag?: string;
|
|
201
|
+
/** True 当仓库声明了 submodule(任一改动条目为 submodule)。前端据此决定是否渲染 Submodule 球。 */
|
|
202
|
+
hasSubmodule?: boolean;
|
|
201
203
|
error?: string;
|
|
202
204
|
}
|
|
203
205
|
export interface QuickCommitResult {
|