harnessed 4.43.0 → 4.43.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.
- package/bin/harnessed-inject-state.mjs +69 -31
- package/bin/harnessed-stop-hook.mjs +67 -22
- package/dist/cli.mjs +68 -25
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -13,35 +13,80 @@ function isAblated(env = process.env) {
|
|
|
13
13
|
return env.HARNESSED_OFF === '1'
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// src/
|
|
16
|
+
// src/platform/platform.ts
|
|
17
17
|
import { existsSync, readFileSync } from 'node:fs'
|
|
18
18
|
import { homedir } from 'node:os'
|
|
19
19
|
import { join } from 'node:path'
|
|
20
|
-
function
|
|
21
|
-
const override = process.env.HARNESSED_ROOT_OVERRIDE
|
|
22
|
-
if (override !== void 0 && override !== '') return override
|
|
20
|
+
function claudeDescriptor(home = homedir()) {
|
|
23
21
|
const claudeHome = join(home, '.claude')
|
|
22
|
+
return {
|
|
23
|
+
id: 'claude',
|
|
24
|
+
homeDir: claudeHome,
|
|
25
|
+
stateRoot: join(claudeHome, 'harnessed'),
|
|
26
|
+
settingsPath: join(claudeHome, 'settings.json'),
|
|
27
|
+
skillsDir: join(claudeHome, 'skills'),
|
|
28
|
+
commandsDir: join(claudeHome, 'commands'),
|
|
29
|
+
pluginsRegistry: join(claudeHome, 'plugins', 'installed_plugins.json'),
|
|
30
|
+
// mcpConfigPath is a SIBLING of `.claude` (`<home>/.claude.json`), based on
|
|
31
|
+
// the same home base — not a child of homeDir.
|
|
32
|
+
mcpConfigPath: join(home, '.claude.json'),
|
|
33
|
+
// claude writes its env keys into JSON settings.json (capability present).
|
|
34
|
+
supportsEnvKeyWrite: true,
|
|
35
|
+
// Claude Code exposes the active session id to Bash-invoked CLI + hooks.
|
|
36
|
+
sessionIdEnv: 'CLAUDE_CODE_SESSION_ID',
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function codexDescriptor(home = homedir()) {
|
|
24
40
|
const codexHome = join(home, '.codex')
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
const configToml = join(codexHome, 'config.toml')
|
|
42
|
+
return {
|
|
43
|
+
id: 'codex',
|
|
44
|
+
homeDir: codexHome,
|
|
45
|
+
stateRoot: join(codexHome, 'harnessed'),
|
|
46
|
+
settingsPath: null,
|
|
47
|
+
// SHARED convention dir, NOT <homeDir>/skills.
|
|
48
|
+
skillsDir: join(home, '.agents', 'skills'),
|
|
49
|
+
commandsDir: join(codexHome, 'prompts'),
|
|
50
|
+
pluginsRegistry: null,
|
|
51
|
+
mcpConfigPath: configToml,
|
|
52
|
+
supportsEnvKeyWrite: false,
|
|
53
|
+
// Measured on codex-cli 0.154: codex shells carry it, equal to hook session_id.
|
|
54
|
+
sessionIdEnv: 'CODEX_SESSION_ID',
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function descriptorById(id, home) {
|
|
58
|
+
if (id === 'claude') return claudeDescriptor(home)
|
|
59
|
+
if (id === 'codex') return codexDescriptor(home)
|
|
60
|
+
return void 0
|
|
61
|
+
}
|
|
62
|
+
function detectPlatform(home = homedir()) {
|
|
63
|
+
const resolved = resolveHost(home)
|
|
64
|
+
const override = process.env.HARNESSED_ROOT_OVERRIDE
|
|
65
|
+
if (override !== void 0 && override !== '') return { ...resolved, stateRoot: override }
|
|
66
|
+
return resolved
|
|
67
|
+
}
|
|
68
|
+
function resolveHost(home) {
|
|
69
|
+
const base = claudeDescriptor(home)
|
|
70
|
+
const envPlatform = process.env.HARNESSED_PLATFORM
|
|
71
|
+
if (envPlatform !== void 0 && envPlatform !== '') {
|
|
72
|
+
const d = descriptorById(envPlatform, home)
|
|
73
|
+
if (d) return d
|
|
74
|
+
}
|
|
75
|
+
const inClaude = Boolean(process.env.CLAUDE_CODE_SESSION_ID?.trim())
|
|
76
|
+
const inCodex = Boolean(process.env.CODEX_SESSION_ID?.trim())
|
|
77
|
+
if (inClaude !== inCodex) return inClaude ? base : codexDescriptor(home)
|
|
78
|
+
for (const pinRoot of [codexDescriptor(home).stateRoot, base.stateRoot]) {
|
|
79
|
+
try {
|
|
80
|
+
const d = descriptorById(readFileSync(join(pinRoot, '.platform'), 'utf8').trim(), home)
|
|
81
|
+
if (d) return d
|
|
82
|
+
} catch {}
|
|
35
83
|
}
|
|
36
84
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
if (existsSync(claudeHome)) return join(claudeHome, 'harnessed')
|
|
42
|
-
if (existsSync(codexHome)) return join(codexHome, 'harnessed')
|
|
85
|
+
if (existsSync(base.homeDir)) return base
|
|
86
|
+
const codex = codexDescriptor(home)
|
|
87
|
+
if (existsSync(codex.homeDir)) return codex
|
|
43
88
|
} catch {}
|
|
44
|
-
return
|
|
89
|
+
return base
|
|
45
90
|
}
|
|
46
91
|
|
|
47
92
|
// src/checkpoint/injectCache.ts
|
|
@@ -449,14 +494,6 @@ function repoKey(cwd) {
|
|
|
449
494
|
}
|
|
450
495
|
return resolve(cwd)
|
|
451
496
|
}
|
|
452
|
-
function harnessedRoot() {
|
|
453
|
-
return hookStateRoot()
|
|
454
|
-
}
|
|
455
|
-
function sessionIdEnvName() {
|
|
456
|
-
const platform = (process.env.HARNESSED_PLATFORM || 'claude').trim()
|
|
457
|
-
if (platform === 'codex') return null
|
|
458
|
-
return 'CLAUDE_CODE_SESSION_ID'
|
|
459
|
-
}
|
|
460
497
|
function readWorkflow(root, keys) {
|
|
461
498
|
let wf = null
|
|
462
499
|
let intent = null
|
|
@@ -508,13 +545,14 @@ function shouldEmitPc(root, repoRoot, sid, pc) {
|
|
|
508
545
|
function main() {
|
|
509
546
|
if (isAblated()) return
|
|
510
547
|
try {
|
|
511
|
-
const
|
|
548
|
+
const platform = detectPlatform()
|
|
549
|
+
const root = platform.stateRoot
|
|
512
550
|
if (process.argv.includes('--invalidate')) {
|
|
513
551
|
invalidateInjectCache(root)
|
|
514
552
|
return
|
|
515
553
|
}
|
|
516
554
|
const key = repoKey(process.cwd())
|
|
517
|
-
const envName =
|
|
555
|
+
const envName = platform.sessionIdEnv
|
|
518
556
|
const sid = envName ? process.env[envName]?.trim() : void 0
|
|
519
557
|
const { wf, intent, ledgerAgeMs } = readWorkflow(root, sid ? [`${key}::${sid}`, key] : [key])
|
|
520
558
|
let learningsMd = ''
|
|
@@ -18,35 +18,80 @@ function isAblated(env = process.env) {
|
|
|
18
18
|
return env.HARNESSED_OFF === '1'
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
// src/
|
|
21
|
+
// src/platform/platform.ts
|
|
22
22
|
import { existsSync, readFileSync } from 'node:fs'
|
|
23
23
|
import { homedir } from 'node:os'
|
|
24
24
|
import { join } from 'node:path'
|
|
25
|
-
function
|
|
26
|
-
const override = process.env.HARNESSED_ROOT_OVERRIDE
|
|
27
|
-
if (override !== void 0 && override !== '') return override
|
|
25
|
+
function claudeDescriptor(home = homedir()) {
|
|
28
26
|
const claudeHome = join(home, '.claude')
|
|
27
|
+
return {
|
|
28
|
+
id: 'claude',
|
|
29
|
+
homeDir: claudeHome,
|
|
30
|
+
stateRoot: join(claudeHome, 'harnessed'),
|
|
31
|
+
settingsPath: join(claudeHome, 'settings.json'),
|
|
32
|
+
skillsDir: join(claudeHome, 'skills'),
|
|
33
|
+
commandsDir: join(claudeHome, 'commands'),
|
|
34
|
+
pluginsRegistry: join(claudeHome, 'plugins', 'installed_plugins.json'),
|
|
35
|
+
// mcpConfigPath is a SIBLING of `.claude` (`<home>/.claude.json`), based on
|
|
36
|
+
// the same home base — not a child of homeDir.
|
|
37
|
+
mcpConfigPath: join(home, '.claude.json'),
|
|
38
|
+
// claude writes its env keys into JSON settings.json (capability present).
|
|
39
|
+
supportsEnvKeyWrite: true,
|
|
40
|
+
// Claude Code exposes the active session id to Bash-invoked CLI + hooks.
|
|
41
|
+
sessionIdEnv: 'CLAUDE_CODE_SESSION_ID',
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function codexDescriptor(home = homedir()) {
|
|
29
45
|
const codexHome = join(home, '.codex')
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
const configToml = join(codexHome, 'config.toml')
|
|
47
|
+
return {
|
|
48
|
+
id: 'codex',
|
|
49
|
+
homeDir: codexHome,
|
|
50
|
+
stateRoot: join(codexHome, 'harnessed'),
|
|
51
|
+
settingsPath: null,
|
|
52
|
+
// SHARED convention dir, NOT <homeDir>/skills.
|
|
53
|
+
skillsDir: join(home, '.agents', 'skills'),
|
|
54
|
+
commandsDir: join(codexHome, 'prompts'),
|
|
55
|
+
pluginsRegistry: null,
|
|
56
|
+
mcpConfigPath: configToml,
|
|
57
|
+
supportsEnvKeyWrite: false,
|
|
58
|
+
// Measured on codex-cli 0.154: codex shells carry it, equal to hook session_id.
|
|
59
|
+
sessionIdEnv: 'CODEX_SESSION_ID',
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function descriptorById(id, home) {
|
|
63
|
+
if (id === 'claude') return claudeDescriptor(home)
|
|
64
|
+
if (id === 'codex') return codexDescriptor(home)
|
|
65
|
+
return void 0
|
|
66
|
+
}
|
|
67
|
+
function detectPlatform(home = homedir()) {
|
|
68
|
+
const resolved = resolveHost(home)
|
|
69
|
+
const override = process.env.HARNESSED_ROOT_OVERRIDE
|
|
70
|
+
if (override !== void 0 && override !== '') return { ...resolved, stateRoot: override }
|
|
71
|
+
return resolved
|
|
72
|
+
}
|
|
73
|
+
function resolveHost(home) {
|
|
74
|
+
const base = claudeDescriptor(home)
|
|
75
|
+
const envPlatform = process.env.HARNESSED_PLATFORM
|
|
76
|
+
if (envPlatform !== void 0 && envPlatform !== '') {
|
|
77
|
+
const d = descriptorById(envPlatform, home)
|
|
78
|
+
if (d) return d
|
|
79
|
+
}
|
|
80
|
+
const inClaude = Boolean(process.env.CLAUDE_CODE_SESSION_ID?.trim())
|
|
81
|
+
const inCodex = Boolean(process.env.CODEX_SESSION_ID?.trim())
|
|
82
|
+
if (inClaude !== inCodex) return inClaude ? base : codexDescriptor(home)
|
|
83
|
+
for (const pinRoot of [codexDescriptor(home).stateRoot, base.stateRoot]) {
|
|
84
|
+
try {
|
|
85
|
+
const d = descriptorById(readFileSync(join(pinRoot, '.platform'), 'utf8').trim(), home)
|
|
86
|
+
if (d) return d
|
|
87
|
+
} catch {}
|
|
40
88
|
}
|
|
41
89
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
if (existsSync(claudeHome)) return join(claudeHome, 'harnessed')
|
|
47
|
-
if (existsSync(codexHome)) return join(codexHome, 'harnessed')
|
|
90
|
+
if (existsSync(base.homeDir)) return base
|
|
91
|
+
const codex = codexDescriptor(home)
|
|
92
|
+
if (existsSync(codex.homeDir)) return codex
|
|
48
93
|
} catch {}
|
|
49
|
-
return
|
|
94
|
+
return base
|
|
50
95
|
}
|
|
51
96
|
|
|
52
97
|
// src/checkpoint/modeBDetect.ts
|
|
@@ -82,7 +127,7 @@ function detectModeB(content) {
|
|
|
82
127
|
// src/checkpoint/stopHookMain.ts
|
|
83
128
|
var MAX_RETRIES = 2
|
|
84
129
|
function stateRoot() {
|
|
85
|
-
return
|
|
130
|
+
return detectPlatform().stateRoot
|
|
86
131
|
}
|
|
87
132
|
function messageSig(content) {
|
|
88
133
|
const text = content
|
package/dist/cli.mjs
CHANGED
|
@@ -38,7 +38,7 @@ var init_package = __esm({
|
|
|
38
38
|
"package.json"() {
|
|
39
39
|
package_default = {
|
|
40
40
|
name: "harnessed",
|
|
41
|
-
version: "4.43.
|
|
41
|
+
version: "4.43.1",
|
|
42
42
|
description: "AI coding harness package manager + composition orchestrator",
|
|
43
43
|
type: "module",
|
|
44
44
|
license: "Apache-2.0",
|
|
@@ -182,15 +182,15 @@ function codexDescriptor(home = homedir()) {
|
|
|
182
182
|
id: "codex",
|
|
183
183
|
homeDir: codexHome,
|
|
184
184
|
stateRoot: join(codexHome, "harnessed"),
|
|
185
|
-
settingsPath:
|
|
185
|
+
settingsPath: null,
|
|
186
186
|
// SHARED convention dir, NOT <homeDir>/skills.
|
|
187
187
|
skillsDir: join(home, ".agents", "skills"),
|
|
188
188
|
commandsDir: join(codexHome, "prompts"),
|
|
189
189
|
pluginsRegistry: null,
|
|
190
190
|
mcpConfigPath: configToml,
|
|
191
191
|
supportsEnvKeyWrite: false,
|
|
192
|
-
//
|
|
193
|
-
sessionIdEnv:
|
|
192
|
+
// Measured on codex-cli 0.154: codex shells carry it, equal to hook session_id.
|
|
193
|
+
sessionIdEnv: "CODEX_SESSION_ID"
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
function descriptorById(id, home) {
|
|
@@ -199,19 +199,27 @@ function descriptorById(id, home) {
|
|
|
199
199
|
return void 0;
|
|
200
200
|
}
|
|
201
201
|
function detectPlatform(home = homedir()) {
|
|
202
|
-
const
|
|
202
|
+
const resolved = resolveHost(home);
|
|
203
203
|
const override = process.env.HARNESSED_ROOT_OVERRIDE;
|
|
204
|
-
if (override !== void 0 && override !== "") return { ...
|
|
204
|
+
if (override !== void 0 && override !== "") return { ...resolved, stateRoot: override };
|
|
205
|
+
return resolved;
|
|
206
|
+
}
|
|
207
|
+
function resolveHost(home) {
|
|
208
|
+
const base = claudeDescriptor(home);
|
|
205
209
|
const envPlatform = process.env.HARNESSED_PLATFORM;
|
|
206
210
|
if (envPlatform !== void 0 && envPlatform !== "") {
|
|
207
211
|
const d = descriptorById(envPlatform, home);
|
|
208
212
|
if (d) return d;
|
|
209
213
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
214
|
+
const inClaude = Boolean(process.env.CLAUDE_CODE_SESSION_ID?.trim());
|
|
215
|
+
const inCodex = Boolean(process.env.CODEX_SESSION_ID?.trim());
|
|
216
|
+
if (inClaude !== inCodex) return inClaude ? base : codexDescriptor(home);
|
|
217
|
+
for (const pinRoot of [codexDescriptor(home).stateRoot, base.stateRoot]) {
|
|
218
|
+
try {
|
|
219
|
+
const d = descriptorById(readFileSync(join(pinRoot, ".platform"), "utf8").trim(), home);
|
|
220
|
+
if (d) return d;
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
215
223
|
}
|
|
216
224
|
try {
|
|
217
225
|
if (existsSync(base.homeDir)) return base;
|
|
@@ -2493,6 +2501,7 @@ async function isPluginRegistered(pluginName) {
|
|
|
2493
2501
|
}
|
|
2494
2502
|
}
|
|
2495
2503
|
for (const path of [getSettingsPath(), getMcpConfigPath()]) {
|
|
2504
|
+
if (path === null) continue;
|
|
2496
2505
|
try {
|
|
2497
2506
|
const raw = await readFile(path, "utf8");
|
|
2498
2507
|
const parsed = JSON.parse(raw);
|
|
@@ -2513,6 +2522,8 @@ var init_readClaudeConfig = __esm({
|
|
|
2513
2522
|
});
|
|
2514
2523
|
async function mergeSettingsEnvKey(key, value, opts = {}) {
|
|
2515
2524
|
const path = getSettingsPath();
|
|
2525
|
+
if (path === null)
|
|
2526
|
+
return { outcome: "warn", message: `no settings file on ${detectPlatform().id} \u2014 skipped` };
|
|
2516
2527
|
let raw;
|
|
2517
2528
|
try {
|
|
2518
2529
|
raw = await readFile(path, "utf8");
|
|
@@ -2644,7 +2655,8 @@ function planEnvExemption(existing) {
|
|
|
2644
2655
|
async function readCurrentEnvValue(deps = {}) {
|
|
2645
2656
|
const readSettings = deps.readSettings ?? (async () => {
|
|
2646
2657
|
try {
|
|
2647
|
-
|
|
2658
|
+
const path = getSettingsPath();
|
|
2659
|
+
return path === null ? null : await readFile(path, "utf8");
|
|
2648
2660
|
} catch {
|
|
2649
2661
|
return null;
|
|
2650
2662
|
}
|
|
@@ -2668,7 +2680,7 @@ function previewLines(existing, newValue) {
|
|
|
2668
2680
|
const change = existing === void 0 ? ` + env.${EXEMPT_ENV_KEY} = "${newValue}"` : ` ~ env.${EXEMPT_ENV_KEY}: "${existing}" \u2192 "${newValue}"`;
|
|
2669
2681
|
return [
|
|
2670
2682
|
`[harnessed] GateGuard \u2194 evidence-guard conflict \u2014 sanctioned fix available:`,
|
|
2671
|
-
` file: ${getSettingsPath()}`,
|
|
2683
|
+
` file: ${getSettingsPath() ?? "(no settings file on this platform)"}`,
|
|
2672
2684
|
change,
|
|
2673
2685
|
` backup: settings.json.<timestamp>.bak under the harnessed backups dir (written first)`
|
|
2674
2686
|
];
|
|
@@ -2764,7 +2776,8 @@ function defaultDeps() {
|
|
|
2764
2776
|
env: process.env,
|
|
2765
2777
|
readSettings: async () => {
|
|
2766
2778
|
try {
|
|
2767
|
-
|
|
2779
|
+
const path = getSettingsPath();
|
|
2780
|
+
return path === null ? null : await readFile(path, "utf8");
|
|
2768
2781
|
} catch {
|
|
2769
2782
|
return null;
|
|
2770
2783
|
}
|
|
@@ -4798,7 +4811,7 @@ async function checkAgentTeams() {
|
|
|
4798
4811
|
let settingsOn = false;
|
|
4799
4812
|
try {
|
|
4800
4813
|
const path = getSettingsPath();
|
|
4801
|
-
const raw = await readFile(path, "utf8");
|
|
4814
|
+
const raw = path === null ? "{}" : await readFile(path, "utf8");
|
|
4802
4815
|
const data = JSON.parse(raw);
|
|
4803
4816
|
settingsValue = data.env?.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS;
|
|
4804
4817
|
settingsOn = settingsValue === "1";
|
|
@@ -5015,7 +5028,8 @@ async function probeSearchMcpKey(server) {
|
|
|
5015
5028
|
} catch {
|
|
5016
5029
|
}
|
|
5017
5030
|
try {
|
|
5018
|
-
const
|
|
5031
|
+
const path = getSettingsPath();
|
|
5032
|
+
const raw = path === null ? "{}" : await readFile(path, "utf8");
|
|
5019
5033
|
const parsed = JSON.parse(raw);
|
|
5020
5034
|
if (parsed?.env && nonEmpty(parsed.env[envVar])) {
|
|
5021
5035
|
return { server, envVar, present: true, source: "settings-env" };
|
|
@@ -5953,6 +5967,12 @@ function checkStaleHooks(deps) {
|
|
|
5953
5967
|
}
|
|
5954
5968
|
});
|
|
5955
5969
|
const exists = deps?.exists ?? existsSync;
|
|
5970
|
+
if (settingsPath === null)
|
|
5971
|
+
return {
|
|
5972
|
+
name: NAME,
|
|
5973
|
+
status: "pass",
|
|
5974
|
+
message: `no settings file on ${detectPlatform().id} \u2014 skipped`
|
|
5975
|
+
};
|
|
5956
5976
|
const raw = readText(settingsPath);
|
|
5957
5977
|
if (raw === null) return { name: NAME, status: "pass", message: "no settings.json" };
|
|
5958
5978
|
let data;
|
|
@@ -6145,6 +6165,12 @@ function checkInjectInvalidate(deps) {
|
|
|
6145
6165
|
return null;
|
|
6146
6166
|
}
|
|
6147
6167
|
});
|
|
6168
|
+
if (settingsPath === null)
|
|
6169
|
+
return {
|
|
6170
|
+
name: NAME3,
|
|
6171
|
+
status: "pass",
|
|
6172
|
+
message: `no settings file on ${detectPlatform().id} \u2014 skipped`
|
|
6173
|
+
};
|
|
6148
6174
|
const raw = readText(settingsPath);
|
|
6149
6175
|
if (raw === null) return { name: NAME3, status: "pass", message: "no settings.json" };
|
|
6150
6176
|
let hooks;
|
|
@@ -7411,6 +7437,7 @@ var init_ccHookAdd2 = __esm({
|
|
|
7411
7437
|
return { ok: false, phase: "preflight", error: e };
|
|
7412
7438
|
}
|
|
7413
7439
|
const settingsPath = getSettingsPath();
|
|
7440
|
+
if (settingsPath === null) return { aborted: true, reason: "platform-mismatch" };
|
|
7414
7441
|
let existing;
|
|
7415
7442
|
try {
|
|
7416
7443
|
existing = await readFile(settingsPath, "utf8");
|
|
@@ -7988,11 +8015,14 @@ async function isAlreadyInstalled(ctx, opts = {}) {
|
|
|
7988
8015
|
if (ctx.opts.dryRun) return false;
|
|
7989
8016
|
const installCfg = ctx.manifest.spec.install;
|
|
7990
8017
|
if (installCfg.method === "cc-hook-add") {
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
8018
|
+
const settingsPath = getSettingsPath();
|
|
8019
|
+
let raw = null;
|
|
8020
|
+
if (settingsPath !== null) {
|
|
8021
|
+
try {
|
|
8022
|
+
raw = await readFile(settingsPath, "utf8");
|
|
8023
|
+
} catch {
|
|
8024
|
+
raw = null;
|
|
8025
|
+
}
|
|
7996
8026
|
}
|
|
7997
8027
|
return detectCcHookInstalled(
|
|
7998
8028
|
raw,
|
|
@@ -15344,10 +15374,21 @@ async function applyPlatformOption(platform, persist) {
|
|
|
15344
15374
|
}
|
|
15345
15375
|
process.env.HARNESSED_PLATFORM = platform;
|
|
15346
15376
|
if (!persist) return;
|
|
15347
|
-
const
|
|
15377
|
+
const [own, other] = platform === "codex" ? [codexDescriptor().stateRoot, claudeDescriptor().stateRoot] : [claudeDescriptor().stateRoot, codexDescriptor().stateRoot];
|
|
15348
15378
|
try {
|
|
15349
|
-
await mkdir(
|
|
15350
|
-
await writeFile(join(
|
|
15379
|
+
await mkdir(own, { recursive: true });
|
|
15380
|
+
await writeFile(join(own, ".platform"), platform, "utf8");
|
|
15381
|
+
const otherPin = join(other, ".platform");
|
|
15382
|
+
let existing;
|
|
15383
|
+
try {
|
|
15384
|
+
const raw = await readFile(otherPin, "utf8");
|
|
15385
|
+
existing = typeof raw === "string" ? raw.trim() : void 0;
|
|
15386
|
+
} catch {
|
|
15387
|
+
existing = void 0;
|
|
15388
|
+
}
|
|
15389
|
+
if (existing !== void 0 && existing !== platform) {
|
|
15390
|
+
await writeFile(otherPin, platform, "utf8");
|
|
15391
|
+
}
|
|
15351
15392
|
} catch (e) {
|
|
15352
15393
|
console.warn(` [--platform] could not persist .platform pin (${e.message})`);
|
|
15353
15394
|
}
|
|
@@ -15820,6 +15861,7 @@ var uninstallCcHookAdd = async (ctx) => {
|
|
|
15820
15861
|
const abort = dryRunGate(ctx);
|
|
15821
15862
|
if (abort) return abort;
|
|
15822
15863
|
const settingsPath = getSettingsPath();
|
|
15864
|
+
if (settingsPath === null) return { ok: true, removedPaths: [] };
|
|
15823
15865
|
let existing;
|
|
15824
15866
|
try {
|
|
15825
15867
|
existing = await readFile(settingsPath, "utf8");
|
|
@@ -16188,6 +16230,7 @@ async function discoverCommandFiles(commandsDir) {
|
|
|
16188
16230
|
return owned;
|
|
16189
16231
|
}
|
|
16190
16232
|
async function checkSettingsEnv(settingsPath) {
|
|
16233
|
+
if (settingsPath === null) return { hasAgentTeams: false, hasUserLang: false, staleHooks: 0 };
|
|
16191
16234
|
try {
|
|
16192
16235
|
const raw = await readFile(settingsPath, "utf8");
|
|
16193
16236
|
const data = JSON.parse(raw);
|
|
@@ -16319,7 +16362,7 @@ async function runUnifiedUninstall(home, dryRun) {
|
|
|
16319
16362
|
}
|
|
16320
16363
|
let removedSettings = false;
|
|
16321
16364
|
let removedHooks = 0;
|
|
16322
|
-
if (hasSettingsChanges || staleHooks > 0) {
|
|
16365
|
+
if (settingsPath !== null && (hasSettingsChanges || staleHooks > 0)) {
|
|
16323
16366
|
try {
|
|
16324
16367
|
const r = await removeSettingsFootprint(settingsPath);
|
|
16325
16368
|
removedSettings = r.envRemoved;
|