harnessed 5.0.4 → 5.0.6

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