@pixelfactoryio/theway 0.9.0 → 0.10.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/dist/theway.js +206 -75
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/commands/archive.md +9 -54
- package/plugin/commands/develop-workflow.md +21 -21
- package/plugin/commands/develop.md +7 -5
- package/plugin/commands/document.md +7 -7
- package/plugin/commands/engineering-light.md +16 -49
- package/plugin/commands/engineering.md +21 -73
- package/plugin/commands/list.md +6 -4
- package/plugin/home/standards/develop.md +6 -4
- package/plugin/home/standards/interaction.md +1 -1
- package/plugin/home/standards/spec-investigation.md +26 -0
- package/plugin/home/standards/spec-review.md +61 -0
- package/plugin/home/templates/coding-standards-template.md +1 -2
- package/plugin/home/templates/fix-spec-template.md +1 -2
- package/plugin/home/templates/light-spec-template.md +1 -2
- package/plugin/home/templates/source-tree-template.md +1 -1
- package/plugin/home/templates/spec-template.md +1 -2
- package/plugin/home/templates/tasks-template.md +3 -2
- package/plugin/home/templates/tech-stack-template.md +1 -2
package/dist/theway.js
CHANGED
|
@@ -9244,9 +9244,44 @@ ${list}`);
|
|
|
9244
9244
|
return 0;
|
|
9245
9245
|
}
|
|
9246
9246
|
|
|
9247
|
-
// src/core/
|
|
9248
|
-
import {
|
|
9247
|
+
// src/core/authority.ts
|
|
9248
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
9249
9249
|
import { join as join3 } from "node:path";
|
|
9250
|
+
function authoritySection(path2) {
|
|
9251
|
+
let text;
|
|
9252
|
+
try {
|
|
9253
|
+
text = readFileSync4(path2, "utf-8");
|
|
9254
|
+
} catch {
|
|
9255
|
+
return null;
|
|
9256
|
+
}
|
|
9257
|
+
const lines = text.split(`
|
|
9258
|
+
`).map((l) => l.replace(/\r$/, ""));
|
|
9259
|
+
const start = lines.indexOf("## Authority");
|
|
9260
|
+
if (start === -1)
|
|
9261
|
+
return null;
|
|
9262
|
+
const next = lines.findIndex((l, i) => i > start && l.startsWith("## "));
|
|
9263
|
+
const body = lines.slice(start, next === -1 ? lines.length : next);
|
|
9264
|
+
while (body.length > 1 && (body[body.length - 1] ?? "").trim() === "")
|
|
9265
|
+
body.pop();
|
|
9266
|
+
return `${body.join(`
|
|
9267
|
+
`)}
|
|
9268
|
+
`;
|
|
9269
|
+
}
|
|
9270
|
+
function cmdAuthority() {
|
|
9271
|
+
const dir = join3(thewayHome(), "standards");
|
|
9272
|
+
const section = authoritySection(join3(dir, "interaction.md")) ?? authoritySection(join3(dir, "interaction.default.md"));
|
|
9273
|
+
if (section === null) {
|
|
9274
|
+
process.stderr.write(`theway: no ## Authority section in ${join3(dir, "interaction.md")} or interaction.default.md; run npx --yes @pixelfactoryio/theway@latest install, then /reload-plugins
|
|
9275
|
+
`);
|
|
9276
|
+
return 1;
|
|
9277
|
+
}
|
|
9278
|
+
process.stdout.write(section);
|
|
9279
|
+
return 0;
|
|
9280
|
+
}
|
|
9281
|
+
|
|
9282
|
+
// src/core/config.ts
|
|
9283
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
9284
|
+
import { join as join4 } from "node:path";
|
|
9250
9285
|
|
|
9251
9286
|
// node_modules/yaml/dist/index.js
|
|
9252
9287
|
var composer = require_composer();
|
|
@@ -9301,7 +9336,7 @@ import {
|
|
|
9301
9336
|
existsSync as existsSync2,
|
|
9302
9337
|
mkdirSync as mkdirSync2,
|
|
9303
9338
|
readdirSync as readdirSync2,
|
|
9304
|
-
readFileSync as
|
|
9339
|
+
readFileSync as readFileSync5,
|
|
9305
9340
|
renameSync as renameSync2,
|
|
9306
9341
|
rmSync,
|
|
9307
9342
|
statSync as statSync2,
|
|
@@ -9312,7 +9347,7 @@ var MANIFEST = ".shipped.json";
|
|
|
9312
9347
|
var sha256 = (data) => createHash("sha256").update(data).digest("hex");
|
|
9313
9348
|
function readManifest(home) {
|
|
9314
9349
|
try {
|
|
9315
|
-
const parsed = JSON.parse(
|
|
9350
|
+
const parsed = JSON.parse(readFileSync5(`${home}/${MANIFEST}`, "utf-8"));
|
|
9316
9351
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
9317
9352
|
return;
|
|
9318
9353
|
return parsed;
|
|
@@ -9335,7 +9370,7 @@ function writeManifest(home, manifest) {
|
|
|
9335
9370
|
}
|
|
9336
9371
|
function backupPath(home, rel, current) {
|
|
9337
9372
|
const bak = `${rel}.bak`;
|
|
9338
|
-
if (!existsSync2(`${home}/${bak}`) ||
|
|
9373
|
+
if (!existsSync2(`${home}/${bak}`) || readFileSync5(`${home}/${bak}`).equals(current))
|
|
9339
9374
|
return bak;
|
|
9340
9375
|
for (let n = 1;; n++) {
|
|
9341
9376
|
if (!existsSync2(`${home}/${bak}.${n}`))
|
|
@@ -9407,7 +9442,7 @@ function copyShipped(src, home) {
|
|
|
9407
9442
|
for (const name of names) {
|
|
9408
9443
|
const rel = `${dir}/${name}`;
|
|
9409
9444
|
const dst = `${home}/${rel}`;
|
|
9410
|
-
const shipped =
|
|
9445
|
+
const shipped = readFileSync5(`${src}/${rel}`);
|
|
9411
9446
|
const old = previous?.[rel];
|
|
9412
9447
|
const sibling = `${dir}/${baseOf(name)}.default.md`;
|
|
9413
9448
|
let removeSibling = true;
|
|
@@ -9415,7 +9450,7 @@ function copyShipped(src, home) {
|
|
|
9415
9450
|
if (!existsSync2(dst)) {
|
|
9416
9451
|
writeAtomic(dst, shipped);
|
|
9417
9452
|
} else {
|
|
9418
|
-
const current =
|
|
9453
|
+
const current = readFileSync5(dst);
|
|
9419
9454
|
if (!current.equals(shipped)) {
|
|
9420
9455
|
if (typeof old === "string" && sha256(current) === old) {
|
|
9421
9456
|
writeAtomic(dst, shipped);
|
|
@@ -9452,7 +9487,7 @@ function copyShipped(src, home) {
|
|
|
9452
9487
|
const path2 = `${home}/${rel}`;
|
|
9453
9488
|
if (!existsSync2(path2))
|
|
9454
9489
|
continue;
|
|
9455
|
-
if (sha256(
|
|
9490
|
+
if (sha256(readFileSync5(path2)) === hash) {
|
|
9456
9491
|
rmSync(path2);
|
|
9457
9492
|
process.stdout.write(`Removed ${rel}: theway no longer ships it
|
|
9458
9493
|
`);
|
|
@@ -9499,7 +9534,7 @@ var dict = () => Object.create(null);
|
|
|
9499
9534
|
var bool = (d) => ({ rule: "boolean", default: d });
|
|
9500
9535
|
var model = (d) => ({ rule: "model", default: d });
|
|
9501
9536
|
var OPT_IN = ["core-principles.md", "sre.md", "web-development.md", "quality.md"];
|
|
9502
|
-
var CORE = ["interaction.md", "develop.md", "tamm-framework.md"];
|
|
9537
|
+
var CORE = ["interaction.md", "develop.md", "tamm-framework.md", "spec-review.md", "spec-investigation.md"];
|
|
9503
9538
|
var SHARED = new Set(["data", "templates", "standards"]);
|
|
9504
9539
|
var keyOf = (name) => name.slice(0, -".md".length).replaceAll("-", "_");
|
|
9505
9540
|
var OPT_IN_KEYS = OPT_IN.map(keyOf);
|
|
@@ -9511,11 +9546,11 @@ function mdFiles(dir) {
|
|
|
9511
9546
|
} catch {
|
|
9512
9547
|
return [];
|
|
9513
9548
|
}
|
|
9514
|
-
return names.filter((n) => n.endsWith(".md") && isFile(
|
|
9549
|
+
return names.filter((n) => n.endsWith(".md") && isFile(join4(dir, n))).sort();
|
|
9515
9550
|
}
|
|
9516
9551
|
function standardsOf(home, project) {
|
|
9517
|
-
const globalDir =
|
|
9518
|
-
const projectDir =
|
|
9552
|
+
const globalDir = join4(home, "standards");
|
|
9553
|
+
const projectDir = join4(home, project, "standards");
|
|
9519
9554
|
const projectNames = SHARED.has(project) ? [] : mdFiles(projectDir);
|
|
9520
9555
|
const shipped = readManifest(home) ?? {};
|
|
9521
9556
|
const out = [];
|
|
@@ -9525,10 +9560,10 @@ function standardsOf(home, project) {
|
|
|
9525
9560
|
const optIn = OPT_IN.includes(name);
|
|
9526
9561
|
if (!optIn && ((`standards/${name}` in shipped) || name.endsWith(".default.md")))
|
|
9527
9562
|
continue;
|
|
9528
|
-
out.push({ path:
|
|
9563
|
+
out.push({ path: join4(globalDir, name), key: keyOf(name), optIn });
|
|
9529
9564
|
}
|
|
9530
9565
|
for (const name of projectNames)
|
|
9531
|
-
out.push({ path:
|
|
9566
|
+
out.push({ path: join4(projectDir, name), key: keyOf(name), optIn: false });
|
|
9532
9567
|
return out;
|
|
9533
9568
|
}
|
|
9534
9569
|
function standardsSchema(standards) {
|
|
@@ -9610,7 +9645,7 @@ function apply(file, schema, layer, into, prefix, warn) {
|
|
|
9610
9645
|
function load(home, file) {
|
|
9611
9646
|
let text;
|
|
9612
9647
|
try {
|
|
9613
|
-
text =
|
|
9648
|
+
text = readFileSync6(join4(home, file), "utf-8");
|
|
9614
9649
|
} catch {
|
|
9615
9650
|
return { error: `theway: ${file}: cannot be read` };
|
|
9616
9651
|
}
|
|
@@ -9624,10 +9659,10 @@ function load(home, file) {
|
|
|
9624
9659
|
}
|
|
9625
9660
|
function effectiveConfig(home, project, loud) {
|
|
9626
9661
|
const files = [];
|
|
9627
|
-
if (isFile(
|
|
9662
|
+
if (isFile(join4(home, "config.yaml")))
|
|
9628
9663
|
files.push("config.yaml");
|
|
9629
|
-
if (isFile(
|
|
9630
|
-
files.push(
|
|
9664
|
+
if (isFile(join4(home, project, "config.yaml")))
|
|
9665
|
+
files.push(join4(project, "config.yaml"));
|
|
9631
9666
|
const roots = [];
|
|
9632
9667
|
for (const file of files) {
|
|
9633
9668
|
const loaded = load(home, file);
|
|
@@ -9653,27 +9688,35 @@ function enabled(config, key) {
|
|
|
9653
9688
|
const all = config.standards;
|
|
9654
9689
|
return !Object.hasOwn(all, key) || all[key].enabled === true;
|
|
9655
9690
|
}
|
|
9656
|
-
function
|
|
9657
|
-
if (
|
|
9658
|
-
return 1;
|
|
9659
|
-
const home = thewayHome();
|
|
9660
|
-
if (!isFile(join3(home, "config.yaml"))) {
|
|
9691
|
+
function loadConfig(home, project) {
|
|
9692
|
+
if (!isFile(join4(home, "config.yaml"))) {
|
|
9661
9693
|
process.stderr.write(`theway: config.yaml not found in ${home}; run npx --yes @pixelfactoryio/theway@latest install, then /reload-plugins
|
|
9662
9694
|
`);
|
|
9663
|
-
return
|
|
9695
|
+
return null;
|
|
9664
9696
|
}
|
|
9665
9697
|
const result = effectiveConfig(home, project, true);
|
|
9666
9698
|
if ("error" in result) {
|
|
9667
9699
|
process.stderr.write(`${result.error}
|
|
9668
9700
|
`);
|
|
9669
|
-
return
|
|
9701
|
+
return null;
|
|
9670
9702
|
}
|
|
9671
|
-
|
|
9703
|
+
return result;
|
|
9704
|
+
}
|
|
9705
|
+
function cmdConfig(project) {
|
|
9706
|
+
if (invalidSegments([["project", project]]))
|
|
9707
|
+
return 1;
|
|
9708
|
+
const loaded = loadConfig(thewayHome(), project);
|
|
9709
|
+
if (loaded === null)
|
|
9710
|
+
return 1;
|
|
9711
|
+
process.stdout.write($stringify(loaded.config));
|
|
9672
9712
|
return 0;
|
|
9673
9713
|
}
|
|
9674
9714
|
|
|
9715
|
+
// src/core/context.ts
|
|
9716
|
+
import { join as join5 } from "node:path";
|
|
9717
|
+
|
|
9675
9718
|
// src/core/standards.ts
|
|
9676
|
-
import { readFileSync as
|
|
9719
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
9677
9720
|
var PHASES = ["engineering", "develop", "document"];
|
|
9678
9721
|
var USER_PHASES = ["engineering", "develop"];
|
|
9679
9722
|
var OPT_IN_PHASES = ["engineering", "document"];
|
|
@@ -9702,7 +9745,7 @@ function parseList(first, rest) {
|
|
|
9702
9745
|
function phasesOf(path2) {
|
|
9703
9746
|
let text;
|
|
9704
9747
|
try {
|
|
9705
|
-
text =
|
|
9748
|
+
text = readFileSync7(path2, "utf-8");
|
|
9706
9749
|
} catch {
|
|
9707
9750
|
process.stderr.write(`theway: warning: ${path2}: cannot be read; skipped
|
|
9708
9751
|
`);
|
|
@@ -9727,35 +9770,59 @@ function phasesOf(path2) {
|
|
|
9727
9770
|
}
|
|
9728
9771
|
return phases;
|
|
9729
9772
|
}
|
|
9773
|
+
function checkPhase(phase) {
|
|
9774
|
+
if (isPhase(phase))
|
|
9775
|
+
return true;
|
|
9776
|
+
const shown = phase.replaceAll(`
|
|
9777
|
+
`, "\\n").replaceAll("\r", "\\r");
|
|
9778
|
+
process.stderr.write(`theway: invalid phase '${shown}': must be engineering, develop or document
|
|
9779
|
+
`);
|
|
9780
|
+
return false;
|
|
9781
|
+
}
|
|
9782
|
+
function selectStandards(loaded, phase) {
|
|
9783
|
+
return loaded.standards.filter((s) => enabled(loaded.config, s.key)).filter((s) => s.optIn ? OPT_IN_PHASES.includes(phase) : phase !== "document" && phasesOf(s.path).includes(phase)).map((s) => s.path);
|
|
9784
|
+
}
|
|
9730
9785
|
function cmdStandards(project, phase) {
|
|
9731
9786
|
if (invalidSegments([["project", project]]))
|
|
9732
9787
|
return 1;
|
|
9733
|
-
if (!
|
|
9734
|
-
const shown = phase.replaceAll(`
|
|
9735
|
-
`, "\\n").replaceAll("\r", "\\r");
|
|
9736
|
-
process.stderr.write(`theway: invalid phase '${shown}': must be engineering, develop or document
|
|
9737
|
-
`);
|
|
9788
|
+
if (!checkPhase(phase))
|
|
9738
9789
|
return 1;
|
|
9739
|
-
}
|
|
9740
9790
|
const result = effectiveConfig(thewayHome(), project, false);
|
|
9741
9791
|
if ("error" in result) {
|
|
9742
9792
|
process.stderr.write(`${result.error}
|
|
9743
9793
|
`);
|
|
9744
9794
|
return 1;
|
|
9745
9795
|
}
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
if (!enabled(result.config, s.key))
|
|
9749
|
-
continue;
|
|
9750
|
-
if (s.optIn ? OPT_IN_PHASES.includes(phase) : phase !== "document" && phasesOf(s.path).includes(phase)) {
|
|
9751
|
-
out += `${s.path}
|
|
9752
|
-
`;
|
|
9753
|
-
}
|
|
9754
|
-
}
|
|
9755
|
-
process.stdout.write(out);
|
|
9796
|
+
process.stdout.write(selectStandards(result, phase).map((p) => `${p}
|
|
9797
|
+
`).join(""));
|
|
9756
9798
|
return 0;
|
|
9757
9799
|
}
|
|
9758
9800
|
|
|
9801
|
+
// src/core/context.ts
|
|
9802
|
+
function cmdContext(project, phase, changeId) {
|
|
9803
|
+
if (invalidSegments([["project", project]]))
|
|
9804
|
+
return 1;
|
|
9805
|
+
if (!checkPhase(phase))
|
|
9806
|
+
return 1;
|
|
9807
|
+
if (invalidSegments([["change id", changeId]]))
|
|
9808
|
+
return 1;
|
|
9809
|
+
const home = thewayHome();
|
|
9810
|
+
const loaded = loadConfig(home, project);
|
|
9811
|
+
if (loaded === null)
|
|
9812
|
+
return 1;
|
|
9813
|
+
const doc = { home };
|
|
9814
|
+
if (changeId !== undefined)
|
|
9815
|
+
doc.change_dir = join5(home, project, "changes", changeId);
|
|
9816
|
+
doc.standards = selectStandards(loaded, phase);
|
|
9817
|
+
doc.config = loaded.config;
|
|
9818
|
+
process.stdout.write($stringify(doc));
|
|
9819
|
+
return 0;
|
|
9820
|
+
}
|
|
9821
|
+
|
|
9822
|
+
// src/core/next-id.ts
|
|
9823
|
+
import { readdirSync as readdirSync4 } from "node:fs";
|
|
9824
|
+
import { join as join6 } from "node:path";
|
|
9825
|
+
|
|
9759
9826
|
// src/core/validate-id.ts
|
|
9760
9827
|
var VERB = /^(add|update|refactor|remove|fix)-/;
|
|
9761
9828
|
var KEBAB = /^(add|update|refactor|remove|fix)-[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
@@ -9814,6 +9881,62 @@ function cmdValidateId(id, series) {
|
|
|
9814
9881
|
return 0;
|
|
9815
9882
|
}
|
|
9816
9883
|
|
|
9884
|
+
// src/core/next-id.ts
|
|
9885
|
+
function dirs(dir) {
|
|
9886
|
+
try {
|
|
9887
|
+
return readdirSync4(dir).filter((n) => isDir(join6(dir, n)));
|
|
9888
|
+
} catch {
|
|
9889
|
+
return [];
|
|
9890
|
+
}
|
|
9891
|
+
}
|
|
9892
|
+
function seriesIdReason(id) {
|
|
9893
|
+
const reason = formatReason(id);
|
|
9894
|
+
if (reason !== "")
|
|
9895
|
+
return reason;
|
|
9896
|
+
const tail = id.slice(id.lastIndexOf("-") + 1);
|
|
9897
|
+
if (/^[0-9]{1,2}$/.test(tail))
|
|
9898
|
+
return `ends in a number (-${tail}); a series id cannot end in a number`;
|
|
9899
|
+
return "";
|
|
9900
|
+
}
|
|
9901
|
+
function cmdNextId(project, seriesId, count) {
|
|
9902
|
+
if (invalidSegments([["project", project]]))
|
|
9903
|
+
return 1;
|
|
9904
|
+
const rest = seriesId.replace(/-[0-9]{2}$/, "");
|
|
9905
|
+
const reason = seriesIdReason(rest);
|
|
9906
|
+
if (reason !== "") {
|
|
9907
|
+
const shown = rest.replaceAll(`
|
|
9908
|
+
`, "\\n").replaceAll("\r", "\\r");
|
|
9909
|
+
process.stderr.write(`invalid change id '${shown}': ${reason}
|
|
9910
|
+
`);
|
|
9911
|
+
return 1;
|
|
9912
|
+
}
|
|
9913
|
+
const changes = join6(thewayHome(), project, "changes");
|
|
9914
|
+
const active = new RegExp(`^${rest}-([0-9]{2})$`);
|
|
9915
|
+
const archived = new RegExp(`^[0-9]{4}-[0-9]{2}-[0-9]{2}-${rest}-([0-9]{2})$`);
|
|
9916
|
+
let max = 0;
|
|
9917
|
+
for (const [dir, pattern] of [
|
|
9918
|
+
[changes, active],
|
|
9919
|
+
[join6(changes, "archive"), archived]
|
|
9920
|
+
]) {
|
|
9921
|
+
for (const name of dirs(dir)) {
|
|
9922
|
+
const m = pattern.exec(name);
|
|
9923
|
+
if (m !== null)
|
|
9924
|
+
max = Math.max(max, Number(m[1]));
|
|
9925
|
+
}
|
|
9926
|
+
}
|
|
9927
|
+
if (max + count > 99) {
|
|
9928
|
+
process.stderr.write(`theway: series ${rest} would go past -99
|
|
9929
|
+
`);
|
|
9930
|
+
return 1;
|
|
9931
|
+
}
|
|
9932
|
+
let out = "";
|
|
9933
|
+
for (let n = max + 1;n <= max + count; n++)
|
|
9934
|
+
out += `${rest}-${String(n).padStart(2, "0")}
|
|
9935
|
+
`;
|
|
9936
|
+
process.stdout.write(out);
|
|
9937
|
+
return 0;
|
|
9938
|
+
}
|
|
9939
|
+
|
|
9817
9940
|
// src/install.ts
|
|
9818
9941
|
import {
|
|
9819
9942
|
accessSync,
|
|
@@ -9824,7 +9947,7 @@ import {
|
|
|
9824
9947
|
existsSync as existsSync3,
|
|
9825
9948
|
lstatSync,
|
|
9826
9949
|
mkdirSync as mkdirSync3,
|
|
9827
|
-
readFileSync as
|
|
9950
|
+
readFileSync as readFileSync8,
|
|
9828
9951
|
readlinkSync,
|
|
9829
9952
|
realpathSync,
|
|
9830
9953
|
renameSync as renameSync3,
|
|
@@ -9834,20 +9957,20 @@ import {
|
|
|
9834
9957
|
writeFileSync as writeFileSync2
|
|
9835
9958
|
} from "node:fs";
|
|
9836
9959
|
import { homedir as homedir2 } from "node:os";
|
|
9837
|
-
import { delimiter, dirname, join as
|
|
9960
|
+
import { delimiter, dirname, join as join7, resolve as resolve3, sep } from "node:path";
|
|
9838
9961
|
import { fileURLToPath } from "node:url";
|
|
9839
9962
|
var self = fileURLToPath(import.meta.url);
|
|
9840
9963
|
var pkgRoot = dirname(dirname(self));
|
|
9841
|
-
var plugin =
|
|
9964
|
+
var plugin = join7(pkgRoot, "plugin");
|
|
9842
9965
|
var PLUGIN_DIRS = [".claude-plugin", "commands"];
|
|
9843
9966
|
var BINARY_MARKER = "theway-cli-binary:pixelfactoryio/theway";
|
|
9844
9967
|
function claudeHome() {
|
|
9845
9968
|
const dir = (process.env.CLAUDE_CONFIG_DIR ?? "").trim();
|
|
9846
|
-
return dir !== "" ? dir :
|
|
9969
|
+
return dir !== "" ? dir : join7(homedir2(), ".claude");
|
|
9847
9970
|
}
|
|
9848
9971
|
function installDir() {
|
|
9849
9972
|
const dir = process.env.THEWAY_INSTALL_DIR ?? "";
|
|
9850
|
-
return dir !== "" ? resolve3(dir) :
|
|
9973
|
+
return dir !== "" ? resolve3(dir) : join7(homedir2(), ".local", "bin");
|
|
9851
9974
|
}
|
|
9852
9975
|
function shownHome(home) {
|
|
9853
9976
|
return resolve3(home) === resolve3(defaultHome()) ? "~/.theway" : resolve3(home);
|
|
@@ -9885,7 +10008,7 @@ function readSettings(path2) {
|
|
|
9885
10008
|
return {};
|
|
9886
10009
|
let data;
|
|
9887
10010
|
try {
|
|
9888
|
-
data = JSON.parse(
|
|
10011
|
+
data = JSON.parse(readFileSync8(path2, "utf-8"));
|
|
9889
10012
|
} catch {
|
|
9890
10013
|
return null;
|
|
9891
10014
|
}
|
|
@@ -9947,15 +10070,15 @@ function invalidSettings(path2) {
|
|
|
9947
10070
|
return fail(`theway: ${path2} is not valid settings JSON; nothing was changed`);
|
|
9948
10071
|
}
|
|
9949
10072
|
function copyPlugin(home) {
|
|
9950
|
-
const tmp =
|
|
9951
|
-
const old =
|
|
9952
|
-
const dest =
|
|
10073
|
+
const tmp = join7(home, `.theway-install-${process.pid}`);
|
|
10074
|
+
const old = join7(home, `.theway-old-${process.pid}`);
|
|
10075
|
+
const dest = join7(home, "skills", "theway");
|
|
9953
10076
|
rmSync2(tmp, { recursive: true, force: true });
|
|
9954
10077
|
try {
|
|
9955
10078
|
for (const dir of PLUGIN_DIRS) {
|
|
9956
|
-
cpSync(
|
|
10079
|
+
cpSync(join7(plugin, dir), join7(tmp, dir), { recursive: true });
|
|
9957
10080
|
}
|
|
9958
|
-
mkdirSync3(
|
|
10081
|
+
mkdirSync3(join7(home, "skills"), { recursive: true });
|
|
9959
10082
|
if (existsSync3(dest))
|
|
9960
10083
|
renameSync3(dest, old);
|
|
9961
10084
|
renameSync3(tmp, dest);
|
|
@@ -9972,29 +10095,29 @@ function removeIfEmpty2(dir) {
|
|
|
9972
10095
|
}
|
|
9973
10096
|
function legacyText(path2, match) {
|
|
9974
10097
|
try {
|
|
9975
|
-
return lstatSync(path2).isFile() && match(
|
|
10098
|
+
return lstatSync(path2).isFile() && match(readFileSync8(path2, "utf-8"));
|
|
9976
10099
|
} catch {
|
|
9977
10100
|
return false;
|
|
9978
10101
|
}
|
|
9979
10102
|
}
|
|
9980
10103
|
function removeLegacyBin(home) {
|
|
9981
10104
|
for (const h of new Set([defaultHome(), resolve3(home)])) {
|
|
9982
|
-
const bin =
|
|
9983
|
-
if (legacyText(
|
|
10105
|
+
const bin = join7(h, "bin");
|
|
10106
|
+
if (legacyText(join7(bin, "theway"), (t) => t.startsWith(`#!/bin/sh
|
|
9984
10107
|
exec node `) && t.endsWith(`theway.js' "$@"
|
|
9985
10108
|
`))) {
|
|
9986
|
-
rmSync2(
|
|
10109
|
+
rmSync2(join7(bin, "theway"), { force: true });
|
|
9987
10110
|
}
|
|
9988
|
-
if (legacyText(
|
|
10111
|
+
if (legacyText(join7(bin, "theway.js"), (t) => t.startsWith(`#!/usr/bin/env node
|
|
9989
10112
|
`))) {
|
|
9990
|
-
rmSync2(
|
|
10113
|
+
rmSync2(join7(bin, "theway.js"), { force: true });
|
|
9991
10114
|
}
|
|
9992
10115
|
removeIfEmpty2(bin);
|
|
9993
10116
|
}
|
|
9994
10117
|
}
|
|
9995
10118
|
function writeBinary(dir) {
|
|
9996
|
-
const dest =
|
|
9997
|
-
const tmp =
|
|
10119
|
+
const dest = join7(dir, "theway");
|
|
10120
|
+
const tmp = join7(dir, `.theway-${process.pid}`);
|
|
9998
10121
|
mkdirSync3(dir, { recursive: true });
|
|
9999
10122
|
try {
|
|
10000
10123
|
copyFileSync2(self, tmp);
|
|
@@ -10017,7 +10140,7 @@ function isThewayBinary(path2) {
|
|
|
10017
10140
|
if (!isFile(path2))
|
|
10018
10141
|
return false;
|
|
10019
10142
|
try {
|
|
10020
|
-
const text =
|
|
10143
|
+
const text = readFileSync8(path2, "utf-8");
|
|
10021
10144
|
return text.startsWith("#!/usr/bin/env node") && text.includes(BINARY_MARKER);
|
|
10022
10145
|
} catch {
|
|
10023
10146
|
return false;
|
|
@@ -10058,7 +10181,7 @@ function copiesOnPath() {
|
|
|
10058
10181
|
for (const dir of (process.env.PATH ?? "").split(delimiter)) {
|
|
10059
10182
|
if (dir === "")
|
|
10060
10183
|
continue;
|
|
10061
|
-
const candidate =
|
|
10184
|
+
const candidate = join7(dir, "theway");
|
|
10062
10185
|
if (!isFile(candidate))
|
|
10063
10186
|
continue;
|
|
10064
10187
|
try {
|
|
@@ -10075,8 +10198,8 @@ function copiesOnPath() {
|
|
|
10075
10198
|
return copies;
|
|
10076
10199
|
}
|
|
10077
10200
|
function checkPath(dir, binary) {
|
|
10078
|
-
const
|
|
10079
|
-
if (!
|
|
10201
|
+
const dirs2 = (process.env.PATH ?? "").split(delimiter).filter((d) => d !== "");
|
|
10202
|
+
if (!dirs2.some((d) => resolve3(d) === dir)) {
|
|
10080
10203
|
process.stdout.write(`Add ${dir} to your PATH, e.g.: export PATH="${dir}:$PATH"
|
|
10081
10204
|
`);
|
|
10082
10205
|
}
|
|
@@ -10087,7 +10210,7 @@ function checkPath(dir, binary) {
|
|
|
10087
10210
|
}
|
|
10088
10211
|
}
|
|
10089
10212
|
function install() {
|
|
10090
|
-
if (!existsSync3(
|
|
10213
|
+
if (!existsSync3(join7(plugin, ".claude-plugin"))) {
|
|
10091
10214
|
return fail("theway: run `npx --yes @pixelfactoryio/theway@latest install` to install or update theway");
|
|
10092
10215
|
}
|
|
10093
10216
|
const cHome = claudeHome();
|
|
@@ -10095,7 +10218,7 @@ function install() {
|
|
|
10095
10218
|
const previous = recordedHome();
|
|
10096
10219
|
const custom = tHome !== resolve3(defaultHome());
|
|
10097
10220
|
const dir = installDir();
|
|
10098
|
-
const settingsPath =
|
|
10221
|
+
const settingsPath = join7(cHome, "settings.json");
|
|
10099
10222
|
const unsafe = unsafeHomeReason(tHome, custom);
|
|
10100
10223
|
if (unsafe !== "") {
|
|
10101
10224
|
return fail(`theway: refusing data home ${resolve3(tHome)}: ${unsafe}; set THEWAY_HOME to a dedicated folder`);
|
|
@@ -10106,7 +10229,7 @@ function install() {
|
|
|
10106
10229
|
const settings = readSettings(resolved.target);
|
|
10107
10230
|
if (settings === null)
|
|
10108
10231
|
return invalidSettings(settingsPath);
|
|
10109
|
-
const target =
|
|
10232
|
+
const target = join7(dir, "theway");
|
|
10110
10233
|
if (occupied(target) && !isThewayBinary(target)) {
|
|
10111
10234
|
return fail(`theway: ${target} exists and is not a theway binary; nothing was changed. Remove it, or set THEWAY_INSTALL_DIR to another folder`);
|
|
10112
10235
|
}
|
|
@@ -10118,7 +10241,7 @@ function install() {
|
|
|
10118
10241
|
} catch (e) {
|
|
10119
10242
|
return fail(`theway: ${e.message}`);
|
|
10120
10243
|
}
|
|
10121
|
-
const status = init(
|
|
10244
|
+
const status = init(join7(plugin, "home"), tHome);
|
|
10122
10245
|
if (status !== 0)
|
|
10123
10246
|
return status;
|
|
10124
10247
|
try {
|
|
@@ -10143,7 +10266,7 @@ function install() {
|
|
|
10143
10266
|
writeSettings(resolved.target, settings);
|
|
10144
10267
|
}
|
|
10145
10268
|
checkPath(dir, binary);
|
|
10146
|
-
const version = JSON.parse(
|
|
10269
|
+
const version = JSON.parse(readFileSync8(join7(pkgRoot, "package.json"), "utf-8")).version;
|
|
10147
10270
|
process.stdout.write(`Installed theway ${version} to ${dest} (theway@skills-dir), ${binary} and ${tHome}. Start a new Claude Code session or run /reload-plugins.
|
|
10148
10271
|
`);
|
|
10149
10272
|
return 0;
|
|
@@ -10152,7 +10275,7 @@ function uninstall() {
|
|
|
10152
10275
|
const cHome = claudeHome();
|
|
10153
10276
|
const tHome = resolveHome().home;
|
|
10154
10277
|
const homes = [...new Set([tHome, recordedHome(), defaultHome()])];
|
|
10155
|
-
const settingsPath =
|
|
10278
|
+
const settingsPath = join7(cHome, "settings.json");
|
|
10156
10279
|
let settingsFile = settingsPath;
|
|
10157
10280
|
if (occupied(settingsPath)) {
|
|
10158
10281
|
const resolved = settingsTarget(settingsPath);
|
|
@@ -10160,8 +10283,8 @@ function uninstall() {
|
|
|
10160
10283
|
return unwritableSettings(settingsPath, resolved.error);
|
|
10161
10284
|
settingsFile = resolved.target;
|
|
10162
10285
|
}
|
|
10163
|
-
rmSync2(
|
|
10164
|
-
const binary =
|
|
10286
|
+
rmSync2(join7(cHome, "skills", "theway"), { recursive: true, force: true });
|
|
10287
|
+
const binary = join7(installDir(), "theway");
|
|
10165
10288
|
const removed = isThewayBinary(binary);
|
|
10166
10289
|
if (removed)
|
|
10167
10290
|
rmSync2(binary, { force: true });
|
|
@@ -10193,6 +10316,11 @@ var nonEmpty = (value) => {
|
|
|
10193
10316
|
throw new InvalidArgumentError("must not be empty");
|
|
10194
10317
|
return value;
|
|
10195
10318
|
};
|
|
10319
|
+
var positive = (value) => {
|
|
10320
|
+
if (!/^[1-9][0-9]*$/.test(value))
|
|
10321
|
+
throw new InvalidArgumentError("must be a positive integer");
|
|
10322
|
+
return Number(value);
|
|
10323
|
+
};
|
|
10196
10324
|
var exit = (code) => {
|
|
10197
10325
|
process.exitCode = code;
|
|
10198
10326
|
};
|
|
@@ -10205,6 +10333,9 @@ function buildProgram() {
|
|
|
10205
10333
|
program2.command("path").argument("[project]").argument("[change-id]").option("--verbose").action((project, change, o) => exit(cmdPath(project, change, o.verbose === true)));
|
|
10206
10334
|
program2.command("config").argument("<project>").action((project) => exit(cmdConfig(project)));
|
|
10207
10335
|
program2.command("standards").argument("<project>").argument("<phase>").action((project, phase) => exit(cmdStandards(project, phase)));
|
|
10336
|
+
program2.command("context").argument("<project>").argument("<phase>").argument("[change-id]").action((project, phase, change) => exit(cmdContext(project, phase, change)));
|
|
10337
|
+
program2.command("authority").action(() => exit(cmdAuthority()));
|
|
10338
|
+
program2.command("next-id").argument("<project>").argument("<series-id>").option("--count <n>", "", positive, 1).action((project, series, o) => exit(cmdNextId(project, series, o.count)));
|
|
10208
10339
|
program2.command("validate-id").argument("<id>").option("--series").action((id, o) => exit(cmdValidateId(id, o.series === true)));
|
|
10209
10340
|
return program2;
|
|
10210
10341
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "theway",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "theway writes a spec and a numbered task list before any code, then implements the tasks in your session or through agents that open a reviewed, CI-green pull request.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Amine",
|
|
@@ -10,18 +10,12 @@ Archive a completed spec by moving it to the archive folder with a timestamp.
|
|
|
10
10
|
|
|
11
11
|
## Locate the home
|
|
12
12
|
|
|
13
|
-
Run `theway path` and use the folder it prints as `<home
|
|
13
|
+
Run `theway path` and use the folder it prints as `<home>`, never a path from elsewhere: TheWay files are stored in `<home>/<project>/`, where `<project>` is the current directory name.
|
|
14
14
|
- If `theway` is not found, tell the user to add the folder theway is installed in (`~/.local/bin` by default) to their `PATH`, or to run `npx --yes @pixelfactoryio/theway@latest install` then `/reload-plugins`, and stop.
|
|
15
|
-
- If
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
This command archives a completed change after it has been:
|
|
21
|
-
- Fully implemented
|
|
22
|
-
- Tested and validated
|
|
23
|
-
- Deployed to production (if applicable)
|
|
24
|
-
- Confirmed working
|
|
15
|
+
- If any `theway` subcommand fails with `error: unknown command '<name>'`, the installed `theway` is older than these commands: tell the user to run `npx --yes @pixelfactoryio/theway@latest install` then `/reload-plugins` and stop.
|
|
16
|
+
- If a `theway` subcommand exits 1 otherwise, quote the error line it wrote to stderr and stop, unless the step that runs it says what to do instead. The steps that do are `validate-id` (fix the ID), `next-id` (fix the series ID) and `archive` (open tasks, `--force` on explicit acceptance). Not every error line starts with `theway:`: `validate-id` and `next-id` write `invalid change id '…'` and `archive` writes `Error: …`.
|
|
17
|
+
- Quote every `theway: warning:` line in your report.
|
|
18
|
+
- Do not check for files under `<home>` before reading them. If a file under `<home>/standards/` or `<home>/templates/` does not exist, theway is not set up: tell the user to run `npx --yes @pixelfactoryio/theway@latest install` then `/reload-plugins` and stop.
|
|
25
19
|
|
|
26
20
|
## Steps
|
|
27
21
|
|
|
@@ -33,14 +27,7 @@ This command archives a completed change after it has been:
|
|
|
33
27
|
|
|
34
28
|
### 2. Verify Completion
|
|
35
29
|
|
|
36
|
-
Run `list
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
theway list <project>
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
- If the change is not at `N/N tasks done`, surface which numbered tasks are open and ask the user to fix them or confirm an override. Do not proceed on your own.
|
|
43
|
-
- `archive` enforces this too: it refuses unless every numbered task in `tasks.md` is ticked; other checkboxes are not tasks (use `--force` only when the user explicitly accepts stale/N-A tasks).
|
|
30
|
+
Run `theway list <project>` and show the task count before archiving. If the change is not at `N/N tasks done`, list its open numbered tasks and ask the user to fix them or accept them. Do not proceed on your own.
|
|
44
31
|
|
|
45
32
|
### 3. Move to Archive
|
|
46
33
|
|
|
@@ -50,40 +37,8 @@ theway archive <project> <change-id>
|
|
|
50
37
|
theway archive <project> <change-id> --force
|
|
51
38
|
```
|
|
52
39
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
- Update architecture docs in `docs/` with any new patterns or conventions
|
|
56
|
-
- Clean up any temporary notes
|
|
57
|
-
|
|
58
|
-
### 5. Confirm Archive
|
|
59
|
-
|
|
60
|
-
- Verify folder moved successfully
|
|
61
|
-
- Confirm archive location: the `Archived: <path>` line, `<home>/<project>/changes/archive/YYYY-MM-DD-[change-id]/`
|
|
40
|
+
When `theway archive` refuses because numbered tasks are open, list them and ask as in Step 2; use `--force` only on the user's explicit acceptance.
|
|
62
41
|
|
|
63
|
-
|
|
42
|
+
### 4. Confirm Archive
|
|
64
43
|
|
|
65
|
-
Archived
|
|
66
|
-
```
|
|
67
|
-
<home>/<project>/changes/archive/
|
|
68
|
-
├── 2025-10-01-implement-api-gateway/
|
|
69
|
-
├── 2025-10-10-add-logging-framework/
|
|
70
|
-
└── 2025-10-15-update-auth-middleware/
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## What Gets Archived
|
|
74
|
-
|
|
75
|
-
The entire change folder including:
|
|
76
|
-
- `spec.md` - The spec analysis with proposal and hardpoints
|
|
77
|
-
- `tasks.md` - Completed task list (all checked)
|
|
78
|
-
- `design.md` - Technical design (if present)
|
|
79
|
-
- Any other files in the change folder
|
|
80
|
-
|
|
81
|
-
## Historical Record
|
|
82
|
-
|
|
83
|
-
Archives serve as:
|
|
84
|
-
- Historical record of decisions
|
|
85
|
-
- Reference for similar future changes
|
|
86
|
-
- Audit trail of what was done and why
|
|
87
|
-
- Learning resource for the team
|
|
88
|
-
|
|
89
|
-
---
|
|
44
|
+
Report the `Archived: <path>` line `theway archive` prints.
|