harnessed 4.48.0 → 4.49.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/README-en.md +1 -0
- package/README.md +1 -0
- package/bin/harnessed-check-docs.mjs +452 -0
- package/bin/harnessed-inject-state.mjs +72 -16
- package/bin/harnessed-stop-hook.mjs +51 -10
- package/dist/cli.mjs +858 -243
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/messages/en.json +2 -0
- package/messages/zh-Hans.json +2 -0
- package/package.json +2 -1
|
@@ -59,10 +59,15 @@ function codexDescriptor(home = homedir()) {
|
|
|
59
59
|
sessionIdEnv: 'CODEX_SESSION_ID',
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
var HOST_IDS = ['claude', 'codex']
|
|
63
|
+
function isHostId(id) {
|
|
64
|
+
return HOST_IDS.includes(id)
|
|
65
|
+
}
|
|
66
|
+
function descriptorFor(id, home = homedir()) {
|
|
67
|
+
return id === 'codex' ? codexDescriptor(home) : claudeDescriptor(home)
|
|
68
|
+
}
|
|
62
69
|
function descriptorById(id, home) {
|
|
63
|
-
|
|
64
|
-
if (id === 'codex') return codexDescriptor(home)
|
|
65
|
-
return void 0
|
|
70
|
+
return isHostId(id) ? descriptorFor(id, home) : void 0
|
|
66
71
|
}
|
|
67
72
|
function detectPlatform(home = homedir()) {
|
|
68
73
|
const resolved = resolveHost(home)
|
|
@@ -71,27 +76,63 @@ function detectPlatform(home = homedir()) {
|
|
|
71
76
|
return resolved
|
|
72
77
|
}
|
|
73
78
|
function resolveHost(home) {
|
|
79
|
+
return resolveHostWithReason(home).descriptor
|
|
80
|
+
}
|
|
81
|
+
function resolveHostWithReason(home = homedir()) {
|
|
74
82
|
const base = claudeDescriptor(home)
|
|
83
|
+
const skipped = []
|
|
75
84
|
const envPlatform = process.env.HARNESSED_PLATFORM
|
|
76
85
|
if (envPlatform !== void 0 && envPlatform !== '') {
|
|
77
86
|
const d = descriptorById(envPlatform, home)
|
|
78
|
-
if (d)
|
|
87
|
+
if (d) {
|
|
88
|
+
return {
|
|
89
|
+
descriptor: d,
|
|
90
|
+
reason: { kind: 'env-platform', envVar: 'HARNESSED_PLATFORM', value: envPlatform },
|
|
91
|
+
skipped,
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
skipped.push({ kind: 'env-platform-unknown', envVar: 'HARNESSED_PLATFORM', value: envPlatform })
|
|
79
95
|
}
|
|
80
96
|
const inClaude = Boolean(process.env.CLAUDE_CODE_SESSION_ID?.trim())
|
|
81
97
|
const inCodex = Boolean(process.env.CODEX_SESSION_ID?.trim())
|
|
82
|
-
if (inClaude !== inCodex)
|
|
98
|
+
if (inClaude !== inCodex) {
|
|
99
|
+
return {
|
|
100
|
+
descriptor: inClaude ? base : codexDescriptor(home),
|
|
101
|
+
reason: {
|
|
102
|
+
kind: 'host-session-env',
|
|
103
|
+
envVar: inClaude ? 'CLAUDE_CODE_SESSION_ID' : 'CODEX_SESSION_ID',
|
|
104
|
+
},
|
|
105
|
+
skipped,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (inClaude && inCodex) skipped.push({ kind: 'host-session-env-ambiguous' })
|
|
83
109
|
for (const pinRoot of [codexDescriptor(home).stateRoot, base.stateRoot]) {
|
|
110
|
+
const pinPath = join(pinRoot, '.platform')
|
|
84
111
|
try {
|
|
85
|
-
const
|
|
86
|
-
|
|
112
|
+
const value = readFileSync(pinPath, 'utf8').trim()
|
|
113
|
+
const d = descriptorById(value, home)
|
|
114
|
+
if (d) return { descriptor: d, reason: { kind: 'platform-pin', pinPath, value }, skipped }
|
|
115
|
+
skipped.push({ kind: 'platform-pin-unknown', pinPath, value })
|
|
87
116
|
} catch {}
|
|
88
117
|
}
|
|
89
118
|
try {
|
|
90
|
-
if (existsSync(base.homeDir))
|
|
119
|
+
if (existsSync(base.homeDir)) {
|
|
120
|
+
return {
|
|
121
|
+
descriptor: base,
|
|
122
|
+
reason: { kind: 'directory-probe', probedDir: base.homeDir },
|
|
123
|
+
skipped,
|
|
124
|
+
}
|
|
125
|
+
}
|
|
91
126
|
const codex = codexDescriptor(home)
|
|
92
|
-
if (existsSync(codex.homeDir))
|
|
127
|
+
if (existsSync(codex.homeDir)) {
|
|
128
|
+
return {
|
|
129
|
+
descriptor: codex,
|
|
130
|
+
reason: { kind: 'directory-probe', probedDir: codex.homeDir },
|
|
131
|
+
skipped,
|
|
132
|
+
}
|
|
133
|
+
}
|
|
93
134
|
} catch {}
|
|
94
|
-
return base
|
|
135
|
+
return { descriptor: base, reason: { kind: 'fallback' }, skipped }
|
|
95
136
|
}
|
|
96
137
|
|
|
97
138
|
// src/checkpoint/modeBDetect.ts
|