mother-brain 0.7.4 → 0.7.6

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
@@ -61,7 +61,10 @@ async function init(options = {}) {
61
61
  const pkg = await fs.readJSON(path.join(packageRoot, "package.json"));
62
62
  await fs.writeJSON(versionFile, {
63
63
  installed: pkg.version,
64
- installedAt: (/* @__PURE__ */ new Date()).toISOString()
64
+ installedAt: (/* @__PURE__ */ new Date()).toISOString(),
65
+ // Startup can use this to avoid hitting the network every run.
66
+ lastUpdateCheckAt: (/* @__PURE__ */ new Date()).toISOString(),
67
+ lastKnownLatest: pkg.version
65
68
  }, { spaces: 2 });
66
69
  const sessionFile = path.join(motherBrainDir, "session-state.json");
67
70
  if (!await fs.pathExists(sessionFile)) {
@@ -205,6 +208,11 @@ async function update() {
205
208
  console.log(chalk2.dim(`Latest: v${latestVersion}
206
209
  `));
207
210
  if (currentVersion.installed === latestVersion) {
211
+ await fs2.writeJSON(versionFile, {
212
+ ...currentVersion,
213
+ lastUpdateCheckAt: (/* @__PURE__ */ new Date()).toISOString(),
214
+ lastKnownLatest: latestVersion
215
+ }, { spaces: 2 });
208
216
  console.log(chalk2.green("\u2705 Already on the latest version!\n"));
209
217
  return;
210
218
  }
@@ -257,7 +265,9 @@ ${markerEnd}`;
257
265
  await fs2.writeJSON(versionFile, {
258
266
  installed: latestVersion,
259
267
  installedAt: (/* @__PURE__ */ new Date()).toISOString(),
260
- previousVersion: currentVersion.installed
268
+ previousVersion: currentVersion.installed,
269
+ lastUpdateCheckAt: (/* @__PURE__ */ new Date()).toISOString(),
270
+ lastKnownLatest: latestVersion
261
271
  }, { spaces: 2 });
262
272
  console.log(chalk2.cyan(`
263
273
  \u2705 Updated to v${latestVersion}!
@@ -798,7 +808,7 @@ async function uninstall(options) {
798
808
  // src/cli.ts
799
809
  import { exec as exec3 } from "child_process";
800
810
  var program = new Command();
801
- var VERSION = "0.7.4";
811
+ var VERSION = "0.7.6";
802
812
  program.name("mother-brain").description("AI-powered project management framework for GitHub Copilot CLI and Codex CLI").version(VERSION);
803
813
  program.command("init").description("Initialize Mother Brain in the current project").option("-f, --force", "Overwrite existing skills").action(init);
804
814
  program.command("update").description("Update Mother Brain skills to the latest version").action(update);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mother-brain",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "AI-powered project management framework for GitHub Copilot CLI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -43,8 +43,14 @@ allowed-tools: powershell view grep glob web_search ask_user create edit skill
43
43
  This ensures Mother Brain works across ALL agent runtimes (GitHub Copilot CLI, Codex CLI, IDE extensions, etc.) even when interactive UI tools are unavailable.
44
44
 
45
45
  ### RULE 3: VERSION CHECK FIRST
46
- - Before showing ANY menu, run: `npm view mother-brain version --json 2>$null`
47
- - Compare to local version
46
+ - Before showing ANY menu, perform a version check (fast-first):
47
+ - Read `.mother-brain/version.json` to get the installed version
48
+ - If `.mother-brain/version.json` contains a fresh cached update check:
49
+ - Fields: `lastUpdateCheckAt` + `lastKnownLatest`
50
+ - TTL: 24 hours
51
+ - Then you may skip the network call and treat `lastKnownLatest` as the latest version for this startup
52
+ - Otherwise, run: `npm view mother-brain version --json 2>$null`
53
+ - Compare installed vs latest
48
54
  - If newer version exists → notify user BEFORE proceeding
49
55
  - **To update**: Run `npx -y mother-brain update` — the CLI handles everything automatically
50
56
 
@@ -382,17 +388,17 @@ Key rules: Use `allow_freeform: true` on all `ask_user` calls. Check freeform re
382
388
  - Proceed immediately to Step 2 (Detect Project State)
383
389
 
384
390
  ### 2. **Detect Project State & Show Progress**
385
-
386
- - Runs version check, meta-mode detection, fast startup optimization, auto-update with improvement capture, and artifact scanning.
387
- - **Read `references/state-detection.md`** for the full detection procedure (version check, meta-mode, fast startup, auto-update Steps A–D, artifact list)
388
- - After detection completes, display the appropriate menu below based on project state:
391
+
392
+ - Runs version check, meta-mode detection, fast startup optimization, auto-update with improvement capture, and artifact scanning.
393
+ - **Read `references/state-detection.md`** for the full detection procedure (version check, meta-mode, fast startup, auto-update Steps A–D, artifact list)
394
+ - After detection completes, display the appropriate menu below based on project state:
389
395
 
390
- **If project exists:**
391
- - Load session state from `docs/session-state.json`
392
-
393
- - **Git Check (ensure git is available)**:
394
- - Check if `.git` folder exists in project root
395
- - If NOT exists:
396
+ **If project exists:**
397
+ - Load session state from `.mother-brain/session-state.json`
398
+
399
+ - **Git Check (ensure git is available)**:
400
+ - Check if `.git` folder exists in project root
401
+ - If NOT exists:
396
402
  ```
397
403
  ⚠️ Git repository not found - initializing...
398
404
  ```
@@ -424,11 +430,11 @@ Key rules: Use `allow_freeform: true` on all `ask_user` calls. Check freeform re
424
430
  - **If "I have a new idea"**: Jump to **Step 2F: Idea Capture & Prioritization**
425
431
  - **If "Improve Mother Brain"**: Jump to **Step 2A: Improve Mother Brain Menu**
426
432
 
427
- **If existing project WITHOUT Mother Brain artifacts (ONBOARDING):**
428
- - Detect: Files exist in directory, but NO `.mother-brain/` folder and NO `docs/vision.md`
429
- - Display:
430
- ```
431
- 🧠 I see an existing project here!
433
+ **If existing project WITHOUT Mother Brain artifacts (ONBOARDING):**
434
+ - Detect: Files exist in directory, but NO `.mother-brain/` folder (Mother Brain not installed here)
435
+ - Display:
436
+ ```
437
+ 🧠 I see an existing project here!
432
438
 
433
439
  I can help you manage this project using the Mother Brain framework.
434
440
  I'll scan your codebase, understand what you've built, and help you
@@ -439,12 +445,19 @@ Key rules: Use `allow_freeform: true` on all `ask_user` calls. Check freeform re
439
445
  - "Yes, onboard Mother Brain into this project"
440
446
  - "No, start fresh (ignore existing files)"
441
447
 
442
- - **If user selects onboarding**: Jump to **Step 2.2: Existing Project Onboarding**
448
+ - **If user selects onboarding**: Jump to **Step 2.2: Existing Project Onboarding**
443
449
 
444
- **If new project (empty directory or user chose fresh start):**
445
- - Display welcome:
446
- ```
447
- 🧠 Welcome to Mother Brain!
450
+ **If Mother Brain is installed but this folder is scaffolding-only (NEW PROJECT):**
451
+ - Detect:
452
+ - `.mother-brain/session-state.json` exists AND its project is unset (e.g., `project: null`)
453
+ - `.mother-brain/docs/vision.md` does NOT exist
454
+ - Repo root contains only Mother Brain scaffolding (e.g., `.mother-brain/`, `.github/`, `.agents/`, `AGENTS.md`, optional `.git/`)
455
+ - Treat this as a **new project** (show the new-project welcome flow below). Do NOT show onboarding.
456
+
457
+ **If new project (empty directory or user chose fresh start):**
458
+ - Display welcome:
459
+ ```
460
+ 🧠 Welcome to Mother Brain!
448
461
 
449
462
  I'm your AI project companion. Tell me what you want to build,
450
463
  and I'll help you make it real—step by step.
@@ -6,27 +6,53 @@
6
6
  - Read `references/boot-screen.md`
7
7
  - Print ONLY the short user-facing startup lines from the template
8
8
  - Do NOT print commands or internal reasoning
9
- - Run version check:
10
- ```powershell
11
- npm view mother-brain version --json 2>$null
12
- ```
13
- - Compare against:
14
- - If in framework repo: `cli/package.json` version field
15
- - If in project: `.mother-brain/version.json` version field
9
+ - **Fast-first version check (cache before network)**:
10
+ 1. Read installed version from `.mother-brain/version.json` (project) or `cli/package.json` (framework repo)
11
+ 2. If in a project folder, check whether `.mother-brain/version.json` has a fresh cached update check:
12
+ - Fields: `lastUpdateCheckAt` + `lastKnownLatest`
13
+ - TTL: 24 hours
14
+ - If fresh: treat `lastKnownLatest` as "Latest" for this startup and SKIP the network call
15
+ 3. If no cache or cache is stale: run the network check:
16
+ ```powershell
17
+ npm view mother-brain version --json 2>$null
18
+ ```
19
+ - After a successful check, update `.mother-brain/version.json` with:
20
+ - `lastUpdateCheckAt`: now
21
+ - `lastKnownLatest`: the npm version
22
+ - If check fails (offline), continue silently without blocking startup
16
23
  - **If newer version exists**:
17
- ```
18
- ⚠️ Mother Brain Update Available
19
-
20
- Installed: v[current]
21
- Latest: v[npm version]
24
+ - **If in a project folder** (has `.mother-brain/version.json`):
25
+ ```
26
+ ⚠️ Mother Brain Update Available
27
+
28
+ Installed: v[current]
29
+ Latest: v[npm version]
30
+
31
+ Update recommended before continuing.
32
+ ```
33
+ - Use `ask_user` with choices:
34
+ - "Update now (recommended)"
35
+ - "Skip this time"
36
+ - **If "Update now"**: Run `npx -y mother-brain update`, then continue
37
+ - **If "Skip"**: Continue but note version mismatch
22
38
 
23
- Update recommended before continuing.
24
- ```
25
- - Use `ask_user` with choices:
26
- - "Update now (recommended)"
27
- - "Skip this time"
28
- - **If "Update now"**: Run auto-update (see update commands below), then continue
29
- - **If "Skip"**: Continue but note version mismatch
39
+ - **If in the Mother Brain framework repo** (source code checkout):
40
+ ```
41
+ ⚠️ Mother Brain Release Ahead of This Checkout
42
+
43
+ Repo version (cli/package.json): v[current]
44
+ Latest release (npm): v[npm version]
45
+
46
+ This usually means your local checkout hasn’t been pulled to the latest tag yet.
47
+ ```
48
+ - Use `ask_user` with choices:
49
+ - "Fetch tags + pull latest framework changes (recommended)"
50
+ - "Skip this time"
51
+ - **If "Fetch tags + pull"**:
52
+ - Run `git fetch --tags origin`
53
+ - Run `git pull --ff-only origin main`
54
+ - Then continue detection
55
+ - **If "Skip"**: Continue but note mismatch
30
56
  - **If current or check fails**: Continue silently
31
57
 
32
58
  **🧬 META-MODE DETECTION (AFTER VERSION CHECK)**:
@@ -37,6 +63,8 @@
37
63
  4. If ALL of these exist → we are in the Mother Brain framework repo
38
64
 
39
65
  - **If in Mother Brain framework repo**:
66
+ - Refresh tags before reporting "last release" (quiet):
67
+ - Run `git fetch --tags origin`
40
68
  - Check `.mother-brain/meta-mode.json` for existing meta session state
41
69
  - Display:
42
70
  ```
@@ -77,11 +105,34 @@
77
105
  - **If NOT in framework repo**: Continue with normal detection below
78
106
 
79
107
  **⚡ FAST STARTUP OPTIMIZATION (MANDATORY)**:
80
- - **Single file check first**: Check ONLY `.mother-brain/session-state.json` - if it exists, project exists
108
+ - **Single file check first**: Check ONLY `.mother-brain/session-state.json`
109
+ - If it exists: Mother Brain is installed in this folder (NOT necessarily an "existing project")
110
+ - If it does not exist: treat as "no Mother Brain artifacts" (possible onboarding or brand-new folder)
81
111
  - **Parallel tool calls**: When multiple checks are needed, run them in ONE response (not sequentially)
82
112
  - **Lazy loading**: Only load vision.md, roadmap.md, README.md when actually needed (not at startup)
83
113
  - **Minimal detection**: For new project detection, a single glob for `.mother-brain/` is sufficient
84
114
  - Goal: User sees menu within 1-2 tool calls, not 6+
115
+
116
+ **🧩 SCAFFOLDING-ONLY DETECTION (CRITICAL - fixes false "existing project" onboarding)**
117
+ - A freshly created folder can look like an "existing project" after `mother-brain init` because init creates:
118
+ - `.mother-brain/session-state.json` (with `project: null`)
119
+ - `.mother-brain/version.json`
120
+ - `.github/skills/*`
121
+ - `.agents/skills/*`
122
+ - `AGENTS.md`
123
+ - `.git/` (if git init is performed)
124
+ - **Rule**: If the folder contains ONLY Mother Brain scaffolding, treat it as a **new project** (show the new-project welcome flow), NOT onboarding.
125
+ - Detect scaffolding-only as:
126
+ 1. `.mother-brain/session-state.json` exists AND its JSON has `project: null` (or no project name)
127
+ 2. `.mother-brain/docs/vision.md` does NOT exist
128
+ 3. The repo root contains no "real project files" beyond:
129
+ - `.mother-brain/`
130
+ - `.github/`
131
+ - `.agents/`
132
+ - `.git/`
133
+ - `AGENTS.md`
134
+ - If all true → show **New Project** welcome menu (Step 2 new project)
135
+ - If false → proceed with normal project/onboarding detection
85
136
 
86
137
  **📦 AUTO-UPDATE CHECK (on startup, if project exists)**:
87
138
  - If `.mother-brain/version.json` exists:
@@ -109,4 +160,4 @@
109
160
  - `.mother-brain/docs/roadmap.md` - Current roadmap (load only when needed)
110
161
  - `.mother-brain/docs/tasks/` - Task documentation folder
111
162
  - `.github/skills/` - Project-specific skills
112
-
163
+