harnessed 5.0.12 → 5.0.13
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/CHANGELOG.md +18 -0
- package/README-en.md +1 -0
- package/README-zh.md +1 -0
- package/README.md +1 -0
- package/bin/harnessed-check-docs.mjs +15 -0
- package/bin/harnessed-update-reminder-worker.mjs +2598 -134
- package/bin/harnessed-update-reminder.mjs +636 -61
- package/dist/cli.mjs +1524 -589
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/messages/en.json +15 -1
- package/messages/zh-Hans.json +15 -1
- package/package.json +1 -1
- package/workflows/auto/SKILL.md +10 -18
- package/workflows/auto/SKILL.zh-Hans.md +8 -18
- package/workflows/discuss/auto/SKILL.md +4 -7
- package/workflows/discuss/auto/SKILL.zh-Hans.md +2 -7
- package/workflows/discuss/phase/SKILL.md +4 -7
- package/workflows/discuss/phase/SKILL.zh-Hans.md +2 -7
- package/workflows/discuss/strategic/SKILL.md +4 -8
- package/workflows/discuss/strategic/SKILL.zh-Hans.md +2 -8
- package/workflows/discuss/subtask/SKILL.md +4 -7
- package/workflows/discuss/subtask/SKILL.zh-Hans.md +2 -7
- package/workflows/harnessed-update/SKILL.md +9 -8
- package/workflows/harnessed-update/SKILL.zh-Hans.md +7 -8
- package/workflows/host-primitives.yaml +8 -8
- package/workflows/host-primitives.zh-Hans.yaml +8 -8
- package/workflows/plan/ai-integration/SKILL.md +7 -7
- package/workflows/plan/ai-integration/SKILL.zh-Hans.md +7 -7
- package/workflows/plan/architecture/SKILL.md +7 -13
- package/workflows/plan/architecture/SKILL.zh-Hans.md +7 -13
- package/workflows/plan/auto/SKILL.md +8 -14
- package/workflows/plan/auto/SKILL.zh-Hans.md +8 -14
- package/workflows/plan/phase/SKILL.md +7 -13
- package/workflows/plan/phase/SKILL.zh-Hans.md +7 -13
- package/workflows/plan/secure/SKILL.md +7 -7
- package/workflows/plan/secure/SKILL.zh-Hans.md +7 -7
- package/workflows/plan/spec/SKILL.md +7 -7
- package/workflows/plan/spec/SKILL.zh-Hans.md +7 -7
- package/workflows/plan/ui/SKILL.md +7 -7
- package/workflows/plan/ui/SKILL.zh-Hans.md +7 -7
- package/workflows/research/SKILL.md +7 -7
- package/workflows/research/SKILL.zh-Hans.md +7 -7
- package/workflows/retro/SKILL.md +8 -15
- package/workflows/retro/SKILL.zh-Hans.md +7 -15
- package/workflows/ship/auto/SKILL.md +8 -14
- package/workflows/ship/auto/SKILL.zh-Hans.md +8 -14
- package/workflows/ship/preflight/SKILL.md +7 -9
- package/workflows/ship/preflight/SKILL.zh-Hans.md +7 -9
- package/workflows/task/auto/SKILL.md +8 -15
- package/workflows/task/auto/SKILL.zh-Hans.md +8 -15
- package/workflows/task/clarify/SKILL.md +2 -10
- package/workflows/task/clarify/SKILL.zh-Hans.md +2 -10
- package/workflows/task/code/SKILL.md +7 -15
- package/workflows/task/code/SKILL.zh-Hans.md +7 -15
- package/workflows/task/deliver/SKILL.md +7 -17
- package/workflows/task/deliver/SKILL.zh-Hans.md +7 -17
- package/workflows/task/test/SKILL.md +7 -14
- package/workflows/task/test/SKILL.zh-Hans.md +7 -14
- package/workflows/verify/auto/SKILL.md +9 -14
- package/workflows/verify/auto/SKILL.zh-Hans.md +9 -14
- package/workflows/verify/code-review/SKILL.md +8 -13
- package/workflows/verify/code-review/SKILL.zh-Hans.md +8 -13
- package/workflows/verify/design/SKILL.md +8 -12
- package/workflows/verify/design/SKILL.zh-Hans.md +7 -12
- package/workflows/verify/eval-review/SKILL.md +8 -12
- package/workflows/verify/eval-review/SKILL.zh-Hans.md +7 -12
- package/workflows/verify/multispec/SKILL.md +8 -15
- package/workflows/verify/multispec/SKILL.zh-Hans.md +7 -15
- package/workflows/verify/paranoid/SKILL.md +7 -14
- package/workflows/verify/paranoid/SKILL.zh-Hans.md +7 -14
- package/workflows/verify/progress/SKILL.md +8 -13
- package/workflows/verify/progress/SKILL.zh-Hans.md +8 -13
- package/workflows/verify/qa/SKILL.md +7 -13
- package/workflows/verify/qa/SKILL.zh-Hans.md +7 -13
- package/workflows/verify/second-opinion/SKILL.md +8 -12
- package/workflows/verify/second-opinion/SKILL.zh-Hans.md +7 -12
- package/workflows/verify/security/SKILL.md +8 -12
- package/workflows/verify/security/SKILL.zh-Hans.md +7 -12
- package/workflows/verify/simplify/SKILL.md +8 -12
- package/workflows/verify/simplify/SKILL.zh-Hans.md +7 -12
- package/workflows/verify/validate-phase/SKILL.md +8 -12
- package/workflows/verify/validate-phase/SKILL.zh-Hans.md +7 -12
|
@@ -14,7 +14,7 @@ var init_package = __esm({
|
|
|
14
14
|
'package.json'() {
|
|
15
15
|
package_default = {
|
|
16
16
|
name: 'harnessed',
|
|
17
|
-
version: '5.0.
|
|
17
|
+
version: '5.0.13',
|
|
18
18
|
description: 'AI coding harness package manager + composition orchestrator',
|
|
19
19
|
type: 'module',
|
|
20
20
|
license: 'Apache-2.0',
|
|
@@ -127,6 +127,550 @@ var init_package = __esm({
|
|
|
127
127
|
},
|
|
128
128
|
})
|
|
129
129
|
|
|
130
|
+
// src/cli/lib/autoUpdateStatus.ts
|
|
131
|
+
import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs'
|
|
132
|
+
import { dirname, join } from 'node:path'
|
|
133
|
+
function autoUpdateStatusPath(stateRoot) {
|
|
134
|
+
return join(stateRoot, AUTO_UPDATE_STATUS_FILE)
|
|
135
|
+
}
|
|
136
|
+
function isFiniteNumber(value) {
|
|
137
|
+
return typeof value === 'number' && Number.isFinite(value)
|
|
138
|
+
}
|
|
139
|
+
function isPlainObject(value) {
|
|
140
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
141
|
+
}
|
|
142
|
+
function isValidDateMs(value) {
|
|
143
|
+
return isFiniteNumber(value) && !Number.isNaN(new Date(value).getTime())
|
|
144
|
+
}
|
|
145
|
+
function parseProgress(value) {
|
|
146
|
+
if (!isPlainObject(value)) return null
|
|
147
|
+
const { received, total, updatedAt } = value
|
|
148
|
+
if (!isFiniteNumber(received) || received < 0) return null
|
|
149
|
+
if (!isFiniteNumber(total) || total < 0) return null
|
|
150
|
+
if (!isValidDateMs(updatedAt)) return null
|
|
151
|
+
return { received, total, updatedAt }
|
|
152
|
+
}
|
|
153
|
+
function parseResult(value) {
|
|
154
|
+
if (!isPlainObject(value)) return null
|
|
155
|
+
const { version, status, reason, message, at } = value
|
|
156
|
+
if (typeof version !== 'string') return null
|
|
157
|
+
if (typeof status !== 'string' || !RESULT_STATUSES.includes(status)) return null
|
|
158
|
+
if (reason !== void 0 && typeof reason !== 'string') return null
|
|
159
|
+
if (message !== void 0 && typeof message !== 'string') return null
|
|
160
|
+
if (!isValidDateMs(at)) return null
|
|
161
|
+
const result = { version, status, at }
|
|
162
|
+
if (typeof reason === 'string') result.reason = reason
|
|
163
|
+
if (typeof message === 'string') result.message = message
|
|
164
|
+
return result
|
|
165
|
+
}
|
|
166
|
+
function parseNotice(value) {
|
|
167
|
+
if (!isPlainObject(value)) return null
|
|
168
|
+
const { from, to, changelog, restart, at } = value
|
|
169
|
+
if (typeof from !== 'string' || typeof to !== 'string') return null
|
|
170
|
+
if (typeof changelog !== 'string' || typeof restart !== 'string') return null
|
|
171
|
+
if (!isValidDateMs(at)) return null
|
|
172
|
+
const consumedAt =
|
|
173
|
+
typeof value.consumedAt === 'number' &&
|
|
174
|
+
Number.isFinite(value.consumedAt) &&
|
|
175
|
+
value.consumedAt >= 0
|
|
176
|
+
? value.consumedAt
|
|
177
|
+
: 0
|
|
178
|
+
return { from, to, changelog, restart, at, consumedAt }
|
|
179
|
+
}
|
|
180
|
+
function parseStatus(value) {
|
|
181
|
+
if (!isPlainObject(value)) return null
|
|
182
|
+
if (value.schemaVersion !== 1) return null
|
|
183
|
+
const consent = value.consent
|
|
184
|
+
if (!isPlainObject(consent)) return null
|
|
185
|
+
if (typeof consent.autoUpdate !== 'boolean' || typeof consent.enabled !== 'boolean') return null
|
|
186
|
+
if (typeof value.channel !== 'string' || !CHANNELS.includes(value.channel)) return null
|
|
187
|
+
if (typeof value.installed !== 'string') return null
|
|
188
|
+
if (value.latest !== null && typeof value.latest !== 'string') return null
|
|
189
|
+
if (typeof value.state !== 'string' || !AUTO_UPDATE_STATES.includes(value.state)) return null
|
|
190
|
+
const progress = parseProgress(value.progress)
|
|
191
|
+
if (!progress) return null
|
|
192
|
+
const lastResult = value.lastResult === null ? null : parseResult(value.lastResult)
|
|
193
|
+
if (value.lastResult !== null && !lastResult) return null
|
|
194
|
+
if (!Array.isArray(value.history)) return null
|
|
195
|
+
const history = []
|
|
196
|
+
for (const entry of value.history) {
|
|
197
|
+
const parsed = parseResult(entry)
|
|
198
|
+
if (!parsed) return null
|
|
199
|
+
history.push(parsed)
|
|
200
|
+
}
|
|
201
|
+
const notice = value.notice === null ? null : parseNotice(value.notice)
|
|
202
|
+
if (value.notice !== null && !notice) return null
|
|
203
|
+
return {
|
|
204
|
+
schemaVersion: 1,
|
|
205
|
+
consent: { autoUpdate: consent.autoUpdate, enabled: consent.enabled },
|
|
206
|
+
channel: value.channel,
|
|
207
|
+
installed: value.installed,
|
|
208
|
+
latest: value.latest,
|
|
209
|
+
state: value.state,
|
|
210
|
+
progress,
|
|
211
|
+
lastResult,
|
|
212
|
+
history,
|
|
213
|
+
notice,
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function readAutoUpdateStatus(path) {
|
|
217
|
+
let text
|
|
218
|
+
try {
|
|
219
|
+
text = readFileSync(path, 'utf8')
|
|
220
|
+
} catch {
|
|
221
|
+
return null
|
|
222
|
+
}
|
|
223
|
+
let parsed
|
|
224
|
+
try {
|
|
225
|
+
parsed = JSON.parse(text)
|
|
226
|
+
} catch {
|
|
227
|
+
return null
|
|
228
|
+
}
|
|
229
|
+
return parseStatus(parsed)
|
|
230
|
+
}
|
|
231
|
+
function writeAutoUpdateStatus(path, status) {
|
|
232
|
+
const dir = dirname(path)
|
|
233
|
+
mkdirSync(dir, { recursive: true })
|
|
234
|
+
const tmp = `${path}.${process.pid}.${++tmpCounter}.tmp`
|
|
235
|
+
try {
|
|
236
|
+
writeFileSync(
|
|
237
|
+
tmp,
|
|
238
|
+
`${JSON.stringify(status, null, 2)}
|
|
239
|
+
`,
|
|
240
|
+
'utf8',
|
|
241
|
+
)
|
|
242
|
+
renameSync(tmp, path)
|
|
243
|
+
} catch (error) {
|
|
244
|
+
try {
|
|
245
|
+
rmSync(tmp, { force: true })
|
|
246
|
+
} catch {}
|
|
247
|
+
throw error
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function hasResumableAutoUpdateWork(status) {
|
|
251
|
+
if (!status) return false
|
|
252
|
+
const entries = status.lastResult ? [...status.history, status.lastResult] : status.history
|
|
253
|
+
const resumableFailure = entries.some(
|
|
254
|
+
(entry) =>
|
|
255
|
+
entry.status === 'failed' && (entry.message ?? '').startsWith(AUTO_UPDATE_RESUMABLE_MARKER),
|
|
256
|
+
)
|
|
257
|
+
if (resumableFailure) return true
|
|
258
|
+
return IN_PROGRESS_STATES.includes(status.state) && status.progress.received > 0
|
|
259
|
+
}
|
|
260
|
+
var AUTO_UPDATE_STATUS_FILE,
|
|
261
|
+
AUTO_UPDATE_RESUMABLE_MARKER,
|
|
262
|
+
AUTO_UPDATE_STATES,
|
|
263
|
+
CHANNELS,
|
|
264
|
+
RESULT_STATUSES,
|
|
265
|
+
IN_PROGRESS_STATES,
|
|
266
|
+
tmpCounter
|
|
267
|
+
var init_autoUpdateStatus = __esm({
|
|
268
|
+
'src/cli/lib/autoUpdateStatus.ts'() {
|
|
269
|
+
'use strict'
|
|
270
|
+
AUTO_UPDATE_STATUS_FILE = 'auto-update-status.json'
|
|
271
|
+
AUTO_UPDATE_RESUMABLE_MARKER = '[resumable]'
|
|
272
|
+
AUTO_UPDATE_STATES = [
|
|
273
|
+
'idle',
|
|
274
|
+
'downloading',
|
|
275
|
+
'verifying',
|
|
276
|
+
'swapping',
|
|
277
|
+
'handover',
|
|
278
|
+
'updated',
|
|
279
|
+
'failed',
|
|
280
|
+
'skipped',
|
|
281
|
+
]
|
|
282
|
+
CHANNELS = ['binary', 'npm', 'bun', 'node']
|
|
283
|
+
RESULT_STATUSES = ['updated', 'failed', 'skipped']
|
|
284
|
+
IN_PROGRESS_STATES = ['downloading', 'verifying', 'swapping', 'handover']
|
|
285
|
+
tmpCounter = 0
|
|
286
|
+
},
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
// src/cli/lib/updateReminderPreferences.ts
|
|
290
|
+
import { closeSync, constants, fstatSync, openSync, readSync } from 'node:fs'
|
|
291
|
+
function readRaw(path) {
|
|
292
|
+
let descriptor
|
|
293
|
+
try {
|
|
294
|
+
descriptor = openSync(path, constants.O_RDONLY | constants.O_NONBLOCK)
|
|
295
|
+
const info = fstatSync(descriptor)
|
|
296
|
+
if (!info.isFile() || info.size > MAX_PREFERENCES_BYTES) return { kind: 'unreadable' }
|
|
297
|
+
const buffer = Buffer.alloc(info.size)
|
|
298
|
+
const bytes = readSync(descriptor, buffer, 0, buffer.length, 0)
|
|
299
|
+
return { kind: 'parsed', value: JSON.parse(buffer.toString('utf8', 0, bytes)) }
|
|
300
|
+
} catch (error) {
|
|
301
|
+
if (error.code === 'ENOENT') return { kind: 'missing' }
|
|
302
|
+
return { kind: 'unreadable' }
|
|
303
|
+
} finally {
|
|
304
|
+
if (descriptor !== void 0) {
|
|
305
|
+
try {
|
|
306
|
+
closeSync(descriptor)
|
|
307
|
+
} catch {}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
function readUpdateReminderPreferencesFile(path) {
|
|
312
|
+
const raw = readRaw(path)
|
|
313
|
+
if (raw.kind === 'missing') {
|
|
314
|
+
return {
|
|
315
|
+
preferences: { enabled: true, autoUpdate: false, unreadable: false },
|
|
316
|
+
missing: true,
|
|
317
|
+
document: null,
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (raw.kind === 'unreadable') {
|
|
321
|
+
return {
|
|
322
|
+
preferences: { enabled: false, autoUpdate: false, unreadable: true },
|
|
323
|
+
missing: false,
|
|
324
|
+
document: null,
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
const value = raw.value
|
|
328
|
+
const record = typeof value === 'object' && value !== null ? value : {}
|
|
329
|
+
return {
|
|
330
|
+
preferences: {
|
|
331
|
+
enabled: record.enabled === true,
|
|
332
|
+
// `autoUpdate` is INDEPENDENT of `enabled` — two separate consents.
|
|
333
|
+
// Only a strict `true` counts; anything else is off.
|
|
334
|
+
autoUpdate: record.autoUpdate === true,
|
|
335
|
+
unreadable: false,
|
|
336
|
+
},
|
|
337
|
+
missing: false,
|
|
338
|
+
document: typeof value === 'object' && value !== null ? record : null,
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
var MAX_PREFERENCES_BYTES
|
|
342
|
+
var init_updateReminderPreferences = __esm({
|
|
343
|
+
'src/cli/lib/updateReminderPreferences.ts'() {
|
|
344
|
+
'use strict'
|
|
345
|
+
MAX_PREFERENCES_BYTES = 64 * 1024
|
|
346
|
+
},
|
|
347
|
+
})
|
|
348
|
+
|
|
349
|
+
// messages/en.json
|
|
350
|
+
var en_default
|
|
351
|
+
var init_en = __esm({
|
|
352
|
+
'messages/en.json'() {
|
|
353
|
+
en_default = {
|
|
354
|
+
'setup.workflows_not_found': 'error: workflows directory not found at {{path}}',
|
|
355
|
+
'setup.nothing_to_install':
|
|
356
|
+
'setup: no workflow directories with SKILL.md found \u2014 nothing to install',
|
|
357
|
+
'setup.dry_run.header': '[dry-run] setup would install {{count}} workflow(s) to {{path}}:',
|
|
358
|
+
'setup.dry_run.run_hint': ' run without --dry-run to execute',
|
|
359
|
+
'setup.copy_failed': ' error: failed to copy {{name}}: {{message}}',
|
|
360
|
+
'setup.step_a_complete': 'Step A: {{count}} workflows installed to {{path}}',
|
|
361
|
+
'setup.step_a_render.complete': ' generated {{count}}/{{total}} command files',
|
|
362
|
+
'setup.step_a_render.warnings_header':
|
|
363
|
+
' [A.5] warnings \u2014 some capability cmds could not be fully resolved:',
|
|
364
|
+
'setup.command_warning': ' [A.6] {{message}}',
|
|
365
|
+
'setup.step_c.created': ' [C] created {{path}} + enabled Agent Teams',
|
|
366
|
+
'setup.step_c.already_enabled': ' [C] Agent Teams already enabled ({{path}})',
|
|
367
|
+
'setup.step_c.enabled_backup':
|
|
368
|
+
' [C] enabled Agent Teams in {{path}} (backup saved \u2192 {{backupPath}})',
|
|
369
|
+
'setup.step_c.skipped': ' [C] Agent Teams enable skipped: {{message}}',
|
|
370
|
+
'setup.step_d.created': ' [D] created {{path}} + wrote env.HARNESSED_USER_LANG={{lang}}',
|
|
371
|
+
'setup.step_d.already_set':
|
|
372
|
+
' [D] env.HARNESSED_USER_LANG={{lang}} already set in {{path}} \u2014 respecting user override',
|
|
373
|
+
'setup.step_d.enabled_backup':
|
|
374
|
+
' [D] wrote env.HARNESSED_USER_LANG={{lang}} in {{path}} (backup saved \u2192 {{backupPath}})',
|
|
375
|
+
'setup.step_d.skipped': ' [D] User language write skipped: {{message}}',
|
|
376
|
+
'setup.step_b_complete':
|
|
377
|
+
'Upstream components: {{installed}} installed / {{already}} already-installed / {{skipped}} skipped / {{failed}} failed [{{seconds}}s]',
|
|
378
|
+
'setup.complete':
|
|
379
|
+
'setup complete \u2014 {{skills}} workflows + {{manifests}} base manifests configured',
|
|
380
|
+
'setup.mcp_hint': 'Run /mcp in Claude Code to verify MCP server connections.',
|
|
381
|
+
'setup.mcp_hint_codex': 'Run codex mcp list to verify MCP server connections.',
|
|
382
|
+
'setup.search_key_hint.header':
|
|
383
|
+
'\n\u26A0 Search MCP API keys missing \u2014 the server(s) below are installed but will fail at query time until the key is configured:',
|
|
384
|
+
'setup.search_key_hint.header_codex':
|
|
385
|
+
'\n\u26A0 Search MCP API keys not visible to this check: Codex checks only process env. Verify the tools first; if authentication fails, set the key in your shell environment.',
|
|
386
|
+
'setup.search_key_hint.line':
|
|
387
|
+
' {{server}}: set {{envVar}} \u2014 add it to the ~/.claude/settings.json "env" block (e.g. {"env": {"{{envVar}}": "<your-key>"}}) or export {{envVar}} in your shell',
|
|
388
|
+
'setup.search_key_hint.line_codex':
|
|
389
|
+
' {{server}}: set {{envVar}} in your shell environment (export {{envVar}}="<your-key>")',
|
|
390
|
+
'setup.optional_offer.ecc_note':
|
|
391
|
+
" ecc (bonus tier): installing it unlocks finer-grained scenario orchestration (per-language review/build expert routing etc.); the trade-off is ~20k+ tokens/session of static listing overhead \u2014 inherent to ECC's own scale (281 skills / 94 commands / 67 agents), not introduced by harnessed.",
|
|
392
|
+
'setup.bundled_summary':
|
|
393
|
+
'\nharnessed workflows bundled at <packageRoot>/workflows/ (share-only, read-only)',
|
|
394
|
+
'setup.bundled_location': '',
|
|
395
|
+
'setup.doctor_hint': '\nRun harnessed doctor to verify your environment.',
|
|
396
|
+
'agent_teams.missing_header':
|
|
397
|
+
'\n\u26A0\uFE0F Agent Teams not enabled \u2014 parallelism upgrade path unavailable',
|
|
398
|
+
'agent_teams.missing_fix':
|
|
399
|
+
' fix: claude config set env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS 1',
|
|
400
|
+
'agent_teams.missing_explanation':
|
|
401
|
+
' harnessed task parallelism uses Subagent or Agent Teams (CC 2.1.178+)',
|
|
402
|
+
'agent_teams.missing_nonblocking':
|
|
403
|
+
' non-blocking \u2014 auto-degrades to subagent fan-out\n',
|
|
404
|
+
'install.manifest_not_found': "error: manifest '{{name}}' not found",
|
|
405
|
+
'install.manifest_not_found.fix':
|
|
406
|
+
' fix: ensure manifests/tools/{{name}}.yaml, manifests/skill-packs/{{name}}.yaml, or manifests/optional/{{name}}.yaml exists',
|
|
407
|
+
'install.audit_hint': " fix: run 'harnessed audit' to inspect manifest issues",
|
|
408
|
+
'install.success': 'installed {{name}}',
|
|
409
|
+
'install.success_with_version': 'installed {{name}}@{{version}}',
|
|
410
|
+
'install.already_installed':
|
|
411
|
+
'already-installed {{name}} (idempotent check hit; nothing to do)',
|
|
412
|
+
'install.already_installed_with_version':
|
|
413
|
+
'already-installed {{name}}@{{version}} (idempotent check hit; nothing to do)',
|
|
414
|
+
'install.aborted': 'aborted: {{reason}}',
|
|
415
|
+
'uninstall.dry_run.preview': "[dry-run] would uninstall '{{name}}' via method '{{method}}'",
|
|
416
|
+
'uninstall.dry_run.run_hint': ' run without --dry-run to execute',
|
|
417
|
+
'uninstall.confirm.prompt': "Uninstall '{{name}}'? This cannot be undone.",
|
|
418
|
+
'uninstall.cancelled': 'aborted: user cancelled',
|
|
419
|
+
'uninstall.completed': 'uninstalled {{name}}',
|
|
420
|
+
'uninstall.unified.nothing': 'nothing to do \u2014 no harnessed artifacts found',
|
|
421
|
+
'uninstall.unified.header': 'harnessed uninstall will remove the following:',
|
|
422
|
+
'uninstall.unified.commands':
|
|
423
|
+
' Commands: {{count}} harnessed-generated slash command file(s) in ~/.claude/commands/',
|
|
424
|
+
'uninstall.unified.agent_roles':
|
|
425
|
+
' Agent roles: {{count}} harnessed-generated codex agent role file(s) in ~/.codex/agents/',
|
|
426
|
+
'uninstall.unified.skills':
|
|
427
|
+
' Skills: {{count}} workflow skill directory(ies) in ~/.claude/skills/',
|
|
428
|
+
'uninstall.unified.settings':
|
|
429
|
+
' Settings: harnessed env vars (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, HARNESSED_USER_LANG) from ~/.claude/settings.json',
|
|
430
|
+
'uninstall.unified.hooks':
|
|
431
|
+
' Hooks: {{count}} harnessed Stop/UserPromptSubmit hook(s) in ~/.claude/settings.json',
|
|
432
|
+
'uninstall.unified.state_dir':
|
|
433
|
+
' State directory: ~/.claude/harnessed/ (includes backups, audit log, state, lock)',
|
|
434
|
+
'uninstall.unified.upstream_note':
|
|
435
|
+
'\nUpstream components (npm packages, MCP servers, CC plugins, git-cloned repos, npx skills) are NOT affected.',
|
|
436
|
+
'uninstall.unified.dry_run_hint':
|
|
437
|
+
'\n(dry-run \u2014 re-run without --dry-run to actually remove)',
|
|
438
|
+
'uninstall.unified.confirm':
|
|
439
|
+
"Remove harnessed's own files? Upstream components (npm packages, MCP servers, CC plugins, etc.) will NOT be affected. This cannot be undone.",
|
|
440
|
+
'uninstall.unified.removing': 'removing harnessed files...',
|
|
441
|
+
'uninstall.unified.removed_commands': ' removed {{count}} command file(s)',
|
|
442
|
+
'uninstall.unified.removed_agent_roles': ' removed {{count}} codex agent role file(s)',
|
|
443
|
+
'uninstall.unified.removed_skills': ' removed {{count}} skill directory(ies)',
|
|
444
|
+
'uninstall.unified.removed_settings':
|
|
445
|
+
' removed harnessed env vars from ~/.claude/settings.json',
|
|
446
|
+
'uninstall.unified.removed_hooks':
|
|
447
|
+
' removed {{count}} harnessed hook(s) from ~/.claude/settings.json',
|
|
448
|
+
'uninstall.unified.removed_state_dir': ' removed ~/.claude/harnessed/',
|
|
449
|
+
'uninstall.unified.partial_failure':
|
|
450
|
+
'\n{{count}} item(s) could not be removed (permission denied or already gone):',
|
|
451
|
+
'uninstall.unified.complete':
|
|
452
|
+
"uninstall complete \u2014 harnessed's own files have been removed",
|
|
453
|
+
'uninstall.unified.cli_hint_header':
|
|
454
|
+
'\nto remove the harnessed CLI itself (the step above did not \u2014 it only cleared setup files):',
|
|
455
|
+
'uninstall.unified.cli_hint_binary':
|
|
456
|
+
' binary: delete {{path}}\n then remove {{dir}} from your PATH',
|
|
457
|
+
'uninstall.unified.cli_hint_npm': ' npm: npm uninstall -g harnessed',
|
|
458
|
+
'uninstall.unified.cli_hint_other':
|
|
459
|
+
" installed both ways? remove the other too \u2014 npm: 'npm uninstall -g harnessed' / binary: delete the exe + its bin dir from PATH",
|
|
460
|
+
'gc.invalid_duration': "error: invalid --older-than '{{value}}'",
|
|
461
|
+
'gc.invalid_duration.fix': ' fix: use format <N>{d|h|m|w} e.g. 30d / 24h / 60m / 4w',
|
|
462
|
+
'gc.no_backups': 'no backups found ({{root}} absent) \u2014 nothing to gc',
|
|
463
|
+
'gc.no_old_snapshots': 'no snapshots older than {{cutoff}} (kept {{keptCount}} most-recent)',
|
|
464
|
+
'gc.summary_will_delete': 'would delete {{count}} snapshot(s), ~{{sizeKb}} KB total:',
|
|
465
|
+
'gc.summary_deleting': 'deleting {{count}} snapshot(s), ~{{sizeKb}} KB total:',
|
|
466
|
+
'gc.dry_run_rerun_hint': '\n(dry-run \u2014 re-run without --dry-run to actually delete)',
|
|
467
|
+
'gc.ledger_will_prune':
|
|
468
|
+
'would prune {{count}} stale workflow slot(s) from the ledger (kept {{kept}}):',
|
|
469
|
+
'gc.ledger_pruned':
|
|
470
|
+
'pruned {{count}} stale workflow slot(s) from the ledger (kept {{kept}}):',
|
|
471
|
+
'doctor.summary.fail': '\nsome checks failed (see fix hints above)',
|
|
472
|
+
'doctor.summary.warn': '\nall checks ok (with warnings \u2014 see hints above)',
|
|
473
|
+
'doctor.summary.pass': '\nall checks passed',
|
|
474
|
+
'doctor.host_scope': 'host: {{host}} \u2014 {{applied}} of {{total}} checks apply\n',
|
|
475
|
+
'doctor.matrix.legend':
|
|
476
|
+
'\nn/a = the check is not declared for that host in the registry, so it was not run',
|
|
477
|
+
'check_docs.clean': 'documentation discipline: no violations',
|
|
478
|
+
'check_docs.state_line_limit':
|
|
479
|
+
'STATE.md is {{lines}} lines > the {{limit}}-line digest limit \u2014 archive older phase narrative to RETROSPECTIVE.md (override for one run: HARNESSED_ALLOW_LONG_STATE=1)',
|
|
480
|
+
'check_docs.state_key_decisions':
|
|
481
|
+
"{{count}} '\u5173\u952E\u51B3\u8BAE ship \u603B\u7ED3' section(s) > {{limit}} \u2014 keep only the current one; move the rest to RETROSPECTIVE.md",
|
|
482
|
+
'check_docs.state_errata':
|
|
483
|
+
"historical commentary '{{excerpt}}' belongs in RETROSPECTIVE.md, not in the STATE digest",
|
|
484
|
+
'check_docs.roadmap_narrative':
|
|
485
|
+
'closing narrative inlined in an overview doc ({{signals}}) \u2014 ROADMAP carries one line + a pointer per phase; narrative goes to SUMMARY / VERIFICATION',
|
|
486
|
+
'check_docs.summary_halt':
|
|
487
|
+
'\ndocumentation discipline: {{halt}} blocking + {{warn}} advisory violation(s)',
|
|
488
|
+
'check_docs.summary_warn':
|
|
489
|
+
'\ndocumentation discipline: {{warn}} advisory violation(s) (non-blocking)',
|
|
490
|
+
'backup.no_backups': 'no backups found ({{root}} absent)',
|
|
491
|
+
'backup.no_backups_empty': 'no backups found ({{root}} empty)',
|
|
492
|
+
'backup.total_snapshots': '\n{{count}} snapshot(s) total',
|
|
493
|
+
'rollback.metadata_unreadable': 'error: cannot read {{path}}: {{message}}',
|
|
494
|
+
'rollback.metadata_unreadable.fix':
|
|
495
|
+
" fix: run 'harnessed backup list' to see available timestamps",
|
|
496
|
+
'rollback.checksum_mismatch':
|
|
497
|
+
'error: backup checksum mismatch for {{target}} (expected {{expected}}, got {{actual}})',
|
|
498
|
+
'rollback.restored': 'restored {{count}} file(s) from {{timestamp}}',
|
|
499
|
+
'status.no_installs': 'no installs recorded ({{path}} absent or empty)',
|
|
500
|
+
'status.summary_installs': '\n{{count}} install(s) recorded',
|
|
501
|
+
'status.lock_held': '\nlock: held (since {{since}}){{staleSuffix}}',
|
|
502
|
+
'status.lock_held.stale_suffix': ' \u2014 STALE',
|
|
503
|
+
'status.lock_release_hint': ' to release: wait for process to finish or delete {{path}}',
|
|
504
|
+
'status.lock_free': '\nlock: free',
|
|
505
|
+
'here.no_workflow': 'no active workflow for this repo ({{path}} has no entry for cwd)',
|
|
506
|
+
'here.no_workflow.hint':
|
|
507
|
+
' to start: run a stage (e.g. `harnessed gates discuss`) or `harnessed run <workflow>`',
|
|
508
|
+
'audit_log.no_records_file': 'no audit records found ({{path}} does not exist)',
|
|
509
|
+
'audit_log.no_records_empty': 'no audit records found (audit.log is empty)',
|
|
510
|
+
'audit_log.jq_missing': '\u2717 jq not found in PATH \u2014 run: harnessed doctor',
|
|
511
|
+
'audit_log.tail_invalid': '\u2717 --tail must be a positive integer',
|
|
512
|
+
'audit_log.head_invalid': '\u2717 --head must be a positive integer',
|
|
513
|
+
'execute_task.require_task': 'error: --task <text> is required',
|
|
514
|
+
'execute_task.load_phases_failed':
|
|
515
|
+
'error: failed to load workflows/{{workflow}}/phases.yaml \u2014 {{message}}',
|
|
516
|
+
'execute_task.precommit_skipped':
|
|
517
|
+
'\u26A0\uFE0F before-commit pre-flight skipped ({{message}}); subagent will biome-check at commit time.',
|
|
518
|
+
'research.require_query': 'error: --query <text> is required',
|
|
519
|
+
'manifest_add.non_interactive_warn':
|
|
520
|
+
'[ee-5-gate] WARN: --non-interactive skips 5-question prompt (D-03 dry-run-only). plan-phase hard reject still applies.',
|
|
521
|
+
'manifest_add.dry_run_preview':
|
|
522
|
+
'[manifest-add] dry-run preview for upstream: {{upstream}} \u2192 {{path}}',
|
|
523
|
+
'manifest_add.empty_answer': 'error: EE-5 gate requires non-empty answer',
|
|
524
|
+
'manifest_add.gate_passed_wrote': '[manifest-add] EE-5 gate passed; wrote {{path}}',
|
|
525
|
+
'manifest_add.gate_passed_dry_run':
|
|
526
|
+
'[manifest-add] EE-5 gate passed (dry-run); would write {{path}}',
|
|
527
|
+
'resume.fail': '\u2717 {{error}}',
|
|
528
|
+
'resume.corrupt': '\u2717 {{error}}\n path: {{path}}',
|
|
529
|
+
'auto_update.consent_on': '[harnessed] auto-update ON',
|
|
530
|
+
'auto_update.consent_off': '[harnessed] auto-update OFF',
|
|
531
|
+
'auto_update.preferences_replaced':
|
|
532
|
+
'[harnessed] the preferences file was unreadable (invalid JSON) \u2014 it has been replaced.',
|
|
533
|
+
'auto_update.reminder_off_note': `[harnessed] the update reminder is OFF \u2014 the "new version available" notice will not be printed. Use 'harnessed auto-update status' to check on it.`,
|
|
534
|
+
'auto_update.path.host': ' host: {{host}}',
|
|
535
|
+
'auto_update.path.preferences': ' preferences: {{path}}',
|
|
536
|
+
'auto_update.path.status': ' status: {{path}}',
|
|
537
|
+
'auto_update.error.unsupported_host': 'unsupported host: {{host}} (expected claude or codex)',
|
|
538
|
+
'auto_update.error.runtime': 'could not resolve the {{host}} update-reminder runtime',
|
|
539
|
+
'auto_update.notice.updated_from': 'harnessed updated {{from}} -> {{to}}.',
|
|
540
|
+
'auto_update.notice.updated_to': 'harnessed updated to {{to}}.',
|
|
541
|
+
'auto_update.notice.restart': 'Restart {{host}} so the new version + hooks take effect.',
|
|
542
|
+
'auto_update.notice.codex_trust':
|
|
543
|
+
"Codex hooks still need your trust confirmed \u2014 approve the harness hook registration in Codex (or run 'harnessed setup' there).",
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
})
|
|
547
|
+
|
|
548
|
+
// src/i18n/index.ts
|
|
549
|
+
import { readFileSync as readFileSync2 } from 'node:fs'
|
|
550
|
+
import { dirname as dirname2, join as join2, resolve } from 'node:path'
|
|
551
|
+
import { fileURLToPath } from 'node:url'
|
|
552
|
+
function mapToSupported(raw) {
|
|
553
|
+
if (!raw) return 'en'
|
|
554
|
+
if (/^zh([^a-z]|$)/i.test(raw)) return 'zh-Hans'
|
|
555
|
+
return 'en'
|
|
556
|
+
}
|
|
557
|
+
function detectLocale() {
|
|
558
|
+
const raw =
|
|
559
|
+
process.env.HARNESSED_LANG ||
|
|
560
|
+
process.env.LC_ALL ||
|
|
561
|
+
process.env.LANG ||
|
|
562
|
+
process.env.LANGUAGE ||
|
|
563
|
+
safeIntlLocale()
|
|
564
|
+
return mapToSupported(raw)
|
|
565
|
+
}
|
|
566
|
+
function safeIntlLocale() {
|
|
567
|
+
try {
|
|
568
|
+
return Intl.DateTimeFormat().resolvedOptions().locale
|
|
569
|
+
} catch {
|
|
570
|
+
return void 0
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function messagesDir() {
|
|
574
|
+
const here = dirname2(fileURLToPath(import.meta.url))
|
|
575
|
+
const candidates = []
|
|
576
|
+
if (wiredMessagesDirProvider) {
|
|
577
|
+
try {
|
|
578
|
+
candidates.push(wiredMessagesDirProvider())
|
|
579
|
+
} catch {}
|
|
580
|
+
}
|
|
581
|
+
candidates.push(resolve(here, '..', '..', 'messages'), resolve(here, '..', 'messages'))
|
|
582
|
+
for (const c of candidates) {
|
|
583
|
+
try {
|
|
584
|
+
readFileSync2(join2(c, 'en.json'), 'utf8')
|
|
585
|
+
return c
|
|
586
|
+
} catch {}
|
|
587
|
+
}
|
|
588
|
+
return resolve(process.cwd(), 'messages')
|
|
589
|
+
}
|
|
590
|
+
function loadLocale(locale) {
|
|
591
|
+
if (cache[locale]) return cache[locale]
|
|
592
|
+
const path = join2(messagesDir(), `${locale}.json`)
|
|
593
|
+
try {
|
|
594
|
+
const raw = readFileSync2(path, 'utf8')
|
|
595
|
+
cache[locale] = JSON.parse(raw)
|
|
596
|
+
} catch {
|
|
597
|
+
cache[locale] = locale === 'en' ? en_default : {}
|
|
598
|
+
}
|
|
599
|
+
return cache[locale]
|
|
600
|
+
}
|
|
601
|
+
function getLocale() {
|
|
602
|
+
if (currentLocale === null) currentLocale = detectLocale()
|
|
603
|
+
return currentLocale
|
|
604
|
+
}
|
|
605
|
+
function t(key, params) {
|
|
606
|
+
const locale = getLocale()
|
|
607
|
+
const primary = loadLocale(locale)
|
|
608
|
+
let template = primary[key]
|
|
609
|
+
if (template === void 0 && locale !== 'en') {
|
|
610
|
+
template = loadLocale('en')[key]
|
|
611
|
+
}
|
|
612
|
+
if (template === void 0) template = key
|
|
613
|
+
if (!params) return template
|
|
614
|
+
return template.replace(/\{\{(\w+)\}\}/g, (_match, name) => {
|
|
615
|
+
const v = params[name]
|
|
616
|
+
return v === void 0 ? `{{${name}}}` : String(v)
|
|
617
|
+
})
|
|
618
|
+
}
|
|
619
|
+
var currentLocale, cache, wiredMessagesDirProvider
|
|
620
|
+
var init_i18n = __esm({
|
|
621
|
+
'src/i18n/index.ts'() {
|
|
622
|
+
'use strict'
|
|
623
|
+
init_en()
|
|
624
|
+
currentLocale = null
|
|
625
|
+
cache = {}
|
|
626
|
+
wiredMessagesDirProvider = null
|
|
627
|
+
},
|
|
628
|
+
})
|
|
629
|
+
|
|
630
|
+
// src/cli/lib/autoUpdateNotice.ts
|
|
631
|
+
function isPrintableAutoUpdateNotice(notice) {
|
|
632
|
+
if (!notice) return false
|
|
633
|
+
if (notice.to.trim() === '') return false
|
|
634
|
+
return (notice.consumedAt ?? 0) === 0
|
|
635
|
+
}
|
|
636
|
+
function formatAutoUpdateNotice(notice) {
|
|
637
|
+
const host = notice.restart.trim() || 'Claude Code'
|
|
638
|
+
const from = notice.from.trim()
|
|
639
|
+
const lines = []
|
|
640
|
+
lines.push(
|
|
641
|
+
from
|
|
642
|
+
? t('auto_update.notice.updated_from', { from, to: notice.to })
|
|
643
|
+
: t('auto_update.notice.updated_to', { to: notice.to }),
|
|
644
|
+
)
|
|
645
|
+
const changelog = notice.changelog.trim()
|
|
646
|
+
if (changelog) lines.push('', changelog)
|
|
647
|
+
lines.push('', t('auto_update.notice.restart', { host }))
|
|
648
|
+
if (host === 'Codex') {
|
|
649
|
+
lines.push(t('auto_update.notice.codex_trust'))
|
|
650
|
+
}
|
|
651
|
+
return lines.join('\n')
|
|
652
|
+
}
|
|
653
|
+
function consumeAutoUpdateNotice(statusPath, now) {
|
|
654
|
+
const status = readAutoUpdateStatus(statusPath)
|
|
655
|
+
const notice = status?.notice
|
|
656
|
+
if (!status || !notice) return false
|
|
657
|
+
if ((notice.consumedAt ?? 0) !== 0) return false
|
|
658
|
+
if (notice.to.trim() === '') return false
|
|
659
|
+
try {
|
|
660
|
+
writeAutoUpdateStatus(statusPath, { ...status, notice: { ...notice, consumedAt: now } })
|
|
661
|
+
return true
|
|
662
|
+
} catch {
|
|
663
|
+
return false
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
var init_autoUpdateNotice = __esm({
|
|
667
|
+
'src/cli/lib/autoUpdateNotice.ts'() {
|
|
668
|
+
'use strict'
|
|
669
|
+
init_i18n()
|
|
670
|
+
init_autoUpdateStatus()
|
|
671
|
+
},
|
|
672
|
+
})
|
|
673
|
+
|
|
130
674
|
// src/cli/lib/updateReminderCache.ts
|
|
131
675
|
import fs from 'node:fs'
|
|
132
676
|
function isReminderVersion(value) {
|
|
@@ -137,12 +681,12 @@ function isReminderVersion(value) {
|
|
|
137
681
|
)
|
|
138
682
|
}
|
|
139
683
|
function parseCache(text, identity, now) {
|
|
140
|
-
const
|
|
141
|
-
if (!
|
|
684
|
+
const cache2 = JSON.parse(text)
|
|
685
|
+
if (!cache2 || cache2.schemaVersion !== 1 || !cache2.identity) return null
|
|
142
686
|
const keys = ['host', 'runtime', 'channel', 'source', 'fingerprint']
|
|
143
687
|
if (identity.host !== 'claude' && identity.host !== 'codex') return null
|
|
144
688
|
for (const key of keys) {
|
|
145
|
-
const value =
|
|
689
|
+
const value = cache2.identity[key]
|
|
146
690
|
if (
|
|
147
691
|
typeof value !== 'string' ||
|
|
148
692
|
!value.length ||
|
|
@@ -152,7 +696,7 @@ function parseCache(text, identity, now) {
|
|
|
152
696
|
return null
|
|
153
697
|
}
|
|
154
698
|
}
|
|
155
|
-
const { installed, latest, state, checkedAt, retryAfter } =
|
|
699
|
+
const { installed, latest, state, checkedAt, retryAfter } = cache2
|
|
156
700
|
if (
|
|
157
701
|
!isReminderVersion(installed) ||
|
|
158
702
|
typeof checkedAt !== 'number' ||
|
|
@@ -202,10 +746,10 @@ function readReminderCache(cachePath, identity, now = Date.now()) {
|
|
|
202
746
|
}
|
|
203
747
|
}
|
|
204
748
|
}
|
|
205
|
-
function shouldRefreshReminder(
|
|
206
|
-
if (!
|
|
207
|
-
if (
|
|
208
|
-
return
|
|
749
|
+
function shouldRefreshReminder(cache2, now) {
|
|
750
|
+
if (!cache2) return true
|
|
751
|
+
if (cache2.retryAfter > now) return false
|
|
752
|
+
return cache2.state === 'unknown' || now - cache2.checkedAt >= REMINDER_TTL_MS
|
|
209
753
|
}
|
|
210
754
|
function isReminderWorkerActive(cachePath, now) {
|
|
211
755
|
try {
|
|
@@ -226,36 +770,74 @@ var init_updateReminderCache = __esm({
|
|
|
226
770
|
},
|
|
227
771
|
})
|
|
228
772
|
|
|
773
|
+
// src/platform/stateRoot.ts
|
|
774
|
+
import { homedir } from 'node:os'
|
|
775
|
+
import { join as join3, resolve as resolve2 } from 'node:path'
|
|
776
|
+
function canonicalStateRoot(hostId) {
|
|
777
|
+
const override = process.env.HARNESSED_ROOT_OVERRIDE?.trim()
|
|
778
|
+
if (override) return resolve2(override)
|
|
779
|
+
const nativeHome =
|
|
780
|
+
hostId === 'codex'
|
|
781
|
+
? process.env.CODEX_HOME?.trim() || join3(homedir(), '.codex')
|
|
782
|
+
: process.env.CLAUDE_CONFIG_DIR?.trim() || join3(homedir(), '.claude')
|
|
783
|
+
return resolve2(join3(nativeHome, 'harnessed'))
|
|
784
|
+
}
|
|
785
|
+
var init_stateRoot = __esm({
|
|
786
|
+
'src/platform/stateRoot.ts'() {
|
|
787
|
+
'use strict'
|
|
788
|
+
},
|
|
789
|
+
})
|
|
790
|
+
|
|
229
791
|
// src/compile/updateReminderEntrypoint.ts
|
|
230
792
|
init_package()
|
|
793
|
+
init_autoUpdateStatus()
|
|
794
|
+
init_updateReminderPreferences()
|
|
231
795
|
import { createHash } from 'node:crypto'
|
|
232
|
-
import {
|
|
233
|
-
import { homedir } from 'node:os'
|
|
234
|
-
import { dirname, isAbsolute, join, resolve } from 'node:path'
|
|
235
|
-
import { fileURLToPath } from 'node:url'
|
|
796
|
+
import { statSync } from 'node:fs'
|
|
797
|
+
import { homedir as homedir2 } from 'node:os'
|
|
798
|
+
import { dirname as dirname3, isAbsolute, join as join4, resolve as resolve3 } from 'node:path'
|
|
799
|
+
import { fileURLToPath as fileURLToPath2 } from 'node:url'
|
|
236
800
|
|
|
237
801
|
// src/cli/updateReminderHookMain.ts
|
|
802
|
+
init_autoUpdateNotice()
|
|
803
|
+
init_autoUpdateStatus()
|
|
238
804
|
init_updateReminderCache()
|
|
239
805
|
import childProcess from 'node:child_process'
|
|
240
806
|
async function runUpdateReminderHook(options) {
|
|
241
807
|
try {
|
|
242
|
-
if (!options.enabled) return 0
|
|
243
808
|
const now = (options.now ?? Date.now)()
|
|
244
|
-
const
|
|
245
|
-
|
|
809
|
+
const write =
|
|
810
|
+
options.write ??
|
|
811
|
+
((text) => {
|
|
812
|
+
process.stdout.write(text)
|
|
813
|
+
})
|
|
814
|
+
let resumable = false
|
|
815
|
+
if (options.statusPath) {
|
|
816
|
+
try {
|
|
817
|
+
const status = readAutoUpdateStatus(options.statusPath)
|
|
818
|
+
const notice = status?.notice ?? null
|
|
819
|
+
if (notice && isPrintableAutoUpdateNotice(notice)) {
|
|
820
|
+
write(`${formatAutoUpdateNotice(notice)}
|
|
821
|
+
`)
|
|
822
|
+
consumeAutoUpdateNotice(options.statusPath, now)
|
|
823
|
+
}
|
|
824
|
+
resumable = hasResumableAutoUpdateWork(status)
|
|
825
|
+
} catch {}
|
|
826
|
+
}
|
|
827
|
+
const cache2 = readReminderCache(options.cachePath, options.identity, now)
|
|
828
|
+
if (options.enabled && cache2?.state === 'behind') {
|
|
246
829
|
try {
|
|
247
|
-
const write =
|
|
248
|
-
options.write ??
|
|
249
|
-
((text) => {
|
|
250
|
-
process.stdout.write(text)
|
|
251
|
-
})
|
|
252
830
|
write(
|
|
253
|
-
`Harnessed update available: ${
|
|
831
|
+
`Harnessed update available: ${cache2.installed} -> ${cache2.latest}. Run /harnessed-update.
|
|
254
832
|
`,
|
|
255
833
|
)
|
|
256
834
|
} catch {}
|
|
257
835
|
}
|
|
258
|
-
if (
|
|
836
|
+
if (
|
|
837
|
+
(options.enabled || options.autoUpdate) &&
|
|
838
|
+
(shouldRefreshReminder(cache2, now) || resumable) &&
|
|
839
|
+
!isReminderWorkerActive(options.cachePath, now)
|
|
840
|
+
) {
|
|
259
841
|
const spawn = options.spawn ?? childProcess.spawn
|
|
260
842
|
const child = spawn(options.worker.executable, options.worker.args, {
|
|
261
843
|
detached: true,
|
|
@@ -271,6 +853,7 @@ async function runUpdateReminderHook(options) {
|
|
|
271
853
|
}
|
|
272
854
|
|
|
273
855
|
// src/compile/updateReminderEntrypoint.ts
|
|
856
|
+
init_stateRoot()
|
|
274
857
|
var UPDATE_REMINDER_OPERATION = 'update-reminder'
|
|
275
858
|
var UPDATE_REMINDER_WORKER_OPERATION = 'update-reminder-worker'
|
|
276
859
|
var UPDATE_REMINDER_PREFERENCES_FILE = 'update-reminder-preferences.json'
|
|
@@ -299,16 +882,14 @@ function resolveUpdateReminderRuntime(options = {}) {
|
|
|
299
882
|
host = value
|
|
300
883
|
} else if (flag === '--state-root') {
|
|
301
884
|
if (explicitStateRoot !== void 0 || !isAbsolute(value)) return null
|
|
302
|
-
explicitStateRoot =
|
|
885
|
+
explicitStateRoot = resolve3(value)
|
|
303
886
|
} else return null
|
|
304
887
|
}
|
|
305
|
-
const nativeHome =
|
|
888
|
+
const nativeHome = resolve3(
|
|
306
889
|
(host === 'codex' ? process.env.CODEX_HOME?.trim() : process.env.CLAUDE_CONFIG_DIR) ||
|
|
307
|
-
|
|
890
|
+
join4(homedir2(), host === 'codex' ? '.codex' : '.claude'),
|
|
308
891
|
)
|
|
309
|
-
const stateRoot =
|
|
310
|
-
explicitStateRoot ??
|
|
311
|
-
resolve(process.env.HARNESSED_ROOT_OVERRIDE || join(nativeHome, 'harnessed'))
|
|
892
|
+
const stateRoot = explicitStateRoot ?? canonicalStateRoot(host)
|
|
312
893
|
const channel = options.compiled ? 'binary' : process.versions.bun ? 'bun' : 'npm'
|
|
313
894
|
const source = channel === 'binary' ? BINARY_SOURCE : `${channel}:harnessed`
|
|
314
895
|
const fingerprint = createHash('sha256')
|
|
@@ -324,8 +905,11 @@ function resolveUpdateReminderRuntime(options = {}) {
|
|
|
324
905
|
return {
|
|
325
906
|
stateRoot,
|
|
326
907
|
nativeHome,
|
|
327
|
-
cachePath:
|
|
328
|
-
preferencesPath:
|
|
908
|
+
cachePath: join4(stateRoot, `update-reminder-${host}.json`),
|
|
909
|
+
preferencesPath: join4(stateRoot, UPDATE_REMINDER_PREFERENCES_FILE),
|
|
910
|
+
// The auto-update status file of THIS host — the hook reads the pending
|
|
911
|
+
// update notice from it, the worker writes the run state into it.
|
|
912
|
+
statusPath: autoUpdateStatusPath(stateRoot),
|
|
329
913
|
installed: package_default.version,
|
|
330
914
|
identity: {
|
|
331
915
|
host,
|
|
@@ -339,7 +923,10 @@ function resolveUpdateReminderRuntime(options = {}) {
|
|
|
339
923
|
args: [
|
|
340
924
|
options.compiled
|
|
341
925
|
? UPDATE_REMINDER_WORKER_OPERATION
|
|
342
|
-
:
|
|
926
|
+
: join4(
|
|
927
|
+
dirname3(fileURLToPath2(import.meta.url)),
|
|
928
|
+
'harnessed-update-reminder-worker.mjs',
|
|
929
|
+
),
|
|
343
930
|
'--platform',
|
|
344
931
|
host,
|
|
345
932
|
...(explicitStateRoot ? ['--state-root', explicitStateRoot] : []),
|
|
@@ -347,40 +934,28 @@ function resolveUpdateReminderRuntime(options = {}) {
|
|
|
347
934
|
},
|
|
348
935
|
}
|
|
349
936
|
}
|
|
350
|
-
function
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const value = JSON.parse(buffer.toString('utf8', 0, bytes))
|
|
360
|
-
return (
|
|
361
|
-
typeof value === 'object' &&
|
|
362
|
-
value !== null &&
|
|
363
|
-
'schemaVersion' in value &&
|
|
364
|
-
value.schemaVersion === 1 &&
|
|
365
|
-
'enabled' in value &&
|
|
366
|
-
value.enabled === true
|
|
367
|
-
)
|
|
368
|
-
} catch (error) {
|
|
369
|
-
return error.code === 'ENOENT'
|
|
370
|
-
} finally {
|
|
371
|
-
if (descriptor !== void 0) {
|
|
372
|
-
try {
|
|
373
|
-
closeSync(descriptor)
|
|
374
|
-
} catch {}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
937
|
+
function readConsents(path) {
|
|
938
|
+
const { preferences, missing, document } = readUpdateReminderPreferencesFile(path)
|
|
939
|
+
if (preferences.unreadable) return { enabled: false, autoUpdate: false }
|
|
940
|
+
if (missing) return { enabled: true, autoUpdate: false }
|
|
941
|
+
const known = document?.schemaVersion === 1
|
|
942
|
+
return { enabled: known && preferences.enabled, autoUpdate: known && preferences.autoUpdate }
|
|
943
|
+
}
|
|
944
|
+
function anyConsent(consents) {
|
|
945
|
+
return consents.enabled || consents.autoUpdate
|
|
377
946
|
}
|
|
378
947
|
async function runUpdateReminderEntrypoint(options = {}) {
|
|
379
948
|
try {
|
|
380
949
|
const runtime = resolveUpdateReminderRuntime(options)
|
|
381
|
-
if (!runtime
|
|
950
|
+
if (!runtime) return 0
|
|
951
|
+
const consents = readConsents(runtime.preferencesPath)
|
|
952
|
+
if (!anyConsent(consents)) return 0
|
|
382
953
|
if (!statSync(runtime.stateRoot).isDirectory()) return 0
|
|
383
|
-
return await runUpdateReminderHook({
|
|
954
|
+
return await runUpdateReminderHook({
|
|
955
|
+
...runtime,
|
|
956
|
+
enabled: consents.enabled,
|
|
957
|
+
autoUpdate: consents.autoUpdate,
|
|
958
|
+
})
|
|
384
959
|
} catch {}
|
|
385
960
|
return 0
|
|
386
961
|
}
|