@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,117 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
2
|
+
import { lstatSync, mkdirSync, realpathSync } from 'node:fs'
|
|
3
|
+
import { join, resolve } from 'node:path'
|
|
4
|
+
import { pathToFileURL } from 'node:url'
|
|
5
|
+
|
|
6
|
+
function run(binary, args, cwd, failure) {
|
|
7
|
+
try {
|
|
8
|
+
return execFileSync(binary, args, {
|
|
9
|
+
cwd,
|
|
10
|
+
encoding: 'utf8',
|
|
11
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
12
|
+
env: { ...process.env, GH_PROMPT_DISABLED: '1', GIT_TERMINAL_PROMPT: '0' },
|
|
13
|
+
}).trim()
|
|
14
|
+
} catch {
|
|
15
|
+
throw new Error(failure)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function ticketIdentity(repository, number) {
|
|
20
|
+
const parts = repository?.split('/') ?? []
|
|
21
|
+
if (
|
|
22
|
+
parts.length !== 2 ||
|
|
23
|
+
!/^[a-z0-9_-][a-z0-9._-]*$/i.test(parts[0]) ||
|
|
24
|
+
!/^[a-z0-9._-]+$/i.test(parts[1]) ||
|
|
25
|
+
parts[1] === '.' ||
|
|
26
|
+
parts[1] === '..' ||
|
|
27
|
+
!/^[1-9]\d*$/.test(number) ||
|
|
28
|
+
!Number.isSafeInteger(Number(number))
|
|
29
|
+
) {
|
|
30
|
+
throw new Error('Expected a GitHub owner/repository and a positive issue number.')
|
|
31
|
+
}
|
|
32
|
+
return { repository: parts.join('/').toLowerCase(), number: Number(number) }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function projectDirectory(parent, name) {
|
|
36
|
+
// The parent is an operator-owned directory. Refuse redirected children.
|
|
37
|
+
const path = join(parent, name)
|
|
38
|
+
try {
|
|
39
|
+
mkdirSync(path)
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error.code !== 'EEXIST') throw error
|
|
42
|
+
}
|
|
43
|
+
if (!lstatSync(path).isDirectory()) throw new Error('A builder directory conflicts with an existing entry.')
|
|
44
|
+
return path
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function resolveTicket(root, input, number) {
|
|
48
|
+
const ticket = ticketIdentity(input, number)
|
|
49
|
+
const api = (endpoint) =>
|
|
50
|
+
JSON.parse(
|
|
51
|
+
run(
|
|
52
|
+
'gh',
|
|
53
|
+
['api', '--hostname', 'github.com', endpoint],
|
|
54
|
+
root,
|
|
55
|
+
'GitHub lookup failed. Check the repository, issue number, and configured access.',
|
|
56
|
+
),
|
|
57
|
+
)
|
|
58
|
+
const repo = api('repos/' + ticket.repository)
|
|
59
|
+
const identity = ticketIdentity(repo.full_name, number)
|
|
60
|
+
const issue = api('repos/' + identity.repository + '/issues/' + identity.number)
|
|
61
|
+
const url = 'https://github.com/' + identity.repository + '/issues/' + identity.number
|
|
62
|
+
if (
|
|
63
|
+
issue.pull_request ||
|
|
64
|
+
issue.number !== identity.number ||
|
|
65
|
+
issue.html_url?.toLowerCase() !== url ||
|
|
66
|
+
typeof issue.title !== 'string' ||
|
|
67
|
+
!(issue.body === null || typeof issue.body === 'string')
|
|
68
|
+
) {
|
|
69
|
+
throw new Error('GitHub did not resolve the requested issue in this repository.')
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!Number.isSafeInteger(repo.id) || repo.id <= 0) throw new Error('Missing GitHub repository ID.')
|
|
73
|
+
return { ...identity, id: repo.id, url, title: issue.title, body: issue.body ?? '' }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function openTicket(root, input, number) {
|
|
77
|
+
const ticket = resolveTicket(root, input, number)
|
|
78
|
+
const projects = projectDirectory(root, 'projects')
|
|
79
|
+
const checkout = join(projects, String(ticket.id))
|
|
80
|
+
const info = lstatSync(checkout, { throwIfNoEntry: false })
|
|
81
|
+
if (!info) {
|
|
82
|
+
run(
|
|
83
|
+
'gh',
|
|
84
|
+
['repo', 'clone', 'github.com/' + ticket.repository, checkout],
|
|
85
|
+
root,
|
|
86
|
+
'Clone failed. Check GitHub access and the builder destination.',
|
|
87
|
+
)
|
|
88
|
+
} else if (!info.isDirectory()) {
|
|
89
|
+
throw new Error('The checkout destination is occupied.')
|
|
90
|
+
}
|
|
91
|
+
const git = (...args) =>
|
|
92
|
+
run('git', args, checkout, 'The checkout destination is not a usable Git checkout.')
|
|
93
|
+
const origin = git('remote', 'get-url', 'origin')
|
|
94
|
+
const remote = /^(?:https:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)(.+)$/i.exec(origin)
|
|
95
|
+
if (
|
|
96
|
+
realpathSync(git('rev-parse', '--show-toplevel')) !== realpathSync(checkout) ||
|
|
97
|
+
!remote ||
|
|
98
|
+
![ticket.repository, ticket.repository + '.git'].includes(remote[1].toLowerCase())
|
|
99
|
+
) {
|
|
100
|
+
throw new Error('The checkout destination belongs to another repository.')
|
|
101
|
+
}
|
|
102
|
+
return { ...ticket, checkout }
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Builder-side checkout stage. Its JSON result is the input to preparation.
|
|
106
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
|
107
|
+
try {
|
|
108
|
+
const [root, repository, number, ...extra] = process.argv.slice(2)
|
|
109
|
+
if (!root || extra.length || !number) {
|
|
110
|
+
throw new Error('Usage: node builder-project.mjs <builder-directory> <owner/repository> <issue-number>')
|
|
111
|
+
}
|
|
112
|
+
console.log(JSON.stringify(openTicket(realpathSync(root), repository, number)))
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.error(error.message)
|
|
115
|
+
process.exitCode = 1
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
2
|
+
|
|
3
|
+
const owner = 'yairabf'
|
|
4
|
+
const name = 'ew-private'
|
|
5
|
+
|
|
6
|
+
function github(path, ...args) {
|
|
7
|
+
const response = execFileSync('gh', ['api', '--hostname', 'github.com', path, ...args], {
|
|
8
|
+
encoding: 'utf8',
|
|
9
|
+
stdio: ['ignore', 'pipe', 'inherit'],
|
|
10
|
+
})
|
|
11
|
+
return JSON.parse(response)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function packageVisibility() {
|
|
15
|
+
const pages = github(
|
|
16
|
+
'/user/packages?package_type=npm&per_page=100',
|
|
17
|
+
'--paginate', '--slurp',
|
|
18
|
+
)
|
|
19
|
+
if (!Array.isArray(pages) || pages.length === 0 || !pages.every(Array.isArray)) {
|
|
20
|
+
throw new Error('GitHub returned an unexpected package list.')
|
|
21
|
+
}
|
|
22
|
+
const packages = pages.flat()
|
|
23
|
+
if (packages.some((entry) => typeof entry?.name !== 'string' || entry.name.length === 0 ||
|
|
24
|
+
!['private', 'public', 'internal'].includes(entry.visibility))) {
|
|
25
|
+
throw new Error('GitHub returned unexpected package visibility metadata.')
|
|
26
|
+
}
|
|
27
|
+
const matches = packages.filter((entry) => entry.name === name || entry.name === `@${owner}/${name}`)
|
|
28
|
+
if (matches.length > 1) throw new Error('GitHub returned conflicting package entries.')
|
|
29
|
+
return matches[0]?.visibility
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const [phase] = process.argv.slice(2)
|
|
34
|
+
if (process.argv.length !== 3 || !['before', 'after'].includes(phase)) {
|
|
35
|
+
throw new Error('Usage: node engineering-workflows/check-package-visibility.mjs before|after')
|
|
36
|
+
}
|
|
37
|
+
if (!process.env.GH_TOKEN?.startsWith('ghp_') || github('/user').login !== owner) {
|
|
38
|
+
throw new Error(`Set GH_TOKEN to a classic GitHub Packages token owned by ${owner}.`)
|
|
39
|
+
}
|
|
40
|
+
const visibility = packageVisibility()
|
|
41
|
+
if (visibility === 'public' || visibility === 'internal') {
|
|
42
|
+
throw new Error(`@${owner}/${name} is ${visibility}. Stop and resolve the package identity with the owner.`)
|
|
43
|
+
}
|
|
44
|
+
if (visibility === 'private') {
|
|
45
|
+
console.log(`GitHub confirms @${owner}/${name} is private.`)
|
|
46
|
+
} else if (phase === 'before') {
|
|
47
|
+
console.log(`GitHub lists no @${owner}/${name} package for the owner. Use the unlinked first-publish path.`)
|
|
48
|
+
} else {
|
|
49
|
+
throw new Error(`GitHub did not confirm private visibility for @${owner}/${name}.`)
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(`Engineering Workflows package visibility: ${error.message}`)
|
|
53
|
+
process.exitCode = 1
|
|
54
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
2
|
+
import {
|
|
3
|
+
accessSync,
|
|
4
|
+
constants,
|
|
5
|
+
cpSync,
|
|
6
|
+
linkSync,
|
|
7
|
+
lstatSync,
|
|
8
|
+
mkdirSync,
|
|
9
|
+
mkdtempSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
readdirSync,
|
|
12
|
+
realpathSync,
|
|
13
|
+
renameSync,
|
|
14
|
+
rmSync,
|
|
15
|
+
writeFileSync,
|
|
16
|
+
} from 'node:fs'
|
|
17
|
+
import { tmpdir } from 'node:os'
|
|
18
|
+
import { basename, dirname, join, posix, resolve } from 'node:path'
|
|
19
|
+
import { fileURLToPath } from 'node:url'
|
|
20
|
+
|
|
21
|
+
const pack = fileURLToPath(new URL('.', import.meta.url))
|
|
22
|
+
export const sourceRoot = dirname(resolve(pack))
|
|
23
|
+
const roles = ['workflow-initiate', 'workflow-investigate', 'workflow-plan', 'workflow-implement', 'workflow-review']
|
|
24
|
+
const roots = ['.agents/skills', '.claude/skills']
|
|
25
|
+
const prerequisites = ['.agents/skills/grill-me', '.agents/skills/grilling']
|
|
26
|
+
|
|
27
|
+
export const rolePaths = roots.flatMap((root) => roles.map((role) => {
|
|
28
|
+
const target = `${root}/${role}`
|
|
29
|
+
return { source: `engineering-workflows/${target}`, target }
|
|
30
|
+
}))
|
|
31
|
+
export const bundledPaths = prerequisites.map((source) => ({
|
|
32
|
+
source,
|
|
33
|
+
target: `.engineering-workflows/prerequisites/${basename(source)}`,
|
|
34
|
+
}))
|
|
35
|
+
export const ciPath = {
|
|
36
|
+
source: 'engineering-workflows/workflows/engineering-workflows.yml',
|
|
37
|
+
target: '.github/workflows/engineering-workflows.yml',
|
|
38
|
+
}
|
|
39
|
+
export const stampPath = '.engineering-workflows/revision.txt'
|
|
40
|
+
|
|
41
|
+
function git(directory, ...args) {
|
|
42
|
+
return execFileSync('git', ['-C', directory, ...args], {
|
|
43
|
+
encoding: 'utf8',
|
|
44
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
45
|
+
}).trimEnd()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function stat(path) {
|
|
49
|
+
try {
|
|
50
|
+
return lstatSync(path)
|
|
51
|
+
} catch (error) {
|
|
52
|
+
if (error.code !== 'ENOENT') throw error
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function sameTree(left, right) {
|
|
57
|
+
const leftStat = stat(left)
|
|
58
|
+
const rightStat = stat(right)
|
|
59
|
+
if (leftStat?.isFile() && rightStat?.isFile()) {
|
|
60
|
+
return (leftStat.mode & 0o111) === (rightStat.mode & 0o111) &&
|
|
61
|
+
readFileSync(left).equals(readFileSync(right))
|
|
62
|
+
}
|
|
63
|
+
if (!leftStat?.isDirectory() || !rightStat?.isDirectory()) return false
|
|
64
|
+
|
|
65
|
+
const names = readdirSync(left)
|
|
66
|
+
return names.length === readdirSync(right).length &&
|
|
67
|
+
names.every((name) => sameTree(join(left, name), join(right, name)))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function targetPath(target, relative) {
|
|
71
|
+
let path = target
|
|
72
|
+
for (const part of relative.split('/')) {
|
|
73
|
+
path = join(path, part)
|
|
74
|
+
const existing = stat(path)
|
|
75
|
+
if (existing && !existing.isDirectory()) {
|
|
76
|
+
throw new Error(`Expected a directory at ${path}`)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return path
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function checkWritableParent(destination) {
|
|
83
|
+
let parent = dirname(destination)
|
|
84
|
+
while (!stat(parent)) parent = dirname(parent)
|
|
85
|
+
try {
|
|
86
|
+
accessSync(parent, constants.W_OK | constants.X_OK)
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error.code !== 'EACCES' && error.code !== 'EPERM' && error.code !== 'EROFS') throw error
|
|
89
|
+
throw new Error(`Cannot install ${destination}: write or traversal access denied at ${parent}`)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function register(from, to) {
|
|
94
|
+
const parent = dirname(to)
|
|
95
|
+
mkdirSync(parent, { recursive: true })
|
|
96
|
+
const stage = mkdtempSync(join(parent, '.workflow-install-'))
|
|
97
|
+
try {
|
|
98
|
+
const staged = join(stage, 'content')
|
|
99
|
+
cpSync(from, staged, { recursive: true })
|
|
100
|
+
if (stat(to)) throw new Error(`Destination appeared during installation: ${to}`)
|
|
101
|
+
if (stat(staged).isFile()) {
|
|
102
|
+
linkSync(staged, to)
|
|
103
|
+
} else {
|
|
104
|
+
renameSync(staged, to)
|
|
105
|
+
}
|
|
106
|
+
} finally {
|
|
107
|
+
rmSync(stage, { recursive: true, force: true })
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function checkoutRevision() {
|
|
112
|
+
const revision = git(sourceRoot, 'rev-parse', 'HEAD')
|
|
113
|
+
const changes = git(sourceRoot, 'status', '--porcelain', '--untracked-files=all', '--ignored=matching',
|
|
114
|
+
'--', 'engineering-workflows', ...prerequisites)
|
|
115
|
+
if (changes) throw new Error('Run the installer from a clean checkout of the chosen pack revision.')
|
|
116
|
+
return revision
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function install(target, revision = checkoutRevision(), { githubCi = false } = {}) {
|
|
120
|
+
const destination = targetPath(target, '.engineering-workflows')
|
|
121
|
+
const stamp = join(target, stampPath)
|
|
122
|
+
if (stat(stamp)?.isFile()) {
|
|
123
|
+
const previous = readFileSync(stamp, 'utf8').trim()
|
|
124
|
+
if (/^[a-f0-9]{40}$/.test(previous) && previous !== revision) {
|
|
125
|
+
throw new Error(`A different workflow pack revision is installed at ${stamp} (${previous}). Run engineering-workflows upgrade with the desired pin.`)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const resources = mkdtempSync(join(tmpdir(), 'engineering-workflows-'))
|
|
129
|
+
try {
|
|
130
|
+
const bundled = join(resources, 'prerequisites')
|
|
131
|
+
mkdirSync(bundled)
|
|
132
|
+
for (const path of bundledPaths) {
|
|
133
|
+
cpSync(join(sourceRoot, path.source), join(bundled, basename(path.target)), { recursive: true })
|
|
134
|
+
}
|
|
135
|
+
writeFileSync(join(resources, 'revision.txt'), revision + '\n')
|
|
136
|
+
|
|
137
|
+
const copies = rolePaths.map((path) => [join(sourceRoot, path.source), targetPath(target, path.target)])
|
|
138
|
+
copies.push([resources, destination])
|
|
139
|
+
if (githubCi) {
|
|
140
|
+
copies.push([
|
|
141
|
+
join(sourceRoot, ciPath.source),
|
|
142
|
+
join(targetPath(target, posix.dirname(ciPath.target)), basename(ciPath.target)),
|
|
143
|
+
])
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const missing = copies.filter(([from, to]) => {
|
|
147
|
+
if (!stat(to)) return true
|
|
148
|
+
if (!sameTree(from, to)) throw new Error(`Existing content differs at ${to}`)
|
|
149
|
+
return false
|
|
150
|
+
})
|
|
151
|
+
for (const [, to] of missing) checkWritableParent(to)
|
|
152
|
+
for (const [from, to] of missing) register(from, to)
|
|
153
|
+
|
|
154
|
+
const result = missing.length ? 'Installed' : 'Already installed'
|
|
155
|
+
console.log(`${result} Engineering Workflows at ${revision}`)
|
|
156
|
+
} finally {
|
|
157
|
+
rmSync(resources, { recursive: true, force: true })
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function checkoutRoot(directory) {
|
|
162
|
+
const requested = resolve(directory)
|
|
163
|
+
try {
|
|
164
|
+
const target = realpathSync(git(requested, 'rev-parse', '--show-toplevel'))
|
|
165
|
+
if (target !== realpathSync(requested)) throw new Error('Expected the Git root.')
|
|
166
|
+
return target
|
|
167
|
+
} catch {
|
|
168
|
+
throw new Error(`Use the root of an accessible Git worktree: ${requested}`)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (process.argv[1] && stat(process.argv[1]) && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
173
|
+
try {
|
|
174
|
+
if (process.argv.length !== 3) {
|
|
175
|
+
throw new Error('Usage: node engineering-workflows/install.mjs <target-git-root>')
|
|
176
|
+
}
|
|
177
|
+
install(checkoutRoot(process.argv[2]))
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error(`Engineering Workflows: ${error.message}`)
|
|
180
|
+
process.exitCode = 1
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# Mission controller
|
|
2
|
+
|
|
3
|
+
Run the controller from the pack root with Node 22 or later. Choose a dedicated
|
|
4
|
+
state directory on a local filesystem that supports hard links. Its parent
|
|
5
|
+
must exist and the directory must be outside the pack and the target checkout.
|
|
6
|
+
Each directory tracks one active mission and retains delivered missions. Keep
|
|
7
|
+
the directory private, since it contains the original handoffs. Leave
|
|
8
|
+
credentials in the role or GitHub runtime's credential store.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
node engineering-workflows/mission-controller.mjs --help
|
|
12
|
+
node engineering-workflows/mission-controller.mjs --state "$mission_state" submit OWNER/REPO 7 mission.md
|
|
13
|
+
node engineering-workflows/mission-controller.mjs --state "$mission_state" status
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Use the observed revision as `--at REVISION` when recording a handoff, approving
|
|
17
|
+
a plan, or submitting another ticket. Keep the revision that a role was given
|
|
18
|
+
with its result. If another invocation advances the mission, read status and
|
|
19
|
+
check whether the result still applies. Running the identical command with the
|
|
20
|
+
original revision and inputs reports the previously accepted revision. After an
|
|
21
|
+
interruption, run status and retry from the last published revision. Use
|
|
22
|
+
`status OWNER/REPO ISSUE` to look up a ticket without relying on the current
|
|
23
|
+
checkout. Leave the saved JSON and Markdown files as written by the controller.
|
|
24
|
+
|
|
25
|
+
## Connect a builder-local MCP client
|
|
26
|
+
|
|
27
|
+
Configure a trusted client to launch the following stdio server with Node 22 or
|
|
28
|
+
later. Replace both example paths with absolute paths on the machine launching
|
|
29
|
+
the process. The second path is the builder's existing project bind mount
|
|
30
|
+
followed by `ew-remote/mission-state`. Its parent must exist. The launching
|
|
31
|
+
account needs access to that private directory. The server negotiates MCP
|
|
32
|
+
revision `2025-06-18`.
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"mcpServers": {
|
|
37
|
+
"missions": {
|
|
38
|
+
"command": "node",
|
|
39
|
+
"args": ["/path/to/pack/engineering-workflows/mission-mcp.mjs", "--state", "/path/to/project-bind/ew-remote/mission-state"]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For a disposable exercise, use an empty temporary directory as the parent and
|
|
46
|
+
set the final argument to its `mission-state` child. In the client:
|
|
47
|
+
|
|
48
|
+
1. Call `submit_mission` with `{"repository":"example/demo","issue":7,"markdown":"Show the output option in CLI help."}`. Expect `{"revision":1}`. Reconnecting and repeating this call returns the same revision.
|
|
49
|
+
2. Call `mission_status` with `{}`, or with `{"repository":"example/demo","issue":7}`. Expect `stage` to be `preparation`, `revision` to be 1, a readiness instruction in `nextAction`, and null for `pendingPlan` and `prUrl`.
|
|
50
|
+
3. On a configured builder using a real ticket, the operator runs `node engineering-workflows/builder-plan.mjs run OWNER/REPO ISSUE` separately. When status reaches `approval`, display the returned pending plan as Markdown text. The operator approves the plan through the builder. Subsequent status calls include the latest recorded PR URL when available.
|
|
51
|
+
|
|
52
|
+
For the next ticket in the same store, read current status after delivery and
|
|
53
|
+
pass its revision as `expectedRevision` to submit. Repeat the same arguments,
|
|
54
|
+
including that revision, when retrying. The default expected revision is zero.
|
|
55
|
+
Each successful result includes structured JSON and its text equivalent.
|
|
56
|
+
Tool errors set `isError` and return `code` and `message` in both forms.
|
|
57
|
+
|
|
58
|
+
| Code | Client action |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `invalid_input` | Correct the fields using the advertised schema. |
|
|
61
|
+
| `missing_mission` | Check the ticket, or submit the first mission. |
|
|
62
|
+
| `stale_revision` | Read current status before deciding whether to resubmit. |
|
|
63
|
+
| `active_mission` | Resume the active ticket and wait for delivery. |
|
|
64
|
+
| `internal_failure` | Ask the operator to check store access and integrity. |
|
|
65
|
+
|
|
66
|
+
## What to submit
|
|
67
|
+
|
|
68
|
+
The mission input is UTF-8 Markdown with the goal and any acceptance criteria,
|
|
69
|
+
source reference, and constraints you have. The controller adds the canonical
|
|
70
|
+
issue URL. Include that URL in every subsequent UTF-8 Markdown handoff. In
|
|
71
|
+
artifact references, include the full filename shown by status. The command
|
|
72
|
+
checks the revision, stage, and handoff identifiers. Use the existing
|
|
73
|
+
[development workflow](../workflows/development.md) to collect and verify the
|
|
74
|
+
facts supplied by each role.
|
|
75
|
+
|
|
76
|
+
| Handoff | Content and action |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| `record ready FILE` | Run Initiate or confirm readiness for a reused checkout. Record the absolute `**Checkout:**`, the `**Base branch:**`, and the result under `## Readiness`. |
|
|
79
|
+
| `record brief FILE` | Run Investigator in a fresh read-only session. Use the role template, including the Mission, Repository context, and Verified findings sections. |
|
|
80
|
+
| `record clarification FILE` | Save the planner's question or the operator's answer while planning. Pass the clarification and saved brief to Planner. |
|
|
81
|
+
| `record plan FILE` | Use the plan template, cite the saved brief filename in Mission and evidence, and include one `**Decision:** Pending` line under Human approval. Submit a revised pending plan if the approved plan changes before a candidate is recorded. |
|
|
82
|
+
| `record plan-feedback FILE` | Send clarification or requested changes back to Planner while a plan awaits approval. Status includes the saved draft to revise, the investigation brief, and feedback. |
|
|
83
|
+
| `approve PLAN_FILENAME` | Copy the exact pending filename from status. The controller creates an approved Markdown copy for the developer. |
|
|
84
|
+
| `record candidate FILE` | Use the implementation handoff. Give the saved approved filename in Approved plan, the full SHA in Candidate commit, and separate Target (`OWNER/REPO`), Branch, and Worktree fields. Use an absolute worktree path distinct from the readiness checkout. Put factual tests and observed results under Verification. |
|
|
85
|
+
| `record review FILE` | Use the independent review template. Name the exact SHA under Candidate and the saved approved filename under Mission and approved plan. Set Target and base to `OWNER/REPO` and add Base branch and full Base commit fields. Set Verdict to `Pass — reason`, `Changes requested — reason`, or `Blocked — reason`. A passing or changes-requested report includes Acceptance criteria and Thermo review and required changes. |
|
|
86
|
+
| `record evidence FILE` | To resume a blocked review, give the exact Candidate SHA and the missing evidence. Keep the blocked report as part of the review history. If the code changes, submit its new candidate or repair handoff for fresh review. |
|
|
87
|
+
| `record repair FILE` | Use the same branch and worktree, and link the review requesting changes and the reviewed SHA in Repair details. In the fresh review, cite the saved repair filename and the review that requested it under Repair review. |
|
|
88
|
+
| `record continue FILE` | After two unsuccessful repairs, record the operator's decision to authorize one more repair. Include the outstanding issues and how to proceed. |
|
|
89
|
+
| `record delivery FILE` | Record the same-repository PR URL under PR, its full current SHA under Head, CI as Pending, Failed, or Passed, and Advisory review as Pending or Resolved. Cite check results and the advisory outcome (including applicable skips) under Evidence. A new head requires a fresh review. |
|
|
90
|
+
| `record head-changed FILE` | Use the delivery fields after verifying that the actual PR head changed, including when it returns to a previously reviewed SHA. If an existing PR changes again while awaiting a candidate or its review or repair, record the latest observed head and retain the earlier history. Submit that head as a candidate and obtain fresh review and delivery evidence. |
|
|
91
|
+
|
|
92
|
+
Use fields such as `**Candidate:** VALUE` or `- **Candidate** — VALUE`. Keep
|
|
93
|
+
role text and fixture evidence separate from the commands you execute. The
|
|
94
|
+
controller records supplied evidence locally. Use the existing GitHub
|
|
95
|
+
workflow to verify the PR head, publish changes, and make the merge decision.
|
|
96
|
+
|
|
97
|
+
## Run a disposable local example
|
|
98
|
+
|
|
99
|
+
From the pack root, paste this block into Bash. It uses fixture handoffs and
|
|
100
|
+
does not contact GitHub.
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
example_dir=$(mktemp -d)
|
|
104
|
+
example_state="$example_dir/state"
|
|
105
|
+
example_issue=https://github.com/example/demo/issues/7
|
|
106
|
+
example_sha=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
107
|
+
example_base=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
|
|
108
|
+
mkdir "$example_dir/checkout" "$example_dir/worktree"
|
|
109
|
+
|
|
110
|
+
mission() {
|
|
111
|
+
node engineering-workflows/mission-controller.mjs --state "$example_state" "$@"
|
|
112
|
+
}
|
|
113
|
+
handoff() {
|
|
114
|
+
{ printf '%s\n\n' "$example_issue"; cat; } > "$example_dir/handoff.md"
|
|
115
|
+
}
|
|
116
|
+
saved_name() {
|
|
117
|
+
mission status | sed -n "s|^$1: .*/||p"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
handoff <<'MD'
|
|
121
|
+
Goal: Show the output option in CLI help.
|
|
122
|
+
Acceptance criterion: Help lists the output option.
|
|
123
|
+
MD
|
|
124
|
+
mission submit example/demo 7 "$example_dir/handoff.md"
|
|
125
|
+
mission status
|
|
126
|
+
|
|
127
|
+
handoff <<MD
|
|
128
|
+
**Checkout:** $example_dir/checkout
|
|
129
|
+
**Base branch:** main
|
|
130
|
+
|
|
131
|
+
## Readiness
|
|
132
|
+
|
|
133
|
+
Fixture readiness is verified.
|
|
134
|
+
MD
|
|
135
|
+
mission --at 1 record ready "$example_dir/handoff.md"
|
|
136
|
+
|
|
137
|
+
handoff <<'MD'
|
|
138
|
+
## Mission
|
|
139
|
+
|
|
140
|
+
Show the output option in CLI help.
|
|
141
|
+
|
|
142
|
+
## Repository context
|
|
143
|
+
|
|
144
|
+
The fixture uses main.
|
|
145
|
+
|
|
146
|
+
## Verified findings
|
|
147
|
+
|
|
148
|
+
Help omits an existing option.
|
|
149
|
+
MD
|
|
150
|
+
mission --at 2 record brief "$example_dir/handoff.md"
|
|
151
|
+
example_brief=$(saved_name 'Investigation brief')
|
|
152
|
+
|
|
153
|
+
handoff <<MD
|
|
154
|
+
## Mission and evidence
|
|
155
|
+
|
|
156
|
+
See $example_brief.
|
|
157
|
+
|
|
158
|
+
## Planned changes
|
|
159
|
+
|
|
160
|
+
Update CLI help.
|
|
161
|
+
|
|
162
|
+
## Acceptance criteria
|
|
163
|
+
|
|
164
|
+
Help lists the output option.
|
|
165
|
+
|
|
166
|
+
## Verification
|
|
167
|
+
|
|
168
|
+
Run the CLI with --help.
|
|
169
|
+
|
|
170
|
+
## Human approval
|
|
171
|
+
|
|
172
|
+
**Decision:** Pending
|
|
173
|
+
MD
|
|
174
|
+
mission --at 3 record plan "$example_dir/handoff.md"
|
|
175
|
+
mission --at 4 approve "$(saved_name 'Pending plan')"
|
|
176
|
+
example_plan=$(saved_name 'Approved plan')
|
|
177
|
+
|
|
178
|
+
handoff <<MD
|
|
179
|
+
**Approved plan:** $example_plan
|
|
180
|
+
**Target:** example/demo
|
|
181
|
+
**Branch:** feature/help
|
|
182
|
+
**Worktree:** $example_dir/worktree
|
|
183
|
+
**Candidate commit:** $example_sha
|
|
184
|
+
|
|
185
|
+
## Verification
|
|
186
|
+
|
|
187
|
+
The fixture help check passed.
|
|
188
|
+
MD
|
|
189
|
+
mission --at 5 record candidate "$example_dir/handoff.md"
|
|
190
|
+
|
|
191
|
+
handoff <<MD
|
|
192
|
+
**Mission and approved plan:** $example_plan
|
|
193
|
+
**Target and base:** example/demo
|
|
194
|
+
**Base branch:** main
|
|
195
|
+
**Base commit:** $example_base
|
|
196
|
+
**Candidate:** $example_sha
|
|
197
|
+
**Verdict:** Pass — the exact candidate met the acceptance criterion.
|
|
198
|
+
|
|
199
|
+
## Acceptance criteria
|
|
200
|
+
|
|
201
|
+
Help lists the output option.
|
|
202
|
+
|
|
203
|
+
## Thermo review and required changes
|
|
204
|
+
|
|
205
|
+
The fixture has no required changes.
|
|
206
|
+
MD
|
|
207
|
+
mission --at 6 record review "$example_dir/handoff.md"
|
|
208
|
+
|
|
209
|
+
handoff <<MD
|
|
210
|
+
**PR:** https://github.com/example/demo/pull/8
|
|
211
|
+
**Head:** $example_sha
|
|
212
|
+
**CI:** Passed
|
|
213
|
+
**Advisory review:** Resolved
|
|
214
|
+
|
|
215
|
+
## Evidence
|
|
216
|
+
|
|
217
|
+
The fixture CI passed and the advisory review reported no findings.
|
|
218
|
+
MD
|
|
219
|
+
mission --at 7 record delivery "$example_dir/handoff.md"
|
|
220
|
+
mission status example/demo 7
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
The final status starts with `example/demo#7 · delivered · revision 8` and shows
|
|
224
|
+
the approved plan, passing SHA, PR URL, saved CI evidence, and human merge
|
|
225
|
+
decision. Run `node --test engineering-workflows/mission/mission-controller.test.mjs`
|
|
226
|
+
to exercise competing submissions, interrupted writes, approval invalidation,
|
|
227
|
+
blocked review, bounded repair, and stale delivery evidence.
|
|
228
|
+
|
|
229
|
+
## Run a ticket on the builder
|
|
230
|
+
|
|
231
|
+
An empty repository can go through investigation and planning. Before implementation,
|
|
232
|
+
initialize and publish the base branch from the builder checkout named in the status
|
|
233
|
+
message. Run the same ticket again. The builder records the initial commit, repeats
|
|
234
|
+
investigation and planning with the saved operator answers, and waits for approval
|
|
235
|
+
of the new plan.
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
Point the Docker CLI at the Windows builder and run
|
|
239
|
+
`node engineering-workflows/builder-plan.mjs run OWNER/REPO ISSUE` from the
|
|
240
|
+
repository root. Preparation checks the reader's Pi catalog and records the
|
|
241
|
+
checkout and base branch in the mission controller. Repeat the same command
|
|
242
|
+
to resume using the saved revision. A different active ticket is reported
|
|
243
|
+
before opening the requested checkout. Builder state is under
|
|
244
|
+
`ew-remote/mission-state`. If the client terminates while holding
|
|
245
|
+
`ew-remote/mission-run.lock`, verify that the original invocation has ended
|
|
246
|
+
and inspect controller status before removing the empty lock directory.
|
|
247
|
+
|
|
248
|
+
The adapter runs eligible roles until a human decision, a delivery result, or
|
|
249
|
+
a failure. Each fresh Pi session uses the reader's configured runtime. Its
|
|
250
|
+
workspace tool executes in a separate container with only the assigned project
|
|
251
|
+
copy mounted. Investigation uses a temporary writable clone. Planning and
|
|
252
|
+
review mount their workspace read-only. Implementation and repairs share the
|
|
253
|
+
dedicated issue branch and clone. A changed or dirty candidate after an
|
|
254
|
+
interruption needs reconciliation before another developer session.
|
|
255
|
+
|
|
256
|
+
Use the same builder CLI with `status OWNER/REPO ISSUE` to see the stage,
|
|
257
|
+
revision and saved filenames. Use `show OWNER/REPO ISSUE FILENAME` to read a
|
|
258
|
+
handoff. For an investigator question, create a UTF-8 Markdown answer with the
|
|
259
|
+
ticket URL, exact question filename and a populated `## Answer` section. Run
|
|
260
|
+
`investigation-answer OWNER/REPO ISSUE ANSWER.md REVISION`, then `run` again.
|
|
261
|
+
For a pending plan, inspect its contents and use
|
|
262
|
+
`approve OWNER/REPO ISSUE PLAN_FILENAME REVISION`, then `run`. The
|
|
263
|
+
`plan-feedback`, `evidence`, `continue`, and `delivery` commands accept a
|
|
264
|
+
Markdown file and observed revision as documented in the handoff table above.
|
|
265
|
+
Repeat `run` to refresh pending PR checks. Record the advisory disposition for
|
|
266
|
+
the observed head after reviewing the findings. The operator decides on merge.
|
|
267
|
+
|
|
268
|
+
If an implementation or repair has committed its work but the captured handoff
|
|
269
|
+
fails validation, inspect the reported workspace, commit, failed check and saved
|
|
270
|
+
output. Correct the Markdown using the actual commit and verification evidence.
|
|
271
|
+
Run `recover-handoff OWNER/REPO ISSUE CORRECTED.md REVISION`, then `run`.
|
|
272
|
+
The replacement is checked against the same workspace, SHA, branch, plan and
|
|
273
|
+
mission revision before it can reach review. Recovery preserves the original
|
|
274
|
+
captured artifact and does not invoke the developer again.
|
|
275
|
+
|
|
276
|
+
If the planner needs a decision, status shows `planning-waiting` and the saved
|
|
277
|
+
question filename. Read it with `show`. Write the ticket URL, that filename
|
|
278
|
+
and a populated `## Answer` section in a UTF-8 file, then run
|
|
279
|
+
`clarification OWNER/REPO ISSUE ANSWER.md REVISION` and resume with `run`.
|
|
280
|
+
The new planner session receives the original brief, question and answer.
|
|
281
|
+
Operator Markdown files may use Windows or Unix line endings.
|