@loomwright/cli 0.12.0 → 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/CHANGELOG.md +14 -2
- package/dist/cli.js +93 -36
- package/package.json +9 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes per release. `loomwright update` applies them to an installed workspace (see [docs/cli.md](docs/cli.md#update)).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 1.0.0
|
|
6
6
|
|
|
7
7
|
### Major Changes
|
|
8
8
|
|
|
9
|
-
-
|
|
9
|
+
- d537614: The package and binary are renamed to `@loomwright/cli` and `loomwright`. `ai-factory` keeps working as a deprecated alias, so existing scripts and installs continue to run.
|
|
10
|
+
|
|
11
|
+
The on-disk names (`factory.config.jsonc`, `factory.lock.json`, `.factory/`) and the `AI_FACTORY_*` environment variables are unchanged.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- b7a5208: Commands spawn fewer git processes. Managed files record their merge base as a git blob written
|
|
16
|
+
in-process (one `rev-parse` per sync instead of one `git hash-object` per file), the check-only
|
|
17
|
+
gate guard takes one `status --porcelain=v2 --branch` snapshot instead of a `status` plus a
|
|
18
|
+
`rev-parse HEAD` on both sides of every gate, and workspace discovery asks `rev-parse` once per
|
|
19
|
+
level. `bun run test` now runs test files in parallel (`bun run test:serial` keeps the old single
|
|
20
|
+
process; `bun run test:fast` skips the integration-heavy files), and the fixtures build their
|
|
21
|
+
workspaces once per process instead of once per test.
|
|
10
22
|
|
|
11
23
|
## 0.12.0
|
|
12
24
|
|
package/dist/cli.js
CHANGED
|
@@ -14682,7 +14682,7 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
14682
14682
|
});
|
|
14683
14683
|
|
|
14684
14684
|
// src/cli/main.ts
|
|
14685
|
-
import { resolve as
|
|
14685
|
+
import { resolve as resolve9 } from "node:path";
|
|
14686
14686
|
import { createInterface } from "node:readline/promises";
|
|
14687
14687
|
|
|
14688
14688
|
// src/cli/exit-codes.ts
|
|
@@ -14743,7 +14743,7 @@ class TransientError extends Error {
|
|
|
14743
14743
|
}
|
|
14744
14744
|
|
|
14745
14745
|
// src/version.ts
|
|
14746
|
-
var FACTORY_VERSION = "0.
|
|
14746
|
+
var FACTORY_VERSION = "1.0.0";
|
|
14747
14747
|
var PACKAGE_NAME = "@loomwright/cli";
|
|
14748
14748
|
var runVersion = (version) => `npx ${PACKAGE_NAME}@${version}`;
|
|
14749
14749
|
|
|
@@ -22702,16 +22702,20 @@ async function findWorkspaceRoot(start) {
|
|
|
22702
22702
|
const configRoot = findConfigRoot(start);
|
|
22703
22703
|
if (configRoot)
|
|
22704
22704
|
return configRoot;
|
|
22705
|
-
|
|
22706
|
-
|
|
22707
|
-
|
|
22708
|
-
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
|
-
|
|
22712
|
-
|
|
22705
|
+
let root;
|
|
22706
|
+
for (let cwd = start;; ) {
|
|
22707
|
+
const res = await git(["rev-parse", "--show-toplevel", "--show-superproject-working-tree"], {
|
|
22708
|
+
cwd
|
|
22709
|
+
});
|
|
22710
|
+
if (res.code !== 0)
|
|
22711
|
+
return root;
|
|
22712
|
+
const [top = "", parent = ""] = res.stdout.split(`
|
|
22713
|
+
`).map((line) => line.trim());
|
|
22714
|
+
if (top !== "")
|
|
22715
|
+
root = top;
|
|
22716
|
+
if (parent === "")
|
|
22713
22717
|
return root;
|
|
22714
|
-
|
|
22718
|
+
cwd = parent;
|
|
22715
22719
|
}
|
|
22716
22720
|
}
|
|
22717
22721
|
function formatZodIssues(error) {
|
|
@@ -26895,7 +26899,8 @@ import {
|
|
|
26895
26899
|
writeFileSync as writeFileSync4
|
|
26896
26900
|
} from "node:fs";
|
|
26897
26901
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
26898
|
-
import { dirname as dirname4, join as join21 } from "node:path";
|
|
26902
|
+
import { dirname as dirname4, join as join21, resolve as resolve2 } from "node:path";
|
|
26903
|
+
import { deflateSync } from "node:zlib";
|
|
26899
26904
|
|
|
26900
26905
|
// src/render/workspace.ts
|
|
26901
26906
|
import { readFileSync as readFileSync13 } from "node:fs";
|
|
@@ -31908,8 +31913,42 @@ function removeOwned(root, path, mode) {
|
|
|
31908
31913
|
`);
|
|
31909
31914
|
writeAtomic(abs, rest.trim() === "" ? "" : rest);
|
|
31910
31915
|
}
|
|
31911
|
-
|
|
31912
|
-
|
|
31916
|
+
|
|
31917
|
+
class BlobStore {
|
|
31918
|
+
#root;
|
|
31919
|
+
#pending;
|
|
31920
|
+
#seq = 0;
|
|
31921
|
+
constructor(root) {
|
|
31922
|
+
this.#root = root;
|
|
31923
|
+
this.#pending = this.#objectDir();
|
|
31924
|
+
}
|
|
31925
|
+
async#objectDir() {
|
|
31926
|
+
const res = await exec(["git", "rev-parse", "--git-path", "objects", "--show-object-format"], {
|
|
31927
|
+
cwd: this.#root
|
|
31928
|
+
});
|
|
31929
|
+
const [dir = "", format = ""] = res.stdout.split(`
|
|
31930
|
+
`).map((line) => line.trim());
|
|
31931
|
+
if (res.code !== 0 || dir === "" || format !== "sha1")
|
|
31932
|
+
return;
|
|
31933
|
+
return resolve2(this.#root, dir);
|
|
31934
|
+
}
|
|
31935
|
+
async write(content) {
|
|
31936
|
+
const dir = await this.#pending;
|
|
31937
|
+
if (dir === undefined) {
|
|
31938
|
+
return execOk(["git", "hash-object", "-w", "--stdin"], { cwd: this.#root, input: content });
|
|
31939
|
+
}
|
|
31940
|
+
const body = Buffer.from(content, "utf8");
|
|
31941
|
+
const header = Buffer.from(`blob ${body.length}\x00`, "utf8");
|
|
31942
|
+
const oid = createHash2("sha1").update(header).update(body).digest("hex");
|
|
31943
|
+
const file = join21(dir, oid.slice(0, 2), oid.slice(2));
|
|
31944
|
+
if (!existsSync17(file)) {
|
|
31945
|
+
mkdirSync6(dirname4(file), { recursive: true });
|
|
31946
|
+
const tmp = join21(dir, `tmp_loomwright_${process.pid}_${this.#seq++}`);
|
|
31947
|
+
writeFileSync4(tmp, deflateSync(Buffer.concat([header, body])));
|
|
31948
|
+
renameSync4(tmp, file);
|
|
31949
|
+
}
|
|
31950
|
+
return oid;
|
|
31951
|
+
}
|
|
31913
31952
|
}
|
|
31914
31953
|
async function blobText(root, blob) {
|
|
31915
31954
|
const res = await exec(["git", "cat-file", "-p", blob], { cwd: root });
|
|
@@ -31947,12 +31986,13 @@ async function executeSync(root, plan, previous, options = {}) {
|
|
|
31947
31986
|
const managed = {};
|
|
31948
31987
|
const merged = [];
|
|
31949
31988
|
const conflicts = [];
|
|
31989
|
+
const blobs = new BlobStore(root);
|
|
31950
31990
|
const entry = async (file) => ({
|
|
31951
31991
|
template: file.template,
|
|
31952
31992
|
templateVersion: FACTORY_VERSION,
|
|
31953
31993
|
mode: file.mode,
|
|
31954
31994
|
sha256: sha256(file.content),
|
|
31955
|
-
blob: await
|
|
31995
|
+
blob: await blobs.write(file.content)
|
|
31956
31996
|
});
|
|
31957
31997
|
for (const change of plan) {
|
|
31958
31998
|
const prev = previous[change.path];
|
|
@@ -32256,7 +32296,7 @@ function parseCommandArgs(command, args, options, allowPositionals = false) {
|
|
|
32256
32296
|
|
|
32257
32297
|
// src/cli/commands/pipeline-commands.ts
|
|
32258
32298
|
import { existsSync as existsSync34, readFileSync as readFileSync30 } from "node:fs";
|
|
32259
|
-
import { join as join45, relative as relative9, resolve as
|
|
32299
|
+
import { join as join45, relative as relative9, resolve as resolve6 } from "node:path";
|
|
32260
32300
|
|
|
32261
32301
|
// src/pipeline/approve.ts
|
|
32262
32302
|
import { existsSync as existsSync22, readFileSync as readFileSync18 } from "node:fs";
|
|
@@ -32562,13 +32602,29 @@ import { createHash as createHash4 } from "node:crypto";
|
|
|
32562
32602
|
import { existsSync as existsSync23, mkdirSync as mkdirSync10, readFileSync as readFileSync19, rmSync as rmSync9, writeFileSync as writeFileSync8 } from "node:fs";
|
|
32563
32603
|
import { dirname as dirname7, join as join27 } from "node:path";
|
|
32564
32604
|
var MISSING = "missing";
|
|
32565
|
-
async function
|
|
32566
|
-
const res = await git(["status", "--porcelain=
|
|
32567
|
-
cwd: worktree
|
|
32568
|
-
});
|
|
32605
|
+
async function state(worktree) {
|
|
32606
|
+
const res = await git(["status", "--porcelain=v2", "-z", "--branch", "--no-renames", "--untracked-files=all"], { cwd: worktree });
|
|
32569
32607
|
if (res.code !== 0)
|
|
32570
32608
|
throw new Error(`git status failed in ${worktree}: ${res.stderr.trim()}`);
|
|
32571
|
-
|
|
32609
|
+
const records = res.stdout.split("\x00");
|
|
32610
|
+
const paths = [];
|
|
32611
|
+
let head = "";
|
|
32612
|
+
for (let i = 0;i < records.length; i++) {
|
|
32613
|
+
const record = records[i] ?? "";
|
|
32614
|
+
if (record.startsWith("# branch.oid "))
|
|
32615
|
+
head = record.slice("# branch.oid ".length);
|
|
32616
|
+
else if (record.startsWith("? "))
|
|
32617
|
+
paths.push(record.slice(2));
|
|
32618
|
+
else if (record.startsWith("1 "))
|
|
32619
|
+
paths.push(record.split(" ").slice(8).join(" "));
|
|
32620
|
+
else if (record.startsWith("u "))
|
|
32621
|
+
paths.push(record.split(" ").slice(10).join(" "));
|
|
32622
|
+
else if (record.startsWith("2 ")) {
|
|
32623
|
+
paths.push(record.split(" ").slice(9).join(" "));
|
|
32624
|
+
i++;
|
|
32625
|
+
}
|
|
32626
|
+
}
|
|
32627
|
+
return { head, paths };
|
|
32572
32628
|
}
|
|
32573
32629
|
function hashFile(abs) {
|
|
32574
32630
|
if (!existsSync23(abs))
|
|
@@ -32577,10 +32633,11 @@ function hashFile(abs) {
|
|
|
32577
32633
|
return { hash: createHash4("sha256").update(content).digest("hex"), content };
|
|
32578
32634
|
}
|
|
32579
32635
|
async function snapshot(worktree) {
|
|
32636
|
+
const { head, paths } = await state(worktree);
|
|
32580
32637
|
const entries = new Map;
|
|
32581
|
-
for (const path of
|
|
32638
|
+
for (const path of paths)
|
|
32582
32639
|
entries.set(path, hashFile(join27(worktree, path)));
|
|
32583
|
-
return { worktree, head
|
|
32640
|
+
return { worktree, head, entries };
|
|
32584
32641
|
}
|
|
32585
32642
|
async function changedSince(before) {
|
|
32586
32643
|
const after = await snapshot(before.worktree);
|
|
@@ -34028,11 +34085,11 @@ function isGeneratedLockfile(path) {
|
|
|
34028
34085
|
|
|
34029
34086
|
// src/policy/sandbox.ts
|
|
34030
34087
|
import { existsSync as existsSync28, readFileSync as readFileSync26 } from "node:fs";
|
|
34031
|
-
import { isAbsolute, join as join36, resolve as
|
|
34088
|
+
import { isAbsolute, join as join36, resolve as resolve4 } from "node:path";
|
|
34032
34089
|
|
|
34033
34090
|
// src/policy/realpath.ts
|
|
34034
34091
|
import { lstatSync, readlinkSync, realpathSync as realpathSync2 } from "node:fs";
|
|
34035
|
-
import { basename as basename2, dirname as dirname8, join as join35, resolve as
|
|
34092
|
+
import { basename as basename2, dirname as dirname8, join as join35, resolve as resolve3 } from "node:path";
|
|
34036
34093
|
function realPathOf(abs, depth = 0) {
|
|
34037
34094
|
if (depth > 40)
|
|
34038
34095
|
return abs;
|
|
@@ -34045,7 +34102,7 @@ function realPathOf(abs, depth = 0) {
|
|
|
34045
34102
|
return join35(realpathSync2.native(current), ...missing.reverse());
|
|
34046
34103
|
} catch {
|
|
34047
34104
|
if (st.isSymbolicLink()) {
|
|
34048
|
-
const target =
|
|
34105
|
+
const target = resolve3(dirname8(current), readlinkSync(current));
|
|
34049
34106
|
return realPathOf(join35(target, ...missing.reverse()), depth + 1);
|
|
34050
34107
|
}
|
|
34051
34108
|
return abs;
|
|
@@ -34170,14 +34227,14 @@ function gitWritableDirs(worktree) {
|
|
|
34170
34227
|
const text = readFileSync26(dotGit, "utf8");
|
|
34171
34228
|
const m = text.match(/^gitdir:\s*(.+)$/m);
|
|
34172
34229
|
if (m?.[1])
|
|
34173
|
-
gitDir = isAbsolute(m[1].trim()) ? m[1].trim() :
|
|
34230
|
+
gitDir = isAbsolute(m[1].trim()) ? m[1].trim() : resolve4(worktree, m[1].trim());
|
|
34174
34231
|
} catch {
|
|
34175
34232
|
return [join36(dotGit, "index"), join36(dotGit, "index.lock"), join36(dotGit, "objects")];
|
|
34176
34233
|
}
|
|
34177
34234
|
let common = gitDir;
|
|
34178
34235
|
try {
|
|
34179
34236
|
const rel = readFileSync26(join36(gitDir, "commondir"), "utf8").trim();
|
|
34180
|
-
common = isAbsolute(rel) ? rel :
|
|
34237
|
+
common = isAbsolute(rel) ? rel : resolve4(gitDir, rel);
|
|
34181
34238
|
} catch {}
|
|
34182
34239
|
return [gitDir, join36(common, "objects")];
|
|
34183
34240
|
}
|
|
@@ -34569,14 +34626,14 @@ class GraphUpdater {
|
|
|
34569
34626
|
}
|
|
34570
34627
|
|
|
34571
34628
|
// src/policy/scope.ts
|
|
34572
|
-
import { isAbsolute as isAbsolute2, normalize, relative as relative7, resolve as
|
|
34629
|
+
import { isAbsolute as isAbsolute2, normalize, relative as relative7, resolve as resolve5 } from "node:path";
|
|
34573
34630
|
var architectDirs = (changeId) => [
|
|
34574
34631
|
`openspec/changes/${changeId}/`,
|
|
34575
34632
|
`.factory/context/${changeId}/`
|
|
34576
34633
|
];
|
|
34577
34634
|
var IMPLEMENTING_ROLES = new Set(["implementer", "tester"]);
|
|
34578
34635
|
function checkEdit(ctx, path, approval) {
|
|
34579
|
-
const abs = normalize(isAbsolute2(path) ? path :
|
|
34636
|
+
const abs = normalize(isAbsolute2(path) ? path : resolve5(ctx.directory, path));
|
|
34580
34637
|
const rel = relative7(ctx.directory, abs);
|
|
34581
34638
|
if (rel === "" || rel.startsWith("..") || isAbsolute2(rel)) {
|
|
34582
34639
|
return {
|
|
@@ -37417,7 +37474,7 @@ in openspec/changes/<id>/questions.md and .factory/clarifications/<id>.md.
|
|
|
37417
37474
|
const { values, positionals } = parseCommandArgs("run", args, RUN_OPTIONS, true);
|
|
37418
37475
|
let request = positionals.join(" ").trim();
|
|
37419
37476
|
if (values.request !== undefined) {
|
|
37420
|
-
request = readFileSync30(
|
|
37477
|
+
request = readFileSync30(resolve6(io.cwd, values.request), "utf8").trim();
|
|
37421
37478
|
}
|
|
37422
37479
|
if (request === "")
|
|
37423
37480
|
throw new UsageError('run: expected a request, e.g. loomwright run "add a health endpoint"');
|
|
@@ -38210,7 +38267,7 @@ function benchCommand(cli) {
|
|
|
38210
38267
|
import { basename as basename3 } from "node:path";
|
|
38211
38268
|
|
|
38212
38269
|
// src/cli/completion/engine.ts
|
|
38213
|
-
import { resolve as
|
|
38270
|
+
import { resolve as resolve7 } from "node:path";
|
|
38214
38271
|
|
|
38215
38272
|
// src/cli/completion/registry.ts
|
|
38216
38273
|
var registry2 = [];
|
|
@@ -38502,7 +38559,7 @@ async function splitGlobals(words, cwd) {
|
|
|
38502
38559
|
if (word === "-C") {
|
|
38503
38560
|
if (i + 1 >= words.length)
|
|
38504
38561
|
return { rest: [], cwd: dir, dirPending: true };
|
|
38505
|
-
dir =
|
|
38562
|
+
dir = resolve7(dir, words[i + 1] ?? "");
|
|
38506
38563
|
i += 2;
|
|
38507
38564
|
continue;
|
|
38508
38565
|
}
|
|
@@ -38541,7 +38598,7 @@ import {
|
|
|
38541
38598
|
writeFileSync as writeFileSync16
|
|
38542
38599
|
} from "node:fs";
|
|
38543
38600
|
import { homedir } from "node:os";
|
|
38544
|
-
import { dirname as dirname12, isAbsolute as isAbsolute3, join as join49, resolve as
|
|
38601
|
+
import { dirname as dirname12, isAbsolute as isAbsolute3, join as join49, resolve as resolve8 } from "node:path";
|
|
38545
38602
|
var SHELLS = ["bash", "zsh", "fish"];
|
|
38546
38603
|
function isShell(value) {
|
|
38547
38604
|
return SHELLS.includes(value);
|
|
@@ -38630,7 +38687,7 @@ var START2 = "# >>> ai-factory completion >>>";
|
|
|
38630
38687
|
var END2 = "# <<< ai-factory completion <<<";
|
|
38631
38688
|
var rcPath = (shell, cwd, override) => {
|
|
38632
38689
|
if (override !== undefined)
|
|
38633
|
-
return isAbsolute3(override) ? override :
|
|
38690
|
+
return isAbsolute3(override) ? override : resolve8(cwd, override);
|
|
38634
38691
|
const home = homedir();
|
|
38635
38692
|
if (shell === "bash")
|
|
38636
38693
|
return join49(home, ".bashrc");
|
|
@@ -42531,7 +42588,7 @@ async function runCli(argv, io) {
|
|
|
42531
42588
|
io.err("error: -C needs a directory");
|
|
42532
42589
|
return ExitCode.Usage;
|
|
42533
42590
|
}
|
|
42534
|
-
cwd =
|
|
42591
|
+
cwd = resolve9(cwd, dir);
|
|
42535
42592
|
} else if (arg === "-V" || arg === "--version") {
|
|
42536
42593
|
io.out(FACTORY_VERSION);
|
|
42537
42594
|
return ExitCode.Ok;
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loomwright/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Loomwright: repo-local AI software factory — OpenSpec + Graphify + opencode v2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Lars Roth",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/Supporterino/
|
|
10
|
+
"url": "git+https://github.com/Supporterino/Loomwright.git"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://github.com/Supporterino/
|
|
12
|
+
"homepage": "https://github.com/Supporterino/Loomwright#readme",
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/Supporterino/
|
|
14
|
+
"url": "https://github.com/Supporterino/Loomwright/issues"
|
|
15
15
|
},
|
|
16
|
-
"packageManager": "bun@1.4.
|
|
16
|
+
"packageManager": "bun@1.4.4",
|
|
17
17
|
"bin": {
|
|
18
18
|
"loomwright": "./dist/cli.js",
|
|
19
19
|
"ai-factory": "./dist/cli.js"
|
|
@@ -35,12 +35,14 @@
|
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "bun scripts/build-plugin.ts && bun build src/cli/bin.ts --target=node --outfile dist/cli.js && bun scripts/write-dist-package.ts",
|
|
37
37
|
"dev": "bun src/cli/bin.ts",
|
|
38
|
-
"test": "bun test --timeout 60000",
|
|
38
|
+
"test": "bun test --timeout 60000 --parallel",
|
|
39
|
+
"test:serial": "bun test --timeout 60000",
|
|
40
|
+
"test:fast": "bun test --timeout 60000 --parallel --path-ignore-patterns='**/pipeline.test.ts' --path-ignore-patterns='**/workspace-install.test.ts' --path-ignore-patterns='**/reword.test.ts' --path-ignore-patterns='**/gates-run.test.ts' --path-ignore-patterns='**/review-loop.test.ts' --path-ignore-patterns='**/init.test.ts' --path-ignore-patterns='**/contract-gate.test.ts'",
|
|
39
41
|
"typecheck": "tsc --noEmit",
|
|
40
42
|
"lint": "biome check .",
|
|
41
43
|
"format": "biome format --write .",
|
|
42
44
|
"format:check": "biome format .",
|
|
43
|
-
"check": "biome check . && tsc --noEmit && bun test
|
|
45
|
+
"check": "biome check . && tsc --noEmit && bun run test",
|
|
44
46
|
"changeset": "changeset",
|
|
45
47
|
"release:version": "changeset version && bun scripts/sync-version.ts && bun scripts/release-snapshot.ts",
|
|
46
48
|
"build:plugin": "bun scripts/build-plugin.ts",
|