@aipper/aiws 0.0.3 → 0.0.4

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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@aipper/aiws",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "AI Workspace CLI (init/update/validate) for Claude Code / OpenCode / Codex / iFlow.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "aiws": "./bin/aiws.js"
8
8
  },
9
9
  "dependencies": {
10
- "@aipper/aiws-spec": "0.0.3"
10
+ "@aipper/aiws-spec": "0.0.4"
11
11
  },
12
12
  "files": [
13
13
  "bin",
@@ -123,6 +123,20 @@ async function checkWorktreePrereqs(gitRoot) {
123
123
  return { ok: true };
124
124
  }
125
125
 
126
+ /**
127
+ * Best-effort detection for "unknown option" errors related to --recurse-submodules.
128
+ *
129
+ * We only fall back when the option itself appears in output, to avoid silently
130
+ * bypassing submodule safety checks when switching fails for real reasons
131
+ * (e.g. dirty submodules).
132
+ *
133
+ * @param {{ stdout: string, stderr: string }} res
134
+ */
135
+ function outputMentionsRecurseSubmodules(res) {
136
+ const out = `${res.stderr || ""}\n${res.stdout || ""}`;
137
+ return out.includes("recurse-submodules");
138
+ }
139
+
126
140
  /**
127
141
  * @param {string} changeDir
128
142
  * @param {string} baseBranch
@@ -867,15 +881,31 @@ export async function changeStartCommand(options) {
867
881
  }
868
882
  } else {
869
883
  if (hasBranch) {
870
- const sw = await runCommand("git", ["switch", branch], { cwd: gitRoot });
884
+ let sw = await runCommand("git", ["switch", ...(hasGitmodules ? ["--recurse-submodules"] : []), branch], { cwd: gitRoot });
885
+ if (sw.code !== 0 && hasGitmodules && outputMentionsRecurseSubmodules(sw)) {
886
+ console.error("warn: git switch does not support --recurse-submodules; switching without it (submodules may be out of sync).");
887
+ sw = await runCommand("git", ["switch", branch], { cwd: gitRoot });
888
+ }
871
889
  if (sw.code !== 0) {
872
- const co = await runCommand("git", ["checkout", branch], { cwd: gitRoot });
890
+ let co = await runCommand("git", ["checkout", ...(hasGitmodules ? ["--recurse-submodules"] : []), branch], { cwd: gitRoot });
891
+ if (co.code !== 0 && hasGitmodules && outputMentionsRecurseSubmodules(co)) {
892
+ console.error("warn: git checkout does not support --recurse-submodules; checking out without it (submodules may be out of sync).");
893
+ co = await runCommand("git", ["checkout", branch], { cwd: gitRoot });
894
+ }
873
895
  if (co.code !== 0) throw new UserError("Failed to switch branch.", { details: co.stderr || co.stdout });
874
896
  }
875
897
  } else {
876
- const sw = await runCommand("git", ["switch", "-c", branch], { cwd: gitRoot });
898
+ let sw = await runCommand("git", ["switch", ...(hasGitmodules ? ["--recurse-submodules"] : []), "-c", branch], { cwd: gitRoot });
899
+ if (sw.code !== 0 && hasGitmodules && outputMentionsRecurseSubmodules(sw)) {
900
+ console.error("warn: git switch does not support --recurse-submodules; switching without it (submodules may be out of sync).");
901
+ sw = await runCommand("git", ["switch", "-c", branch], { cwd: gitRoot });
902
+ }
877
903
  if (sw.code !== 0) {
878
- const co = await runCommand("git", ["checkout", "-b", branch], { cwd: gitRoot });
904
+ let co = await runCommand("git", ["checkout", ...(hasGitmodules ? ["--recurse-submodules"] : []), "-b", branch], { cwd: gitRoot });
905
+ if (co.code !== 0 && hasGitmodules && outputMentionsRecurseSubmodules(co)) {
906
+ console.error("warn: git checkout does not support --recurse-submodules; checking out without it (submodules may be out of sync).");
907
+ co = await runCommand("git", ["checkout", "-b", branch], { cwd: gitRoot });
908
+ }
879
909
  if (co.code !== 0) throw new UserError("Failed to create branch.", { details: co.stderr || co.stdout });
880
910
  }
881
911
  }