create-ombutocode 0.2.14 → 0.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -0
- package/bin/create-ombutocode.js +833 -183
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,66 @@ What it does:
|
|
|
46
46
|
`docs/`; if it is not, it says so — the scheduler builds in git worktrees,
|
|
47
47
|
so a repository is needed before agents can run.
|
|
48
48
|
|
|
49
|
+
## Upgrade an existing project
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
cd /path/to/project
|
|
53
|
+
npx create-ombutocode@latest --upgrade
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Moves the workbench (`.ombutocode/`) of an existing project to this
|
|
57
|
+
installer's pinned release. `<dir>` is optional and defaults to the current
|
|
58
|
+
directory; it must contain `.ombutocode/src/package.json` (a directory
|
|
59
|
+
without a workbench is pointed at `--into-existing` instead). Use `@latest`
|
|
60
|
+
so the newest installer, and therefore the newest release, is the one that
|
|
61
|
+
runs. The full contract lives in `UPGRADING.md` at the repository root;
|
|
62
|
+
this is the summary.
|
|
63
|
+
|
|
64
|
+
What it does, in order:
|
|
65
|
+
|
|
66
|
+
1. Refuses to run if `.ombutocode/.instance.lock` names a live Electron
|
|
67
|
+
process (close the app first), and exits 0 without changes if the
|
|
68
|
+
project is already at the pinned release (`--force` reinstalls; it is
|
|
69
|
+
also required to downgrade).
|
|
70
|
+
2. Writes `.ombutocode-backup-<version>-<YYYYMMDD-HHMMSS>.zip` in the
|
|
71
|
+
project root with `data/`, `codingagents/`, `planning/`, `features/`,
|
|
72
|
+
`profiles/`, `codingagent-state.json` and the old `src/package.json`,
|
|
73
|
+
then verifies the archive (entry count, CRCs, `ombutocode.db` present).
|
|
74
|
+
The zip is written with Node's own `zlib` — the installer still has no
|
|
75
|
+
runtime dependencies.
|
|
76
|
+
3. Clones the pinned release into a temporary directory, as a fresh
|
|
77
|
+
install does.
|
|
78
|
+
4. Replaces workbench code by allow-list and nothing else: `src/`
|
|
79
|
+
(deleted whole, `node_modules` included), `tools/`, `templates/`,
|
|
80
|
+
`scripts/`, `bench/`, `buildandrun*`, `initombuto*`,
|
|
81
|
+
`OMBUTOCODE_ENGINEERING_GUIDE.md`, `README.md`, `LICENSE` and
|
|
82
|
+
`codingagent-templates.json`.
|
|
83
|
+
5. Runs `npm install --no-audit --no-fund` in the new `src/`
|
|
84
|
+
(`--omit-dev` applies here too).
|
|
85
|
+
6. Prints the old and new version and the backup path.
|
|
86
|
+
|
|
87
|
+
What it never touches: `.ombutocode/data/` (database, ticket files,
|
|
88
|
+
headless settings), `logs/`, `run-output/`, `codingagent-state.json`,
|
|
89
|
+
`codingagents/codingagents.yml` (if the release's copy differs it is
|
|
90
|
+
written alongside as `codingagents.yml.new` for you to merge), existing
|
|
91
|
+
files in `profiles/` (missing ones are added), and every file under
|
|
92
|
+
`docs/` — the only thing added there is a skill template under
|
|
93
|
+
`docs/Skills/` that the release ships and the project lacks. Anything
|
|
94
|
+
under `.ombutocode/` not named in step 4 is left as it was. The project's
|
|
95
|
+
own files, `.gitignore` included, are not modified, and nothing is
|
|
96
|
+
committed: review `git status` and commit the result yourself.
|
|
97
|
+
|
|
98
|
+
Restoring from the backup, from the project root:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
git checkout -- .ombutocode # the workbench code, if committed
|
|
102
|
+
unzip -o .ombutocode-backup-<version>-<stamp>.zip # your state; Expand-Archive -Force on Windows
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The zip's entries are rooted at `.ombutocode/`, so it extracts straight
|
|
106
|
+
back into place. If the upgrade fails after step 4 has started, the
|
|
107
|
+
installer prints these same instructions.
|
|
108
|
+
|
|
49
109
|
## Headless-only install
|
|
50
110
|
|
|
51
111
|
```bash
|
|
@@ -68,9 +128,22 @@ toolchain.
|
|
|
68
128
|
|--------|--------|
|
|
69
129
|
| `<project-name>` | Create a new project directory (must not exist). |
|
|
70
130
|
| `--into-existing <dir>` | Adopt into an existing directory instead. Mutually exclusive with `<project-name>`. |
|
|
131
|
+
| `--upgrade [<dir>]` | Upgrade the workbench in `<dir>` (default: current directory) to the pinned release. Mutually exclusive with `--into-existing`. |
|
|
132
|
+
| `--no-backup` | With `--upgrade`: skip the backup zip. |
|
|
133
|
+
| `--force` | With `--upgrade`: proceed even if the project is already at, or newer than, the pinned release. |
|
|
71
134
|
| `--omit-dev` | `npm install --omit=dev --legacy-peer-deps`; no UI toolchain. |
|
|
72
135
|
| `-h`, `--help` | Show usage. |
|
|
73
136
|
|
|
137
|
+
## Tests
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
node --test create-ombutocode/test/*.test.js
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Plain `node:test`, no network: the ZIP writer round-trip (cross-checked
|
|
144
|
+
against `unzip` or `Expand-Archive` when one is available) and the upgrade
|
|
145
|
+
replace step on a fake `.ombutocode/` tree.
|
|
146
|
+
|
|
74
147
|
## Publishing
|
|
75
148
|
|
|
76
149
|
See `DeployInstructions.md` at the repository root: bump `CLONE_REF`,
|
package/bin/create-ombutocode.js
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const os = require('os');
|
|
5
5
|
const path = require('path');
|
|
6
|
+
const zlib = require('zlib');
|
|
6
7
|
const { execSync } = require('child_process');
|
|
7
8
|
|
|
8
9
|
const REPO_URL = 'https://github.com/FrancoisBotha/ombutocode.git';
|
|
9
10
|
// Installer version is kept in lockstep with the workbench version
|
|
10
11
|
// (.ombutocode/src/package.json) — every workbench release bumps both
|
|
11
12
|
// to the same number. See DeployInstructions.md §3 and §3.0.
|
|
12
|
-
const VERSION = '0.2.
|
|
13
|
+
const VERSION = '0.2.16';
|
|
13
14
|
|
|
14
15
|
// Pinned Ombuto Code workbench release to clone.
|
|
15
16
|
//
|
|
@@ -21,7 +22,7 @@ const VERSION = '0.2.14';
|
|
|
21
22
|
// 2. Bump CLONE_REF below to the new tag
|
|
22
23
|
// 3. Bump this installer's VERSION (above) and the package.json version
|
|
23
24
|
// 4. `npm publish` the installer (see DeployInstructions.md §3)
|
|
24
|
-
const CLONE_REF = 'v0.2.
|
|
25
|
+
const CLONE_REF = 'v0.2.16';
|
|
25
26
|
|
|
26
27
|
// Files and directories at the repo root that belong to the Ombuto Code
|
|
27
28
|
// upstream project and should be removed from a scaffolded user project.
|
|
@@ -78,6 +79,46 @@ const OMBUTO_GITIGNORE_LINES = [
|
|
|
78
79
|
'.ombutocode/src/dist/',
|
|
79
80
|
];
|
|
80
81
|
|
|
82
|
+
// ── Upgrade contract ──
|
|
83
|
+
//
|
|
84
|
+
// `--upgrade` replaces the workbench code inside an existing project's
|
|
85
|
+
// .ombutocode/ with the pinned release and leaves everything else alone.
|
|
86
|
+
// These lists are the "Overwrite with the new release" / "Preserve" tables
|
|
87
|
+
// in UPGRADING.md. The upgrade only ever deletes or writes the paths named
|
|
88
|
+
// in UPGRADE_REPLACE_*; nothing under .ombutocode/ is wiped wholesale, so a
|
|
89
|
+
// file that is in neither list is simply left as it was.
|
|
90
|
+
|
|
91
|
+
// Directories replaced wholesale: the old one is deleted (src/ including
|
|
92
|
+
// its node_modules) and the release's copy moved in.
|
|
93
|
+
const UPGRADE_REPLACE_DIRS = ['src', 'tools', 'templates', 'scripts', 'bench'];
|
|
94
|
+
|
|
95
|
+
// Plain files replaced with the release's copy.
|
|
96
|
+
const UPGRADE_REPLACE_FILES = [
|
|
97
|
+
'OMBUTOCODE_ENGINEERING_GUIDE.md',
|
|
98
|
+
'README.md',
|
|
99
|
+
'LICENSE',
|
|
100
|
+
'codingagent-templates.json',
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
// Launcher scripts: every plain file directly under .ombutocode/ whose name
|
|
104
|
+
// starts with one of these (buildandrun, buildandrun.bat, buildandrun.sh,
|
|
105
|
+
// initombuto, initombuto.bat, …) is replaced.
|
|
106
|
+
const UPGRADE_REPLACE_PREFIXES = ['buildandrun', 'initombuto'];
|
|
107
|
+
|
|
108
|
+
// Project state captured in the backup zip before anything is replaced,
|
|
109
|
+
// relative to .ombutocode/. Entries that do not exist are skipped. The
|
|
110
|
+
// workbench version marker (src/package.json) rides along so the archive
|
|
111
|
+
// records what it was taken from.
|
|
112
|
+
const UPGRADE_BACKUP_PATHS = [
|
|
113
|
+
'data',
|
|
114
|
+
'codingagents',
|
|
115
|
+
'codingagent-state.json',
|
|
116
|
+
'planning',
|
|
117
|
+
'features',
|
|
118
|
+
'profiles',
|
|
119
|
+
'src/package.json',
|
|
120
|
+
];
|
|
121
|
+
|
|
81
122
|
// ── Helpers ──
|
|
82
123
|
|
|
83
124
|
function log(msg) { console.log(` ${msg}`); }
|
|
@@ -122,6 +163,29 @@ function moveDirSync(src, dest) {
|
|
|
122
163
|
}
|
|
123
164
|
}
|
|
124
165
|
|
|
166
|
+
// Copy every file under srcDir into destDir that does not already exist
|
|
167
|
+
// there, recursing into sub-directories. Existing files are never touched.
|
|
168
|
+
// Returns the relative paths that were added.
|
|
169
|
+
function copyMissingFiles(srcDir, destDir) {
|
|
170
|
+
const added = [];
|
|
171
|
+
const walk = (src, rel) => {
|
|
172
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
173
|
+
const srcPath = path.join(src, entry.name);
|
|
174
|
+
const relPath = rel ? `${rel}/${entry.name}` : entry.name;
|
|
175
|
+
const destPath = path.join(destDir, relPath);
|
|
176
|
+
if (entry.isDirectory()) {
|
|
177
|
+
walk(srcPath, relPath);
|
|
178
|
+
} else if (entry.isFile() && !fs.existsSync(destPath)) {
|
|
179
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
180
|
+
fs.copyFileSync(srcPath, destPath);
|
|
181
|
+
added.push(relPath);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
if (fs.existsSync(srcDir)) walk(srcDir, '');
|
|
186
|
+
return added;
|
|
187
|
+
}
|
|
188
|
+
|
|
125
189
|
function stripUpstreamFiles(projectDir) {
|
|
126
190
|
for (const name of UPSTREAM_FILES_TO_STRIP) {
|
|
127
191
|
const target = path.join(projectDir, name);
|
|
@@ -133,6 +197,34 @@ function stripUpstreamFiles(projectDir) {
|
|
|
133
197
|
}
|
|
134
198
|
}
|
|
135
199
|
|
|
200
|
+
// Clone the pinned release into a fresh temp directory and reduce it to the
|
|
201
|
+
// workbench: drop the clone's git history, the installer package, the
|
|
202
|
+
// upstream maintainer files and the upstream docs/ (which hold the Ombuto
|
|
203
|
+
// Code project's own specs and must not leak into someone else's repo).
|
|
204
|
+
// Returns the path of the clone's .ombutocode/ and a cleanup function; the
|
|
205
|
+
// temp directory is also removed on process exit.
|
|
206
|
+
function cloneWorkbench() {
|
|
207
|
+
heading(`Cloning Ombuto Code ${CLONE_REF}`);
|
|
208
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'create-ombutocode-'));
|
|
209
|
+
const cloneDir = path.join(tempRoot, 'clone');
|
|
210
|
+
const cleanupTemp = () => { try { fs.rmSync(tempRoot, { recursive: true, force: true }); } catch {} };
|
|
211
|
+
process.on('exit', cleanupTemp);
|
|
212
|
+
run(`git clone --depth 1 --branch ${CLONE_REF} ${REPO_URL} "${cloneDir}"`);
|
|
213
|
+
|
|
214
|
+
heading('Preparing workbench files');
|
|
215
|
+
fs.rmSync(path.join(cloneDir, '.git'), { recursive: true, force: true });
|
|
216
|
+
fs.rmSync(path.join(cloneDir, 'create-ombutocode'), { recursive: true, force: true });
|
|
217
|
+
stripUpstreamFiles(cloneDir);
|
|
218
|
+
fs.rmSync(path.join(cloneDir, 'docs'), { recursive: true, force: true });
|
|
219
|
+
log('Discarded upstream docs/');
|
|
220
|
+
|
|
221
|
+
const clonedOmbutocode = path.join(cloneDir, '.ombutocode');
|
|
222
|
+
if (!fs.existsSync(path.join(clonedOmbutocode, 'src', 'package.json'))) {
|
|
223
|
+
fatal('.ombutocode/src/package.json not found in the clone — repository may be corrupted.');
|
|
224
|
+
}
|
|
225
|
+
return { clonedOmbutocode, cleanupTemp };
|
|
226
|
+
}
|
|
227
|
+
|
|
136
228
|
// Copy the template files into projectDir. With `skipExisting`, a file that
|
|
137
229
|
// is already there (the adopted project's own README, CLAUDE.md, …) is left
|
|
138
230
|
// untouched.
|
|
@@ -215,6 +307,383 @@ function runInitombuto(projectDir, initArgs, env) {
|
|
|
215
307
|
}
|
|
216
308
|
}
|
|
217
309
|
|
|
310
|
+
// ── Minimal ZIP writer / reader ──
|
|
311
|
+
//
|
|
312
|
+
// The installer has no runtime dependencies and must stay that way, so the
|
|
313
|
+
// upgrade backup is written with Node's built-in zlib and a hand-rolled ZIP
|
|
314
|
+
// container: local file headers, a central directory and an end-of-central-
|
|
315
|
+
// directory record, which is everything `unzip`, Expand-Archive and Finder
|
|
316
|
+
// need. No zip64 — fewer than 65,535 entries and under 4 GB — which is far
|
|
317
|
+
// beyond what a workbench backup holds.
|
|
318
|
+
|
|
319
|
+
const CRC32_TABLE = (() => {
|
|
320
|
+
const table = new Int32Array(256);
|
|
321
|
+
for (let n = 0; n < 256; n++) {
|
|
322
|
+
let c = n;
|
|
323
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
324
|
+
table[n] = c;
|
|
325
|
+
}
|
|
326
|
+
return table;
|
|
327
|
+
})();
|
|
328
|
+
|
|
329
|
+
function crc32(buf) {
|
|
330
|
+
let c = -1;
|
|
331
|
+
for (let i = 0; i < buf.length; i++) c = CRC32_TABLE[(c ^ buf[i]) & 0xff] ^ (c >>> 8);
|
|
332
|
+
return (c ^ -1) >>> 0;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// MS-DOS date/time fields as stored in ZIP headers (2-second resolution,
|
|
336
|
+
// nothing before 1980).
|
|
337
|
+
function dosDateTime(date) {
|
|
338
|
+
const d = date.getFullYear() < 1980 ? new Date(1980, 0, 1) : date;
|
|
339
|
+
return {
|
|
340
|
+
time: (d.getHours() << 11) | (d.getMinutes() << 5) | (d.getSeconds() >> 1),
|
|
341
|
+
date: ((d.getFullYear() - 1980) << 9) | ((d.getMonth() + 1) << 5) | d.getDate(),
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const ZIP_MAX_ENTRIES = 0xffff;
|
|
346
|
+
const ZIP_MAX_BYTES = 0xffffffff;
|
|
347
|
+
|
|
348
|
+
// Write a ZIP archive. `entries` is an array of { name, data } or
|
|
349
|
+
// { name, file } (read from disk at write time, so a backup does not have
|
|
350
|
+
// to sit in memory all at once), with an optional `mtime`. Names use
|
|
351
|
+
// forward slashes. Each entry is deflated unless that would not save
|
|
352
|
+
// anything, in which case it is stored. Returns { entries, bytes }.
|
|
353
|
+
function writeZip(zipPath, entries) {
|
|
354
|
+
if (entries.length > ZIP_MAX_ENTRIES) {
|
|
355
|
+
throw new Error(`too many files for a plain ZIP archive (${entries.length})`);
|
|
356
|
+
}
|
|
357
|
+
const fd = fs.openSync(zipPath, 'w');
|
|
358
|
+
const central = [];
|
|
359
|
+
let offset = 0;
|
|
360
|
+
const write = (buf) => { fs.writeSync(fd, buf); offset += buf.length; };
|
|
361
|
+
try {
|
|
362
|
+
for (const entry of entries) {
|
|
363
|
+
const data = entry.data !== undefined ? entry.data : fs.readFileSync(entry.file);
|
|
364
|
+
const mtime = entry.mtime || (entry.file ? fs.statSync(entry.file).mtime : new Date());
|
|
365
|
+
if (data.length > ZIP_MAX_BYTES) throw new Error(`${entry.name} is too large for a plain ZIP archive`);
|
|
366
|
+
const name = Buffer.from(entry.name, 'utf8');
|
|
367
|
+
const crc = crc32(data);
|
|
368
|
+
let method = 8;
|
|
369
|
+
let payload = zlib.deflateRawSync(data);
|
|
370
|
+
if (payload.length >= data.length) { method = 0; payload = data; }
|
|
371
|
+
const { time, date } = dosDateTime(mtime);
|
|
372
|
+
|
|
373
|
+
const local = Buffer.alloc(30);
|
|
374
|
+
local.writeUInt32LE(0x04034b50, 0); // local file header signature
|
|
375
|
+
local.writeUInt16LE(20, 4); // version needed to extract (2.0)
|
|
376
|
+
local.writeUInt16LE(0x0800, 6); // flags: UTF-8 file names
|
|
377
|
+
local.writeUInt16LE(method, 8);
|
|
378
|
+
local.writeUInt16LE(time, 10);
|
|
379
|
+
local.writeUInt16LE(date, 12);
|
|
380
|
+
local.writeUInt32LE(crc, 14);
|
|
381
|
+
local.writeUInt32LE(payload.length, 18);
|
|
382
|
+
local.writeUInt32LE(data.length, 22);
|
|
383
|
+
local.writeUInt16LE(name.length, 26);
|
|
384
|
+
local.writeUInt16LE(0, 28); // extra field length
|
|
385
|
+
central.push({ name, method, time, date, crc, compressedSize: payload.length, size: data.length, offset });
|
|
386
|
+
write(local);
|
|
387
|
+
write(name);
|
|
388
|
+
write(payload);
|
|
389
|
+
if (offset > ZIP_MAX_BYTES) throw new Error('archive is too large for a plain ZIP archive');
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const cdStart = offset;
|
|
393
|
+
for (const e of central) {
|
|
394
|
+
const header = Buffer.alloc(46);
|
|
395
|
+
header.writeUInt32LE(0x02014b50, 0); // central directory header signature
|
|
396
|
+
header.writeUInt16LE(20, 4); // version made by
|
|
397
|
+
header.writeUInt16LE(20, 6); // version needed to extract
|
|
398
|
+
header.writeUInt16LE(0x0800, 8); // flags: UTF-8 file names
|
|
399
|
+
header.writeUInt16LE(e.method, 10);
|
|
400
|
+
header.writeUInt16LE(e.time, 12);
|
|
401
|
+
header.writeUInt16LE(e.date, 14);
|
|
402
|
+
header.writeUInt32LE(e.crc, 16);
|
|
403
|
+
header.writeUInt32LE(e.compressedSize, 20);
|
|
404
|
+
header.writeUInt32LE(e.size, 24);
|
|
405
|
+
header.writeUInt16LE(e.name.length, 28);
|
|
406
|
+
header.writeUInt16LE(0, 30); // extra field length
|
|
407
|
+
header.writeUInt16LE(0, 32); // file comment length
|
|
408
|
+
header.writeUInt16LE(0, 34); // disk number start
|
|
409
|
+
header.writeUInt16LE(0, 36); // internal attributes
|
|
410
|
+
header.writeUInt32LE(0, 38); // external attributes
|
|
411
|
+
header.writeUInt32LE(e.offset, 42); // local header offset
|
|
412
|
+
write(header);
|
|
413
|
+
write(e.name);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const eocd = Buffer.alloc(22);
|
|
417
|
+
eocd.writeUInt32LE(0x06054b50, 0); // end of central directory signature
|
|
418
|
+
eocd.writeUInt16LE(0, 4); // this disk
|
|
419
|
+
eocd.writeUInt16LE(0, 6); // disk with the central directory
|
|
420
|
+
eocd.writeUInt16LE(central.length, 8); // entries on this disk
|
|
421
|
+
eocd.writeUInt16LE(central.length, 10); // entries total
|
|
422
|
+
eocd.writeUInt32LE(offset - cdStart, 12);
|
|
423
|
+
eocd.writeUInt32LE(cdStart, 16);
|
|
424
|
+
eocd.writeUInt16LE(0, 20); // comment length
|
|
425
|
+
write(eocd);
|
|
426
|
+
} finally {
|
|
427
|
+
fs.closeSync(fd);
|
|
428
|
+
}
|
|
429
|
+
return { entries: central.length, bytes: offset };
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// Read a ZIP archive's central directory: [{ name, method, crc32, size,
|
|
433
|
+
// compressedSize, offset }]. With `verify`, every entry's data is also
|
|
434
|
+
// inflated and checked against its CRC, which is what makes the backup
|
|
435
|
+
// trustworthy before anything is deleted. Throws on a malformed archive.
|
|
436
|
+
function readZipEntries(zipPath, { verify = false } = {}) {
|
|
437
|
+
const buf = fs.readFileSync(zipPath);
|
|
438
|
+
let eocd = -1;
|
|
439
|
+
for (let i = buf.length - 22; i >= Math.max(0, buf.length - 22 - 0xffff); i--) {
|
|
440
|
+
if (buf.readUInt32LE(i) === 0x06054b50) { eocd = i; break; }
|
|
441
|
+
}
|
|
442
|
+
if (eocd < 0) throw new Error(`${zipPath}: not a ZIP archive (no end-of-central-directory record)`);
|
|
443
|
+
const count = buf.readUInt16LE(eocd + 10);
|
|
444
|
+
const cdSize = buf.readUInt32LE(eocd + 12);
|
|
445
|
+
const cdOffset = buf.readUInt32LE(eocd + 16);
|
|
446
|
+
|
|
447
|
+
const entries = [];
|
|
448
|
+
let p = cdOffset;
|
|
449
|
+
for (let i = 0; i < count; i++) {
|
|
450
|
+
if (p + 46 > buf.length || buf.readUInt32LE(p) !== 0x02014b50) {
|
|
451
|
+
throw new Error(`${zipPath}: corrupt central directory at entry ${i}`);
|
|
452
|
+
}
|
|
453
|
+
const nameLen = buf.readUInt16LE(p + 28);
|
|
454
|
+
const extraLen = buf.readUInt16LE(p + 30);
|
|
455
|
+
const commentLen = buf.readUInt16LE(p + 32);
|
|
456
|
+
entries.push({
|
|
457
|
+
name: buf.toString('utf8', p + 46, p + 46 + nameLen),
|
|
458
|
+
method: buf.readUInt16LE(p + 10),
|
|
459
|
+
crc32: buf.readUInt32LE(p + 16),
|
|
460
|
+
compressedSize: buf.readUInt32LE(p + 20),
|
|
461
|
+
size: buf.readUInt32LE(p + 24),
|
|
462
|
+
offset: buf.readUInt32LE(p + 42),
|
|
463
|
+
});
|
|
464
|
+
p += 46 + nameLen + extraLen + commentLen;
|
|
465
|
+
}
|
|
466
|
+
if (p !== cdOffset + cdSize) throw new Error(`${zipPath}: central directory size mismatch`);
|
|
467
|
+
|
|
468
|
+
if (verify) {
|
|
469
|
+
for (const e of entries) {
|
|
470
|
+
const h = e.offset;
|
|
471
|
+
if (buf.readUInt32LE(h) !== 0x04034b50) throw new Error(`${zipPath}: bad local header for ${e.name}`);
|
|
472
|
+
const dataStart = h + 30 + buf.readUInt16LE(h + 26) + buf.readUInt16LE(h + 28);
|
|
473
|
+
const payload = buf.subarray(dataStart, dataStart + e.compressedSize);
|
|
474
|
+
let data;
|
|
475
|
+
try {
|
|
476
|
+
data = e.method === 8 ? zlib.inflateRawSync(payload) : payload;
|
|
477
|
+
} catch (err) {
|
|
478
|
+
throw new Error(`${zipPath}: ${e.name} does not verify (${err.message})`);
|
|
479
|
+
}
|
|
480
|
+
if (data.length !== e.size || crc32(data) !== e.crc32) {
|
|
481
|
+
throw new Error(`${zipPath}: ${e.name} does not verify (size or CRC mismatch)`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return entries;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// ── Upgrade helpers ──
|
|
489
|
+
|
|
490
|
+
function isPidAlive(pid) {
|
|
491
|
+
try { process.kill(pid, 0); return true; } catch (err) { return err.code === 'EPERM'; }
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// Executable name of a running process, or null if it cannot be determined.
|
|
495
|
+
function processImageName(pid) {
|
|
496
|
+
const opts = { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] };
|
|
497
|
+
try {
|
|
498
|
+
if (process.platform === 'win32') {
|
|
499
|
+
const out = execSync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`, opts);
|
|
500
|
+
const m = out.match(/^"([^"]+)","(\d+)"/m);
|
|
501
|
+
return m && Number(m[2]) === pid ? m[1] : null;
|
|
502
|
+
}
|
|
503
|
+
return execSync(`ps -p ${pid} -o comm=`, opts).trim() || null;
|
|
504
|
+
} catch {
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// The workbench writes its PID to .ombutocode/.instance.lock on startup and
|
|
510
|
+
// removes the file on a clean exit (see acquireProjectLock in main.js). A
|
|
511
|
+
// crashed app, or a project scaffolded from a clone, leaves a stale PID
|
|
512
|
+
// behind, so a lock only counts when that PID is alive and — where the OS
|
|
513
|
+
// tells us — actually belongs to Electron / Ombuto Code rather than to some
|
|
514
|
+
// unrelated process that inherited the number. Returns { pid, image } for
|
|
515
|
+
// a running workbench, else null.
|
|
516
|
+
function findRunningWorkbench(ombutoDir) {
|
|
517
|
+
const lockPath = path.join(ombutoDir, '.instance.lock');
|
|
518
|
+
if (!fs.existsSync(lockPath)) return null;
|
|
519
|
+
const pid = parseInt(fs.readFileSync(lockPath, 'utf8').trim(), 10);
|
|
520
|
+
if (!Number.isFinite(pid) || pid <= 0 || pid === process.pid) return null;
|
|
521
|
+
if (!isPidAlive(pid)) return null;
|
|
522
|
+
const image = processImageName(pid);
|
|
523
|
+
if (image && !/electron|ombuto/i.test(image)) return null;
|
|
524
|
+
return { pid, image };
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function readWorkbenchVersion(ombutoDir) {
|
|
528
|
+
const pkgPath = path.join(ombutoDir, 'src', 'package.json');
|
|
529
|
+
try {
|
|
530
|
+
const version = JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version;
|
|
531
|
+
return typeof version === 'string' && version ? version : null;
|
|
532
|
+
} catch {
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Numeric dotted-version comparison: negative if a < b, positive if a > b.
|
|
538
|
+
function compareVersions(a, b) {
|
|
539
|
+
const pa = String(a).split('.').map((n) => parseInt(n, 10) || 0);
|
|
540
|
+
const pb = String(b).split('.').map((n) => parseInt(n, 10) || 0);
|
|
541
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
542
|
+
const diff = (pa[i] || 0) - (pb[i] || 0);
|
|
543
|
+
if (diff !== 0) return diff;
|
|
544
|
+
}
|
|
545
|
+
return 0;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
// Every file under the preserved paths (UPGRADE_BACKUP_PATHS), as ZIP
|
|
549
|
+
// entries named `.ombutocode/<relative path>` so the archive extracts back
|
|
550
|
+
// into place from the project root.
|
|
551
|
+
function collectBackupEntries(ombutoDir) {
|
|
552
|
+
const entries = [];
|
|
553
|
+
const walk = (abs, rel) => {
|
|
554
|
+
for (const entry of fs.readdirSync(abs, { withFileTypes: true })) {
|
|
555
|
+
const absPath = path.join(abs, entry.name);
|
|
556
|
+
const relPath = `${rel}/${entry.name}`;
|
|
557
|
+
if (entry.isDirectory()) walk(absPath, relPath);
|
|
558
|
+
else if (entry.isFile()) entries.push({ name: relPath, file: absPath });
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
for (const p of UPGRADE_BACKUP_PATHS) {
|
|
562
|
+
const abs = path.join(ombutoDir, p);
|
|
563
|
+
if (!fs.existsSync(abs)) continue;
|
|
564
|
+
const rel = `.ombutocode/${p}`;
|
|
565
|
+
if (fs.statSync(abs).isDirectory()) walk(abs, rel);
|
|
566
|
+
else entries.push({ name: rel, file: abs });
|
|
567
|
+
}
|
|
568
|
+
return entries;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// Write `.ombutocode-backup-<version>-<YYYYMMDD-HHMMSS>.zip` into projectDir
|
|
572
|
+
// and verify it by re-reading the central directory (entry count, CRCs, and
|
|
573
|
+
// that ombutocode.db made it in whenever it existed). Returns
|
|
574
|
+
// { zipPath, entries, bytes }.
|
|
575
|
+
function backupWorkbenchState(projectDir, currentVersion, now = new Date()) {
|
|
576
|
+
const ombutoDir = path.join(projectDir, '.ombutocode');
|
|
577
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
578
|
+
const stamp = `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
579
|
+
const zipPath = path.join(projectDir, `.ombutocode-backup-${currentVersion}-${stamp}.zip`);
|
|
580
|
+
|
|
581
|
+
const entries = collectBackupEntries(ombutoDir);
|
|
582
|
+
const written = writeZip(zipPath, entries);
|
|
583
|
+
const listed = readZipEntries(zipPath, { verify: true });
|
|
584
|
+
if (listed.length !== entries.length) {
|
|
585
|
+
throw new Error(`backup verification failed: wrote ${entries.length} entries, archive lists ${listed.length}`);
|
|
586
|
+
}
|
|
587
|
+
const dbName = '.ombutocode/data/ombutocode.db';
|
|
588
|
+
if (fs.existsSync(path.join(ombutoDir, 'data', 'ombutocode.db')) && !listed.some((e) => e.name === dbName)) {
|
|
589
|
+
throw new Error(`backup verification failed: ${dbName} is missing from the archive`);
|
|
590
|
+
}
|
|
591
|
+
return { zipPath, entries: listed.length, bytes: written.bytes };
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// Replace the workbench code in targetOmbutoDir with the release in
|
|
595
|
+
// newOmbutoDir, following the upgrade contract above. newOmbutoDir is
|
|
596
|
+
// consumed (its directories are moved, not copied). Returns a summary:
|
|
597
|
+
// { replaced, removed, profilesAdded, codingagentsAdded, codingagentsNew }.
|
|
598
|
+
function replaceWorkbench(targetOmbutoDir, newOmbutoDir, logFn = log) {
|
|
599
|
+
const result = { replaced: [], removed: [], profilesAdded: [], codingagentsAdded: [], codingagentsNew: null };
|
|
600
|
+
const rm = (p) => fs.rmSync(p, { recursive: true, force: true, maxRetries: 3 });
|
|
601
|
+
|
|
602
|
+
// Directories: delete the old one entirely, then move the release's in.
|
|
603
|
+
for (const name of UPGRADE_REPLACE_DIRS) {
|
|
604
|
+
const target = path.join(targetOmbutoDir, name);
|
|
605
|
+
const source = path.join(newOmbutoDir, name);
|
|
606
|
+
const hadOld = fs.existsSync(target);
|
|
607
|
+
if (hadOld) rm(target);
|
|
608
|
+
if (fs.existsSync(source)) {
|
|
609
|
+
moveDirSync(source, target);
|
|
610
|
+
result.replaced.push(`${name}/`);
|
|
611
|
+
logFn(`Replaced ${name}/`);
|
|
612
|
+
} else if (hadOld) {
|
|
613
|
+
result.removed.push(`${name}/`);
|
|
614
|
+
logFn(`Removed ${name}/ (not shipped by this release)`);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// Plain files, including every launcher script (buildandrun*, initombuto*)
|
|
619
|
+
// present on either side, so a launcher the release dropped goes too.
|
|
620
|
+
const fileNames = new Set(UPGRADE_REPLACE_FILES);
|
|
621
|
+
for (const dir of [targetOmbutoDir, newOmbutoDir]) {
|
|
622
|
+
if (!fs.existsSync(dir)) continue;
|
|
623
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
624
|
+
if (entry.isFile() && UPGRADE_REPLACE_PREFIXES.some((p) => entry.name.startsWith(p))) {
|
|
625
|
+
fileNames.add(entry.name);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
for (const name of fileNames) {
|
|
630
|
+
const target = path.join(targetOmbutoDir, name);
|
|
631
|
+
const source = path.join(newOmbutoDir, name);
|
|
632
|
+
const hadOld = fs.existsSync(target);
|
|
633
|
+
if (hadOld) rm(target);
|
|
634
|
+
if (fs.existsSync(source)) {
|
|
635
|
+
fs.copyFileSync(source, target);
|
|
636
|
+
try { fs.chmodSync(target, fs.statSync(source).mode); } catch {}
|
|
637
|
+
result.replaced.push(name);
|
|
638
|
+
logFn(`Replaced ${name}`);
|
|
639
|
+
} else if (hadOld) {
|
|
640
|
+
result.removed.push(name);
|
|
641
|
+
logFn(`Removed ${name} (not shipped by this release)`);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// profiles/: additive only — the same rule initombuto applies to skills.
|
|
646
|
+
result.profilesAdded = copyMissingFiles(path.join(newOmbutoDir, 'profiles'), path.join(targetOmbutoDir, 'profiles'));
|
|
647
|
+
for (const rel of result.profilesAdded) logFn(`Added profiles/${rel}`);
|
|
648
|
+
|
|
649
|
+
// codingagents/: codingagents.yml is the user's agent configuration and is
|
|
650
|
+
// never overwritten. When the release's copy differs it is written
|
|
651
|
+
// alongside as codingagents.yml.new for the user to merge. Any other file
|
|
652
|
+
// the release ships in that directory is added only if missing.
|
|
653
|
+
const ymlSource = path.join(newOmbutoDir, 'codingagents', 'codingagents.yml');
|
|
654
|
+
const ymlTarget = path.join(targetOmbutoDir, 'codingagents', 'codingagents.yml');
|
|
655
|
+
const ymlNew = `${ymlTarget}.new`;
|
|
656
|
+
if (fs.existsSync(ymlSource) && fs.existsSync(ymlTarget)) {
|
|
657
|
+
if (fs.readFileSync(ymlSource).equals(fs.readFileSync(ymlTarget))) {
|
|
658
|
+
if (fs.existsSync(ymlNew)) rm(ymlNew);
|
|
659
|
+
} else {
|
|
660
|
+
fs.copyFileSync(ymlSource, ymlNew);
|
|
661
|
+
result.codingagentsNew = ymlNew;
|
|
662
|
+
logFn('Kept codingagents/codingagents.yml; the release\'s version differs and was written as codingagents.yml.new');
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
result.codingagentsAdded = copyMissingFiles(path.join(newOmbutoDir, 'codingagents'), path.join(targetOmbutoDir, 'codingagents'));
|
|
666
|
+
for (const rel of result.codingagentsAdded) logFn(`Added codingagents/${rel}`);
|
|
667
|
+
|
|
668
|
+
return result;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// Seed docs/Skills/ with any skill template the release ships that the
|
|
672
|
+
// project does not have yet — the same file-by-file rule initombuto uses.
|
|
673
|
+
// initombuto itself is deliberately not run here: even with --keep-docs it
|
|
674
|
+
// deletes the database, ticket files, features and agent state first.
|
|
675
|
+
// Returns the relative paths added.
|
|
676
|
+
function seedMissingSkills(projectDir, ombutoDir, logFn = log) {
|
|
677
|
+
const docsDir = path.join(projectDir, 'docs');
|
|
678
|
+
if (!fs.existsSync(docsDir)) {
|
|
679
|
+
logFn('No docs/ directory — skipped skill seeding');
|
|
680
|
+
return [];
|
|
681
|
+
}
|
|
682
|
+
const added = copyMissingFiles(path.join(ombutoDir, 'templates', 'skills'), path.join(docsDir, 'Skills'));
|
|
683
|
+
for (const rel of added) logFn(`Added docs/Skills/${rel}`);
|
|
684
|
+
return added;
|
|
685
|
+
}
|
|
686
|
+
|
|
218
687
|
// ── CLI ──
|
|
219
688
|
|
|
220
689
|
const HELP = `
|
|
@@ -225,6 +694,7 @@ const HELP = `
|
|
|
225
694
|
Usage:
|
|
226
695
|
npx create-ombutocode <project-name> [--omit-dev]
|
|
227
696
|
npx create-ombutocode --into-existing <dir> [--omit-dev]
|
|
697
|
+
npx create-ombutocode --upgrade [<dir>] [--no-backup] [--force] [--omit-dev]
|
|
228
698
|
|
|
229
699
|
Options:
|
|
230
700
|
--into-existing <dir> Adopt Ombuto Code into an existing directory
|
|
@@ -233,6 +703,21 @@ const HELP = `
|
|
|
233
703
|
any file that is already there, and never runs
|
|
234
704
|
git init/add/commit. <dir> must exist and must
|
|
235
705
|
not already contain .ombutocode/.
|
|
706
|
+
--upgrade [<dir>] Upgrade the workbench (.ombutocode/) of an
|
|
707
|
+
existing project to this installer's release,
|
|
708
|
+
${CLONE_REF}. <dir> defaults to the current directory.
|
|
709
|
+
Replaces only workbench code (src/, tools/,
|
|
710
|
+
templates/, scripts/, bench/, the launcher
|
|
711
|
+
scripts, the engineering guide, README, LICENSE
|
|
712
|
+
and codingagent-templates.json); the database,
|
|
713
|
+
tickets, codingagents.yml, profiles and docs/
|
|
714
|
+
are left alone. Zips the preserved state into
|
|
715
|
+
.ombutocode-backup-<version>-<timestamp>.zip
|
|
716
|
+
first, and refuses to run while the workbench
|
|
717
|
+
is open.
|
|
718
|
+
--no-backup Skip the backup zip (--upgrade only).
|
|
719
|
+
--force Upgrade even when the project is already at
|
|
720
|
+
${CLONE_REF} or newer (--upgrade only).
|
|
236
721
|
--omit-dev Install with \`npm install --omit=dev
|
|
237
722
|
--legacy-peer-deps\`: no Electron, Vite or
|
|
238
723
|
electron-builder. For headless and CLI use only —
|
|
@@ -250,163 +735,307 @@ const HELP = `
|
|
|
250
735
|
npx create-ombutocode --into-existing /app --omit-dev
|
|
251
736
|
cd /app
|
|
252
737
|
node .ombutocode/src/headless.js status
|
|
738
|
+
|
|
739
|
+
Example (upgrade the workbench in the current project):
|
|
740
|
+
cd my-app
|
|
741
|
+
npx create-ombutocode@latest --upgrade
|
|
253
742
|
`;
|
|
254
743
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
744
|
+
function main() {
|
|
745
|
+
const args = process.argv.slice(2);
|
|
746
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
747
|
+
console.log(HELP);
|
|
748
|
+
process.exit(0);
|
|
749
|
+
}
|
|
260
750
|
|
|
261
|
-
let projectName = null;
|
|
262
|
-
let intoExisting = null;
|
|
263
|
-
let
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
751
|
+
let projectName = null;
|
|
752
|
+
let intoExisting = null;
|
|
753
|
+
let upgrade = null; // false: not requested; string: directory to upgrade
|
|
754
|
+
let omitDev = false;
|
|
755
|
+
let noBackup = false;
|
|
756
|
+
let force = false;
|
|
757
|
+
|
|
758
|
+
for (let i = 0; i < args.length; i++) {
|
|
759
|
+
const arg = args[i];
|
|
760
|
+
if (arg === '--omit-dev') {
|
|
761
|
+
omitDev = true;
|
|
762
|
+
} else if (arg === '--no-backup') {
|
|
763
|
+
noBackup = true;
|
|
764
|
+
} else if (arg === '--force') {
|
|
765
|
+
force = true;
|
|
766
|
+
} else if (arg === '--into-existing') {
|
|
767
|
+
intoExisting = args[i + 1];
|
|
768
|
+
i++;
|
|
769
|
+
if (!intoExisting || intoExisting.startsWith('-')) {
|
|
770
|
+
fatal('--into-existing requires a directory:\n\n npx create-ombutocode --into-existing /path/to/repo\n');
|
|
771
|
+
}
|
|
772
|
+
} else if (arg.startsWith('--into-existing=')) {
|
|
773
|
+
intoExisting = arg.slice('--into-existing='.length);
|
|
774
|
+
if (!intoExisting) {
|
|
775
|
+
fatal('--into-existing requires a directory:\n\n npx create-ombutocode --into-existing /path/to/repo\n');
|
|
776
|
+
}
|
|
777
|
+
} else if (arg === '--upgrade') {
|
|
778
|
+
// Optional directory; defaults to the current directory.
|
|
779
|
+
if (args[i + 1] !== undefined && !args[i + 1].startsWith('-')) {
|
|
780
|
+
upgrade = args[i + 1];
|
|
781
|
+
i++;
|
|
782
|
+
} else {
|
|
783
|
+
upgrade = '.';
|
|
784
|
+
}
|
|
785
|
+
} else if (arg.startsWith('--upgrade=')) {
|
|
786
|
+
upgrade = arg.slice('--upgrade='.length) || '.';
|
|
787
|
+
} else if (arg.startsWith('-')) {
|
|
788
|
+
fatal(`Unknown option "${arg}". Run with --help for usage.`);
|
|
789
|
+
} else if (projectName === null) {
|
|
790
|
+
projectName = arg;
|
|
791
|
+
} else {
|
|
792
|
+
fatal(`Unexpected argument "${arg}". Run with --help for usage.`);
|
|
279
793
|
}
|
|
280
|
-
} else if (arg.startsWith('-')) {
|
|
281
|
-
fatal(`Unknown option "${arg}". Run with --help for usage.`);
|
|
282
|
-
} else if (projectName === null) {
|
|
283
|
-
projectName = arg;
|
|
284
|
-
} else {
|
|
285
|
-
fatal(`Unexpected argument "${arg}". Run with --help for usage.`);
|
|
286
794
|
}
|
|
287
|
-
}
|
|
288
795
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
// peers automatically. --legacy-peer-deps turns that off; --omit=peer does
|
|
292
|
-
// not (verified against npm 10). Nothing headless.js loads needs a peer.
|
|
293
|
-
const npmInstallCmd = omitDev
|
|
294
|
-
? 'npm install --no-audit --no-fund --omit=dev --legacy-peer-deps'
|
|
295
|
-
: 'npm install --no-audit --no-fund';
|
|
296
|
-
// initombuto runs its own plain `npm install`; npm reads npm_config_* from
|
|
297
|
-
// the environment, so this keeps that second install from adding the dev
|
|
298
|
-
// dependencies and Electron back.
|
|
299
|
-
const initEnv = omitDev
|
|
300
|
-
? { ...process.env, npm_config_omit: 'dev', npm_config_legacy_peer_deps: 'true' }
|
|
301
|
-
: process.env;
|
|
302
|
-
|
|
303
|
-
function noteOmitDev() {
|
|
304
|
-
if (!omitDev) return;
|
|
305
|
-
log('--omit-dev: Electron, Vite and electron-builder were not installed.');
|
|
306
|
-
log('The workbench UI cannot be built from this install; use the headless CLI');
|
|
307
|
-
log('(node .ombutocode/src/headless.js) or re-run `npm install` in .ombutocode/src.');
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// ═════════════════════════════════════════════════════════════════════
|
|
311
|
-
// Adopt into an existing directory
|
|
312
|
-
// ═════════════════════════════════════════════════════════════════════
|
|
313
|
-
|
|
314
|
-
if (intoExisting !== null) {
|
|
315
|
-
if (projectName !== null) {
|
|
316
|
-
fatal('Give either a <project-name> or --into-existing <dir>, not both.');
|
|
796
|
+
if ((noBackup || force) && upgrade === null) {
|
|
797
|
+
fatal('--no-backup and --force only apply to --upgrade. Run with --help for usage.');
|
|
317
798
|
}
|
|
318
799
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
800
|
+
// --omit=dev alone still downloads Electron: @electron/remote (a runtime
|
|
801
|
+
// dependency) declares electron as a peer dependency and npm 7+ installs
|
|
802
|
+
// peers automatically. --legacy-peer-deps turns that off; --omit=peer does
|
|
803
|
+
// not (verified against npm 10). Nothing headless.js loads needs a peer.
|
|
804
|
+
const npmInstallCmd = omitDev
|
|
805
|
+
? 'npm install --no-audit --no-fund --omit=dev --legacy-peer-deps'
|
|
806
|
+
: 'npm install --no-audit --no-fund';
|
|
807
|
+
// initombuto runs its own plain `npm install`; npm reads npm_config_* from
|
|
808
|
+
// the environment, so this keeps that second install from adding the dev
|
|
809
|
+
// dependencies and Electron back.
|
|
810
|
+
const initEnv = omitDev
|
|
811
|
+
? { ...process.env, npm_config_omit: 'dev', npm_config_legacy_peer_deps: 'true' }
|
|
812
|
+
: process.env;
|
|
813
|
+
|
|
814
|
+
function noteOmitDev() {
|
|
815
|
+
if (!omitDev) return;
|
|
816
|
+
log('--omit-dev: Electron, Vite and electron-builder were not installed.');
|
|
817
|
+
log('The workbench UI cannot be built from this install; use the headless CLI');
|
|
818
|
+
log('(node .ombutocode/src/headless.js) or re-run `npm install` in .ombutocode/src.');
|
|
322
819
|
}
|
|
323
|
-
if (fs.existsSync(path.join(targetDir, '.ombutocode'))) {
|
|
324
|
-
fatal(`"${targetDir}" already contains .ombutocode/ — refusing to overwrite an existing Ombuto Code installation.`);
|
|
325
|
-
}
|
|
326
|
-
const targetName = path.basename(targetDir);
|
|
327
|
-
const targetIsGitRepo = fs.existsSync(path.join(targetDir, '.git'));
|
|
328
820
|
|
|
329
|
-
console.log(`
|
|
821
|
+
const banner = () => console.log(`
|
|
330
822
|
╔═══════════════════════════════════════════╗
|
|
331
823
|
║ create-ombutocode v${VERSION} ║
|
|
332
824
|
║ Agentic Software Engineering Workbench ║
|
|
333
825
|
╚═══════════════════════════════════════════╝
|
|
334
826
|
`);
|
|
335
|
-
console.log(`Adopting Ombuto Code into: ${targetDir}`);
|
|
336
827
|
|
|
337
|
-
//
|
|
828
|
+
// ═════════════════════════════════════════════════════════════════════
|
|
829
|
+
// Upgrade the workbench in an existing project
|
|
830
|
+
// ═════════════════════════════════════════════════════════════════════
|
|
338
831
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
832
|
+
if (upgrade !== null) {
|
|
833
|
+
if (intoExisting !== null) {
|
|
834
|
+
fatal('--upgrade cannot be combined with --into-existing.');
|
|
835
|
+
}
|
|
836
|
+
// `create-ombutocode my-app --upgrade` reads as naturally as
|
|
837
|
+
// `--upgrade my-app`; treat the positional as the directory.
|
|
838
|
+
if (projectName !== null) {
|
|
839
|
+
if (upgrade !== '.') fatal(`Unexpected argument "${projectName}". Run with --help for usage.`);
|
|
840
|
+
upgrade = projectName;
|
|
841
|
+
}
|
|
345
842
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
// initombuto below instead, file by file, only where nothing exists yet.
|
|
843
|
+
const projectDir = path.resolve(upgrade);
|
|
844
|
+
const ombutoDir = path.join(projectDir, '.ombutocode');
|
|
845
|
+
if (!fs.existsSync(path.join(ombutoDir, 'src', 'package.json'))) {
|
|
846
|
+
fatal(`"${projectDir}" does not contain .ombutocode/src/package.json — nothing to upgrade.\n To add Ombuto Code to a directory that does not have it yet, use:\n\n npx create-ombutocode --into-existing "${projectDir}"\n`);
|
|
847
|
+
}
|
|
352
848
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
fs.rmSync(path.join(cloneDir, 'create-ombutocode'), { recursive: true, force: true });
|
|
356
|
-
stripUpstreamFiles(cloneDir);
|
|
357
|
-
fs.rmSync(path.join(cloneDir, 'docs'), { recursive: true, force: true });
|
|
358
|
-
log('Discarded upstream docs/');
|
|
849
|
+
banner();
|
|
850
|
+
console.log(`Upgrading Ombuto Code in: ${projectDir}`);
|
|
359
851
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
852
|
+
// ── Step 1: Preflight ──
|
|
853
|
+
|
|
854
|
+
heading('Checking the project');
|
|
855
|
+
const running = findRunningWorkbench(ombutoDir);
|
|
856
|
+
if (running) {
|
|
857
|
+
fatal(`The workbench appears to be running for this project (PID ${running.pid}${running.image ? `, ${running.image}` : ''}).\n Close Ombuto Code and run the upgrade again. If the app is not running,\n delete the stale lock file .ombutocode/.instance.lock and retry.`);
|
|
858
|
+
}
|
|
859
|
+
const currentVersion = readWorkbenchVersion(ombutoDir) || 'unknown';
|
|
860
|
+
const targetVersion = CLONE_REF.replace(/^v/, '');
|
|
861
|
+
const cmp = currentVersion === 'unknown' ? -1 : compareVersions(currentVersion, targetVersion);
|
|
862
|
+
if (cmp === 0 && !force) {
|
|
863
|
+
log(`.ombutocode is already at ${targetVersion} — nothing to do. (Use --force to reinstall it anyway.)`);
|
|
864
|
+
process.exit(0);
|
|
865
|
+
}
|
|
866
|
+
if (cmp > 0 && !force) {
|
|
867
|
+
fatal(`.ombutocode is at ${currentVersion}, which is newer than this installer's release (${targetVersion}).\n Run \`npx create-ombutocode@latest --upgrade\` to use the newest installer, or pass --force to downgrade.`);
|
|
868
|
+
}
|
|
869
|
+
log(`Upgrading .ombutocode from ${currentVersion} to ${targetVersion}${cmp > 0 ? ' (downgrade, --force)' : cmp === 0 ? ' (reinstall, --force)' : ''}`);
|
|
870
|
+
|
|
871
|
+
// ── Step 2: Backup ──
|
|
872
|
+
|
|
873
|
+
let backup = null;
|
|
874
|
+
if (noBackup) {
|
|
875
|
+
heading('Backup');
|
|
876
|
+
log('--no-backup: skipping the backup zip.');
|
|
877
|
+
} else {
|
|
878
|
+
heading('Backing up project state');
|
|
879
|
+
try {
|
|
880
|
+
backup = backupWorkbenchState(projectDir, currentVersion);
|
|
881
|
+
} catch (err) {
|
|
882
|
+
fatal(`Could not write the backup: ${err.message}\n Nothing has been changed. Fix the problem and retry, or pass --no-backup.`);
|
|
883
|
+
}
|
|
884
|
+
log(`Wrote ${path.basename(backup.zipPath)} (${backup.entries} files, ${(backup.bytes / 1024).toFixed(0)} KB)`);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
// ── Step 3: Fetch the release ──
|
|
888
|
+
|
|
889
|
+
const { clonedOmbutocode, cleanupTemp } = cloneWorkbench();
|
|
890
|
+
|
|
891
|
+
// ── Step 4: Replace the workbench code ──
|
|
892
|
+
//
|
|
893
|
+
// From here on the project is being modified. Any failure — including
|
|
894
|
+
// one inside `run()`, which exits the process — has to leave the user
|
|
895
|
+
// with clear recovery instructions, hence the exit hook.
|
|
896
|
+
|
|
897
|
+
heading('Replacing workbench code');
|
|
898
|
+
let replacing = true;
|
|
899
|
+
process.on('exit', (code) => {
|
|
900
|
+
if (code === 0 || !replacing) return;
|
|
901
|
+
console.error(`
|
|
902
|
+
✖ The upgrade did not complete; .ombutocode/ may be half-replaced.
|
|
903
|
+
To restore the previous workbench:
|
|
904
|
+
git checkout -- .ombutocode # if it was committed, and
|
|
905
|
+
${backup ? ` unzip -o "${path.basename(backup.zipPath)}" # or Expand-Archive on Windows\n` : ''} then re-run the upgrade once the cause is fixed.`);
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
let summary;
|
|
909
|
+
try {
|
|
910
|
+
summary = replaceWorkbench(ombutoDir, clonedOmbutocode);
|
|
911
|
+
seedMissingSkills(projectDir, ombutoDir);
|
|
912
|
+
} catch (err) {
|
|
913
|
+
fatal(`Replacing the workbench failed: ${err.message}`);
|
|
914
|
+
}
|
|
915
|
+
cleanupTemp();
|
|
916
|
+
|
|
917
|
+
// ── Step 5: Install dependencies ──
|
|
918
|
+
|
|
919
|
+
heading('Installing dependencies');
|
|
920
|
+
run(npmInstallCmd, { cwd: path.join(ombutoDir, 'src') });
|
|
921
|
+
noteOmitDev();
|
|
922
|
+
replacing = false;
|
|
923
|
+
|
|
924
|
+
// ── Done ──
|
|
925
|
+
|
|
926
|
+
const newVersion = readWorkbenchVersion(ombutoDir) || targetVersion;
|
|
927
|
+
console.log(`
|
|
928
|
+
╔═══════════════════════════════════════════╗
|
|
929
|
+
║ Workbench upgraded! ║
|
|
930
|
+
╚═══════════════════════════════════════════╝
|
|
931
|
+
|
|
932
|
+
.ombutocode: ${currentVersion} → ${newVersion}
|
|
933
|
+
`);
|
|
934
|
+
if (backup) {
|
|
935
|
+
console.log(` Backup of your database, tickets, agent config and profiles:
|
|
936
|
+
${backup.zipPath}
|
|
937
|
+
Delete it once you are happy with the upgrade (or ignore .ombutocode-backup-*.zip).
|
|
938
|
+
`);
|
|
939
|
+
}
|
|
940
|
+
if (summary.codingagentsNew) {
|
|
941
|
+
console.log(` codingagents/codingagents.yml was kept as-is. This release ships a
|
|
942
|
+
different default, written next to it as codingagents.yml.new — compare
|
|
943
|
+
and merge anything you want, then delete the .new file.
|
|
944
|
+
`);
|
|
945
|
+
}
|
|
946
|
+
console.log(` Next:
|
|
947
|
+
git status # review what changed under .ombutocode/ and docs/Skills/
|
|
948
|
+
git add -A .ombutocode docs && git commit -m "Upgrade Ombuto Code to ${newVersion}"
|
|
949
|
+
|
|
950
|
+
Check the release notes for version-specific steps:
|
|
951
|
+
https://github.com/FrancoisBotha/ombutocode/releases
|
|
952
|
+
${omitDev ? `
|
|
953
|
+
# Headless CLI:
|
|
954
|
+
node .ombutocode/src/headless.js status
|
|
955
|
+
` : `
|
|
956
|
+
# Launch the workbench:
|
|
957
|
+
.ombutocode/buildandrun.bat # Windows
|
|
958
|
+
bash .ombutocode/buildandrun # macOS / Linux
|
|
959
|
+
`}`);
|
|
960
|
+
process.exit(0);
|
|
363
961
|
}
|
|
364
|
-
moveDirSync(clonedOmbutocode, path.join(targetDir, '.ombutocode'));
|
|
365
|
-
log('Added .ombutocode/');
|
|
366
|
-
cleanupTemp();
|
|
367
962
|
|
|
368
|
-
|
|
369
|
-
|
|
963
|
+
// ═════════════════════════════════════════════════════════════════════
|
|
964
|
+
// Adopt into an existing directory
|
|
965
|
+
// ═════════════════════════════════════════════════════════════════════
|
|
370
966
|
|
|
371
|
-
|
|
967
|
+
if (intoExisting !== null) {
|
|
968
|
+
if (projectName !== null) {
|
|
969
|
+
fatal('Give either a <project-name> or --into-existing <dir>, not both.');
|
|
970
|
+
}
|
|
372
971
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
972
|
+
const targetDir = path.resolve(intoExisting);
|
|
973
|
+
if (!fs.existsSync(targetDir) || !fs.statSync(targetDir).isDirectory()) {
|
|
974
|
+
fatal(`Directory "${targetDir}" does not exist. --into-existing adopts an existing directory; use \`npx create-ombutocode <project-name>\` to create a new one.`);
|
|
975
|
+
}
|
|
976
|
+
if (fs.existsSync(path.join(targetDir, '.ombutocode'))) {
|
|
977
|
+
fatal(`"${targetDir}" already contains .ombutocode/ — refusing to overwrite an existing Ombuto Code installation. To move it to this installer's release, use \`npx create-ombutocode --upgrade "${targetDir}"\`.`);
|
|
978
|
+
}
|
|
979
|
+
const targetName = path.basename(targetDir);
|
|
980
|
+
const targetIsGitRepo = fs.existsSync(path.join(targetDir, '.git'));
|
|
376
981
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
// --keep-docs: never wipe docs/. initombuto still creates every missing
|
|
380
|
-
// docs/ folder, starter document and skill file, and skips any file that
|
|
381
|
-
// already exists, which is the non-destructive merge an adopted repo needs.
|
|
982
|
+
banner();
|
|
983
|
+
console.log(`Adopting Ombuto Code into: ${targetDir}`);
|
|
382
984
|
|
|
383
|
-
|
|
384
|
-
|
|
985
|
+
// ── Step 1: Clone the pinned release and reduce it to the workbench ──
|
|
986
|
+
//
|
|
987
|
+
// Only .ombutocode/ travels into the adopted directory. The clone's
|
|
988
|
+
// docs/ holds the upstream project's own specs and epics, which must not
|
|
989
|
+
// leak into someone else's repository — the docs/ skeleton is seeded by
|
|
990
|
+
// initombuto below instead, file by file, only where nothing exists yet.
|
|
385
991
|
|
|
386
|
-
|
|
992
|
+
const { clonedOmbutocode, cleanupTemp } = cloneWorkbench();
|
|
993
|
+
moveDirSync(clonedOmbutocode, path.join(targetDir, '.ombutocode'));
|
|
994
|
+
log('Added .ombutocode/');
|
|
995
|
+
cleanupTemp();
|
|
387
996
|
|
|
388
|
-
|
|
997
|
+
writeTemplateFiles(targetDir, targetName, { skipExisting: true });
|
|
998
|
+
ensureGitignore(targetDir);
|
|
999
|
+
|
|
1000
|
+
// ── Step 2: Install dependencies ──
|
|
1001
|
+
|
|
1002
|
+
heading('Installing dependencies');
|
|
1003
|
+
run(npmInstallCmd, { cwd: path.join(targetDir, '.ombutocode', 'src') });
|
|
1004
|
+
noteOmitDev();
|
|
1005
|
+
|
|
1006
|
+
// ── Step 3: Initialise project data ──
|
|
1007
|
+
//
|
|
1008
|
+
// --keep-docs: never wipe docs/. initombuto still creates every missing
|
|
1009
|
+
// docs/ folder, starter document and skill file, and skips any file that
|
|
1010
|
+
// already exists, which is the non-destructive merge an adopted repo needs.
|
|
1011
|
+
|
|
1012
|
+
heading('Initialising project');
|
|
1013
|
+
runInitombuto(targetDir, ['--keep-docs', targetDir], initEnv);
|
|
1014
|
+
|
|
1015
|
+
// ── No Step 4: the directory's git history is the owner's business ──
|
|
1016
|
+
|
|
1017
|
+
console.log(`
|
|
389
1018
|
╔═══════════════════════════════════════════╗
|
|
390
1019
|
║ Workbench added! ║
|
|
391
1020
|
╚═══════════════════════════════════════════╝
|
|
392
1021
|
|
|
393
1022
|
cd ${targetName}
|
|
394
1023
|
`);
|
|
395
|
-
|
|
396
|
-
|
|
1024
|
+
if (targetIsGitRepo) {
|
|
1025
|
+
console.log(` This directory is already a git repository. Nothing was committed;
|
|
397
1026
|
when you are ready, commit the workbench and its docs skeleton:
|
|
398
1027
|
|
|
399
1028
|
git add .ombutocode docs .gitignore
|
|
400
1029
|
git commit -m "Add Ombuto Code workbench"
|
|
401
1030
|
`);
|
|
402
|
-
|
|
403
|
-
|
|
1031
|
+
} else {
|
|
1032
|
+
console.log(` This directory is not a git repository. The workbench needs one
|
|
404
1033
|
(agents build in git worktrees), so initialise it before running agents:
|
|
405
1034
|
|
|
406
1035
|
git init && git add -A && git commit -m "Initial commit"
|
|
407
1036
|
`);
|
|
408
|
-
|
|
409
|
-
|
|
1037
|
+
}
|
|
1038
|
+
console.log(` # Read this first:
|
|
410
1039
|
GettingStarted.md — what's in the project and what to do next
|
|
411
1040
|
${omitDev ? `
|
|
412
1041
|
# Headless CLI:
|
|
@@ -418,92 +1047,87 @@ ${omitDev ? `
|
|
|
418
1047
|
`}
|
|
419
1048
|
Happy building!
|
|
420
1049
|
`);
|
|
421
|
-
|
|
422
|
-
}
|
|
1050
|
+
process.exit(0);
|
|
1051
|
+
}
|
|
423
1052
|
|
|
424
|
-
// ═════════════════════════════════════════════════════════════════════
|
|
425
|
-
// Create a new project
|
|
426
|
-
// ═════════════════════════════════════════════════════════════════════
|
|
1053
|
+
// ═════════════════════════════════════════════════════════════════════
|
|
1054
|
+
// Create a new project
|
|
1055
|
+
// ═════════════════════════════════════════════════════════════════════
|
|
427
1056
|
|
|
428
|
-
if (!projectName) {
|
|
429
|
-
|
|
430
|
-
}
|
|
1057
|
+
if (!projectName) {
|
|
1058
|
+
fatal('Please specify a project name:\n\n npx create-ombutocode my-app\n');
|
|
1059
|
+
}
|
|
431
1060
|
|
|
432
|
-
if (fs.existsSync(projectName)) {
|
|
433
|
-
|
|
434
|
-
}
|
|
1061
|
+
if (fs.existsSync(projectName)) {
|
|
1062
|
+
fatal(`Directory "${projectName}" already exists.`);
|
|
1063
|
+
}
|
|
435
1064
|
|
|
436
|
-
// ── Banner ──
|
|
1065
|
+
// ── Banner ──
|
|
437
1066
|
|
|
438
|
-
|
|
439
|
-
╔═══════════════════════════════════════════╗
|
|
440
|
-
║ create-ombutocode v${VERSION} ║
|
|
441
|
-
║ Agentic Software Engineering Workbench ║
|
|
442
|
-
╚═══════════════════════════════════════════╝
|
|
443
|
-
`);
|
|
1067
|
+
banner();
|
|
444
1068
|
|
|
445
|
-
console.log(`Creating project: ${projectName}`);
|
|
1069
|
+
console.log(`Creating project: ${projectName}`);
|
|
446
1070
|
|
|
447
|
-
// ── Step 1: Clone the repository at the pinned release tag ──
|
|
1071
|
+
// ── Step 1: Clone the repository at the pinned release tag ──
|
|
448
1072
|
|
|
449
|
-
heading(`Cloning Ombuto Code ${CLONE_REF}`);
|
|
450
|
-
run(`git clone --depth 1 --branch ${CLONE_REF} ${REPO_URL} "${projectName}"`);
|
|
1073
|
+
heading(`Cloning Ombuto Code ${CLONE_REF}`);
|
|
1074
|
+
run(`git clone --depth 1 --branch ${CLONE_REF} ${REPO_URL} "${projectName}"`);
|
|
451
1075
|
|
|
452
|
-
const projectDir = path.resolve(projectName);
|
|
1076
|
+
const projectDir = path.resolve(projectName);
|
|
453
1077
|
|
|
454
|
-
// Remove the .git directory so the user starts fresh
|
|
455
|
-
const gitDir = path.join(projectDir, '.git');
|
|
456
|
-
if (fs.existsSync(gitDir)) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
}
|
|
1078
|
+
// Remove the .git directory so the user starts fresh
|
|
1079
|
+
const gitDir = path.join(projectDir, '.git');
|
|
1080
|
+
if (fs.existsSync(gitDir)) {
|
|
1081
|
+
log('Removing upstream .git history...');
|
|
1082
|
+
fs.rmSync(gitDir, { recursive: true, force: true });
|
|
1083
|
+
}
|
|
460
1084
|
|
|
461
|
-
// Remove create-ombutocode directory (the installer itself)
|
|
462
|
-
const installerDir = path.join(projectDir, 'create-ombutocode');
|
|
463
|
-
if (fs.existsSync(installerDir)) {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
1085
|
+
// Remove create-ombutocode directory (the installer itself)
|
|
1086
|
+
const installerDir = path.join(projectDir, 'create-ombutocode');
|
|
1087
|
+
if (fs.existsSync(installerDir)) {
|
|
1088
|
+
log('Removing installer package...');
|
|
1089
|
+
fs.rmSync(installerDir, { recursive: true, force: true });
|
|
1090
|
+
}
|
|
467
1091
|
|
|
468
|
-
// ── Step 1b: Strip upstream maintainer files & write project templates ──
|
|
469
|
-
//
|
|
470
|
-
// The Ombuto Code repo we just cloned contains files that belong to the
|
|
471
|
-
// upstream project (README, CLA, CONTRIBUTING, DeployInstructions, CLAUDE,
|
|
472
|
-
// root LICENSE) — they should not travel into the user's new project.
|
|
473
|
-
// Replace them with minimal project-specific templates.
|
|
474
|
-
|
|
475
|
-
heading('Preparing project files');
|
|
476
|
-
stripUpstreamFiles(projectDir);
|
|
477
|
-
writeTemplateFiles(projectDir, projectName);
|
|
478
|
-
|
|
479
|
-
// ── Step 2: Install dependencies ──
|
|
480
|
-
|
|
481
|
-
heading('Installing dependencies');
|
|
482
|
-
const srcDir = path.join(projectDir, '.ombutocode', 'src');
|
|
483
|
-
if (fs.existsSync(path.join(srcDir, 'package.json'))) {
|
|
484
|
-
run(npmInstallCmd, { cwd: srcDir });
|
|
485
|
-
noteOmitDev();
|
|
486
|
-
} else {
|
|
487
|
-
fatal('.ombutocode/src/package.json not found — repository may be corrupted.');
|
|
488
|
-
}
|
|
1092
|
+
// ── Step 1b: Strip upstream maintainer files & write project templates ──
|
|
1093
|
+
//
|
|
1094
|
+
// The Ombuto Code repo we just cloned contains files that belong to the
|
|
1095
|
+
// upstream project (README, CLA, CONTRIBUTING, DeployInstructions, CLAUDE,
|
|
1096
|
+
// root LICENSE) — they should not travel into the user's new project.
|
|
1097
|
+
// Replace them with minimal project-specific templates.
|
|
489
1098
|
|
|
490
|
-
|
|
1099
|
+
heading('Preparing project files');
|
|
1100
|
+
stripUpstreamFiles(projectDir);
|
|
1101
|
+
writeTemplateFiles(projectDir, projectName);
|
|
491
1102
|
|
|
492
|
-
|
|
1103
|
+
// ── Step 2: Install dependencies ──
|
|
493
1104
|
|
|
494
|
-
|
|
495
|
-
|
|
1105
|
+
heading('Installing dependencies');
|
|
1106
|
+
const srcDir = path.join(projectDir, '.ombutocode', 'src');
|
|
1107
|
+
if (fs.existsSync(path.join(srcDir, 'package.json'))) {
|
|
1108
|
+
run(npmInstallCmd, { cwd: srcDir });
|
|
1109
|
+
noteOmitDev();
|
|
1110
|
+
} else {
|
|
1111
|
+
fatal('.ombutocode/src/package.json not found — repository may be corrupted.');
|
|
1112
|
+
}
|
|
496
1113
|
|
|
497
|
-
// ── Step
|
|
1114
|
+
// ── Step 3: Initialise project data ──
|
|
1115
|
+
|
|
1116
|
+
heading('Initialising project');
|
|
498
1117
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
run('git add -A', { cwd: projectDir });
|
|
502
|
-
run('git commit -m "Initial commit — Ombuto Code project"', { cwd: projectDir });
|
|
1118
|
+
// Run initombuto with --clear to create fresh docs/
|
|
1119
|
+
runInitombuto(projectDir, ['--clear', projectDir], initEnv);
|
|
503
1120
|
|
|
504
|
-
// ──
|
|
1121
|
+
// ── Step 4: Initialise git ──
|
|
505
1122
|
|
|
506
|
-
|
|
1123
|
+
heading('Initialising Git repository');
|
|
1124
|
+
run('git init', { cwd: projectDir });
|
|
1125
|
+
run('git add -A', { cwd: projectDir });
|
|
1126
|
+
run('git commit -m "Initial commit — Ombuto Code project"', { cwd: projectDir });
|
|
1127
|
+
|
|
1128
|
+
// ── Done ──
|
|
1129
|
+
|
|
1130
|
+
console.log(`
|
|
507
1131
|
╔═══════════════════════════════════════════╗
|
|
508
1132
|
║ Project ready! ║
|
|
509
1133
|
╚═══════════════════════════════════════════╝
|
|
@@ -519,3 +1143,29 @@ console.log(`
|
|
|
519
1143
|
|
|
520
1144
|
Happy building!
|
|
521
1145
|
`);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// Exported for the tests in ../test; the CLI only runs when this file is
|
|
1149
|
+
// executed directly.
|
|
1150
|
+
module.exports = {
|
|
1151
|
+
VERSION,
|
|
1152
|
+
CLONE_REF,
|
|
1153
|
+
UPGRADE_REPLACE_DIRS,
|
|
1154
|
+
UPGRADE_REPLACE_FILES,
|
|
1155
|
+
UPGRADE_REPLACE_PREFIXES,
|
|
1156
|
+
UPGRADE_BACKUP_PATHS,
|
|
1157
|
+
crc32,
|
|
1158
|
+
writeZip,
|
|
1159
|
+
readZipEntries,
|
|
1160
|
+
collectBackupEntries,
|
|
1161
|
+
backupWorkbenchState,
|
|
1162
|
+
replaceWorkbench,
|
|
1163
|
+
seedMissingSkills,
|
|
1164
|
+
findRunningWorkbench,
|
|
1165
|
+
compareVersions,
|
|
1166
|
+
copyMissingFiles,
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
if (require.main === module) {
|
|
1170
|
+
main();
|
|
1171
|
+
}
|