instar 1.0.13 → 1.1.1

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.
Files changed (70) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +52 -2
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/init.d.ts +17 -0
  5. package/dist/commands/init.d.ts.map +1 -1
  6. package/dist/commands/init.js +156 -64
  7. package/dist/commands/init.js.map +1 -1
  8. package/dist/commands/server.d.ts.map +1 -1
  9. package/dist/commands/server.js +68 -4
  10. package/dist/commands/server.js.map +1 -1
  11. package/dist/commands/setup.d.ts +3 -1
  12. package/dist/commands/setup.d.ts.map +1 -1
  13. package/dist/commands/setup.js +67 -28
  14. package/dist/commands/setup.js.map +1 -1
  15. package/dist/commands/worktree.d.ts +17 -4
  16. package/dist/commands/worktree.d.ts.map +1 -1
  17. package/dist/commands/worktree.js +28 -4
  18. package/dist/commands/worktree.js.map +1 -1
  19. package/dist/core/AgentWorktreeDetector.d.ts +63 -0
  20. package/dist/core/AgentWorktreeDetector.d.ts.map +1 -0
  21. package/dist/core/AgentWorktreeDetector.js +329 -0
  22. package/dist/core/AgentWorktreeDetector.js.map +1 -0
  23. package/dist/core/InstarWorktreeManager.d.ts +99 -0
  24. package/dist/core/InstarWorktreeManager.d.ts.map +1 -0
  25. package/dist/core/InstarWorktreeManager.js +447 -0
  26. package/dist/core/InstarWorktreeManager.js.map +1 -0
  27. package/dist/core/MachineIdentity.d.ts.map +1 -1
  28. package/dist/core/MachineIdentity.js +2 -0
  29. package/dist/core/MachineIdentity.js.map +1 -1
  30. package/dist/core/PostUpdateMigrator.d.ts +25 -0
  31. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  32. package/dist/core/PostUpdateMigrator.js +258 -0
  33. package/dist/core/PostUpdateMigrator.js.map +1 -1
  34. package/dist/memory/NativeModuleHealer.d.ts +15 -0
  35. package/dist/memory/NativeModuleHealer.d.ts.map +1 -1
  36. package/dist/memory/NativeModuleHealer.js +22 -0
  37. package/dist/memory/NativeModuleHealer.js.map +1 -1
  38. package/dist/monitoring/NativeHealDegradationBridge.d.ts +32 -0
  39. package/dist/monitoring/NativeHealDegradationBridge.d.ts.map +1 -0
  40. package/dist/monitoring/NativeHealDegradationBridge.js +61 -0
  41. package/dist/monitoring/NativeHealDegradationBridge.js.map +1 -0
  42. package/dist/monitoring/PromptGate.d.ts +12 -0
  43. package/dist/monitoring/PromptGate.d.ts.map +1 -1
  44. package/dist/monitoring/PromptGate.js +44 -0
  45. package/dist/monitoring/PromptGate.js.map +1 -1
  46. package/dist/scaffold/templates.d.ts.map +1 -1
  47. package/dist/scaffold/templates.js +17 -0
  48. package/dist/scaffold/templates.js.map +1 -1
  49. package/dist/server/AgentServer.d.ts.map +1 -1
  50. package/dist/server/AgentServer.js +6 -0
  51. package/dist/server/AgentServer.js.map +1 -1
  52. package/package.json +1 -1
  53. package/scripts/lint-no-direct-destructive.js +7 -0
  54. package/scripts/resolve-release-tier.mjs +192 -0
  55. package/src/data/builtin-manifest.json +57 -49
  56. package/src/scaffold/templates.ts +17 -0
  57. package/src/templates/scripts/instar-watchdog.sh +169 -6
  58. package/src/templates/scripts/instar-worktree-create.sh +79 -0
  59. package/upgrades/1.1.0.md +320 -0
  60. package/upgrades/1.1.1.md +58 -0
  61. package/upgrades/side-effects/agent-worktree-convention-layer-1-2-5.md +280 -0
  62. package/upgrades/side-effects/agent-worktree-convention-layer-3-4.md +285 -0
  63. package/upgrades/side-effects/feat-fix-parent-framework-intercept.md +59 -0
  64. package/upgrades/side-effects/feat-install-claude-gating.md +67 -0
  65. package/upgrades/side-effects/feat-install-framework-flag.md +65 -0
  66. package/upgrades/side-effects/feat-portability-shadow-capabilities.md +63 -0
  67. package/upgrades/side-effects/feat-setup-framework-flag.md +65 -0
  68. package/upgrades/side-effects/lockdown-layer-2.md +123 -0
  69. package/upgrades/side-effects/native-heal-degradation-bridge.md +206 -0
  70. package/upgrades/side-effects/watchdog-bind-failure-probe.md +174 -0
@@ -469,6 +469,13 @@ const SHELL_ALLOWLIST = new Set([
469
469
  // ports this to a Node script that uses SafeGitExecutor and removes this
470
470
  // entry.
471
471
  'src/templates/scripts/git-sync-gate.sh',
472
+ // Wrapper installed into every agent's `.bin/`. Primary path delegates
473
+ // to `instar worktree create` (which uses SafeGitExecutor). The inline
474
+ // fallback at the bottom of the file runs only when neither `instar`
475
+ // nor `npx` is on PATH — a documented last-resort path. The direct
476
+ // `git worktree add` there is intentional and bounded to that case.
477
+ // Spec: docs/specs/AGENT-WORKTREE-CONVENTION-SPEC.md §Sequencing.
478
+ 'src/templates/scripts/instar-worktree-create.sh',
472
479
  ]);
473
480
 
474
481
  function lintShellFile(file, text) {
@@ -0,0 +1,192 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * resolve-release-tier — Layer 2 of the Deployment Lockdown spec.
4
+ *
5
+ * Reads `.instar/release-tier.json` (committed) and decides whether the
6
+ * current publish attempt is permitted by the declared release tier.
7
+ *
8
+ * Why this exists. The 2026-05-19 deployment misalignment shipped four
9
+ * "v1.0.x" PRs as v0.28.122–v0.28.125 patches because the workflow had no
10
+ * concept of "we are in a holding pattern" or "this is a major-version arc."
11
+ * Every PR was a patch by definition. Layer 1 made package.json the version
12
+ * authority; Layer 2 (this script) makes the release-tier file the publish
13
+ * authority. Together they let an operator declare "no deploy" in code that
14
+ * the workflow physically honors.
15
+ *
16
+ * Allowed tier values:
17
+ * "patch" — auto-publish on every NEXT.md-bearing PR (current default).
18
+ * "minor" — auto-publish only when LOCAL.minor > NPM.minor.
19
+ * "major" — auto-publish only when LOCAL.major > NPM.major AND Layer 5
20
+ * multi-signatures are present. Layer 5 is not yet shipped, so
21
+ * this tier currently blocks until Layer 5 lands.
22
+ * "hold" — auto-publish DISABLED. Used during major-feature work, after
23
+ * an incident, or whenever the operator wants to pause shipping.
24
+ *
25
+ * Missing file → defaults to "patch" (the pre-Layer-2 behavior). This keeps
26
+ * the script safe for older checkouts that haven't been migrated.
27
+ *
28
+ * Usage:
29
+ * node scripts/resolve-release-tier.mjs <localVersion> <npmVersion>
30
+ * [--config-path <path>]
31
+ * → exit 0 + prints "allow" to stdout when publish is permitted
32
+ * → exit 0 + prints "skip" to stdout when tier blocks (workflow should
33
+ * skip cleanly, not fail the run; reason goes to stderr)
34
+ * → exit 2 on bad usage / invalid tier file (workflow should fail loudly)
35
+ *
36
+ * Exported as a function for unit testing.
37
+ */
38
+
39
+ import { readFileSync, existsSync } from 'node:fs';
40
+
41
+ const VALID_TIERS = ['patch', 'minor', 'major', 'hold'];
42
+
43
+ /**
44
+ * @param {string} a semver "x.y.z"
45
+ * @param {string} b semver "x.y.z"
46
+ * @returns {"gt"|"eq"|"lt"} a compared to b
47
+ */
48
+ export function compareSemver(a, b) {
49
+ const pa = String(a).split('.').map(Number);
50
+ const pb = String(b).split('.').map(Number);
51
+ for (let i = 0; i < 3; i++) {
52
+ const x = pa[i] || 0;
53
+ const y = pb[i] || 0;
54
+ if (x > y) return 'gt';
55
+ if (x < y) return 'lt';
56
+ }
57
+ return 'eq';
58
+ }
59
+
60
+ /**
61
+ * Compare major / minor components only.
62
+ * @param {string} a
63
+ * @param {string} b
64
+ * @returns {"gt"|"eq"|"lt"}
65
+ */
66
+ function compareMajorMinor(a, b, depth) {
67
+ const pa = String(a).split('.').map(Number);
68
+ const pb = String(b).split('.').map(Number);
69
+ for (let i = 0; i < depth; i++) {
70
+ const x = pa[i] || 0;
71
+ const y = pb[i] || 0;
72
+ if (x > y) return 'gt';
73
+ if (x < y) return 'lt';
74
+ }
75
+ return 'eq';
76
+ }
77
+
78
+ /**
79
+ * @typedef {{ tier: "patch"|"minor"|"major"|"hold", reason?: string, setAt?: string, setBy?: string }} TierConfig
80
+ * @typedef {{ decision: "allow"|"skip", reason: string, tier: string }} Resolution
81
+ */
82
+
83
+ /**
84
+ * @param {unknown} raw parsed JSON
85
+ * @returns {TierConfig}
86
+ */
87
+ export function validateTierConfig(raw) {
88
+ if (!raw || typeof raw !== 'object') {
89
+ throw new Error('release-tier.json must be a JSON object');
90
+ }
91
+ const obj = /** @type {Record<string, unknown>} */ (raw);
92
+ const tier = obj.tier;
93
+ if (typeof tier !== 'string' || !VALID_TIERS.includes(tier)) {
94
+ throw new Error(
95
+ `release-tier.json: invalid tier "${String(tier)}"; must be one of ${VALID_TIERS.join(', ')}`
96
+ );
97
+ }
98
+ return /** @type {TierConfig} */ (obj);
99
+ }
100
+
101
+ /**
102
+ * Read the release-tier config. Missing file → defaults to patch.
103
+ * @param {string} configPath
104
+ * @returns {TierConfig}
105
+ */
106
+ export function readTierConfig(configPath) {
107
+ if (!existsSync(configPath)) {
108
+ return { tier: 'patch', reason: 'no .instar/release-tier.json present; defaulting to patch (pre-Layer-2 behavior)' };
109
+ }
110
+ const raw = JSON.parse(readFileSync(configPath, 'utf8'));
111
+ return validateTierConfig(raw);
112
+ }
113
+
114
+ /**
115
+ * Decide whether the current publish attempt is allowed by the declared tier.
116
+ * @param {TierConfig} config
117
+ * @param {string} localVersion package.json
118
+ * @param {string} npmVersion `npm view instar version`
119
+ * @returns {Resolution}
120
+ */
121
+ export function resolveReleaseTier(config, localVersion, npmVersion) {
122
+ const { tier } = config;
123
+
124
+ if (tier === 'hold') {
125
+ return {
126
+ decision: 'skip',
127
+ tier,
128
+ reason: `tier=hold: auto-publish is paused${config.reason ? ` (${config.reason})` : ''}. Change .instar/release-tier.json to "patch" / "minor" / "major" to resume.`,
129
+ };
130
+ }
131
+
132
+ if (tier === 'patch') {
133
+ return { decision: 'allow', tier, reason: 'tier=patch: routine maintenance line' };
134
+ }
135
+
136
+ if (tier === 'minor') {
137
+ const cmp = compareMajorMinor(localVersion, npmVersion, 2);
138
+ if (cmp === 'gt') {
139
+ return { decision: 'allow', tier, reason: `tier=minor: package.json (${localVersion}) declares a minor leap over npm (${npmVersion})` };
140
+ }
141
+ return {
142
+ decision: 'skip',
143
+ tier,
144
+ reason: `tier=minor: package.json (${localVersion}) does not declare a minor leap over npm (${npmVersion}). Bump package.json minor or change tier to "patch".`,
145
+ };
146
+ }
147
+
148
+ if (tier === 'major') {
149
+ // Layer 5 multi-signature gate not yet implemented. Until it ships, the
150
+ // major tier blocks publishes outright. This is intentional: the spec
151
+ // requires both LOCAL.major > NPM.major AND signature verification before
152
+ // a major publish. Lacking the latter, we refuse rather than ship a
153
+ // major version with only single-agent authority.
154
+ return {
155
+ decision: 'skip',
156
+ tier,
157
+ reason: 'tier=major: multi-signature requirement (Layer 5) not yet implemented; major publishes are blocked until that layer lands.',
158
+ };
159
+ }
160
+
161
+ // Defensive: validateTierConfig rejects unknown tiers, but TypeScript-style
162
+ // exhaustiveness still wants a fallback.
163
+ throw new Error(`unhandled tier "${tier}"`);
164
+ }
165
+
166
+ // CLI entrypoint
167
+ if (import.meta.url === `file://${process.argv[1]}`) {
168
+ const args = process.argv.slice(2);
169
+ let configPath = '.instar/release-tier.json';
170
+ const positional = [];
171
+ for (let i = 0; i < args.length; i++) {
172
+ if (args[i] === '--config-path') {
173
+ configPath = args[++i];
174
+ } else {
175
+ positional.push(args[i]);
176
+ }
177
+ }
178
+ const [localVersion, npmVersion] = positional;
179
+ if (!localVersion || !npmVersion) {
180
+ process.stderr.write('usage: resolve-release-tier.mjs <localVersion> <npmVersion> [--config-path <path>]\n');
181
+ process.exit(2);
182
+ }
183
+ try {
184
+ const config = readTierConfig(configPath);
185
+ const result = resolveReleaseTier(config, localVersion, npmVersion);
186
+ process.stderr.write(`${result.reason}\n`);
187
+ process.stdout.write(result.decision);
188
+ } catch (err) {
189
+ process.stderr.write(`resolve-release-tier: ${err instanceof Error ? err.message : String(err)}\n`);
190
+ process.exit(2);
191
+ }
192
+ }
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-05-19T21:07:55.340Z",
5
- "instarVersion": "1.0.13",
6
- "entryCount": 189,
4
+ "generatedAt": "2026-05-20T20:25:25.571Z",
5
+ "instarVersion": "1.1.1",
6
+ "entryCount": 190,
7
7
  "entries": {
8
8
  "hook:session-start": {
9
9
  "id": "hook:session-start",
@@ -11,7 +11,7 @@
11
11
  "domain": "identity",
12
12
  "sourcePath": "src/core/PostUpdateMigrator.ts",
13
13
  "installedPath": ".instar/hooks/instar/session-start.sh",
14
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
14
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
15
15
  "since": "2025-01-01"
16
16
  },
17
17
  "hook:dangerous-command-guard": {
@@ -20,7 +20,7 @@
20
20
  "domain": "safety",
21
21
  "sourcePath": "src/core/PostUpdateMigrator.ts",
22
22
  "installedPath": ".instar/hooks/instar/dangerous-command-guard.sh",
23
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
23
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
24
24
  "since": "2025-01-01"
25
25
  },
26
26
  "hook:grounding-before-messaging": {
@@ -29,7 +29,7 @@
29
29
  "domain": "safety",
30
30
  "sourcePath": "src/core/PostUpdateMigrator.ts",
31
31
  "installedPath": ".instar/hooks/instar/grounding-before-messaging.sh",
32
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
32
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
33
33
  "since": "2025-01-01"
34
34
  },
35
35
  "hook:compaction-recovery": {
@@ -38,7 +38,7 @@
38
38
  "domain": "identity",
39
39
  "sourcePath": "src/core/PostUpdateMigrator.ts",
40
40
  "installedPath": ".instar/hooks/instar/compaction-recovery.sh",
41
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
41
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
42
42
  "since": "2025-01-01"
43
43
  },
44
44
  "hook:external-operation-gate": {
@@ -47,7 +47,7 @@
47
47
  "domain": "safety",
48
48
  "sourcePath": "src/core/PostUpdateMigrator.ts",
49
49
  "installedPath": ".instar/hooks/instar/external-operation-gate.js",
50
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
50
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
51
51
  "since": "2025-01-01"
52
52
  },
53
53
  "hook:deferral-detector": {
@@ -56,7 +56,7 @@
56
56
  "domain": "safety",
57
57
  "sourcePath": "src/core/PostUpdateMigrator.ts",
58
58
  "installedPath": ".instar/hooks/instar/deferral-detector.js",
59
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
59
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
60
60
  "since": "2025-01-01"
61
61
  },
62
62
  "hook:post-action-reflection": {
@@ -65,7 +65,7 @@
65
65
  "domain": "evolution",
66
66
  "sourcePath": "src/core/PostUpdateMigrator.ts",
67
67
  "installedPath": ".instar/hooks/instar/post-action-reflection.js",
68
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
68
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
69
69
  "since": "2025-01-01"
70
70
  },
71
71
  "hook:external-communication-guard": {
@@ -74,7 +74,7 @@
74
74
  "domain": "safety",
75
75
  "sourcePath": "src/core/PostUpdateMigrator.ts",
76
76
  "installedPath": ".instar/hooks/instar/external-communication-guard.js",
77
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
77
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
78
78
  "since": "2025-01-01"
79
79
  },
80
80
  "hook:scope-coherence-collector": {
@@ -83,7 +83,7 @@
83
83
  "domain": "coherence",
84
84
  "sourcePath": "src/core/PostUpdateMigrator.ts",
85
85
  "installedPath": ".instar/hooks/instar/scope-coherence-collector.js",
86
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
86
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
87
87
  "since": "2025-01-01"
88
88
  },
89
89
  "hook:scope-coherence-checkpoint": {
@@ -92,7 +92,7 @@
92
92
  "domain": "coherence",
93
93
  "sourcePath": "src/core/PostUpdateMigrator.ts",
94
94
  "installedPath": ".instar/hooks/instar/scope-coherence-checkpoint.js",
95
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
95
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
96
96
  "since": "2025-01-01"
97
97
  },
98
98
  "hook:free-text-guard": {
@@ -101,7 +101,7 @@
101
101
  "domain": "safety",
102
102
  "sourcePath": "src/core/PostUpdateMigrator.ts",
103
103
  "installedPath": ".instar/hooks/instar/free-text-guard.sh",
104
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
104
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
105
105
  "since": "2025-01-01"
106
106
  },
107
107
  "hook:claim-intercept": {
@@ -110,7 +110,7 @@
110
110
  "domain": "coherence",
111
111
  "sourcePath": "src/core/PostUpdateMigrator.ts",
112
112
  "installedPath": ".instar/hooks/instar/claim-intercept.js",
113
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
113
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
114
114
  "since": "2025-01-01"
115
115
  },
116
116
  "hook:claim-intercept-response": {
@@ -119,7 +119,7 @@
119
119
  "domain": "coherence",
120
120
  "sourcePath": "src/core/PostUpdateMigrator.ts",
121
121
  "installedPath": ".instar/hooks/instar/claim-intercept-response.js",
122
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
122
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
123
123
  "since": "2025-01-01"
124
124
  },
125
125
  "hook:auto-approve-permissions": {
@@ -128,7 +128,7 @@
128
128
  "domain": "safety",
129
129
  "sourcePath": "src/core/PostUpdateMigrator.ts",
130
130
  "installedPath": ".instar/hooks/instar/auto-approve-permissions.js",
131
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
131
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
132
132
  "since": "2025-01-01"
133
133
  },
134
134
  "job:health-check": {
@@ -752,7 +752,7 @@
752
752
  "type": "cli-command",
753
753
  "domain": "setup",
754
754
  "sourcePath": "src/cli.ts",
755
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
755
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
756
756
  "since": "2025-01-01"
757
757
  },
758
758
  "cli:setup": {
@@ -760,7 +760,7 @@
760
760
  "type": "cli-command",
761
761
  "domain": "setup",
762
762
  "sourcePath": "src/cli.ts",
763
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
763
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
764
764
  "since": "2025-01-01"
765
765
  },
766
766
  "cli:add": {
@@ -768,7 +768,7 @@
768
768
  "type": "cli-command",
769
769
  "domain": "setup",
770
770
  "sourcePath": "src/cli.ts",
771
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
771
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
772
772
  "since": "2025-01-01"
773
773
  },
774
774
  "cli:backup": {
@@ -776,7 +776,7 @@
776
776
  "type": "cli-command",
777
777
  "domain": "operations",
778
778
  "sourcePath": "src/cli.ts",
779
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
779
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
780
780
  "since": "2025-01-01"
781
781
  },
782
782
  "cli:git": {
@@ -784,7 +784,7 @@
784
784
  "type": "cli-command",
785
785
  "domain": "coordination",
786
786
  "sourcePath": "src/cli.ts",
787
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
787
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
788
788
  "since": "2025-01-01"
789
789
  },
790
790
  "cli:memory": {
@@ -792,7 +792,7 @@
792
792
  "type": "cli-command",
793
793
  "domain": "memory",
794
794
  "sourcePath": "src/cli.ts",
795
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
795
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
796
796
  "since": "2025-01-01"
797
797
  },
798
798
  "cli:knowledge": {
@@ -800,7 +800,7 @@
800
800
  "type": "cli-command",
801
801
  "domain": "memory",
802
802
  "sourcePath": "src/cli.ts",
803
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
803
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
804
804
  "since": "2025-01-01"
805
805
  },
806
806
  "cli:semantic": {
@@ -808,7 +808,7 @@
808
808
  "type": "cli-command",
809
809
  "domain": "memory",
810
810
  "sourcePath": "src/cli.ts",
811
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
811
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
812
812
  "since": "2025-01-01"
813
813
  },
814
814
  "cli:intent": {
@@ -816,7 +816,7 @@
816
816
  "type": "cli-command",
817
817
  "domain": "intent",
818
818
  "sourcePath": "src/cli.ts",
819
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
819
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
820
820
  "since": "2025-01-01"
821
821
  },
822
822
  "cli:feedback": {
@@ -824,7 +824,7 @@
824
824
  "type": "cli-command",
825
825
  "domain": "feedback",
826
826
  "sourcePath": "src/cli.ts",
827
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
827
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
828
828
  "since": "2025-01-01"
829
829
  },
830
830
  "cli:server": {
@@ -832,7 +832,7 @@
832
832
  "type": "cli-command",
833
833
  "domain": "server",
834
834
  "sourcePath": "src/cli.ts",
835
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
835
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
836
836
  "since": "2025-01-01"
837
837
  },
838
838
  "cli:status": {
@@ -840,7 +840,7 @@
840
840
  "type": "cli-command",
841
841
  "domain": "monitoring",
842
842
  "sourcePath": "src/cli.ts",
843
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
843
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
844
844
  "since": "2025-01-01"
845
845
  },
846
846
  "cli:user": {
@@ -848,7 +848,7 @@
848
848
  "type": "cli-command",
849
849
  "domain": "users",
850
850
  "sourcePath": "src/cli.ts",
851
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
851
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
852
852
  "since": "2025-01-01"
853
853
  },
854
854
  "cli:relationship": {
@@ -856,7 +856,7 @@
856
856
  "type": "cli-command",
857
857
  "domain": "relationships",
858
858
  "sourcePath": "src/cli.ts",
859
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
859
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
860
860
  "since": "2025-01-01"
861
861
  },
862
862
  "cli:job": {
@@ -864,7 +864,7 @@
864
864
  "type": "cli-command",
865
865
  "domain": "scheduling",
866
866
  "sourcePath": "src/cli.ts",
867
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
867
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
868
868
  "since": "2025-01-01"
869
869
  },
870
870
  "cli:lifeline": {
@@ -872,7 +872,7 @@
872
872
  "type": "cli-command",
873
873
  "domain": "communication",
874
874
  "sourcePath": "src/cli.ts",
875
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
875
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
876
876
  "since": "2025-01-01"
877
877
  },
878
878
  "cli:list": {
@@ -880,7 +880,7 @@
880
880
  "type": "cli-command",
881
881
  "domain": "monitoring",
882
882
  "sourcePath": "src/cli.ts",
883
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
883
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
884
884
  "since": "2025-01-01"
885
885
  },
886
886
  "cli:autostart": {
@@ -888,7 +888,7 @@
888
888
  "type": "cli-command",
889
889
  "domain": "operations",
890
890
  "sourcePath": "src/cli.ts",
891
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
891
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
892
892
  "since": "2025-01-01"
893
893
  },
894
894
  "cli:migrate": {
@@ -896,7 +896,7 @@
896
896
  "type": "cli-command",
897
897
  "domain": "updates",
898
898
  "sourcePath": "src/cli.ts",
899
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
899
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
900
900
  "since": "2025-01-01"
901
901
  },
902
902
  "cli:machines": {
@@ -904,7 +904,7 @@
904
904
  "type": "cli-command",
905
905
  "domain": "coordination",
906
906
  "sourcePath": "src/cli.ts",
907
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
907
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
908
908
  "since": "2025-01-01"
909
909
  },
910
910
  "cli:whoami": {
@@ -912,7 +912,7 @@
912
912
  "type": "cli-command",
913
913
  "domain": "identity",
914
914
  "sourcePath": "src/cli.ts",
915
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
915
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
916
916
  "since": "2025-01-01"
917
917
  },
918
918
  "cli:pair": {
@@ -920,7 +920,7 @@
920
920
  "type": "cli-command",
921
921
  "domain": "coordination",
922
922
  "sourcePath": "src/cli.ts",
923
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
923
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
924
924
  "since": "2025-01-01"
925
925
  },
926
926
  "cli:join": {
@@ -928,7 +928,7 @@
928
928
  "type": "cli-command",
929
929
  "domain": "coordination",
930
930
  "sourcePath": "src/cli.ts",
931
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
931
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
932
932
  "since": "2025-01-01"
933
933
  },
934
934
  "cli:wakeup": {
@@ -936,7 +936,7 @@
936
936
  "type": "cli-command",
937
937
  "domain": "coordination",
938
938
  "sourcePath": "src/cli.ts",
939
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
939
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
940
940
  "since": "2025-01-01"
941
941
  },
942
942
  "cli:leave": {
@@ -944,7 +944,7 @@
944
944
  "type": "cli-command",
945
945
  "domain": "coordination",
946
946
  "sourcePath": "src/cli.ts",
947
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
947
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
948
948
  "since": "2025-01-01"
949
949
  },
950
950
  "cli:doctor": {
@@ -952,7 +952,7 @@
952
952
  "type": "cli-command",
953
953
  "domain": "monitoring",
954
954
  "sourcePath": "src/cli.ts",
955
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
955
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
956
956
  "since": "2025-01-01"
957
957
  },
958
958
  "cli:review": {
@@ -960,7 +960,7 @@
960
960
  "type": "cli-command",
961
961
  "domain": "monitoring",
962
962
  "sourcePath": "src/cli.ts",
963
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
963
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
964
964
  "since": "2025-01-01"
965
965
  },
966
966
  "cli:nuke": {
@@ -968,7 +968,7 @@
968
968
  "type": "cli-command",
969
969
  "domain": "operations",
970
970
  "sourcePath": "src/cli.ts",
971
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
971
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
972
972
  "since": "2025-01-01"
973
973
  },
974
974
  "cli:playbook": {
@@ -976,7 +976,7 @@
976
976
  "type": "cli-command",
977
977
  "domain": "context",
978
978
  "sourcePath": "src/cli.ts",
979
- "contentHash": "300a4557e6ab4e7d0280493a445b10333e4b57f7ef3dea12767703e0fc001f41",
979
+ "contentHash": "a20f6fdbf151bdf22fb8f134fcb8bee872148b34e1f49d1fd962fb47e7200ba1",
980
980
  "since": "2025-01-01"
981
981
  },
982
982
  "template:build-stop-hook.sh": {
@@ -1104,7 +1104,15 @@
1104
1104
  "type": "template",
1105
1105
  "domain": "operations",
1106
1106
  "sourcePath": "src/templates/scripts/instar-watchdog.sh",
1107
- "contentHash": "14ec34c724149dd3df73c6296af39d09a95a74b3d471bea971aa2894c078aed3",
1107
+ "contentHash": "364033171d32f6458b0ebe6c757a55efd578260c3211b2bfe80c5cf56e0ce0ef",
1108
+ "since": "2025-01-01"
1109
+ },
1110
+ "template:instar-worktree-create.sh": {
1111
+ "id": "template:instar-worktree-create.sh",
1112
+ "type": "template",
1113
+ "domain": "operations",
1114
+ "sourcePath": "src/templates/scripts/instar-worktree-create.sh",
1115
+ "contentHash": "2e3f78d72a00a56a9bae9dfe0af0ecc48557e5af2cd59fc6435356784c8e6796",
1108
1116
  "since": "2025-01-01"
1109
1117
  },
1110
1118
  "template:serendipity-capture.sh": {
@@ -1424,7 +1432,7 @@
1424
1432
  "type": "subsystem",
1425
1433
  "domain": "server",
1426
1434
  "sourcePath": "src/server/AgentServer.ts",
1427
- "contentHash": "510f556002273a0ba882a9db9cb99a22b5d96eeb1362570d5e23e12de23bb55f",
1435
+ "contentHash": "6e996e6ea45338ffe019e539eaa738af05d5ad9a1ca35c9d93a8ba198599f759",
1428
1436
  "since": "2025-01-01"
1429
1437
  },
1430
1438
  "subsystem:session-manager": {
@@ -1456,7 +1464,7 @@
1456
1464
  "type": "subsystem",
1457
1465
  "domain": "updates",
1458
1466
  "sourcePath": "src/core/PostUpdateMigrator.ts",
1459
- "contentHash": "5ddc7a551c4e996307288ce70f6faf60337f8571a5e8f1825added7993cd48ce",
1467
+ "contentHash": "a5a854fd1aa35f15f48183ddf263d8a0cb2dc7f67e3c513a92b4acdc0c6d28f1",
1460
1468
  "since": "2025-01-01"
1461
1469
  },
1462
1470
  "subsystem:scheduler": {
@@ -235,6 +235,15 @@ export function generateMemoryMd(agentName: string): string {
235
235
 
236
236
  _Patterns and conventions discovered while working on this project._
237
237
 
238
+ - **Worktree convention.** Create worktrees for collaborator repos with
239
+ \`instar worktree create <branch>\` — never \`git worktree add\` directly
240
+ into a shared checkout, and never hardcode another agent's name into the
241
+ path. The CLI resolves your agent's home automatically and refuses
242
+ unsafe placements. Reason: the macOS sandbox can revoke filesystem
243
+ access mid-session to anything outside the agent home, with no
244
+ in-session recovery path. The agent home (\`~/.instar/agents/<agent>/\`)
245
+ is the one location the sandbox cannot revoke.
246
+
238
247
  ## Tools & Scripts
239
248
 
240
249
  _Custom scripts, jobs, and integrations that have been built._
@@ -1145,6 +1154,14 @@ instar playbook doctor # Verify everything is healthy
1145
1154
  ### Self-Evolution
1146
1155
 
1147
1156
  Record what I learn. Build infrastructure, not one-offs. Grow to meet the user's needs. Every session should leave things slightly better than I found them.
1157
+
1158
+ ## Worktree Convention
1159
+
1160
+ Create worktrees for collaborator repos with \`instar worktree create <branch>\` — it resolves your agent's home automatically. Never hardcode another agent's name or place worktrees inside the shared checkout.
1161
+
1162
+ **Why:** the macOS sandbox can revoke filesystem access to anything outside the agent home mid-session, with no in-session recovery path. The agent home (\`~/.instar/agents/<agent>/\`) is the one location the sandbox cannot revoke. \`instar worktree create\` places the worktree at \`~/.instar/agents/<agent>/.worktrees/<slug>/\` and refuses any other destination. Spec: \`docs/specs/AGENT-WORKTREE-CONVENTION-SPEC.md\`.
1163
+
1164
+ **Caveat — git identity env vars:** the CLI sets per-worktree \`user.name\` / \`user.email\` to \`Instar Agent (<name>)\` / \`<name>@instar.local\`. \`GIT_AUTHOR_NAME\` / \`GIT_COMMITTER_EMAIL\` in the calling environment override that local config. Agents that care about commit attribution must avoid exporting those vars.
1148
1165
  `;
1149
1166
 
1150
1167
  if (hasTelegram) {