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