@rezti/dsh-rez-suite 0.1.22 → 0.1.24
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.md +5 -3
- package/lib/client.d.ts +2 -16
- package/lib/client.js +9 -145
- package/lib/index.d.ts +3 -1
- package/lib/index.js +108 -222
- package/lib/style.css +0 -81
- package/package.json +10 -10
- package/src/boss/mount.ts +54 -20
- package/src/boss/register.ts +50 -11
- package/src/boss/seed.ts +55 -18
- package/src/client/api.ts +0 -12
- package/src/client/index.ts +3 -16
- package/src/client/locales.ts +2 -16
- package/src/client/panel/panel.module.css +0 -82
- package/src/index.ts +9 -8
- package/src/protocol.ts +0 -13
- package/src/routes.ts +2 -30
- package/templates/staff/finance/.agents/skills/staff-finance/SKILL.md +6 -0
- package/templates/staff/finance/AGENTS.md +68 -0
- package/templates/staff/finance/BOOTSTRAP.md +23 -0
- package/templates/staff/finance/IDENTITY.md +8 -0
- package/templates/staff/finance/MEMORY.md +9 -0
- package/templates/staff/finance/PRIORITIES.md +3 -0
- package/templates/staff/finance/SOUL.md +6 -0
- package/templates/staff/finance/USER.md +8 -0
- package/templates/staff/finance/memory/.gitkeep +0 -0
- package/templates/staff/hr/.agents/skills/staff-hr/SKILL.md +6 -0
- package/templates/staff/hr/AGENTS.md +52 -0
- package/templates/staff/hr/BOOTSTRAP.md +23 -0
- package/templates/staff/hr/IDENTITY.md +8 -0
- package/templates/staff/hr/MEMORY.md +9 -0
- package/templates/staff/hr/PRIORITIES.md +3 -0
- package/templates/staff/hr/SOUL.md +6 -0
- package/templates/staff/hr/USER.md +8 -0
- package/templates/staff/hr/memory/.gitkeep +0 -0
- package/templates/staff/legal/.agents/skills/staff-legal/SKILL.md +6 -0
- package/templates/staff/legal/AGENTS.md +48 -0
- package/templates/staff/legal/BOOTSTRAP.md +23 -0
- package/templates/staff/legal/IDENTITY.md +8 -0
- package/templates/staff/legal/MEMORY.md +9 -0
- package/templates/staff/legal/PRIORITIES.md +3 -0
- package/templates/staff/legal/SOUL.md +6 -0
- package/templates/staff/legal/USER.md +8 -0
- package/templates/staff/legal/memory/.gitkeep +0 -0
- package/src/client/upgrade-button.tsx +0 -115
- package/src/self-update.ts +0 -155
package/src/self-update.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-place upgrade of @rezti/dsh-rez-suite inside the running dsh profile.
|
|
3
|
-
* pnpm add writes the new bits; Node cannot replace an already-imported host
|
|
4
|
-
* module, so we respawn the same argv after the HTTP response flushes.
|
|
5
|
-
*/
|
|
6
|
-
import { spawn } from 'node:child_process'
|
|
7
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
8
|
-
import { dirname, join } from 'node:path'
|
|
9
|
-
import { fileURLToPath } from 'node:url'
|
|
10
|
-
import type { RezUpdateApplyResult, RezUpdateStatus } from './protocol.ts'
|
|
11
|
-
|
|
12
|
-
export const SUITE_PACKAGE = '@rezti/dsh-rez-suite'
|
|
13
|
-
const NPM_LATEST = 'https://registry.npmjs.org/@rezti/dsh-rez-suite/latest'
|
|
14
|
-
const PNPM_TIMEOUT_MS = 180_000
|
|
15
|
-
|
|
16
|
-
export function compareVersions(left: string, right: string): number {
|
|
17
|
-
const a = left.split('.').map((part) => Number.parseInt(part, 10) || 0)
|
|
18
|
-
const b = right.split('.').map((part) => Number.parseInt(part, 10) || 0)
|
|
19
|
-
const n = Math.max(a.length, b.length)
|
|
20
|
-
for (let i = 0; i < n; i += 1) {
|
|
21
|
-
const av = a[i] ?? 0
|
|
22
|
-
const bv = b[i] ?? 0
|
|
23
|
-
if (av > bv) return 1
|
|
24
|
-
if (av < bv) return -1
|
|
25
|
-
}
|
|
26
|
-
return 0
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function readInstalledVersion(packageDir: string): string {
|
|
30
|
-
const raw = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8')) as { version?: unknown }
|
|
31
|
-
if (typeof raw.version !== 'string' || raw.version === '') throw new Error('suite package.json missing version')
|
|
32
|
-
return raw.version
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function findProfileDir(startDir: string): string {
|
|
36
|
-
let dir = startDir
|
|
37
|
-
for (let i = 0; i < 12; i += 1) {
|
|
38
|
-
const manifest = join(dir, 'package.json')
|
|
39
|
-
if (existsSync(manifest)) {
|
|
40
|
-
try {
|
|
41
|
-
const raw = JSON.parse(readFileSync(manifest, 'utf8')) as { dsh?: { profile?: { bundles?: unknown } } }
|
|
42
|
-
if (Array.isArray(raw.dsh?.profile?.bundles)) return dir
|
|
43
|
-
} catch {
|
|
44
|
-
// keep walking
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const parent = dirname(dir)
|
|
48
|
-
if (parent === dir) break
|
|
49
|
-
dir = parent
|
|
50
|
-
}
|
|
51
|
-
throw new Error('cannot find dsh profile directory (no package.json with dsh.profile.bundles)')
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function shellQuote(value: string): string {
|
|
55
|
-
return `'${value.replaceAll("'", `'\\''`)}'`
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function relaunchScript(argv: string[], parentPid: number): string {
|
|
59
|
-
return `while kill -0 ${parentPid} 2>/dev/null; do sleep 0.15; done; sleep 0.25; exec ${argv.map(shellQuote).join(' ')}`
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export async function fetchLatestVersion(fetchImpl: typeof fetch = fetch): Promise<string> {
|
|
63
|
-
const response = await fetchImpl(NPM_LATEST, { headers: { accept: 'application/json' } })
|
|
64
|
-
if (!response.ok) throw new Error(`npm registry HTTP ${response.status}`)
|
|
65
|
-
const body = await response.json() as { version?: unknown }
|
|
66
|
-
if (typeof body.version !== 'string' || body.version === '') throw new Error('npm registry missing version')
|
|
67
|
-
return body.version
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function runPnpmAdd(cwd: string, spec: string, env: NodeJS.ProcessEnv = process.env): Promise<void> {
|
|
71
|
-
return new Promise((resolve, reject) => {
|
|
72
|
-
const child = spawn('pnpm', ['add', spec], { cwd, env, stdio: ['ignore', 'pipe', 'pipe'] })
|
|
73
|
-
let stderr = ''
|
|
74
|
-
child.stderr.on('data', (chunk: Buffer) => { stderr += chunk.toString() })
|
|
75
|
-
const timer = setTimeout(() => {
|
|
76
|
-
child.kill('SIGTERM')
|
|
77
|
-
reject(new Error('pnpm add timed out after 3 minutes'))
|
|
78
|
-
}, PNPM_TIMEOUT_MS)
|
|
79
|
-
child.on('error', (error) => {
|
|
80
|
-
clearTimeout(timer)
|
|
81
|
-
reject(error)
|
|
82
|
-
})
|
|
83
|
-
child.on('close', (code) => {
|
|
84
|
-
clearTimeout(timer)
|
|
85
|
-
if (code === 0) resolve()
|
|
86
|
-
else reject(new Error(stderr.trim() || `pnpm add exited ${String(code)}`))
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function spawnRelaunch(argv: string[], parentPid: number, cwd: string, env: NodeJS.ProcessEnv = process.env): void {
|
|
92
|
-
const child = spawn('/bin/bash', ['-c', relaunchScript(argv, parentPid)], {
|
|
93
|
-
cwd,
|
|
94
|
-
env,
|
|
95
|
-
detached: true,
|
|
96
|
-
stdio: 'ignore',
|
|
97
|
-
})
|
|
98
|
-
child.unref()
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface SelfUpdateIo {
|
|
102
|
-
packageDir: string
|
|
103
|
-
fetchLatest: () => Promise<string>
|
|
104
|
-
install: (profileDir: string, spec: string) => Promise<void>
|
|
105
|
-
relaunch: () => void
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
let inflight: Promise<unknown> | undefined
|
|
109
|
-
|
|
110
|
-
export function createSelfUpdate(io: SelfUpdateIo) {
|
|
111
|
-
const status = async (): Promise<RezUpdateStatus> => {
|
|
112
|
-
const installed = readInstalledVersion(io.packageDir)
|
|
113
|
-
const latest = await io.fetchLatest()
|
|
114
|
-
return {
|
|
115
|
-
package: SUITE_PACKAGE,
|
|
116
|
-
installed,
|
|
117
|
-
latest,
|
|
118
|
-
outdated: compareVersions(latest, installed) > 0,
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const apply = async (): Promise<RezUpdateApplyResult> => {
|
|
123
|
-
if (inflight !== undefined) throw new Error('upgrade already running')
|
|
124
|
-
const work = (async () => {
|
|
125
|
-
const snapshot = await status()
|
|
126
|
-
if (!snapshot.outdated) {
|
|
127
|
-
return { ...snapshot, restarting: false }
|
|
128
|
-
}
|
|
129
|
-
const profileDir = findProfileDir(io.packageDir)
|
|
130
|
-
await io.install(profileDir, `${SUITE_PACKAGE}@${snapshot.latest}`)
|
|
131
|
-
return { ...snapshot, installed: snapshot.latest, outdated: false, restarting: true }
|
|
132
|
-
})()
|
|
133
|
-
inflight = work
|
|
134
|
-
try {
|
|
135
|
-
return await work
|
|
136
|
-
} finally {
|
|
137
|
-
inflight = undefined
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return { status, apply, relaunch: io.relaunch }
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function liveSelfUpdate(): ReturnType<typeof createSelfUpdate> {
|
|
145
|
-
const packageDir = dirname(fileURLToPath(new URL('.', import.meta.url)))
|
|
146
|
-
return createSelfUpdate({
|
|
147
|
-
packageDir,
|
|
148
|
-
fetchLatest: () => fetchLatestVersion(),
|
|
149
|
-
install: (profileDir, spec) => runPnpmAdd(profileDir, spec),
|
|
150
|
-
relaunch: () => {
|
|
151
|
-
spawnRelaunch(process.argv, process.pid, process.cwd())
|
|
152
|
-
setTimeout(() => { process.exit(0) }, 50)
|
|
153
|
-
},
|
|
154
|
-
})
|
|
155
|
-
}
|