@yairabf/engineering-workflows 0.0.0-stage → 1.0.0
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/.agents/skills/grill-me/SKILL.md +7 -0
- package/.agents/skills/grill-me/agents/openai.yaml +5 -0
- package/.agents/skills/grilling/SKILL.md +28 -0
- package/.agents/skills/grilling/agents/openai.yaml +3 -0
- package/engineering-workflows/.agents/skills/workflow-implement/SKILL.md +17 -0
- package/engineering-workflows/.agents/skills/workflow-implement/references/implementation-handoff.md +17 -0
- package/engineering-workflows/.agents/skills/workflow-initiate/SKILL.md +49 -0
- package/engineering-workflows/.agents/skills/workflow-initiate/references/preparation.md +80 -0
- package/engineering-workflows/.agents/skills/workflow-initiate/references/prerequisites.json +53 -0
- package/engineering-workflows/.agents/skills/workflow-initiate/references/readiness.md +87 -0
- package/engineering-workflows/.agents/skills/workflow-initiate/scripts/marker.mjs +97 -0
- package/engineering-workflows/.agents/skills/workflow-investigate/SKILL.md +55 -0
- package/engineering-workflows/.agents/skills/workflow-investigate/references/investigation-brief.md +38 -0
- package/engineering-workflows/.agents/skills/workflow-plan/SKILL.md +46 -0
- package/engineering-workflows/.agents/skills/workflow-plan/references/implementation-plan.md +31 -0
- package/engineering-workflows/.agents/skills/workflow-review/SKILL.md +56 -0
- package/engineering-workflows/.agents/skills/workflow-review/references/independent-review.md +29 -0
- package/engineering-workflows/.claude/skills/workflow-implement/SKILL.md +10 -0
- package/engineering-workflows/.claude/skills/workflow-initiate/SKILL.md +10 -0
- package/engineering-workflows/.claude/skills/workflow-investigate/SKILL.md +10 -0
- package/engineering-workflows/.claude/skills/workflow-plan/SKILL.md +10 -0
- package/engineering-workflows/.claude/skills/workflow-review/SKILL.md +10 -0
- package/engineering-workflows/README.md +282 -0
- package/engineering-workflows/builder/delivery.mjs +177 -0
- package/engineering-workflows/builder/delivery.test.mjs +154 -0
- package/engineering-workflows/builder/drive.mjs +184 -0
- package/engineering-workflows/builder/drive.test.mjs +350 -0
- package/engineering-workflows/builder/handoff.mjs +40 -0
- package/engineering-workflows/builder/mission-role.mjs +294 -0
- package/engineering-workflows/builder/pi-session.mjs +45 -0
- package/engineering-workflows/builder/reader-guard.mjs +58 -0
- package/engineering-workflows/builder/role-session.mjs +42 -0
- package/engineering-workflows/builder/stage.mjs +446 -0
- package/engineering-workflows/builder/workspace-tool.mjs +20 -0
- package/engineering-workflows/builder-plan.mjs +174 -0
- package/engineering-workflows/builder-project.mjs +117 -0
- package/engineering-workflows/check-package-visibility.mjs +54 -0
- package/engineering-workflows/install.mjs +182 -0
- package/engineering-workflows/mission/README.md +281 -0
- package/engineering-workflows/mission/controller.mjs +54 -0
- package/engineering-workflows/mission/mission-controller.test.mjs +382 -0
- package/engineering-workflows/mission/mission-mcp.test.mjs +102 -0
- package/engineering-workflows/mission/status.mjs +113 -0
- package/engineering-workflows/mission/store.mjs +180 -0
- package/engineering-workflows/mission/tools.mjs +54 -0
- package/engineering-workflows/mission/transitions.mjs +269 -0
- package/engineering-workflows/mission-controller.mjs +72 -0
- package/engineering-workflows/mission-mcp.mjs +66 -0
- package/engineering-workflows/prerequisites.mjs +205 -0
- package/engineering-workflows/readiness.mjs +263 -0
- package/engineering-workflows/release-targets.mjs +12 -0
- package/engineering-workflows/setup.mjs +70 -0
- package/engineering-workflows/stage-release.mjs +45 -0
- package/engineering-workflows/upgrade.mjs +333 -0
- package/engineering-workflows/workflows/development.md +372 -0
- package/engineering-workflows/workflows/engineering-workflows.yml +90 -0
- package/package.json +21 -4
- package/README.md +0 -3
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process'
|
|
2
|
+
import { accessSync, constants, copyFileSync, cpSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import { tmpdir } from 'node:os'
|
|
4
|
+
import { basename, dirname, isAbsolute, join, relative, sep } from 'node:path'
|
|
5
|
+
import { checkWritableParent, register, stat, targetPath } from './install.mjs'
|
|
6
|
+
|
|
7
|
+
const manifest = new URL('.agents/skills/workflow-initiate/references/prerequisites.json', import.meta.url)
|
|
8
|
+
export const prerequisites = JSON.parse(readFileSync(manifest, 'utf8'))
|
|
9
|
+
export const skillRoots = {
|
|
10
|
+
pi: '.pi/skills',
|
|
11
|
+
opencode: '.opencode/skills',
|
|
12
|
+
'claude-code': '.claude/skills',
|
|
13
|
+
codex: '.agents/skills',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function command(bin, args, cwd, options) {
|
|
17
|
+
return spawnSync(bin, args, {
|
|
18
|
+
cwd, encoding: 'utf8', timeout: 30_000, maxBuffer: 32 * 1024 * 1024, ...options,
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function run(bin, args, cwd, operation) {
|
|
23
|
+
if (command(bin, args, cwd, { timeout: 180_000 }).status !== 0) {
|
|
24
|
+
throw new Error(operation)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function checkSkill(directory, skill) {
|
|
29
|
+
const definition = join(directory, 'SKILL.md')
|
|
30
|
+
try {
|
|
31
|
+
const body = readFileSync(definition, 'utf8')
|
|
32
|
+
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(body)?.[1]
|
|
33
|
+
const id = frontmatter?.match(/^name:\s*['"]?([\w-]+)['"]?\s*$/m)?.[1]
|
|
34
|
+
if (id !== skill.id) throw new Error(`Invalid name in ${definition}`)
|
|
35
|
+
for (const file of skill.requiredFiles) {
|
|
36
|
+
const path = join(directory, file)
|
|
37
|
+
const details = stat(path)
|
|
38
|
+
if (!details?.isFile() || !details.size) throw new Error(`Missing or empty resource ${path}`)
|
|
39
|
+
accessSync(path, constants.R_OK)
|
|
40
|
+
}
|
|
41
|
+
if (skill.id === 'grill-me') {
|
|
42
|
+
const companion = join(dirname(realpathSync(directory)), 'grilling')
|
|
43
|
+
checkSkill(companion, { id: 'grilling', requiredFiles: [] })
|
|
44
|
+
}
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error.code === 'ENOENT' || error.code === 'EACCES' || error.code === 'EPERM') {
|
|
47
|
+
throw new Error(`Cannot read ${error.path ?? definition}`)
|
|
48
|
+
}
|
|
49
|
+
throw error
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function destinations(skill) {
|
|
54
|
+
return skill.perHarness
|
|
55
|
+
? Object.entries(skillRoots).map(([harness, root]) => ({ root, harnesses: [harness] }))
|
|
56
|
+
: [
|
|
57
|
+
{ root: skillRoots.codex, harnesses: ['pi', 'opencode', 'codex'] },
|
|
58
|
+
{ root: skillRoots['claude-code'], harnesses: ['claude-code'] },
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function discoveredWorking(skill, harnesses, discovery) {
|
|
63
|
+
return harnesses.every((harness) => {
|
|
64
|
+
const definition = discovery[harness]?.skills.get(skill.id)
|
|
65
|
+
if (!definition) return false
|
|
66
|
+
try {
|
|
67
|
+
checkSkill(dirname(definition), skill)
|
|
68
|
+
return true
|
|
69
|
+
} catch {
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function fetchSource(skill, stage, missing) {
|
|
76
|
+
const git = (args, operation) => run('git', args, stage, operation)
|
|
77
|
+
git(['init', '-q'], 'Cannot initialize a temporary Git checkout.')
|
|
78
|
+
const remote = `https://github.com/${skill.repository}.git`
|
|
79
|
+
git(['remote', 'add', 'origin', remote], 'Cannot configure the staged Git source.')
|
|
80
|
+
git(['config', 'remote.origin.promisor', 'true'], 'Cannot configure the staged Git source.')
|
|
81
|
+
git(['config', 'remote.origin.partialclonefilter', 'blob:none'], 'Cannot configure the staged Git source.')
|
|
82
|
+
git(['fetch', '-q', '--depth=1', '--filter=blob:none', 'origin', skill.revision],
|
|
83
|
+
`Cannot fetch ${skill.repository} at ${skill.revision}. Check GitHub connectivity and access.`)
|
|
84
|
+
const paths = skill.perHarness ? missing.map(({ root }) => `${root}/${skill.id}`) : [skill.directory]
|
|
85
|
+
git(['sparse-checkout', 'set', ...paths], `Cannot select ${skill.repository} skill files.`)
|
|
86
|
+
git(['checkout', '-q', '--detach', 'FETCH_HEAD'], `Cannot unpack ${skill.repository} skill files.`)
|
|
87
|
+
const revision = command('git', ['rev-parse', 'HEAD'], stage).stdout?.trim()
|
|
88
|
+
if (revision !== skill.revision) throw new Error(`Unexpected source revision for ${skill.repository}.`)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function graphifyRuntime(target, packageName) {
|
|
92
|
+
if (command('graphify', ['--version'], target).status === 0) return
|
|
93
|
+
const tool = ['uv', 'pipx'].find((bin) => command(bin, ['--version'], target).status === 0)
|
|
94
|
+
if (!tool) throw new Error('Install uv or pipx to provision the missing Graphify CLI.')
|
|
95
|
+
const args = tool === 'uv' ? ['tool', 'install', packageName] : ['install', packageName]
|
|
96
|
+
run(tool, args, target, `Cannot install the ${packageName} CLI with ${tool}.`)
|
|
97
|
+
if (command('graphify', ['--version'], target).status !== 0) {
|
|
98
|
+
throw new Error(`Add the ${tool} tool bin directory to PATH and rerun setup.`)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function stageRegistration(skill, stage, root, target) {
|
|
103
|
+
if (!skill.repository) {
|
|
104
|
+
if (skill.source) return join(stage, '.agents/skills', skill.id)
|
|
105
|
+
const bundled = join(target, '.engineering-workflows/prerequisites')
|
|
106
|
+
if (skill.id === 'grill-me') {
|
|
107
|
+
cpSync(join(bundled, skill.id), join(stage, skill.id), { recursive: true })
|
|
108
|
+
cpSync(join(bundled, 'grilling'), join(stage, 'grilling'), { recursive: true, force: false })
|
|
109
|
+
const definition = join(stage, skill.id, 'SKILL.md')
|
|
110
|
+
const body = readFileSync(definition, 'utf8')
|
|
111
|
+
if (!body.includes('../grilling/SKILL.md')) {
|
|
112
|
+
writeFileSync(definition, body.trimEnd() +
|
|
113
|
+
'\n\nIf the Skill tool is unavailable, read and follow [Grilling](../grilling/SKILL.md).\n')
|
|
114
|
+
}
|
|
115
|
+
return join(stage, skill.id)
|
|
116
|
+
}
|
|
117
|
+
return join(bundled, skill.id)
|
|
118
|
+
}
|
|
119
|
+
const original = join(stage, skill.perHarness ? `${root}/${skill.id}` : skill.directory)
|
|
120
|
+
const staged = join(stage, 'registration', root, skill.id)
|
|
121
|
+
cpSync(original, staged, { recursive: true })
|
|
122
|
+
for (const notice of skill.notices) {
|
|
123
|
+
const copy = join(staged, basename(notice))
|
|
124
|
+
if (!stat(copy)) copyFileSync(join(stage, notice), copy)
|
|
125
|
+
}
|
|
126
|
+
if (skill.id === 'ui-ux-pro-max') {
|
|
127
|
+
const definition = join(staged, 'SKILL.md')
|
|
128
|
+
const prefix = '${CLAUDE_PLUGIN_ROOT}/.claude/skills/ui-ux-pro-max/'
|
|
129
|
+
writeFileSync(definition, readFileSync(definition, 'utf8').replaceAll(prefix, `${root}/${skill.id}/`))
|
|
130
|
+
}
|
|
131
|
+
return staged
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function installedDirectory(target, path, existing) {
|
|
135
|
+
if (existing.isDirectory()) return path
|
|
136
|
+
if (!existing.isSymbolicLink()) throw new Error(`Expected a directory at ${path}`)
|
|
137
|
+
|
|
138
|
+
let resolved
|
|
139
|
+
try {
|
|
140
|
+
resolved = realpathSync(path)
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (['ENOENT', 'ENOTDIR', 'ELOOP', 'EACCES', 'EPERM'].includes(error.code)) {
|
|
143
|
+
throw new Error(`Cannot resolve prerequisite link at ${path}`)
|
|
144
|
+
}
|
|
145
|
+
throw error
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const location = relative(target, resolved)
|
|
149
|
+
if (location === '..' || location.startsWith(`..${sep}`) || isAbsolute(location)) {
|
|
150
|
+
throw new Error(`Prerequisite link points outside the checkout at ${path}`)
|
|
151
|
+
}
|
|
152
|
+
if (!stat(resolved)?.isDirectory()) {
|
|
153
|
+
throw new Error(`Prerequisite link does not point to a directory at ${path}`)
|
|
154
|
+
}
|
|
155
|
+
return resolved
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function preparePrerequisites(target, discovery) {
|
|
159
|
+
const failures = []
|
|
160
|
+
// Install the companion first so Grill Me can resolve it as soon as it is registered.
|
|
161
|
+
const ordered = [...prerequisites].sort((a, b) => Number(b.id === 'grilling') - Number(a.id === 'grilling'))
|
|
162
|
+
for (const skill of ordered) {
|
|
163
|
+
const missing = []
|
|
164
|
+
for (const destination of destinations(skill)) {
|
|
165
|
+
try {
|
|
166
|
+
const parent = targetPath(target, destination.root)
|
|
167
|
+
const path = join(parent, skill.id)
|
|
168
|
+
const existing = stat(path)
|
|
169
|
+
if (existing) checkSkill(installedDirectory(target, path, existing), skill)
|
|
170
|
+
else if (!discoveredWorking(skill, destination.harnesses, discovery)) {
|
|
171
|
+
checkWritableParent(path)
|
|
172
|
+
missing.push({ ...destination, path })
|
|
173
|
+
}
|
|
174
|
+
} catch (error) {
|
|
175
|
+
failures.push({ id: skill.id, harnesses: destination.harnesses, message: error.message })
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
let stage
|
|
179
|
+
try {
|
|
180
|
+
if (skill.source) graphifyRuntime(target, skill.source)
|
|
181
|
+
if (!missing.length) continue
|
|
182
|
+
stage = mkdtempSync(join(tmpdir(), 'workflow-prerequisite-'))
|
|
183
|
+
if (skill.source) {
|
|
184
|
+
run('git', ['init', '-q'], stage, 'Cannot initialize the Graphify staging checkout.')
|
|
185
|
+
run('graphify', ['install', '--project', '--platform', 'agents'], stage,
|
|
186
|
+
'Graphify cannot stage the generic project skill. Check the installed CLI.')
|
|
187
|
+
}
|
|
188
|
+
if (skill.repository) fetchSource(skill, stage, missing)
|
|
189
|
+
for (const { path, root } of missing) {
|
|
190
|
+
const staged = stageRegistration(skill, stage, root, target)
|
|
191
|
+
checkSkill(staged, skill)
|
|
192
|
+
register(staged, path)
|
|
193
|
+
}
|
|
194
|
+
} catch (error) {
|
|
195
|
+
failures.push({
|
|
196
|
+
id: skill.id,
|
|
197
|
+
harnesses: skill.source ? Object.keys(skillRoots) : missing.flatMap(({ harnesses }) => harnesses),
|
|
198
|
+
message: error.message,
|
|
199
|
+
})
|
|
200
|
+
} finally {
|
|
201
|
+
if (stage) rmSync(stage, { recursive: true, force: true })
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return failures
|
|
205
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process'
|
|
2
|
+
import { createHash } from 'node:crypto'
|
|
3
|
+
import {
|
|
4
|
+
closeSync, copyFileSync, mkdirSync, mkdtempSync, openSync, readFileSync,
|
|
5
|
+
realpathSync, rmSync, writeFileSync,
|
|
6
|
+
} from 'node:fs'
|
|
7
|
+
import { tmpdir } from 'node:os'
|
|
8
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path'
|
|
9
|
+
import { createInterface } from 'node:readline'
|
|
10
|
+
import { checkSkill, command, prerequisites, skillRoots } from './prerequisites.mjs'
|
|
11
|
+
|
|
12
|
+
const roles = [
|
|
13
|
+
{ id: 'workflow-initiate', requiredFiles: [
|
|
14
|
+
'references/preparation.md', 'references/prerequisites.json', 'references/readiness.md', 'scripts/marker.mjs',
|
|
15
|
+
] },
|
|
16
|
+
{ id: 'workflow-investigate', requiredFiles: ['references/investigation-brief.md'] },
|
|
17
|
+
{ id: 'workflow-plan', requiredFiles: ['references/implementation-plan.md'] },
|
|
18
|
+
{ id: 'workflow-implement', requiredFiles: ['references/implementation-handoff.md'] },
|
|
19
|
+
{ id: 'workflow-review', requiredFiles: ['references/independent-review.md'] },
|
|
20
|
+
]
|
|
21
|
+
const uiSkill = prerequisites.find(({ id }) => id === 'ui-ux-pro-max')
|
|
22
|
+
|
|
23
|
+
function permitted(rules, id) {
|
|
24
|
+
return rules.findLast(({ permission, pattern }) => {
|
|
25
|
+
if (permission !== '*' && permission !== 'skill') return false
|
|
26
|
+
// OpenCode skill IDs contain letters, numbers and dashes.
|
|
27
|
+
const expression = pattern.replace(/[^a-z0-9*?-]/gi, '\\$&').replaceAll('*', '.*').replaceAll('?', '.')
|
|
28
|
+
return new RegExp(`^${expression}$`).test(id)
|
|
29
|
+
})?.action === 'allow'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function openCodeSkills(target) {
|
|
33
|
+
const stage = mkdtempSync(join(tmpdir(), 'workflow-discovery-'))
|
|
34
|
+
try {
|
|
35
|
+
const output = join(stage, 'catalog.json')
|
|
36
|
+
const descriptor = openSync(output, 'wx')
|
|
37
|
+
try {
|
|
38
|
+
// A regular file avoids the OpenCode CLI's truncated piped output.
|
|
39
|
+
const catalog = command('opencode', ['--pure', 'debug', 'skill'], target, {
|
|
40
|
+
stdio: ['ignore', descriptor, 'pipe'],
|
|
41
|
+
})
|
|
42
|
+
if (catalog.status !== 0) throw new Error('OpenCode could not list its skills.')
|
|
43
|
+
} finally {
|
|
44
|
+
closeSync(descriptor)
|
|
45
|
+
}
|
|
46
|
+
const agent = command('opencode', ['--pure', 'debug', 'agent', 'build'], target)
|
|
47
|
+
if (agent.status !== 0) throw new Error('OpenCode could not report build-agent permissions.')
|
|
48
|
+
const { permission } = JSON.parse(agent.stdout)
|
|
49
|
+
if (!Array.isArray(permission)) throw new Error('OpenCode build-agent permissions are unavailable.')
|
|
50
|
+
const catalog = JSON.parse(readFileSync(output, 'utf8'))
|
|
51
|
+
return new Map(catalog.filter(({ name, location }) =>
|
|
52
|
+
typeof name === 'string' && typeof location === 'string' && isAbsolute(location) &&
|
|
53
|
+
permitted(permission, name)).map(({ name, location }) => [name, location]))
|
|
54
|
+
} finally {
|
|
55
|
+
rmSync(stage, { recursive: true, force: true })
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function codexSkills(target) {
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
const child = spawn('codex', ['app-server', '-c', 'mcp_servers={}', '--listen', 'stdio://'], {
|
|
62
|
+
cwd: target, stdio: ['pipe', 'pipe', 'ignore'],
|
|
63
|
+
})
|
|
64
|
+
const lines = createInterface({ input: child.stdout })
|
|
65
|
+
const timer = setTimeout(() => finish(new Error('Codex skill discovery timed out.')), 20_000)
|
|
66
|
+
let settled = false
|
|
67
|
+
|
|
68
|
+
function finish(error, skills) {
|
|
69
|
+
if (settled) return
|
|
70
|
+
settled = true
|
|
71
|
+
clearTimeout(timer)
|
|
72
|
+
lines.close()
|
|
73
|
+
child.kill()
|
|
74
|
+
if (error) reject(error)
|
|
75
|
+
else resolve(skills)
|
|
76
|
+
}
|
|
77
|
+
function send(message) {
|
|
78
|
+
child.stdin.write(JSON.stringify({ jsonrpc: '2.0', ...message }) + '\n')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
child.once('error', () => finish(new Error('Cannot start Codex skill discovery.')))
|
|
82
|
+
child.stdin.once('error', () => finish(new Error('Cannot query the Codex skill catalog.')))
|
|
83
|
+
child.once('exit', () => finish(new Error('Codex closed its skill discovery interface.')))
|
|
84
|
+
lines.on('line', (line) => {
|
|
85
|
+
try {
|
|
86
|
+
const { id, error, result } = JSON.parse(line)
|
|
87
|
+
if (id !== 1 && id !== 2) return
|
|
88
|
+
if (error) throw new Error('Codex did not provide its skill catalog.')
|
|
89
|
+
if (id === 1) {
|
|
90
|
+
send({ method: 'initialized' })
|
|
91
|
+
send({ id: 2, method: 'skills/list', params: { cwds: [target] } })
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
const catalog = result?.data?.[0]
|
|
95
|
+
if (!Array.isArray(catalog?.skills) || catalog.errors?.length) {
|
|
96
|
+
throw new Error('Codex reported one or more skill discovery errors.')
|
|
97
|
+
}
|
|
98
|
+
const skills = new Map()
|
|
99
|
+
for (const { name, path, enabled } of catalog.skills) {
|
|
100
|
+
if (enabled && typeof path === 'string' && isAbsolute(path) && !skills.has(name)) {
|
|
101
|
+
skills.set(name, path)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
finish(null, skills)
|
|
105
|
+
} catch {
|
|
106
|
+
finish(new Error('Cannot read the Codex skill catalog.'))
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
send({ id: 1, method: 'initialize', params: { clientInfo: { name: 'engineering-workflows', version: '0.1.0' } } })
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export async function discover(target) {
|
|
114
|
+
const entries = await Promise.all(Object.keys(skillRoots).map(async (id) => {
|
|
115
|
+
const binary = id === 'claude-code' ? 'claude' : id
|
|
116
|
+
const version = command(binary, ['--version'], target)
|
|
117
|
+
let reason
|
|
118
|
+
if (version.error?.code === 'ENOENT') reason = `${binary} is not on PATH.`
|
|
119
|
+
else if (version.status !== 0) reason = `${binary} did not respond to --version.`
|
|
120
|
+
else if (id === 'pi' || id === 'claude-code') reason = 'Check skill discovery in the first harness session.'
|
|
121
|
+
else {
|
|
122
|
+
try {
|
|
123
|
+
const skills = id === 'codex' ? await codexSkills(target) : openCodeSkills(target)
|
|
124
|
+
return [id, { skills }]
|
|
125
|
+
} catch {
|
|
126
|
+
reason = 'Automatic discovery is unavailable. Check skills in the first harness session.'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return [id, { skills: new Map(), reason }]
|
|
130
|
+
}))
|
|
131
|
+
return Object.fromEntries(entries)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function pythonCommand(target) {
|
|
135
|
+
return [['python3'], ['python'], ['py', '-3']].find(([binary, ...args]) =>
|
|
136
|
+
/^Python 3\./.test(command(binary, [...args, '--version'], target).stdout ?? ''))
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function verifyRoles(target, harness, skills, roleIds) {
|
|
140
|
+
for (const role of roles.filter(role => roleIds.includes(role.id))) {
|
|
141
|
+
const found = skills.get(role.id)
|
|
142
|
+
if (!found) throw new Error(`${role.id} is missing or disabled in the harness catalog.`)
|
|
143
|
+
const shared = join(target, '.agents/skills', role.id)
|
|
144
|
+
const accepted = [join(shared, 'SKILL.md')]
|
|
145
|
+
if (harness === 'opencode') accepted.push(join(target, '.claude/skills', role.id, 'SKILL.md'))
|
|
146
|
+
if (!accepted.includes(realpathSync(found))) {
|
|
147
|
+
throw new Error(`${role.id} resolves to ${found} instead of the installed workflow role.`)
|
|
148
|
+
}
|
|
149
|
+
checkSkill(shared, role)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function verifyUiSearch(target, definition, python) {
|
|
154
|
+
const directory = dirname(definition)
|
|
155
|
+
const script = join(directory, 'scripts/search.py')
|
|
156
|
+
const localRoots = ['.agents/skills', '.claude/skills'].map((root) => join(target, root, uiSkill.id))
|
|
157
|
+
const pending = `Verify the UI UX Pro Max search in the harness session at ${definition}.`
|
|
158
|
+
if (!localRoots.includes(directory)) return pending
|
|
159
|
+
|
|
160
|
+
const body = readFileSync(definition, 'utf8')
|
|
161
|
+
const advertised = /^python "([^"\r\n]+\/scripts\/search\.py)" "<query>" --domain <domain>\r?$/m.exec(body)?.[1]
|
|
162
|
+
if (!advertised || resolve(target, advertised) !== script) {
|
|
163
|
+
throw new Error(`UI UX Pro Max search command does not resolve to ${script} in ${definition}.`)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const stage = mkdtempSync(join(tmpdir(), 'workflow-ui-search-'))
|
|
167
|
+
try {
|
|
168
|
+
mkdirSync(join(stage, 'scripts'))
|
|
169
|
+
mkdirSync(join(stage, 'data'))
|
|
170
|
+
for (const [name, hash] of Object.entries(uiSkill.searchScripts)) {
|
|
171
|
+
const path = join(directory, 'scripts', name)
|
|
172
|
+
const code = readFileSync(path, 'utf8').replaceAll('\r\n', '\n')
|
|
173
|
+
if (createHash('sha256').update(code).digest('hex') !== hash) return pending
|
|
174
|
+
writeFileSync(join(stage, 'scripts', name), code, { flag: 'wx' })
|
|
175
|
+
}
|
|
176
|
+
const filename = 'data/ux-guidelines.csv'
|
|
177
|
+
copyFileSync(join(directory, filename), join(stage, filename))
|
|
178
|
+
const [binary, ...args] = python
|
|
179
|
+
// Isolate imports to the verified scripts and the Python standard library.
|
|
180
|
+
const invoke = 'import runpy,sys; from pathlib import Path; sys.argv=sys.argv[1:]; ' +
|
|
181
|
+
'sys.path.insert(0,str(Path(sys.argv[0]).parent)); runpy.run_path(sys.argv[0],run_name="__main__")'
|
|
182
|
+
const result = command(binary, [
|
|
183
|
+
...args, '-I', '-S', '-B', '-c', invoke, join(stage, 'scripts/search.py'),
|
|
184
|
+
'keyboard', '--domain', 'ux', '--json',
|
|
185
|
+
], stage)
|
|
186
|
+
if (result.status === 0) {
|
|
187
|
+
try {
|
|
188
|
+
const { results } = JSON.parse(result.stdout)
|
|
189
|
+
if (Array.isArray(results) && results.length) return
|
|
190
|
+
} catch {
|
|
191
|
+
// Missing or malformed output is a failed search check.
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
throw new Error(`UI UX Pro Max could not complete the search at ${script}.`)
|
|
195
|
+
} finally {
|
|
196
|
+
rmSync(stage, { recursive: true, force: true })
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function verifyHarness(target, harness, skills, python = pythonCommand(target), roleIds = roles.map(role => role.id)) {
|
|
201
|
+
if (!python) throw new Error('Python 3 is unavailable on PATH.')
|
|
202
|
+
verifyRoles(target, harness, skills, roleIds)
|
|
203
|
+
for (const skill of prerequisites) {
|
|
204
|
+
const definition = skills.get(skill.id)
|
|
205
|
+
if (!definition) throw new Error(`${skill.id} is missing or disabled in the harness catalog.`)
|
|
206
|
+
checkSkill(dirname(definition), skill)
|
|
207
|
+
}
|
|
208
|
+
if (command('graphify', ['--version'], target).status !== 0) {
|
|
209
|
+
throw new Error('Graphify CLI is unavailable on PATH.')
|
|
210
|
+
}
|
|
211
|
+
return verifyUiSearch(target, skills.get(uiSkill.id), python)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function reportReadiness(target, discovery, failures) {
|
|
215
|
+
const python = pythonCommand(target)
|
|
216
|
+
if (!python) {
|
|
217
|
+
failures.push({ id: 'ui-ux-pro-max', harnesses: Object.keys(skillRoots), message: 'Python 3 is unavailable on PATH.' })
|
|
218
|
+
}
|
|
219
|
+
const marker = join(target, '.agents/skills/workflow-initiate/scripts/marker.mjs')
|
|
220
|
+
const runMarker = (operation, ...ids) => command(process.execPath, [marker, operation, target, ...ids], target)
|
|
221
|
+
const markerState = runMarker('show')
|
|
222
|
+
const verified = []
|
|
223
|
+
const reports = []
|
|
224
|
+
let repairNeeded = markerState.status !== 0
|
|
225
|
+
if (repairNeeded) console.error(markerState.stderr?.trim() || 'Cannot read the readiness marker.')
|
|
226
|
+
|
|
227
|
+
for (const [id, { skills, reason }] of Object.entries(discovery)) {
|
|
228
|
+
const affected = failures.filter(({ harnesses }) => harnesses.includes(id))
|
|
229
|
+
if (affected.length || markerState.status !== 0) {
|
|
230
|
+
const problem = affected.length ? affected.map(({ id }) => id).join(', ') : 'readiness marker'
|
|
231
|
+
reports.push([id, `repair needed (${problem})`])
|
|
232
|
+
} else if (reason) {
|
|
233
|
+
reports.push([id, `pending. ${reason}`])
|
|
234
|
+
} else {
|
|
235
|
+
try {
|
|
236
|
+
const pending = verifyHarness(target, id, skills, python)
|
|
237
|
+
if (pending) reports.push([id, `pending. ${pending}`])
|
|
238
|
+
else {
|
|
239
|
+
verified.push(id)
|
|
240
|
+
reports.push([id, 'ready'])
|
|
241
|
+
}
|
|
242
|
+
} catch (error) {
|
|
243
|
+
repairNeeded = true
|
|
244
|
+
reports.push([id, `repair needed. ${error.message}`])
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (verified.length) {
|
|
249
|
+
const outcome = runMarker('record', ...verified)
|
|
250
|
+
if (outcome.status !== 0) {
|
|
251
|
+
repairNeeded = true
|
|
252
|
+
console.error(outcome.stderr?.trim() || 'Cannot record readiness.')
|
|
253
|
+
for (const report of reports) {
|
|
254
|
+
if (report[1] === 'ready') report[1] = 'repair needed (readiness marker could not be updated)'
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
for (const [id, status] of reports) console.log(`${id}: ${status}`)
|
|
259
|
+
for (const { id, harnesses, message } of failures) {
|
|
260
|
+
console.error(`Repair ${id} (${harnesses.join(', ')}): ${message}`)
|
|
261
|
+
}
|
|
262
|
+
return failures.length > 0 || repairNeeded
|
|
263
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const releaseTargets = {
|
|
2
|
+
private: {
|
|
3
|
+
name: '@yairabf/ew-private',
|
|
4
|
+
registry: 'https://npm.pkg.github.com',
|
|
5
|
+
access: 'restricted',
|
|
6
|
+
},
|
|
7
|
+
public: {
|
|
8
|
+
name: '@yairabf/engineering-workflows',
|
|
9
|
+
registry: 'https://registry.npmjs.org',
|
|
10
|
+
access: 'public',
|
|
11
|
+
},
|
|
12
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from 'node:fs'
|
|
4
|
+
import { checkoutRoot, install } from './install.mjs'
|
|
5
|
+
import { preparePrerequisites } from './prerequisites.mjs'
|
|
6
|
+
import { discover, reportReadiness } from './readiness.mjs'
|
|
7
|
+
|
|
8
|
+
import { releaseTargets } from './release-targets.mjs'
|
|
9
|
+
|
|
10
|
+
const hostedSource = 'ssh://git@github.com/yairabf/my-ai-workflow.git'
|
|
11
|
+
|
|
12
|
+
function pinnedSource() {
|
|
13
|
+
// npm records the verified Git commit in the lockfile above node_modules.
|
|
14
|
+
const { packages } = JSON.parse(readFileSync(new URL('../../../package-lock.json', import.meta.url), 'utf8'))
|
|
15
|
+
const requested = packages?.['']?.dependencies?.['engineering-workflows']
|
|
16
|
+
const entry = Object.entries(packages ?? {}).find(([path]) =>
|
|
17
|
+
path === 'node_modules/engineering-workflows' || path.endsWith('/node_modules/engineering-workflows'))
|
|
18
|
+
const gitCommit = /^git\+([^#]+)#([a-f0-9]{40})$/
|
|
19
|
+
const githubCommit = /^github:[\w.-]+\/[\w.-]+#([a-f0-9]{40})$/
|
|
20
|
+
const [, repository, revision] = gitCommit.exec(entry?.[1]?.resolved) ?? []
|
|
21
|
+
const requestedRevision = gitCommit.exec(requested)?.[2] ?? githubCommit.exec(requested)?.[1]
|
|
22
|
+
if (!revision || revision !== requestedRevision) {
|
|
23
|
+
throw new Error('Use a full Git commit pin for the Engineering Workflows package.')
|
|
24
|
+
}
|
|
25
|
+
return { revision, repository }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function packSource() {
|
|
29
|
+
const manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
|
|
30
|
+
if (manifest.name === 'engineering-workflows' && manifest.engineeringWorkflowsRelease === undefined) {
|
|
31
|
+
return pinnedSource()
|
|
32
|
+
}
|
|
33
|
+
const { version } = manifest
|
|
34
|
+
const commit = manifest.engineeringWorkflowsRelease?.sourceCommit
|
|
35
|
+
const target = Object.values(releaseTargets).find(({ name }) => name === manifest.name)
|
|
36
|
+
if (!target || typeof version !== 'string' || !/^\d+\.\d+\.\d+$/.test(version) ||
|
|
37
|
+
manifest.publishConfig?.registry !== target.registry ||
|
|
38
|
+
manifest.publishConfig?.access !== target.access ||
|
|
39
|
+
typeof commit !== 'string' || !/^[a-f0-9]{40}$/.test(commit)) {
|
|
40
|
+
throw new Error('The Engineering Workflows package release metadata is invalid. Reinstall the pinned release.')
|
|
41
|
+
}
|
|
42
|
+
return { revision: commit, repository: hostedSource }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const usage = 'Usage: engineering-workflows <setup|upgrade> | <plan|get|run> <owner/repository> <issue-number>'
|
|
46
|
+
try {
|
|
47
|
+
const args = process.argv.slice(2)
|
|
48
|
+
if (args.length === 1 && args[0] === '--help') {
|
|
49
|
+
console.log(usage)
|
|
50
|
+
} else if (['plan', 'get', 'run'].includes(args[0])) {
|
|
51
|
+
const { runBuilderRequest } = await import('./builder-plan.mjs')
|
|
52
|
+
await runBuilderRequest(args)
|
|
53
|
+
} else if (args.length === 1 && args[0] === 'upgrade') {
|
|
54
|
+
const target = checkoutRoot(process.cwd())
|
|
55
|
+
const { revision, repository } = packSource()
|
|
56
|
+
const { upgrade } = await import('./upgrade.mjs')
|
|
57
|
+
upgrade(target, revision, repository)
|
|
58
|
+
} else if (args.length === 1 && args[0] === 'setup') {
|
|
59
|
+
const target = checkoutRoot(process.cwd())
|
|
60
|
+
install(target, packSource().revision, { githubCi: true })
|
|
61
|
+
console.log('GitHub CI workflow: .github/workflows/engineering-workflows.yml')
|
|
62
|
+
const failures = preparePrerequisites(target, await discover(target))
|
|
63
|
+
if (reportReadiness(target, await discover(target), failures)) process.exitCode = 1
|
|
64
|
+
} else {
|
|
65
|
+
throw new Error(usage)
|
|
66
|
+
}
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error(`Engineering Workflows: ${error.message}`)
|
|
69
|
+
process.exitCode = 1
|
|
70
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
3
|
+
import { join, resolve } from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
|
|
6
|
+
import { releaseTargets } from './release-targets.mjs'
|
|
7
|
+
|
|
8
|
+
const source = fileURLToPath(new URL('../', import.meta.url))
|
|
9
|
+
|
|
10
|
+
const version = '1.0.0'
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const channel = process.argv[3] ?? 'private'
|
|
14
|
+
if (![3, 4].includes(process.argv.length) || !Object.hasOwn(releaseTargets, channel)) {
|
|
15
|
+
throw new Error('Usage: node engineering-workflows/stage-release.mjs <new-staging-directory> [private|public]')
|
|
16
|
+
}
|
|
17
|
+
const { name, registry, access } = releaseTargets[channel]
|
|
18
|
+
const destination = resolve(process.argv[2])
|
|
19
|
+
const git = (args) => execFileSync('git', ['-C', source, ...args], {
|
|
20
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
21
|
+
})
|
|
22
|
+
const commit = git(['rev-parse', 'HEAD']).toString().trim()
|
|
23
|
+
if (!/^[a-f0-9]{40}$/.test(commit)) throw new Error('Cannot identify the release source commit.')
|
|
24
|
+
const original = JSON.parse(git(['show', `${commit}:package.json`]))
|
|
25
|
+
const archive = git(['archive', commit, '--', 'package.json', ...original.files])
|
|
26
|
+
mkdirSync(destination)
|
|
27
|
+
execFileSync('tar', ['-x', '-f', '-', '-C', destination], { input: archive })
|
|
28
|
+
|
|
29
|
+
const manifestPath = join(destination, 'package.json')
|
|
30
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
|
|
31
|
+
delete manifest.private
|
|
32
|
+
delete manifest.repository
|
|
33
|
+
Object.assign(manifest, {
|
|
34
|
+
name,
|
|
35
|
+
version,
|
|
36
|
+
bin: { ew: manifest.bin['engineering-workflows'] },
|
|
37
|
+
publishConfig: { registry, access },
|
|
38
|
+
engineeringWorkflowsRelease: { sourceCommit: commit },
|
|
39
|
+
})
|
|
40
|
+
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n')
|
|
41
|
+
console.log(`Staged ${name}@${version} from ${commit}`)
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error(`Engineering Workflows release: ${error.message}`)
|
|
44
|
+
process.exitCode = 1
|
|
45
|
+
}
|