@ornexus/neocortex 4.64.4 → 4.65.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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: neocortex
3
- description: "🧠 Neocortex v4.64.4 | OrNexus Team"
3
+ description: "🧠 Neocortex v4.65.0 | OrNexus Team"
4
4
  model: inherit
5
5
  readonly: false
6
6
  is_background: false
@@ -104,7 +104,7 @@ SEMPRE que este agente for invocado, imprima o banner abaixo como PRIMEIRO outpu
104
104
  ┌────────────────────────────────────────────────────────────┐
105
105
  │ │
106
106
  │ ####### N E O C O R T E X │
107
- │ ### ######## v4.64.4 │
107
+ │ ### ######## v4.65.0 │
108
108
  │ ######### ##### │
109
109
  │ ## ############## Development Orchestrator │
110
110
  │ ## ### ###### ## OrNexus Team │
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: neocortex-root
3
- description: "🧠 Neocortex v4.64.4 | OrNexus Team"
3
+ description: "🧠 Neocortex v4.65.0 | OrNexus Team"
4
4
  kind: local
5
5
  tools:
6
6
  # File operations (Gemini CLI built-ins)
@@ -62,7 +62,7 @@ SEMPRE que este agente for invocado, imprima o banner abaixo como PRIMEIRO outpu
62
62
  ┌────────────────────────────────────────────────────────────┐
63
63
  │ │
64
64
  │ ####### N E O C O R T E X │
65
- │ ### ######## v4.64.4 │
65
+ │ ### ######## v4.65.0 │
66
66
  │ ######### ##### │
67
67
  │ ## ############## Development Orchestrator │
68
68
  │ ## ### ###### ## OrNexus Team │
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * Claude Code worktree base for Neocortex v4 story worktrees.
4
+ *
5
+ * Native subagent worktrees (`isolation: "worktree"`) start from the remote
6
+ * default branch unless Claude Code's `worktree.baseRef` is `"head"`. The
7
+ * Neocortex root dispatches phase-1 children from the epic checkout, so the
8
+ * worktree must start from the local HEAD (the epic branch).
9
+ *
10
+ * The helper is additive and preserving: it only adds `worktree.baseRef:
11
+ * "head"` when the key is absent, never overwrites a value the user chose,
12
+ * keeps every other setting, writes atomically and keeps one backup. It is
13
+ * dependency-free so npm tarball installs can use it.
14
+ */
15
+
16
+ const fs = require('fs');
17
+ const path = require('path');
18
+
19
+ const BASE_REF_HEAD = 'head';
20
+
21
+ function settingsFileFor(home) {
22
+ return path.join(home, '.claude', 'settings.json');
23
+ }
24
+
25
+ function readSettings(file) {
26
+ if (!fs.existsSync(file)) return { exists: false, value: null };
27
+ const stat = fs.lstatSync(file);
28
+ if (!stat.isFile() || stat.isSymbolicLink()) return { exists: true, invalid: true, value: null };
29
+ try {
30
+ const value = JSON.parse(fs.readFileSync(file, 'utf8'));
31
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return { exists: true, invalid: true, value: null };
32
+ return { exists: true, value };
33
+ } catch {
34
+ return { exists: true, invalid: true, value: null };
35
+ }
36
+ }
37
+
38
+ /** Read-only state: `head`, `absent`, `user-value`, `settings-invalid` or `claude-absent`. */
39
+ function inspectClaudeWorktreeBaseRef(home) {
40
+ if (!fs.existsSync(path.join(home, '.claude'))) return { state: 'claude-absent' };
41
+ const settings = readSettings(settingsFileFor(home));
42
+ if (settings.invalid) return { state: 'settings-invalid' };
43
+ const worktree = settings.value && settings.value.worktree;
44
+ if (worktree === undefined || worktree === null) return { state: 'absent' };
45
+ if (typeof worktree !== 'object' || Array.isArray(worktree)) return { state: 'settings-invalid' };
46
+ if (worktree.baseRef === undefined) return { state: 'absent' };
47
+ return worktree.baseRef === BASE_REF_HEAD ? { state: 'head' } : { state: 'user-value' };
48
+ }
49
+
50
+ /**
51
+ * Add `worktree.baseRef: "head"` when it is absent. Returns
52
+ * `{ action, reasonCode }`; `action` is `applied`, `unchanged` or `skipped`.
53
+ */
54
+ function ensureClaudeWorktreeBaseRef(home, options) {
55
+ const dryRun = Boolean(options && options.dryRun);
56
+ const inspected = inspectClaudeWorktreeBaseRef(home);
57
+ if (inspected.state === 'head') return { action: 'unchanged', reasonCode: 'claude-worktree-baseref-head' };
58
+ if (inspected.state === 'user-value') return { action: 'skipped', reasonCode: 'claude-worktree-baseref-user-value-kept' };
59
+ if (inspected.state === 'settings-invalid') return { action: 'skipped', reasonCode: 'claude-settings-invalid' };
60
+ if (inspected.state === 'claude-absent') return { action: 'skipped', reasonCode: 'claude-code-not-installed' };
61
+ if (dryRun) return { action: 'skipped', reasonCode: 'claude-worktree-baseref-dry-run' };
62
+
63
+ const file = settingsFileFor(home);
64
+ const current = readSettings(file);
65
+ const base = current.value || {};
66
+ const next = Object.assign({}, base, {
67
+ worktree: Object.assign({}, base.worktree || {}, { baseRef: BASE_REF_HEAD }),
68
+ });
69
+ if (current.exists) fs.copyFileSync(file, `${file}.neocortex-backup`);
70
+ const temporary = `${file}.neocortex-tmp-${process.pid}`;
71
+ fs.writeFileSync(temporary, `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
72
+ fs.renameSync(temporary, file);
73
+ return { action: 'applied', reasonCode: 'claude-worktree-baseref-applied' };
74
+ }
75
+
76
+ module.exports = { inspectClaudeWorktreeBaseRef, ensureClaudeWorktreeBaseRef, BASE_REF_HEAD };
77
+
78
+ if (require.main === module) {
79
+ const home = process.argv[2] || process.env.HOME || '';
80
+ const dryRun = process.argv.includes('--dry-run');
81
+ try {
82
+ const result = ensureClaudeWorktreeBaseRef(home, { dryRun });
83
+ process.stdout.write(`${JSON.stringify(result)}\n`);
84
+ } catch {
85
+ process.stdout.write(`${JSON.stringify({ action: 'skipped', reasonCode: 'claude-worktree-baseref-write-failed' })}\n`);
86
+ }
87
+ }
@@ -64,7 +64,7 @@ task directive, I keep root-owned inline/shell-loop execution.
64
64
  ┌────────────────────────────────────────────────────────────┐
65
65
  │ │
66
66
  │ ####### N E O C O R T E X │
67
- │ ### ######## v4.64.4 │
67
+ │ ### ######## v4.65.0 │
68
68
  │ ######### ##### │
69
69
  │ ## ############## Development Orchestrator │
70
70
  │ ## ### ###### ## OrNexus Team │
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: "neocortex"
3
- description: "Neocortex v4.64.4 | OrNexus Team"
3
+ description: "Neocortex v4.65.0 | OrNexus Team"
4
4
  tools:
5
5
  # Read / Edit (built-in tool sets)
6
6
  - read
@@ -72,7 +72,7 @@ SEMPRE que este agente for invocado, imprima o banner abaixo como PRIMEIRO outpu
72
72
  ┌────────────────────────────────────────────────────────────┐
73
73
  │ │
74
74
  │ ####### N E O C O R T E X │
75
- │ ### ######## v4.64.4 │
75
+ │ ### ######## v4.65.0 │
76
76
  │ ######### ##### │
77
77
  │ ## ############## Development Orchestrator │
78
78
  │ ## ### ###### ## OrNexus Team │