codebyplan 1.9.0 → 1.10.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/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.9.0";
17
+ VERSION = "1.10.0";
18
18
  PACKAGE_NAME = "codebyplan";
19
19
  }
20
20
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebyplan",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "CLI for CodeByPlan — AI-powered development planning and tracking",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,6 +23,7 @@ Examples:
23
23
  - Must run from the **main repo** (the non-worktree checkout)
24
24
  - Working tree should be clean
25
25
  - Branch should not already exist as a worktree
26
+ - New branches are always rooted at `origin/{production}` (read from `.codebyplan/git.json`), independent of the main repo's currently checked-out branch
26
27
 
27
28
  ## Instructions
28
29
 
@@ -87,18 +88,23 @@ If it exists, stop and inform the user.
87
88
 
88
89
  ### Step 4: Create Branch If Needed
89
90
 
91
+ Resolve the production branch: read `.codebyplan/git.json` and take `branch_config.production` (fall back to `main` if the file or field is absent). Call this `$PRODUCTION`.
92
+
90
93
  Check if branch exists:
91
94
 
92
95
  ```bash
93
96
  git branch --list "$BRANCH_NAME"
94
97
  ```
95
98
 
96
- If branch does NOT exist, create it from current HEAD:
99
+ If branch does NOT exist, create it from the freshest production tip — **not** from the main repo's ambient HEAD (which is often a stale home branch such as `codebyplan-main`):
97
100
 
98
101
  ```bash
99
- git branch "$BRANCH_NAME"
102
+ git fetch origin "$PRODUCTION" 2>/dev/null || true
103
+ git branch "$BRANCH_NAME" "origin/$PRODUCTION"
100
104
  ```
101
105
 
106
+ This guarantees every worktree starts at `origin/{production}` regardless of which branch the main repo currently has checked out.
107
+
102
108
  ### Step 5: Create Worktree
103
109
 
104
110
  ```bash
@@ -204,6 +210,7 @@ No need to mark as `skip-worktree` — the committed files are merge-safe per CH
204
210
  **Branch**: [branch-name]
205
211
  **Path**: [worktree-path]
206
212
  **Main repo**: [main-repo-path]
213
+ **Base**: origin/[production] ([sha])
207
214
  **CodeByPlan**: Registered (worktree ID: [id])
208
215
 
209
216
  ### Setup
@@ -74,6 +74,31 @@ Same rule as `/cbp-session-start` Step 5.7 — only commit files that are **not*
74
74
 
75
75
  Non-blocking — session end proceeds either way.
76
76
 
77
+ ### Step 1.6: Home-Branch Fast-Forward
78
+
79
+ Keep this worktree's **home branch** rooted at the freshest production tip — no prompt, fully non-blocking. Home branches are the folder-named placeholder branches each worktree rests on (e.g. `codebyplan-web`); `feat/*` branches are deliberately skipped — they integrate via `/cbp-merge-main` with QA, never an auto fast-forward.
80
+
81
+ Runs after Step 1.5 so any infra commits land first, and before Step 1.7 so the asset-update CLIs operate on the freshest tree.
82
+
83
+ Resolve the production branch: read `.codebyplan/git.json` and take `branch_config.production` (fall back to `main` if the file or field is absent). Call this `$PRODUCTION`. Then compare the current branch against the worktree's folder name:
84
+
85
+ ```bash
86
+ FOLDER="$(basename "$(git rev-parse --show-toplevel)")"
87
+ CURRENT="$(git rev-parse --abbrev-ref HEAD)"
88
+ ```
89
+
90
+ - **`$CURRENT` != `$FOLDER`** (a `feat/*` or any non-home branch): skip silently — no fetch, no output.
91
+ - **`$CURRENT` == `$FOLDER`** (home branch): fast-forward to `origin/$PRODUCTION`, warning once per failure and continuing:
92
+
93
+ ```bash
94
+ git fetch origin "$PRODUCTION" 2>/dev/null \
95
+ || echo "⚠ home-branch ff: fetch failed — staying on local $CURRENT"
96
+ git merge --ff-only "origin/$PRODUCTION" 2>/dev/null \
97
+ || echo "⚠ home-branch ff: $CURRENT not fast-forwardable (ahead/diverged) — left untouched"
98
+ ```
99
+
100
+ Never rebase, reset, force-push, or stash. A non-fast-forwardable home branch is a signal to reconcile manually, not to overwrite.
101
+
77
102
  ### Step 1.7: Auto-Update CodeByPlan Assets
78
103
 
79
104
  Run the latest published CLIs to pull any asset or config changes. Sub-block A runs first, then Sub-block B. A failure in A does **not** skip B — each sub-block has its own retry-and-warn lane.
@@ -179,7 +204,7 @@ You can close this window.
179
204
  ## Integration
180
205
 
181
206
  - **Triggered by**: user invocation (prompted by `/cbp-todo` when no work remains)
182
- - **Reads**: `.codebyplan/repo.json`, MCP `get_session_logs` (resolve current log), MCP `get_current_task`, MCP `get_rounds`, MCP `get_next_action` (Step 1.3 handoff snapshot)
207
+ - **Reads**: `.codebyplan/repo.json`, `.codebyplan/git.json` (`branch_config.production` for the Step 1.6 home-branch fast-forward), MCP `get_session_logs` (resolve current log), MCP `get_current_task`, MCP `get_rounds`, MCP `get_next_action` (Step 1.3 handoff snapshot)
183
208
  - **Writes**: MCP `update_session_log` (with `ended_at` + `handoff` per TASK-2 alias surface; or `create_session_log` fallback), MCP `update_session_state` (deactivate)
184
209
  - **Spawns**: none
185
210
  - **Triggers**: none at the skill-contract level. Steps 1.5 and 1.7 may invoke `/cbp-git-commit` inline on user approval.
@@ -12,7 +12,7 @@ Activate the session, open a fresh session log, and surface the previous log's p
12
12
 
13
13
  ## Instructions
14
14
 
15
- Do Steps 0–5 and Step 4.5 silently (no intermediate output). Step 5.7 may surface an approval gate. Produce ONE output block at Step 6, then auto-trigger `/cbp-todo`.
15
+ Do Steps 0–5 and Step 4.5 silently (no intermediate output). Step 1.4 may surface a one-line fast-forward note or warning, and Step 5.7 may surface an approval gate. Produce ONE output block at Step 6, then auto-trigger `/cbp-todo`.
16
16
 
17
17
  ### Step 0: MCP Health Check
18
18
 
@@ -50,6 +50,29 @@ Pass `WORKTREE_ID` to MCP tools that support it. Empty output means the (device,
50
50
 
51
51
  **If `worktree_id` resolves to empty** (the (device, path, branch) tuple does not match any registered worktree row): the session continues, but downstream MCP calls treat this caller as untagged — every hard-lock pre-guard sees a NULL `caller_worktree_id` and may reject mutations on assigned rows. Surface a one-line note in the Step 6 output instructing the user to run `npx codebyplan setup` from this directory to register the worktree.
52
52
 
53
+ ### Step 1.4: Home-Branch Fast-Forward
54
+
55
+ Keep this worktree's **home branch** rooted at the freshest production tip — no prompt, fully non-blocking. Home branches are the folder-named placeholder branches each worktree rests on (e.g. `codebyplan-web`); `feat/*` branches are deliberately skipped — they integrate via `/cbp-merge-main` with QA, never an auto fast-forward.
56
+
57
+ Resolve the production branch: read `.codebyplan/git.json` and take `branch_config.production` (fall back to `main` if the file or field is absent). Call this `$PRODUCTION`. Then compare the current branch against the worktree's folder name:
58
+
59
+ ```bash
60
+ FOLDER="$(basename "$(git rev-parse --show-toplevel)")"
61
+ CURRENT="$(git rev-parse --abbrev-ref HEAD)"
62
+ ```
63
+
64
+ - **`$CURRENT` != `$FOLDER`** (a `feat/*` or any non-home branch): skip silently — no fetch, no output.
65
+ - **`$CURRENT` == `$FOLDER`** (home branch): fast-forward to `origin/$PRODUCTION`, warning once per failure and continuing:
66
+
67
+ ```bash
68
+ git fetch origin "$PRODUCTION" 2>/dev/null \
69
+ || echo "⚠ home-branch ff: fetch failed — staying on local $CURRENT"
70
+ git merge --ff-only "origin/$PRODUCTION" 2>/dev/null \
71
+ || echo "⚠ home-branch ff: $CURRENT not fast-forwardable (ahead/diverged) — left untouched"
72
+ ```
73
+
74
+ Never rebase, reset, force-push, or stash. A non-fast-forwardable home branch is a signal to reconcile manually, not to overwrite.
75
+
53
76
  ### Step 2: Check Dev Server
54
77
 
55
78
  **Skip if `server_type` is `"none"`.**
@@ -147,7 +170,7 @@ Trigger `/cbp-todo` to determine what to work on.
147
170
  ## Integration
148
171
 
149
172
  - **Triggered by**: user invocation, `/clear` recovery
150
- - **Reads**: `.codebyplan/repo.json`, MCP `get_session_logs` (worktree-filtered, limit 1 — single call shared by Step 4 and Step 4.5), MCP `health_check`, MCP `get_current_task`, MCP `get_rounds`, MCP `get_checkpoints` / `get_tasks` / `get_rounds` for freshness probe (Step 4.5)
173
+ - **Reads**: `.codebyplan/repo.json`, `.codebyplan/git.json` (`branch_config.production` for the Step 1.4 home-branch fast-forward), MCP `get_session_logs` (worktree-filtered, limit 1 — single call shared by Step 4 and Step 4.5), MCP `health_check`, MCP `get_current_task`, MCP `get_rounds`, MCP `get_checkpoints` / `get_tasks` / `get_rounds` for freshness probe (Step 4.5)
151
174
  - **Writes**: MCP `create_session_log` (new, possibly empty), MCP `update_session_state` (activate)
152
175
  - **Spawns**: none
153
176
  - **Triggers**: `/cbp-git-commit` (conditional, on user approval), `handoff.command` (on fresh handoff hit at Step 4.5), `/cbp-todo` (auto fall-through)