@bbsnly/sdlc 0.1.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/LICENSE +21 -0
- package/README.md +51 -0
- package/bin/sdlc-install.js +72 -0
- package/checksums.txt +14 -0
- package/lib/install.js +322 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anatoliy Babushka
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @bbsnly/sdlc
|
|
2
|
+
|
|
3
|
+
Installs [sdlc](https://github.com/bbsnly/sdlc): a story-driven delivery loop
|
|
4
|
+
for Claude Code, with gates a model cannot talk its way past.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npx @bbsnly/sdlc install
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
That downloads the release for your machine, checks it against the release's
|
|
11
|
+
checksums, and puts the `sdlc` binary in `~/.local/bin` (on Windows,
|
|
12
|
+
`%LOCALAPPDATA%\Programs\sdlc\bin`).
|
|
13
|
+
|
|
14
|
+
Then, in Claude Code:
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
/plugin marketplace add bbsnly/sdlc
|
|
18
|
+
/plugin install sdlc@sdlc
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## What this package is, and is not
|
|
22
|
+
|
|
23
|
+
It is an installer. What ends up on your PATH is the native `sdlc` binary, not
|
|
24
|
+
a Node wrapper around it: sdlc runs as a Claude Code hook on every matching
|
|
25
|
+
tool call, where a Node process start would cost more than everything else in
|
|
26
|
+
the loop put together.
|
|
27
|
+
|
|
28
|
+
For the same reason there is no postinstall script. Installing a native binary
|
|
29
|
+
is something you ask for, not something that happens while you were installing
|
|
30
|
+
something else — and `--ignore-scripts` changes nothing here.
|
|
31
|
+
|
|
32
|
+
## Options
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npx @bbsnly/sdlc install --version 0.1.0 # a version other than this package's
|
|
36
|
+
npx @bbsnly/sdlc install --dir /usr/local/bin
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`SDLC_VERSION` and `SDLC_INSTALL_DIR` do the same, which is easier in a script.
|
|
40
|
+
|
|
41
|
+
## Other ways to install
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
curl -fsSL https://raw.githubusercontent.com/bbsnly/sdlc/main/install.sh | sh
|
|
45
|
+
go install github.com/bbsnly/sdlc/cmd/sdlc@latest
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Licence
|
|
49
|
+
|
|
50
|
+
MIT. See [the repository](https://github.com/bbsnly/sdlc) for the full text,
|
|
51
|
+
the documentation, and the source.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
const { install, Failure } = require('../lib/install.js')
|
|
5
|
+
const pkg = require('../package.json')
|
|
6
|
+
|
|
7
|
+
const USAGE = `Install sdlc, the story-driven delivery loop for Claude Code.
|
|
8
|
+
|
|
9
|
+
npx @bbsnly/sdlc install [--version X.Y.Z] [--dir PATH]
|
|
10
|
+
|
|
11
|
+
--version X.Y.Z install that version instead of this package's own
|
|
12
|
+
--dir PATH install somewhere other than the default
|
|
13
|
+
(~/.local/bin, or %LOCALAPPDATA%\\Programs\\sdlc\\bin)
|
|
14
|
+
-h, --help this
|
|
15
|
+
|
|
16
|
+
The same settings can come from the environment: SDLC_VERSION and
|
|
17
|
+
SDLC_INSTALL_DIR.
|
|
18
|
+
|
|
19
|
+
This package installs a native binary and then gets out of the way: what ends
|
|
20
|
+
up on your PATH is sdlc itself, not a Node wrapper around it.`
|
|
21
|
+
|
|
22
|
+
function parse(argv) {
|
|
23
|
+
const options = {}
|
|
24
|
+
for (let i = 0; i < argv.length; i++) {
|
|
25
|
+
const arg = argv[i]
|
|
26
|
+
if (arg === 'install') continue // `npx @bbsnly/sdlc install` reads better than the bare form
|
|
27
|
+
if (arg === '-h' || arg === '--help') return { help: true }
|
|
28
|
+
if (arg === '-v' || arg === '--print-version') return { printVersion: true }
|
|
29
|
+
const [flag, inline] = arg.includes('=') ? [arg.slice(0, arg.indexOf('=')), arg.slice(arg.indexOf('=') + 1)] : [arg, null]
|
|
30
|
+
const value = inline !== null ? inline : argv[++i]
|
|
31
|
+
if (flag === '--version') options.version = value
|
|
32
|
+
else if (flag === '--dir') options.dir = value
|
|
33
|
+
else return { unknown: arg }
|
|
34
|
+
if (value === undefined) return { missing: flag }
|
|
35
|
+
}
|
|
36
|
+
return options
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function main() {
|
|
40
|
+
const options = parse(process.argv.slice(2))
|
|
41
|
+
if (options.help) {
|
|
42
|
+
console.log(USAGE)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
if (options.printVersion) {
|
|
46
|
+
console.log(pkg.version)
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
if (options.unknown) {
|
|
50
|
+
console.error(`sdlc: unknown option ${options.unknown}\n`)
|
|
51
|
+
console.error(USAGE)
|
|
52
|
+
process.exitCode = 1
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
if (options.missing) {
|
|
56
|
+
console.error(`sdlc: ${options.missing} needs a value\n`)
|
|
57
|
+
console.error(USAGE)
|
|
58
|
+
process.exitCode = 1
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
await install(options)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
main().catch((err) => {
|
|
65
|
+
if (err instanceof Failure) {
|
|
66
|
+
console.error(`sdlc: ${err.message}`)
|
|
67
|
+
for (const line of err.advice) console.error(` ${line}`)
|
|
68
|
+
} else {
|
|
69
|
+
console.error(`sdlc: ${err && err.message ? err.message : err}`)
|
|
70
|
+
}
|
|
71
|
+
process.exitCode = 1
|
|
72
|
+
})
|
package/checksums.txt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
6a99b4dfdd71f28d00652a02c9d1b9d4fed62b2abbdc9a2fe92ce1a78f07b23f install.ps1
|
|
2
|
+
247e19b0eec40312fe71d6a74cccd23e5d788868550100ac5a2add8bbbb0b5fb install.sh
|
|
3
|
+
023293bb5138ca1a2920aa6a997131572de822c7ec00247db1a30a0644cf4dc9 sdlc_0.1.0_darwin_amd64.tar.gz
|
|
4
|
+
ffa0d7b93a46eaa4a48bdd30748724a9cbdbe7c6ac42ee229038353634d27f6e sdlc_0.1.0_darwin_amd64.tar.gz.sbom.json
|
|
5
|
+
5fdadaf19080c147c053c36272f75fba4dffda7136da4104f029a557b6b41422 sdlc_0.1.0_darwin_arm64.tar.gz
|
|
6
|
+
011e28ffe7fe7f9fe9c36e98617465307ea7628517c17113a2ea18d5552137d0 sdlc_0.1.0_darwin_arm64.tar.gz.sbom.json
|
|
7
|
+
f446dfb5e689093a7b290762efe56913e11bef33b87b5d63dc7d1a1f55189d33 sdlc_0.1.0_linux_amd64.tar.gz
|
|
8
|
+
8024a959780130edf3b9d2c3bf9227b98fe0036fc4cddaee1269ccd238f615c8 sdlc_0.1.0_linux_amd64.tar.gz.sbom.json
|
|
9
|
+
99411de0acc80f701280783de0a5b81a96701ac5978c4f4225658bdc05902868 sdlc_0.1.0_linux_arm64.tar.gz
|
|
10
|
+
1db7f5faea42b8a7d0376d67a92d12b30442a9f44f25e13d91e9d9a3018d8c8f sdlc_0.1.0_linux_arm64.tar.gz.sbom.json
|
|
11
|
+
be9c240f44f50e6b166e668f4fe7ccafee25d70d8d58763b5c36e13257cca632 sdlc_0.1.0_windows_amd64.zip
|
|
12
|
+
a5786b4020d6555ca16c97c1c00614f6d03ed46911124231135d7b1f82349d61 sdlc_0.1.0_windows_amd64.zip.sbom.json
|
|
13
|
+
2f41ab2c4afcae5ff37f20dc1854043fb94ff7a6efa85d2036cfccbfc290f187 sdlc_0.1.0_windows_arm64.zip
|
|
14
|
+
d09607e85832d371f07f0c7e472eeffbe4095a1cf993df87fdc00de736d21f77 sdlc_0.1.0_windows_arm64.zip.sbom.json
|
package/lib/install.js
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Download the sdlc release for this machine, check it against the release's
|
|
4
|
+
// checksums, and put the binary somewhere on PATH.
|
|
5
|
+
//
|
|
6
|
+
// Two decisions shape this file, and both are deliberate.
|
|
7
|
+
//
|
|
8
|
+
// There is no postinstall script. Installing a native binary is something you
|
|
9
|
+
// asked for -- `npx @bbsnly/sdlc install` -- not something that happens while
|
|
10
|
+
// you were installing something else. It also means `--ignore-scripts`, which
|
|
11
|
+
// many organisations set, changes nothing here.
|
|
12
|
+
//
|
|
13
|
+
// What lands on your PATH is the native binary, never a Node wrapper around
|
|
14
|
+
// it. sdlc runs as a Claude Code hook, once per matching tool call; a Node
|
|
15
|
+
// process start costs around 45 ms and the binary's own start costs under 4,
|
|
16
|
+
// so a wrapper would be the most expensive thing in the loop.
|
|
17
|
+
|
|
18
|
+
const crypto = require('node:crypto')
|
|
19
|
+
const fs = require('node:fs')
|
|
20
|
+
const os = require('node:os')
|
|
21
|
+
const path = require('node:path')
|
|
22
|
+
const { execFileSync } = require('node:child_process')
|
|
23
|
+
|
|
24
|
+
const REPO = 'bbsnly/sdlc'
|
|
25
|
+
|
|
26
|
+
// SDLC_DOWNLOAD_BASE points this at somewhere other than GitHub. It exists so
|
|
27
|
+
// that this installer can be tested against a local mirror on every commit,
|
|
28
|
+
// rather than only by a real release.
|
|
29
|
+
const downloadBase = () =>
|
|
30
|
+
process.env.SDLC_DOWNLOAD_BASE || `https://github.com/${REPO}/releases/download`
|
|
31
|
+
|
|
32
|
+
class Failure extends Error {
|
|
33
|
+
constructor(what, advice = []) {
|
|
34
|
+
super(what)
|
|
35
|
+
this.advice = advice
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// assetFor names the release archive for one platform. The names are built
|
|
40
|
+
// here rather than discovered, so a missing build is a clear "not released
|
|
41
|
+
// for this platform" instead of a silent fallback to the wrong one.
|
|
42
|
+
function assetFor(platform, arch, version) {
|
|
43
|
+
const goos = { darwin: 'darwin', linux: 'linux', win32: 'windows' }[platform]
|
|
44
|
+
const goarch = { x64: 'amd64', arm64: 'arm64' }[arch]
|
|
45
|
+
if (!goos || !goarch) {
|
|
46
|
+
throw new Failure(`there is no prebuilt sdlc for ${platform}/${arch}.`, [
|
|
47
|
+
'Build from source instead:',
|
|
48
|
+
` go install github.com/${REPO}/cmd/sdlc@latest`,
|
|
49
|
+
])
|
|
50
|
+
}
|
|
51
|
+
const ext = goos === 'windows' ? 'zip' : 'tar.gz'
|
|
52
|
+
return {
|
|
53
|
+
archive: `sdlc_${version}_${goos}_${goarch}.${ext}`,
|
|
54
|
+
binary: goos === 'windows' ? 'sdlc.exe' : 'sdlc',
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// defaultDir is the same place install.sh and install.ps1 use, so the three
|
|
59
|
+
// routes to a working sdlc all end in one file rather than three.
|
|
60
|
+
function defaultDir(platform = process.platform, env = process.env) {
|
|
61
|
+
if (env.SDLC_INSTALL_DIR) return env.SDLC_INSTALL_DIR
|
|
62
|
+
if (platform === 'win32') {
|
|
63
|
+
return path.join(env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'), 'Programs', 'sdlc', 'bin')
|
|
64
|
+
}
|
|
65
|
+
return path.join(os.homedir(), '.local', 'bin')
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// parseChecksums reads the `sha256 filename` lines goreleaser writes. The
|
|
69
|
+
// asterisk is what some sha256sum implementations put before a name read in
|
|
70
|
+
// binary mode; it is not part of the name.
|
|
71
|
+
function parseChecksums(text) {
|
|
72
|
+
const out = new Map()
|
|
73
|
+
for (const line of text.split('\n')) {
|
|
74
|
+
const match = line.trim().match(/^([0-9a-f]{64})\s+\*?(.+)$/i)
|
|
75
|
+
if (match) out.set(match[2].trim(), match[1].toLowerCase())
|
|
76
|
+
}
|
|
77
|
+
return out
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function onPath(dir, env = process.env) {
|
|
81
|
+
const entries = (env.PATH || '').split(path.delimiter).filter(Boolean)
|
|
82
|
+
const same = (a, b) =>
|
|
83
|
+
process.platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b
|
|
84
|
+
return entries.some((entry) => same(path.resolve(entry), path.resolve(dir)))
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// unreachable is a network failure that says what failed. fetch reports every
|
|
88
|
+
// one of them as "fetch failed" and keeps the reason in its cause, and it does
|
|
89
|
+
// not read HTTPS_PROXY by default: behind a proxy npm itself goes through, the
|
|
90
|
+
// download went direct and failed with nothing more to say than that.
|
|
91
|
+
function unreachable(url, what, err) {
|
|
92
|
+
const cause = err && err.cause
|
|
93
|
+
const reason = (cause && (cause.code || cause.message)) || (err && err.message) || String(err)
|
|
94
|
+
return new Failure(what, [
|
|
95
|
+
`why ${url} could not be reached (${reason})`,
|
|
96
|
+
'fix check that this machine can reach github.com. Behind a proxy, use install.sh',
|
|
97
|
+
" or install.ps1 instead: Node's fetch does not use HTTPS_PROXY by default",
|
|
98
|
+
])
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function download(url, into, idle = 60_000) {
|
|
102
|
+
// Without a limit a stalled connection hangs `npx` indefinitely, with nothing
|
|
103
|
+
// on screen after "downloading". A deadline on the whole download failed
|
|
104
|
+
// every link too slow to finish inside it instead, so the limit is on
|
|
105
|
+
// silence: this long to answer, and this long without a byte after that.
|
|
106
|
+
const controller = new AbortController()
|
|
107
|
+
let timer
|
|
108
|
+
const wait = () => {
|
|
109
|
+
clearTimeout(timer)
|
|
110
|
+
timer = setTimeout(() => controller.abort(), idle)
|
|
111
|
+
}
|
|
112
|
+
const what = `could not download ${path.basename(into)}`
|
|
113
|
+
const chunks = []
|
|
114
|
+
wait()
|
|
115
|
+
try {
|
|
116
|
+
const response = await fetch(url, { redirect: 'follow', signal: controller.signal })
|
|
117
|
+
if (!response.ok) {
|
|
118
|
+
throw new Failure(what, [
|
|
119
|
+
`why ${url} answered ${response.status} ${response.statusText}`,
|
|
120
|
+
'fix check that this version is released, and that this machine can reach github.com',
|
|
121
|
+
])
|
|
122
|
+
}
|
|
123
|
+
for await (const chunk of response.body) {
|
|
124
|
+
wait()
|
|
125
|
+
chunks.push(chunk)
|
|
126
|
+
}
|
|
127
|
+
} catch (err) {
|
|
128
|
+
if (err instanceof Failure) throw err
|
|
129
|
+
if (controller.signal.aborted) {
|
|
130
|
+
throw new Failure(what, [
|
|
131
|
+
`why ${url} sent nothing for ${idle / 1000} seconds`,
|
|
132
|
+
'fix check the connection and try again',
|
|
133
|
+
])
|
|
134
|
+
}
|
|
135
|
+
throw unreachable(url, what, err)
|
|
136
|
+
} finally {
|
|
137
|
+
clearTimeout(timer)
|
|
138
|
+
}
|
|
139
|
+
// Written outside the network's try, so a disk that refuses the file is not
|
|
140
|
+
// reported as a server that could not be reached.
|
|
141
|
+
fs.writeFileSync(into, Buffer.concat(chunks))
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// packagedVersion is the release this package was published with, when it
|
|
145
|
+
// carries that release's checksums. That is the release to install: asking
|
|
146
|
+
// the network which one is newest could name another -- from an older cached
|
|
147
|
+
// `npx`, or while a release is open and its npm publish failed -- and the pins
|
|
148
|
+
// for that one would come from the same place as the download.
|
|
149
|
+
//
|
|
150
|
+
// Only pins that list this machine's archive for the package's version count.
|
|
151
|
+
// A checksums.txt left in a checkout by another release describes none of its
|
|
152
|
+
// archives, and is no reason to install a version nobody asked for.
|
|
153
|
+
function packagedVersion() {
|
|
154
|
+
const embedded = path.join(__dirname, '..', 'checksums.txt')
|
|
155
|
+
if (!fs.existsSync(embedded)) return ''
|
|
156
|
+
const version = require('../package.json').version
|
|
157
|
+
const { archive } = assetFor(process.platform, process.arch, version)
|
|
158
|
+
return parseChecksums(fs.readFileSync(embedded, 'utf8')).has(archive) ? version : ''
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// The "latest" lookup is the sibling of the download path, so a mirror that
|
|
162
|
+
// serves one serves the other. That is what lets the resolve-the-latest-version
|
|
163
|
+
// path -- the one every reader of the documentation takes -- be tested at all.
|
|
164
|
+
function latestURL() {
|
|
165
|
+
return downloadBase().replace(/\/download$/, '/latest')
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function latestVersion() {
|
|
169
|
+
// Through the redirect rather than the API: the API is rate limited per IP,
|
|
170
|
+
// and a shared network can exhaust it for everyone on it.
|
|
171
|
+
const url = latestURL()
|
|
172
|
+
let response
|
|
173
|
+
try {
|
|
174
|
+
response = await fetch(url, { redirect: 'manual', signal: AbortSignal.timeout(60_000) })
|
|
175
|
+
} catch (err) {
|
|
176
|
+
throw unreachable(url, 'could not work out the latest version of sdlc.', err)
|
|
177
|
+
}
|
|
178
|
+
const location = response.headers.get('location') || ''
|
|
179
|
+
const match = location.match(/\/tag\/v([0-9][^/]*)$/)
|
|
180
|
+
if (!match) {
|
|
181
|
+
throw new Failure('could not work out the latest version of sdlc.', [
|
|
182
|
+
`why ${url} did not redirect to a tag;`,
|
|
183
|
+
' the usual cause is no network, or no release yet',
|
|
184
|
+
'fix pass one: npx @bbsnly/sdlc install --version X.Y.Z',
|
|
185
|
+
])
|
|
186
|
+
}
|
|
187
|
+
return match[1]
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// checksumsFor prefers the copy published inside this package: it was written
|
|
191
|
+
// when the release was built and cannot be changed afterwards, which a file
|
|
192
|
+
// fetched now, from the same place as the download, cannot promise.
|
|
193
|
+
//
|
|
194
|
+
// That copy describes exactly one release, though, and --version or
|
|
195
|
+
// SDLC_VERSION can ask for another. When the archive being installed is not
|
|
196
|
+
// one it lists, the pins for that version are fetched instead -- treating the
|
|
197
|
+
// embedded file as authoritative there would report a missing platform build
|
|
198
|
+
// for a platform the release certainly has. Either fallback is said out loud.
|
|
199
|
+
async function checksumsFor(version, archive, tmp, log) {
|
|
200
|
+
const embedded = path.join(__dirname, '..', 'checksums.txt')
|
|
201
|
+
if (fs.existsSync(embedded)) {
|
|
202
|
+
const pins = parseChecksums(fs.readFileSync(embedded, 'utf8'))
|
|
203
|
+
if (pins.has(archive)) return pins
|
|
204
|
+
log(`sdlc: this package carries the pins for a different release, so the v${version} ones are being fetched`)
|
|
205
|
+
} else {
|
|
206
|
+
log(`sdlc: this package carries no checksums, so they are being fetched from the v${version} release`)
|
|
207
|
+
}
|
|
208
|
+
const fetched = path.join(tmp, 'checksums.txt')
|
|
209
|
+
await download(`${downloadBase()}/v${version}/checksums.txt`, fetched)
|
|
210
|
+
return parseChecksums(fs.readFileSync(fetched, 'utf8'))
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// psQuote makes a value safe inside a single-quoted PowerShell string. The
|
|
214
|
+
// temporary directory sits under the user's profile, so a username with an
|
|
215
|
+
// apostrophe in it -- O'Brien -- would otherwise end the string early and turn
|
|
216
|
+
// a verified download into a parse error.
|
|
217
|
+
function psQuote(value) {
|
|
218
|
+
return value.replace(/'/g, "''")
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function unpack(archive, into, binary) {
|
|
222
|
+
if (archive.endsWith('.zip')) {
|
|
223
|
+
execFileSync('powershell', ['-NoProfile', '-NonInteractive', '-Command',
|
|
224
|
+
`Expand-Archive -LiteralPath '${psQuote(archive)}' -DestinationPath '${psQuote(into)}' -Force`], { stdio: 'pipe' })
|
|
225
|
+
} else {
|
|
226
|
+
execFileSync('tar', ['-xzf', archive, '-C', into, binary], { stdio: 'pipe' })
|
|
227
|
+
}
|
|
228
|
+
return path.join(into, binary)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async function install(options = {}) {
|
|
232
|
+
const log = options.log || console.log
|
|
233
|
+
const version = (options.version || process.env.SDLC_VERSION || '').replace(/^v/, '') ||
|
|
234
|
+
packagedVersion() || (await latestVersion())
|
|
235
|
+
const dir = options.dir || defaultDir()
|
|
236
|
+
const { archive, binary } = assetFor(process.platform, process.arch, version)
|
|
237
|
+
const target = path.join(dir, binary)
|
|
238
|
+
|
|
239
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'sdlc-'))
|
|
240
|
+
let incoming = null
|
|
241
|
+
try {
|
|
242
|
+
log(`sdlc: downloading ${archive}`)
|
|
243
|
+
const downloaded = path.join(tmp, archive)
|
|
244
|
+
await download(`${downloadBase()}/v${version}/${archive}`, downloaded)
|
|
245
|
+
|
|
246
|
+
const expected = (await checksumsFor(version, archive, tmp, log)).get(archive)
|
|
247
|
+
if (!expected) {
|
|
248
|
+
throw new Failure(`checksums.txt does not list ${archive}`, [
|
|
249
|
+
'why the release is missing the build for this platform',
|
|
250
|
+
`fix report it at https://github.com/${REPO}/issues`,
|
|
251
|
+
])
|
|
252
|
+
}
|
|
253
|
+
// Verified before anything is made executable or moved onto a PATH
|
|
254
|
+
// directory. A release you cannot check is a release you should not
|
|
255
|
+
// install.
|
|
256
|
+
const actual = crypto.createHash('sha256').update(fs.readFileSync(downloaded)).digest('hex')
|
|
257
|
+
if (actual !== expected) {
|
|
258
|
+
throw new Failure('the download does not match its checksum, so it is not being installed.', [
|
|
259
|
+
`expected ${expected}`,
|
|
260
|
+
`got ${actual}`,
|
|
261
|
+
'This is either a corrupted download or something worse. Try again; if it',
|
|
262
|
+
`happens twice, report it at https://github.com/${REPO}/issues`,
|
|
263
|
+
])
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const unpacked = unpack(downloaded, tmp, binary)
|
|
267
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
268
|
+
fs.chmodSync(unpacked, 0o755)
|
|
269
|
+
// Through a temporary name in the target's own directory and then rename:
|
|
270
|
+
// a half written binary on PATH is worse than no binary on PATH, and
|
|
271
|
+
// rename is the only step that is atomic.
|
|
272
|
+
incoming = path.join(dir, `.sdlc.incoming.${process.pid}`)
|
|
273
|
+
fs.copyFileSync(unpacked, incoming)
|
|
274
|
+
fs.chmodSync(incoming, 0o755)
|
|
275
|
+
fs.renameSync(incoming, target)
|
|
276
|
+
incoming = null
|
|
277
|
+
} finally {
|
|
278
|
+
fs.rmSync(tmp, { recursive: true, force: true })
|
|
279
|
+
// The staging name is inside the install directory, which the temporary
|
|
280
|
+
// directory's cleanup does not reach. A failed copy would otherwise leave
|
|
281
|
+
// a partial executable there for good.
|
|
282
|
+
if (incoming) fs.rmSync(incoming, { force: true })
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
log(`sdlc: installed v${version} in ${dir}`)
|
|
286
|
+
if (!onPath(dir)) {
|
|
287
|
+
log('')
|
|
288
|
+
log(` ${dir} is not on your PATH. Add it:`)
|
|
289
|
+
log('')
|
|
290
|
+
for (const line of pathHint(process.platform, dir)) log(` ${line}`)
|
|
291
|
+
log('')
|
|
292
|
+
log(process.platform === 'win32'
|
|
293
|
+
? ' in PowerShell, and open a new terminal for it to take effect.'
|
|
294
|
+
: ' and put that line in your shell profile (~/.zshrc, ~/.bashrc) to keep it.')
|
|
295
|
+
}
|
|
296
|
+
log('')
|
|
297
|
+
log('Next, in Claude Code:')
|
|
298
|
+
log('')
|
|
299
|
+
log(' /plugin marketplace add bbsnly/sdlc')
|
|
300
|
+
log(' /plugin install sdlc@sdlc')
|
|
301
|
+
log('')
|
|
302
|
+
log('Then run `sdlc doctor` in a project to check the install.')
|
|
303
|
+
return { version, dir, target }
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// pathHint is what to run to put dir on PATH. On Windows, not `setx PATH
|
|
307
|
+
// "...;%PATH%"`: that writes the machine PATH into the user PATH and truncates
|
|
308
|
+
// the result at 1024 characters. Nor [Environment]::GetEnvironmentVariable,
|
|
309
|
+
// which returns %JAVA_HOME%\bin already expanded, so writing it back froze
|
|
310
|
+
// every such entry at today's value. The raw registry value instead, as
|
|
311
|
+
// install.ps1 reads it, and then the call that tells Explorer -- and so every
|
|
312
|
+
// terminal opened after it -- that PATH changed.
|
|
313
|
+
function pathHint(platform, dir) {
|
|
314
|
+
if (platform !== 'win32') return [`export PATH="${dir}:$PATH"`]
|
|
315
|
+
return [
|
|
316
|
+
"$key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey('Environment', $true)",
|
|
317
|
+
`$key.SetValue('Path', '${psQuote(dir)};' + $key.GetValue('Path', '', 'DoNotExpandEnvironmentNames'), 'ExpandString')`,
|
|
318
|
+
"[Environment]::SetEnvironmentVariable('SDLC_PATH_REFRESH', $null, 'User')",
|
|
319
|
+
]
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
module.exports = { install, assetFor, defaultDir, parseChecksums, onPath, pathHint, download, Failure, REPO }
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bbsnly/sdlc",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Install sdlc: a story-driven delivery loop for Claude Code, with gates a model cannot talk its way past.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Anatoliy Babushka <anatoliybabushka@gmail.com>",
|
|
7
|
+
"homepage": "https://github.com/bbsnly/sdlc",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/bbsnly/sdlc.git",
|
|
11
|
+
"directory": "npm"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/bbsnly/sdlc/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"sdlc",
|
|
18
|
+
"claude-code",
|
|
19
|
+
"tdd",
|
|
20
|
+
"code-review",
|
|
21
|
+
"workflow",
|
|
22
|
+
"gates"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"bin": {
|
|
28
|
+
"sdlc-install": "bin/sdlc-install.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"bin/",
|
|
32
|
+
"lib/",
|
|
33
|
+
"checksums.txt",
|
|
34
|
+
"LICENSE",
|
|
35
|
+
"README.md"
|
|
36
|
+
]
|
|
37
|
+
}
|