codebyplan 1.10.0 → 1.10.2

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/cli.js CHANGED
@@ -14,7 +14,7 @@ var VERSION, PACKAGE_NAME;
14
14
  var init_version = __esm({
15
15
  "src/lib/version.ts"() {
16
16
  "use strict";
17
- VERSION = "1.10.0";
17
+ VERSION = "1.10.2";
18
18
  PACKAGE_NAME = "codebyplan";
19
19
  }
20
20
  });
@@ -516,8 +516,8 @@ async function resolveAndCacheWorktreeId(repoId, projectPath, options) {
516
516
  });
517
517
  if (match) worktreeId = match.id;
518
518
  } catch (err) {
519
- console.error(
520
- `Worktree lookup failed: ${err instanceof Error ? err.message : String(err)}`
519
+ console.warn(
520
+ `Worktree self-heal skipped (non-fatal): worktree lookup failed: ${err instanceof Error ? err.message : String(err)}. Continuing.`
521
521
  );
522
522
  return void 0;
523
523
  }
@@ -585,8 +585,8 @@ async function resolveWorktreeByBranch({
585
585
  }
586
586
  return match?.id ?? null;
587
587
  } catch (err) {
588
- console.error(
589
- `Branch worktree resolve failed: ${err instanceof Error ? err.message : String(err)}`
588
+ console.warn(
589
+ `Worktree self-heal skipped (non-fatal): branch worktree resolve failed: ${err instanceof Error ? err.message : String(err)}. Continuing.`
590
590
  );
591
591
  return null;
592
592
  }
@@ -604,8 +604,8 @@ async function resolveWorktreeId({
604
604
  );
605
605
  return res.worktree_id ?? null;
606
606
  } catch (err) {
607
- console.error(
608
- `Tuple worktree resolve failed: ${err instanceof Error ? err.message : String(err)}`
607
+ console.warn(
608
+ `Worktree self-heal skipped (non-fatal): ${err instanceof Error ? err.message : String(err)}. Continuing \u2014 run \`codebyplan config\` again later to retry.`
609
609
  );
610
610
  return null;
611
611
  }
@@ -4153,7 +4153,27 @@ async function syncConfigToFile(repoId, projectPath, dryRun) {
4153
4153
  ` Warning: failed to cache worktree_id (self-heal skipped): ${msg}`
4154
4154
  );
4155
4155
  }
4156
- const repoRes = await apiGet(`/repos/${repoId}`);
4156
+ let repoRes;
4157
+ try {
4158
+ repoRes = await apiGet(`/repos/${repoId}`);
4159
+ } catch (err) {
4160
+ let message;
4161
+ if (err instanceof ApiError) {
4162
+ if (err.status === 401) {
4163
+ message = "Session expired. Run `codebyplan login` and try again.";
4164
+ } else if (err.status === 403 || err.status === 404) {
4165
+ message = "Repo not found or not accessible to your account. Confirm the repo_id in .codebyplan/repo.json and that you are logged in as the right user.";
4166
+ } else if (err.status >= 500) {
4167
+ message = `CodeByPlan server error (status ${err.status}). Please try again shortly.`;
4168
+ } else {
4169
+ message = `Unexpected API error (status ${err.status}). Please try again.`;
4170
+ }
4171
+ } else {
4172
+ message = "Failed to reach the CodeByPlan API. Check your network connection and try again.";
4173
+ }
4174
+ process.stderr.write(message + "\n");
4175
+ process.exit(1);
4176
+ }
4157
4177
  const repo = repoRes.data;
4158
4178
  let portAllocations = [];
4159
4179
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebyplan",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "description": "CLI for CodeByPlan — AI-powered development planning and tracking",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,12 +10,12 @@ effort: high
10
10
 
11
11
  Codifies the long-lived-branch-integration auto-memory rule (`[[feedback_long-lived-branch-integration]]`): when working on a feat branch that has diverged from main, merge main INTO the feat branch (not the reverse), resolve conflicts with the user, run a scoped QA pass, then return control to the caller — never rebase, never force-push, never push automatically.
12
12
 
13
- Triggered by `/cbp-task-start` (Step 3.6, optional stale-check), `/cbp-task-complete` (Step 4.5, mandatory pre-complete), and `/cbp-checkpoint-end` (Step 0, mandatory pre-shipment). User can also invoke manually at any time.
13
+ Triggered by `/cbp-task-start` (Step 3.6, optional stale-check), `/cbp-task-complete` (Step 5.5, mandatory pre-push — runs after the task commit on a clean tree), and `/cbp-checkpoint-end` (Step 0, mandatory pre-shipment). User can also invoke manually at any time.
14
14
 
15
15
  ## When to Use
16
16
 
17
17
  - **Auto-trigger (optional)**: `/cbp-task-start` Step 3.6 detects the feat branch is >10 commits behind `origin/{BASE}` OR the last fetch is >24h old.
18
- - **Auto-trigger (mandatory)**: `/cbp-task-complete` Step 4.5 — always run before marking a task complete to ensure the feat branch includes the latest main work.
18
+ - **Auto-trigger (mandatory)**: `/cbp-task-complete` Step 5.5 — mandatory pre-push, after the task commit; runs on a clean tree to ensure the feat branch includes the latest main work before the single trailing push.
19
19
  - **Auto-trigger (mandatory)**: `/cbp-checkpoint-end` Step 0 — always run before shipment to ensure no main drift reaches production.
20
20
  - **Manual invocation**: user runs `/cbp-merge-main` directly when they know main has advanced and want to pull it in immediately.
21
21
 
@@ -219,7 +219,7 @@ Return control to the caller. **This skill NEVER pushes** — the caller decides
219
219
 
220
220
  - **Triggered by**:
221
221
  - `/cbp-task-start` Step 3.6 (optional stale-check: >10 commits behind OR >24h fetch age)
222
- - `/cbp-task-complete` Step 4.5 (mandatory pre-complete)
222
+ - `/cbp-task-complete` Step 5.5 (mandatory pre-push, after task commit)
223
223
  - `/cbp-checkpoint-end` Step 0 (mandatory pre-shipment)
224
224
  - User-invocable manually
225
225
  - **Reads**: `.codebyplan/git.json`, MCP `get_checkpoints`, MCP `get_tasks`, git state
@@ -102,26 +102,34 @@ Load `task.qa` and `task.files_changed`:
102
102
 
103
103
  Collect all files_changed from task. Deduplicate (latest action wins).
104
104
 
105
- ### Step 4.5: Merge Production Branch Before Commit (mandatory)
105
+ ### Step 5: Git Commit (no push)
106
106
 
107
- Before committing task work, ensure the feat branch is current with the latest production (main) work. This prevents shipping a stale PR and surfaces conflicts at task-complete time rather than at PR review.
107
+ Commit the task work FIRST, so the merge in Step 5.5 runs against a clean tree. `/cbp-merge-main` must never run before the task commit.
108
108
 
109
- 1. Trigger `/cbp-merge-main`.
110
- 2. If the skill exits with failure (offline, unresolved conflicts, user-aborted): surface the failure and STOP — do NOT proceed to Step 5 (commit). The user resolves and re-invokes `/cbp-task-complete`.
111
- 3. If the skill exits with QA warnings the user chose to commit-as-is: continue to Step 5; surface a soft warning in the Step 9 output (`⚠ Merged with QA failures pending fix in follow-up`).
112
- 4. On clean success: continue to Step 5.
109
+ **Zero-file guard**: if `aggregated_files` is empty (investigative or DB-only tasks), skip the commit. Record "No git commit: zero files changed" in the Step 9 summary, then continue to Step 5.5 (the branch may still need a main sync).
110
+
111
+ **Already-committed guard**: if the aggregated files are already committed (working tree clean for them — e.g. a re-invoke after a Step 5.5 merge failure), skip the commit and continue to Step 5.5; the prior run's task commit still stands.
112
+
113
+ Otherwise: invoke `/cbp-git-commit` to stage approved files and create the commit. Claude does NOT git add directly. Do NOT push here — the push in Step 5.7 carries both this commit and the merge commit.
113
114
 
114
- ### Step 5: Git Commit and Push
115
+ ### Step 5.5: Merge Production Branch (mandatory)
116
+
117
+ Now that task work is committed, ensure the feat branch is current with the latest production (main) work. Running the merge AFTER the commit means `/cbp-merge-main` resolves conflicts against committed work on a clean tree — no dirty-tree interleave, no Step-0 dirty-tree prompt for the task files. This still prevents shipping a stale PR and surfaces conflicts at task-complete time rather than at PR review.
118
+
119
+ 1. Trigger `/cbp-merge-main`.
120
+ 2. If the skill exits with failure (offline, unresolved conflicts, user-aborted): surface the failure and STOP — do NOT proceed to Step 5.7 (push) or Step 7 (complete). The task commit from Step 5 persists; the user resolves and re-invokes `/cbp-task-complete`, which re-runs the merge on the now-clean tree.
121
+ 3. If the skill exits with QA warnings the user chose to commit-as-is: continue to Step 5.7; surface a soft warning in the Step 9 output (`⚠ Merged with QA failures pending fix in follow-up`).
122
+ 4. On clean success: continue to Step 5.7.
115
123
 
116
- **Zero-file guard**: if `aggregated_files` is empty (investigative or DB-only tasks), skip commit and push. Record "No git commit: zero files changed" in the Step 9 summary.
124
+ ### Step 5.7: Push
117
125
 
118
- Otherwise: invoke `/cbp-git-commit` to stage approved files and create the commit. Claude does NOT git add directly. After commit:
126
+ Push once, carrying BOTH the task commit (Step 5) and the merge commit (Step 5.5):
119
127
 
120
128
  ```bash
121
129
  git push origin $(git branch --show-current)
122
130
  ```
123
131
 
124
- If push fails, investigate and fix per migration-infrastructure rule — never skip.
132
+ Skip the push only when nothing was committed in Step 5 AND `/cbp-merge-main` reported already-up-to-date (nothing to push). If push fails, investigate and fix per migration-infrastructure rule — never skip.
125
133
 
126
134
  ### Step 6: Update Task Files
127
135