harnessed 5.0.3 → 5.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-en.md +14 -2
- package/README-zh.md +14 -2
- package/README.md +14 -2
- package/bin/harnessed-update-reminder-worker.mjs +2260 -0
- package/bin/harnessed-update-reminder.mjs +387 -0
- package/dist/cli.mjs +19052 -15801
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/manifests/cc-hooks/update-reminder.yaml +39 -0
- package/manifests/skill-packs/planning-with-files.yaml +2 -2
- package/manifests/tools/superpowers.yaml +2 -2
- package/manifests/tools/webapp-testing.yaml +2 -1
- package/package.json +2 -1
- package/workflows/harnessed-update/SKILL.md +106 -0
- package/workflows/harnessed-update/SKILL.zh-Hans.md +90 -0
- package/workflows/harnessed-update/workflow.yaml +19 -0
- package/workflows/role-prompts.yaml +26 -0
- package/workflows/role-prompts.zh-Hans.yaml +24 -0
- package/workflows/ship/preflight/SKILL.md +14 -2
- package/workflows/ship/preflight/SKILL.zh-Hans.md +12 -2
- package/workflows/ship/preflight/workflow.yaml +9 -3
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// biome-ignore-all format: esbuild-generated (hook drift gate owns this file)
|
|
3
|
+
// biome-ignore-all lint: esbuild-generated
|
|
4
|
+
// biome-ignore-all assist/source/organizeImports: esbuild-generated
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __esm = (fn, res) =>
|
|
7
|
+
function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])((fn = 0))), res
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// package.json
|
|
12
|
+
var package_default
|
|
13
|
+
var init_package = __esm({
|
|
14
|
+
'package.json'() {
|
|
15
|
+
package_default = {
|
|
16
|
+
name: 'harnessed',
|
|
17
|
+
version: '5.0.5',
|
|
18
|
+
description: 'AI coding harness package manager + composition orchestrator',
|
|
19
|
+
type: 'module',
|
|
20
|
+
license: 'Apache-2.0',
|
|
21
|
+
author: 'easyinplay',
|
|
22
|
+
repository: {
|
|
23
|
+
type: 'git',
|
|
24
|
+
url: 'https://github.com/easyinplay/harnessed.git',
|
|
25
|
+
},
|
|
26
|
+
homepage: 'https://github.com/easyinplay/harnessed#readme',
|
|
27
|
+
bugs: 'https://github.com/easyinplay/harnessed/issues',
|
|
28
|
+
keywords: [
|
|
29
|
+
'claude-code',
|
|
30
|
+
'ai-harness',
|
|
31
|
+
'package-manager',
|
|
32
|
+
'composition',
|
|
33
|
+
'skill-pack',
|
|
34
|
+
'mcp',
|
|
35
|
+
'orchestrator',
|
|
36
|
+
],
|
|
37
|
+
engines: {
|
|
38
|
+
node: '>=22.0.0',
|
|
39
|
+
},
|
|
40
|
+
packageManager: 'pnpm@10.12.0',
|
|
41
|
+
bin: {
|
|
42
|
+
harnessed: './dist/cli.mjs',
|
|
43
|
+
'harnessed-inject-state': './bin/harnessed-inject-state.mjs',
|
|
44
|
+
},
|
|
45
|
+
main: './dist/index.mjs',
|
|
46
|
+
types: './dist/index.d.ts',
|
|
47
|
+
exports: {
|
|
48
|
+
'.': {
|
|
49
|
+
types: './dist/index.d.ts',
|
|
50
|
+
import: './dist/index.mjs',
|
|
51
|
+
default: './dist/index.mjs',
|
|
52
|
+
},
|
|
53
|
+
'./schemas': {
|
|
54
|
+
types: './dist/schemas/index.d.ts',
|
|
55
|
+
import: './dist/schemas/index.mjs',
|
|
56
|
+
},
|
|
57
|
+
'./package.json': './package.json',
|
|
58
|
+
},
|
|
59
|
+
files: [
|
|
60
|
+
'dist',
|
|
61
|
+
'bin',
|
|
62
|
+
'manifests',
|
|
63
|
+
'messages',
|
|
64
|
+
'workflows',
|
|
65
|
+
'routing',
|
|
66
|
+
'config-templates',
|
|
67
|
+
'schemas',
|
|
68
|
+
'README.md',
|
|
69
|
+
'README-en.md',
|
|
70
|
+
'README-zh.md',
|
|
71
|
+
'LICENSE',
|
|
72
|
+
'NOTICE',
|
|
73
|
+
'THIRD-PARTY-NOTICES.md',
|
|
74
|
+
],
|
|
75
|
+
scripts: {
|
|
76
|
+
dev: 'tsup --watch',
|
|
77
|
+
build: 'tsc --noEmit && tsup && node ./scripts/build-hooks.mjs',
|
|
78
|
+
'build:hooks': 'node ./scripts/build-hooks.mjs',
|
|
79
|
+
'build:schema': 'node ./scripts/build-schema.mjs',
|
|
80
|
+
'validate:schema': 'node ./scripts/validate-schema.mjs',
|
|
81
|
+
typecheck: 'tsc --noEmit',
|
|
82
|
+
test: 'vitest run --passWithNoTests',
|
|
83
|
+
'test:watch': 'vitest',
|
|
84
|
+
'test:coverage': 'vitest run --coverage --passWithNoTests',
|
|
85
|
+
'test:codex-live': 'node ./scripts/codex-live/run.mjs',
|
|
86
|
+
bench: 'vitest bench --run',
|
|
87
|
+
'bench:runtime': 'node scripts/benchmark-runtime.mjs',
|
|
88
|
+
'test:runtime-channels': 'node scripts/runtime-channel-smoke.mjs',
|
|
89
|
+
'test:docs': 'node --test tests/docs/install-channels.contract.mjs',
|
|
90
|
+
lint: 'biome check .',
|
|
91
|
+
'lint:fix': 'biome check --write .',
|
|
92
|
+
format: 'biome format --write .',
|
|
93
|
+
'build:binary': 'bun scripts/build-binary.mjs',
|
|
94
|
+
},
|
|
95
|
+
dependencies: {
|
|
96
|
+
'@anthropic-ai/claude-agent-sdk': '0.3.142',
|
|
97
|
+
'@clack/prompts': '^0.10.1',
|
|
98
|
+
'@sinclair/typebox': '^0.34.49',
|
|
99
|
+
ajv: '^8.20.0',
|
|
100
|
+
'ajv-errors': '^3.0.0',
|
|
101
|
+
'ajv-formats': '^3.0.1',
|
|
102
|
+
commander: '^13.0.0',
|
|
103
|
+
diff: '^9.0.0',
|
|
104
|
+
'expr-eval': '^2.0.2',
|
|
105
|
+
picocolors: '^1.1.1',
|
|
106
|
+
'proper-lockfile': '^4.1.2',
|
|
107
|
+
'smol-toml': '^1.9.1',
|
|
108
|
+
undici: '^8.12.1',
|
|
109
|
+
yaml: '^2.9.0',
|
|
110
|
+
},
|
|
111
|
+
devDependencies: {
|
|
112
|
+
'@biomejs/biome': '^2.0.0',
|
|
113
|
+
'@types/node': '^22.10.0',
|
|
114
|
+
'@types/proper-lockfile': '^4.1.4',
|
|
115
|
+
'@vitest/coverage-v8': '^4.0.0',
|
|
116
|
+
esbuild: '0.27.7',
|
|
117
|
+
tsup: '^8.3.0',
|
|
118
|
+
typescript: '^5.6.0',
|
|
119
|
+
vitest: '^4.0.0',
|
|
120
|
+
},
|
|
121
|
+
pnpm: {
|
|
122
|
+
onlyBuiltDependencies: ['esbuild'],
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
// src/cli/lib/updateReminderCache.ts
|
|
129
|
+
import fs from 'node:fs'
|
|
130
|
+
function isReminderVersion(value) {
|
|
131
|
+
return (
|
|
132
|
+
typeof value === 'string' &&
|
|
133
|
+
value.length <= 128 &&
|
|
134
|
+
/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(value)
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
function parseCache(text, identity, now) {
|
|
138
|
+
const cache = JSON.parse(text)
|
|
139
|
+
if (!cache || cache.schemaVersion !== 1 || !cache.identity) return null
|
|
140
|
+
const keys = ['host', 'runtime', 'channel', 'source', 'fingerprint']
|
|
141
|
+
if (identity.host !== 'claude' && identity.host !== 'codex') return null
|
|
142
|
+
for (const key of keys) {
|
|
143
|
+
const value = cache.identity[key]
|
|
144
|
+
if (
|
|
145
|
+
typeof value !== 'string' ||
|
|
146
|
+
!value.length ||
|
|
147
|
+
value.length > 512 ||
|
|
148
|
+
value !== identity[key]
|
|
149
|
+
) {
|
|
150
|
+
return null
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const { installed, latest, state, checkedAt, retryAfter } = cache
|
|
154
|
+
if (
|
|
155
|
+
!isReminderVersion(installed) ||
|
|
156
|
+
typeof checkedAt !== 'number' ||
|
|
157
|
+
!Number.isSafeInteger(checkedAt) ||
|
|
158
|
+
checkedAt < 0 ||
|
|
159
|
+
checkedAt > now ||
|
|
160
|
+
typeof retryAfter !== 'number' ||
|
|
161
|
+
!Number.isSafeInteger(retryAfter) ||
|
|
162
|
+
retryAfter < 0
|
|
163
|
+
)
|
|
164
|
+
return null
|
|
165
|
+
if (state === 'unknown') {
|
|
166
|
+
if (latest !== null || retryAfter !== checkedAt + REMINDER_RETRY_MS) return null
|
|
167
|
+
} else if (
|
|
168
|
+
!['behind', 'current', 'ahead'].includes(state ?? '') ||
|
|
169
|
+
!isReminderVersion(latest) ||
|
|
170
|
+
retryAfter !== 0
|
|
171
|
+
)
|
|
172
|
+
return null
|
|
173
|
+
return {
|
|
174
|
+
schemaVersion: 1,
|
|
175
|
+
identity: { ...identity },
|
|
176
|
+
installed,
|
|
177
|
+
latest: latest ?? null,
|
|
178
|
+
state,
|
|
179
|
+
checkedAt,
|
|
180
|
+
retryAfter,
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function readReminderCache(cachePath, identity, now = Date.now()) {
|
|
184
|
+
let descriptor
|
|
185
|
+
try {
|
|
186
|
+
descriptor = fs.openSync(cachePath, fs.constants.O_RDONLY | fs.constants.O_NONBLOCK)
|
|
187
|
+
const stat = fs.fstatSync(descriptor)
|
|
188
|
+
if (!stat.isFile() || stat.size > REMINDER_MAX_BYTES) return null
|
|
189
|
+
const buffer = Buffer.alloc(REMINDER_MAX_BYTES + 1)
|
|
190
|
+
const bytes = fs.readSync(descriptor, buffer, 0, buffer.length, 0)
|
|
191
|
+
if (bytes > REMINDER_MAX_BYTES || bytes < stat.size) return null
|
|
192
|
+
return parseCache(buffer.toString('utf8', 0, bytes), identity, now)
|
|
193
|
+
} catch {
|
|
194
|
+
return null
|
|
195
|
+
} finally {
|
|
196
|
+
if (descriptor !== void 0) {
|
|
197
|
+
try {
|
|
198
|
+
fs.closeSync(descriptor)
|
|
199
|
+
} catch {}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function shouldRefreshReminder(cache, now) {
|
|
204
|
+
if (!cache) return true
|
|
205
|
+
if (cache.retryAfter > now) return false
|
|
206
|
+
return cache.state === 'unknown' || now - cache.checkedAt >= REMINDER_TTL_MS
|
|
207
|
+
}
|
|
208
|
+
function isReminderWorkerActive(cachePath, now) {
|
|
209
|
+
try {
|
|
210
|
+
const lock = fs.statSync(`${cachePath}.lock`)
|
|
211
|
+
return now - lock.mtimeMs < REMINDER_LOCK_STALE_MS
|
|
212
|
+
} catch {
|
|
213
|
+
return false
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
var REMINDER_TTL_MS, REMINDER_RETRY_MS, REMINDER_MAX_BYTES, REMINDER_LOCK_STALE_MS
|
|
217
|
+
var init_updateReminderCache = __esm({
|
|
218
|
+
'src/cli/lib/updateReminderCache.ts'() {
|
|
219
|
+
'use strict'
|
|
220
|
+
REMINDER_TTL_MS = 24 * 60 * 60 * 1e3
|
|
221
|
+
REMINDER_RETRY_MS = 60 * 60 * 1e3
|
|
222
|
+
REMINDER_MAX_BYTES = 16 * 1024
|
|
223
|
+
REMINDER_LOCK_STALE_MS = 3e4
|
|
224
|
+
},
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
// src/compile/updateReminderEntrypoint.ts
|
|
228
|
+
init_package()
|
|
229
|
+
import { createHash } from 'node:crypto'
|
|
230
|
+
import { closeSync, constants, fstatSync, openSync, readSync, statSync } from 'node:fs'
|
|
231
|
+
import { homedir } from 'node:os'
|
|
232
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path'
|
|
233
|
+
import { fileURLToPath } from 'node:url'
|
|
234
|
+
|
|
235
|
+
// src/cli/updateReminderHookMain.ts
|
|
236
|
+
init_updateReminderCache()
|
|
237
|
+
import childProcess from 'node:child_process'
|
|
238
|
+
async function runUpdateReminderHook(options) {
|
|
239
|
+
try {
|
|
240
|
+
if (!options.enabled) return 0
|
|
241
|
+
const now = (options.now ?? Date.now)()
|
|
242
|
+
const cache = readReminderCache(options.cachePath, options.identity, now)
|
|
243
|
+
if (cache?.state === 'behind') {
|
|
244
|
+
try {
|
|
245
|
+
const write =
|
|
246
|
+
options.write ??
|
|
247
|
+
((text) => {
|
|
248
|
+
process.stdout.write(text)
|
|
249
|
+
})
|
|
250
|
+
write(
|
|
251
|
+
`Harnessed update available: ${cache.installed} -> ${cache.latest}. Run /harnessed-update.
|
|
252
|
+
`,
|
|
253
|
+
)
|
|
254
|
+
} catch {}
|
|
255
|
+
}
|
|
256
|
+
if (shouldRefreshReminder(cache, now) && !isReminderWorkerActive(options.cachePath, now)) {
|
|
257
|
+
const spawn = options.spawn ?? childProcess.spawn
|
|
258
|
+
const child = spawn(options.worker.executable, options.worker.args, {
|
|
259
|
+
detached: true,
|
|
260
|
+
stdio: 'ignore',
|
|
261
|
+
windowsHide: true,
|
|
262
|
+
shell: false,
|
|
263
|
+
})
|
|
264
|
+
child.once('error', () => {})
|
|
265
|
+
child.unref()
|
|
266
|
+
}
|
|
267
|
+
} catch {}
|
|
268
|
+
return 0
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// src/compile/updateReminderEntrypoint.ts
|
|
272
|
+
var UPDATE_REMINDER_OPERATION = 'update-reminder'
|
|
273
|
+
var UPDATE_REMINDER_WORKER_OPERATION = 'update-reminder-worker'
|
|
274
|
+
var UPDATE_REMINDER_PREFERENCES_FILE = 'update-reminder-preferences.json'
|
|
275
|
+
var BINARY_SOURCE = 'https://api.github.com/repos/easyinplay/harnessed/releases/latest'
|
|
276
|
+
function resolveUpdateReminderRuntime(options = {}) {
|
|
277
|
+
const args = [...(options.args ?? process.argv.slice(2))]
|
|
278
|
+
if (args[0] === UPDATE_REMINDER_OPERATION || args[0] === UPDATE_REMINDER_WORKER_OPERATION)
|
|
279
|
+
args.shift()
|
|
280
|
+
let host = 'claude'
|
|
281
|
+
let explicitStateRoot
|
|
282
|
+
let platformSpecified = false
|
|
283
|
+
for (let index = 0; index < args.length; index += 2) {
|
|
284
|
+
const flag = args[index]
|
|
285
|
+
const value = args[index + 1]
|
|
286
|
+
if (
|
|
287
|
+
!flag ||
|
|
288
|
+
value === void 0 ||
|
|
289
|
+
[flag, value].some((argument) =>
|
|
290
|
+
Array.from(argument).some((character) => character < ' ' || character === '\x7F'),
|
|
291
|
+
)
|
|
292
|
+
)
|
|
293
|
+
return null
|
|
294
|
+
if (flag === '--platform') {
|
|
295
|
+
if (platformSpecified || (value !== 'claude' && value !== 'codex')) return null
|
|
296
|
+
platformSpecified = true
|
|
297
|
+
host = value
|
|
298
|
+
} else if (flag === '--state-root') {
|
|
299
|
+
if (explicitStateRoot !== void 0 || !isAbsolute(value)) return null
|
|
300
|
+
explicitStateRoot = resolve(value)
|
|
301
|
+
} else return null
|
|
302
|
+
}
|
|
303
|
+
const nativeHome = resolve(
|
|
304
|
+
(host === 'codex' ? process.env.CODEX_HOME?.trim() : process.env.CLAUDE_CONFIG_DIR) ||
|
|
305
|
+
join(homedir(), host === 'codex' ? '.codex' : '.claude'),
|
|
306
|
+
)
|
|
307
|
+
const stateRoot =
|
|
308
|
+
explicitStateRoot ??
|
|
309
|
+
resolve(process.env.HARNESSED_ROOT_OVERRIDE || join(nativeHome, 'harnessed'))
|
|
310
|
+
const channel = options.compiled ? 'binary' : process.versions.bun ? 'bun' : 'npm'
|
|
311
|
+
const source = channel === 'binary' ? BINARY_SOURCE : `${channel}:harnessed`
|
|
312
|
+
const fingerprint = createHash('sha256')
|
|
313
|
+
.update(
|
|
314
|
+
JSON.stringify([
|
|
315
|
+
host === 'codex' ? stateRoot : nativeHome,
|
|
316
|
+
process.execPath,
|
|
317
|
+
package_default.version,
|
|
318
|
+
source,
|
|
319
|
+
]),
|
|
320
|
+
)
|
|
321
|
+
.digest('hex')
|
|
322
|
+
return {
|
|
323
|
+
stateRoot,
|
|
324
|
+
nativeHome,
|
|
325
|
+
cachePath: join(stateRoot, `update-reminder-${host}.json`),
|
|
326
|
+
preferencesPath: join(stateRoot, UPDATE_REMINDER_PREFERENCES_FILE),
|
|
327
|
+
installed: package_default.version,
|
|
328
|
+
identity: {
|
|
329
|
+
host,
|
|
330
|
+
runtime: options.compiled ? 'binary' : process.versions.bun ? 'bun' : 'node',
|
|
331
|
+
channel,
|
|
332
|
+
source,
|
|
333
|
+
fingerprint,
|
|
334
|
+
},
|
|
335
|
+
worker: {
|
|
336
|
+
executable: process.execPath,
|
|
337
|
+
args: [
|
|
338
|
+
options.compiled
|
|
339
|
+
? UPDATE_REMINDER_WORKER_OPERATION
|
|
340
|
+
: join(dirname(fileURLToPath(import.meta.url)), 'harnessed-update-reminder-worker.mjs'),
|
|
341
|
+
'--platform',
|
|
342
|
+
host,
|
|
343
|
+
...(explicitStateRoot ? ['--state-root', explicitStateRoot] : []),
|
|
344
|
+
],
|
|
345
|
+
},
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
function reminderEnabled(path) {
|
|
349
|
+
let descriptor
|
|
350
|
+
try {
|
|
351
|
+
descriptor = openSync(path, constants.O_RDONLY | constants.O_NONBLOCK)
|
|
352
|
+
const info = fstatSync(descriptor)
|
|
353
|
+
if (!info.isFile() || info.size > 1024) return false
|
|
354
|
+
const buffer = Buffer.alloc(1025)
|
|
355
|
+
const bytes = readSync(descriptor, buffer, 0, buffer.length, 0)
|
|
356
|
+
if (bytes > 1024 || bytes < info.size) return false
|
|
357
|
+
const value = JSON.parse(buffer.toString('utf8', 0, bytes))
|
|
358
|
+
return (
|
|
359
|
+
typeof value === 'object' &&
|
|
360
|
+
value !== null &&
|
|
361
|
+
'schemaVersion' in value &&
|
|
362
|
+
value.schemaVersion === 1 &&
|
|
363
|
+
'enabled' in value &&
|
|
364
|
+
value.enabled === true
|
|
365
|
+
)
|
|
366
|
+
} catch (error) {
|
|
367
|
+
return error.code === 'ENOENT'
|
|
368
|
+
} finally {
|
|
369
|
+
if (descriptor !== void 0) {
|
|
370
|
+
try {
|
|
371
|
+
closeSync(descriptor)
|
|
372
|
+
} catch {}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
async function runUpdateReminderEntrypoint(options = {}) {
|
|
377
|
+
try {
|
|
378
|
+
const runtime = resolveUpdateReminderRuntime(options)
|
|
379
|
+
if (!runtime || !reminderEnabled(runtime.preferencesPath)) return 0
|
|
380
|
+
if (!statSync(runtime.stateRoot).isDirectory()) return 0
|
|
381
|
+
return await runUpdateReminderHook({ ...runtime, enabled: true })
|
|
382
|
+
} catch {}
|
|
383
|
+
return 0
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// bin/harnessed-update-reminder.mjs.entry.ts
|
|
387
|
+
await runUpdateReminderEntrypoint()
|