@pixelfactoryio/theway 0.12.0 → 0.13.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 +312 -61
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/commands/engineering-light.md +5 -5
- package/plugin/commands/engineering.md +4 -4
- package/plugin/commands/workflow.md +112 -0
- package/plugin/home/config.yaml +34 -23
- package/plugin/home/lenses/conformance.md +9 -0
- package/plugin/home/lenses/correctness.md +5 -0
- package/plugin/home/standards/commits.md +23 -0
- package/plugin/home/standards/develop.md +2 -2
- package/plugin/home/standards/git-host.md +39 -0
- package/plugin/home/standards/interaction.md +2 -2
- package/plugin/home/standards/spec-review.md +1 -1
- package/plugin/home/workflows/agents.yaml +5 -0
- package/plugin/home/workflows/develop.yaml +4 -0
- package/plugin/workflows/run-pipeline.js +571 -0
- package/plugin/commands/develop-workflow.md +0 -128
- package/plugin/commands/develop.md +0 -41
package/dist/theway.js
CHANGED
|
@@ -9430,7 +9430,12 @@ import {
|
|
|
9430
9430
|
statSync as statSync2,
|
|
9431
9431
|
writeFileSync
|
|
9432
9432
|
} from "node:fs";
|
|
9433
|
-
var SHIPPED_DIRS = [
|
|
9433
|
+
var SHIPPED_DIRS = [
|
|
9434
|
+
{ dir: "standards", ext: ".md", shared: "standards" },
|
|
9435
|
+
{ dir: "templates", ext: ".md" },
|
|
9436
|
+
{ dir: "workflows", ext: ".yaml", shared: "workflows" },
|
|
9437
|
+
{ dir: "lenses", ext: ".md", shared: "lenses" }
|
|
9438
|
+
];
|
|
9434
9439
|
var MANIFEST = ".shipped.json";
|
|
9435
9440
|
var sha256 = (data) => createHash("sha256").update(data).digest("hex");
|
|
9436
9441
|
function readManifest(home) {
|
|
@@ -9523,16 +9528,18 @@ function migrateDataStandards(src, home) {
|
|
|
9523
9528
|
function copyShipped(src, home) {
|
|
9524
9529
|
const previous = readManifest(home);
|
|
9525
9530
|
const manifest = {};
|
|
9526
|
-
for (const dir of SHIPPED_DIRS) {
|
|
9527
|
-
const
|
|
9531
|
+
for (const { dir, ext, shared } of SHIPPED_DIRS) {
|
|
9532
|
+
const isShared = shared !== undefined;
|
|
9533
|
+
const stemOf = (name) => name.slice(0, -ext.length);
|
|
9534
|
+
const defaultExt = `.default${ext}`;
|
|
9528
9535
|
mkdirSync2(`${home}/${dir}`, { recursive: true });
|
|
9529
|
-
const names = readdirSync2(`${src}/${dir}`, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(
|
|
9536
|
+
const names = readdirSync2(`${src}/${dir}`, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(ext)).map((e) => e.name).sort();
|
|
9530
9537
|
for (const name of names) {
|
|
9531
9538
|
const rel = `${dir}/${name}`;
|
|
9532
9539
|
const dst = `${home}/${rel}`;
|
|
9533
9540
|
const shipped = readFileSync5(`${src}/${rel}`);
|
|
9534
9541
|
const old = previous?.[rel];
|
|
9535
|
-
const sibling = `${dir}/${
|
|
9542
|
+
const sibling = `${dir}/${stemOf(name)}${defaultExt}`;
|
|
9536
9543
|
let removeSibling = true;
|
|
9537
9544
|
let record = true;
|
|
9538
9545
|
if (!existsSync2(dst)) {
|
|
@@ -9542,12 +9549,12 @@ function copyShipped(src, home) {
|
|
|
9542
9549
|
if (!current.equals(shipped)) {
|
|
9543
9550
|
if (typeof old === "string" && sha256(current) === old) {
|
|
9544
9551
|
writeAtomic(dst, shipped);
|
|
9545
|
-
} else if (typeof old === "string" ||
|
|
9552
|
+
} else if (typeof old === "string" || isShared && previous === undefined) {
|
|
9546
9553
|
removeSibling = false;
|
|
9547
9554
|
writeAtomic(`${home}/${sibling}`, shipped);
|
|
9548
9555
|
process.stdout.write(`Kept your edited ${rel} (shipped version: ${sibling})
|
|
9549
9556
|
`);
|
|
9550
|
-
} else if (
|
|
9557
|
+
} else if (isShared) {
|
|
9551
9558
|
removeSibling = false;
|
|
9552
9559
|
record = false;
|
|
9553
9560
|
writeAtomic(`${home}/${sibling}`, shipped);
|
|
@@ -9568,9 +9575,9 @@ function copyShipped(src, home) {
|
|
|
9568
9575
|
if (record)
|
|
9569
9576
|
manifest[rel] = sha256(shipped);
|
|
9570
9577
|
}
|
|
9571
|
-
if (
|
|
9578
|
+
if (isShared) {
|
|
9572
9579
|
for (const [rel, hash] of Object.entries(previous ?? {})) {
|
|
9573
|
-
if (!rel.startsWith(
|
|
9580
|
+
if (!rel.startsWith(`${dir}/`) || names.includes(rel.slice(dir.length + 1)))
|
|
9574
9581
|
continue;
|
|
9575
9582
|
const path2 = `${home}/${rel}`;
|
|
9576
9583
|
if (!existsSync2(path2))
|
|
@@ -9580,15 +9587,15 @@ function copyShipped(src, home) {
|
|
|
9580
9587
|
process.stdout.write(`Removed ${rel}: theway no longer ships it
|
|
9581
9588
|
`);
|
|
9582
9589
|
} else {
|
|
9583
|
-
process.stdout.write(`Kept your edited ${rel}: theway no longer ships it, so it is now one of your
|
|
9590
|
+
process.stdout.write(`Kept your edited ${rel}: theway no longer ships it, so it is now one of your ${shared}
|
|
9584
9591
|
`);
|
|
9585
9592
|
}
|
|
9586
9593
|
}
|
|
9587
9594
|
for (const entry of readdirSync2(`${home}/${dir}`, { withFileTypes: true })) {
|
|
9588
9595
|
const file = entry.name;
|
|
9589
|
-
if (!entry.isFile() || !file.endsWith(
|
|
9596
|
+
if (!entry.isFile() || !file.endsWith(defaultExt))
|
|
9590
9597
|
continue;
|
|
9591
|
-
if (!names.includes(`${file.slice(0, -
|
|
9598
|
+
if (!names.includes(`${file.slice(0, -defaultExt.length)}${ext}`))
|
|
9592
9599
|
rmSync(`${home}/${dir}/${file}`, { force: true });
|
|
9593
9600
|
}
|
|
9594
9601
|
}
|
|
@@ -9637,10 +9644,14 @@ var bool = (d) => ({ rule: "boolean", default: d });
|
|
|
9637
9644
|
var model = (d) => ({ rule: "model", default: d });
|
|
9638
9645
|
var OPT_IN = ["core-principles.md", "sre.md", "web-development.md", "quality.md"];
|
|
9639
9646
|
var CORE = ["interaction.md", "develop.md", "tamm-framework.md", "spec-review.md", "spec-investigation.md"];
|
|
9640
|
-
var
|
|
9647
|
+
var CONVENTIONS = ["commits.md", "git-host.md"];
|
|
9648
|
+
var SHARED = new Set(["data", "templates", "standards", "workflows", "lenses"]);
|
|
9649
|
+
var isShared = (project) => SHARED.has(project);
|
|
9650
|
+
var NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
9651
|
+
var isLensList = (v) => Array.isArray(v) && v.length > 0 && v.every((n) => typeof n === "string" && NAME.test(n)) && new Set(v).size === v.length;
|
|
9641
9652
|
var keyOf = (name) => name.slice(0, -".md".length).replaceAll("-", "_");
|
|
9642
9653
|
var OPT_IN_KEYS = OPT_IN.map(keyOf);
|
|
9643
|
-
var
|
|
9654
|
+
var FIXED_KEYS = new Set([...CORE, ...CONVENTIONS].map(keyOf));
|
|
9644
9655
|
function mdFiles(dir) {
|
|
9645
9656
|
let names;
|
|
9646
9657
|
try {
|
|
@@ -9653,11 +9664,11 @@ function mdFiles(dir) {
|
|
|
9653
9664
|
function standardsOf(home, project) {
|
|
9654
9665
|
const globalDir = join4(home, "standards");
|
|
9655
9666
|
const projectDir = join4(home, project, "standards");
|
|
9656
|
-
const projectNames =
|
|
9667
|
+
const projectNames = isShared(project) ? [] : mdFiles(projectDir).filter((n) => !CONVENTIONS.includes(n));
|
|
9657
9668
|
const shipped = readManifest(home) ?? {};
|
|
9658
9669
|
const out = [];
|
|
9659
9670
|
for (const name of mdFiles(globalDir)) {
|
|
9660
|
-
if (CORE.includes(name))
|
|
9671
|
+
if (CORE.includes(name) || CONVENTIONS.includes(name))
|
|
9661
9672
|
continue;
|
|
9662
9673
|
const optIn = OPT_IN.includes(name);
|
|
9663
9674
|
if (!optIn && ((`standards/${name}` in shipped) || name.endsWith(".default.md")))
|
|
@@ -9683,21 +9694,31 @@ function standardsSchema(standards) {
|
|
|
9683
9694
|
var SCHEMA = {
|
|
9684
9695
|
standards: {},
|
|
9685
9696
|
engineering: {
|
|
9686
|
-
|
|
9687
|
-
|
|
9697
|
+
review: {
|
|
9698
|
+
rounds: { rule: "non-negative", default: 1 },
|
|
9699
|
+
model: model("opus")
|
|
9700
|
+
}
|
|
9688
9701
|
},
|
|
9689
9702
|
workflow: {
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
|
|
9693
|
-
|
|
9703
|
+
defaults: {
|
|
9704
|
+
implement: { model: model("opus") },
|
|
9705
|
+
review: {
|
|
9706
|
+
rounds: { rule: "positive", default: 1 },
|
|
9707
|
+
lenses: { rule: "lenses", default: ["conformance", "correctness"] },
|
|
9708
|
+
model: model("opus"),
|
|
9709
|
+
fix_model: model("opus")
|
|
9710
|
+
},
|
|
9711
|
+
pr: { ci_attempts: { rule: "positive", default: 2 }, model: model("sonnet"), fix_model: model("opus") },
|
|
9712
|
+
agent: { model: model("sonnet") }
|
|
9713
|
+
}
|
|
9694
9714
|
}
|
|
9695
9715
|
};
|
|
9696
9716
|
var RULE_TEXT = {
|
|
9697
9717
|
boolean: "true or false",
|
|
9698
9718
|
"non-negative": "a non-negative integer",
|
|
9699
9719
|
positive: "a positive integer",
|
|
9700
|
-
model: "opus, sonnet or haiku"
|
|
9720
|
+
model: "opus, sonnet or haiku",
|
|
9721
|
+
lenses: "a non-empty list of names without duplicates"
|
|
9701
9722
|
};
|
|
9702
9723
|
var isLeaf = (node) => typeof node.rule === "string";
|
|
9703
9724
|
function valid(rule, v) {
|
|
@@ -9710,12 +9731,15 @@ function valid(rule, v) {
|
|
|
9710
9731
|
return typeof v === "number" && Number.isInteger(v) && v >= 1;
|
|
9711
9732
|
case "model":
|
|
9712
9733
|
return v === "opus" || v === "sonnet" || v === "haiku";
|
|
9734
|
+
case "lenses":
|
|
9735
|
+
return isLensList(v);
|
|
9713
9736
|
}
|
|
9714
9737
|
}
|
|
9715
9738
|
function defaults(schema) {
|
|
9716
9739
|
const out = dict();
|
|
9717
|
-
for (const [key, node] of Object.entries(schema))
|
|
9718
|
-
out[key] = isLeaf(node) ? node.default : defaults(node);
|
|
9740
|
+
for (const [key, node] of Object.entries(schema)) {
|
|
9741
|
+
out[key] = isLeaf(node) ? Array.isArray(node.default) ? [...node.default] : node.default : defaults(node);
|
|
9742
|
+
}
|
|
9719
9743
|
return out;
|
|
9720
9744
|
}
|
|
9721
9745
|
var warnLoud = (file, text) => {
|
|
@@ -9731,13 +9755,13 @@ function apply(file, schema, layer, into, prefix, warn) {
|
|
|
9731
9755
|
if (node === undefined) {
|
|
9732
9756
|
if (prefix !== "standards")
|
|
9733
9757
|
warn(file, `unknown key ${dotted}`);
|
|
9734
|
-
else if (
|
|
9758
|
+
else if (FIXED_KEYS.has(key))
|
|
9735
9759
|
warn(file, `${dotted} cannot be switched`);
|
|
9736
9760
|
else
|
|
9737
9761
|
warn(file, `${dotted} has no standard file`);
|
|
9738
9762
|
} else if (isLeaf(node)) {
|
|
9739
9763
|
if (valid(node.rule, value))
|
|
9740
|
-
into[key] = value;
|
|
9764
|
+
into[key] = Array.isArray(value) ? [...value] : value;
|
|
9741
9765
|
else
|
|
9742
9766
|
warn(file, `${dotted} must be ${RULE_TEXT[node.rule]}`);
|
|
9743
9767
|
} else if (value instanceof Map) {
|
|
@@ -10048,6 +10072,232 @@ function cmdNextId(project, seriesId, count) {
|
|
|
10048
10072
|
return 0;
|
|
10049
10073
|
}
|
|
10050
10074
|
|
|
10075
|
+
// src/core/workflow.ts
|
|
10076
|
+
import { readdirSync as readdirSync5 } from "node:fs";
|
|
10077
|
+
import { basename, join as join7, relative } from "node:path";
|
|
10078
|
+
var TYPES = ["implement", "review", "agent", "pr"];
|
|
10079
|
+
var positive = {
|
|
10080
|
+
test: (v) => typeof v === "number" && Number.isInteger(v) && v >= 1,
|
|
10081
|
+
text: "a positive integer"
|
|
10082
|
+
};
|
|
10083
|
+
var model2 = { test: (v) => v === "opus" || v === "sonnet" || v === "haiku", text: "opus, sonnet or haiku" };
|
|
10084
|
+
var lenses = { test: isLensList, text: "a non-empty list of names without duplicates" };
|
|
10085
|
+
var name = {
|
|
10086
|
+
test: (v) => typeof v === "string" && NAME.test(v),
|
|
10087
|
+
text: "a name (lowercase letters, digits and -)"
|
|
10088
|
+
};
|
|
10089
|
+
var nonEmpty = { test: (v) => typeof v === "string" && v.length > 0, text: "a non-empty string" };
|
|
10090
|
+
var bool2 = { test: (v) => typeof v === "boolean", text: "true or false" };
|
|
10091
|
+
var FIELDS = {
|
|
10092
|
+
implement: [["model", model2]],
|
|
10093
|
+
review: [
|
|
10094
|
+
["rounds", positive],
|
|
10095
|
+
["lenses", lenses],
|
|
10096
|
+
["model", model2],
|
|
10097
|
+
["fix_model", model2]
|
|
10098
|
+
],
|
|
10099
|
+
agent: [
|
|
10100
|
+
["name", name],
|
|
10101
|
+
["prompt", nonEmpty],
|
|
10102
|
+
["model", model2]
|
|
10103
|
+
],
|
|
10104
|
+
pr: [
|
|
10105
|
+
["ci_attempts", positive],
|
|
10106
|
+
["model", model2],
|
|
10107
|
+
["fix_model", model2]
|
|
10108
|
+
]
|
|
10109
|
+
};
|
|
10110
|
+
var REQUIRED = ["name", "prompt"];
|
|
10111
|
+
var MODELS = ["model", "fix_model"];
|
|
10112
|
+
var projectDir = (d, kind) => join7(d.home, d.project, kind);
|
|
10113
|
+
var globalDir = (d, kind) => join7(d.home, kind);
|
|
10114
|
+
var searched = (d, kind) => d.own ? `${projectDir(d, kind)} or ${globalDir(d, kind)}` : globalDir(d, kind);
|
|
10115
|
+
function lensPath(d, lens) {
|
|
10116
|
+
const own = join7(projectDir(d, "lenses"), `${lens}.md`);
|
|
10117
|
+
if (d.own && isFile(own))
|
|
10118
|
+
return own;
|
|
10119
|
+
const global = join7(globalDir(d, "lenses"), `${lens}.md`);
|
|
10120
|
+
return isFile(global) ? global : null;
|
|
10121
|
+
}
|
|
10122
|
+
function validate(d, path2, defaults2) {
|
|
10123
|
+
const rel = relative(d.home, path2);
|
|
10124
|
+
const fail = (reason) => ({ error: `theway: ${rel}: ${reason}` });
|
|
10125
|
+
const loaded = load(d.home, rel);
|
|
10126
|
+
if ("error" in loaded)
|
|
10127
|
+
return loaded;
|
|
10128
|
+
const root = loaded.root;
|
|
10129
|
+
if (!(root instanceof Map))
|
|
10130
|
+
return fail("not a map");
|
|
10131
|
+
for (const key of root.keys()) {
|
|
10132
|
+
if (key !== "default" && key !== "agents" && key !== "steps")
|
|
10133
|
+
return fail(`unknown key ${String(key)}`);
|
|
10134
|
+
}
|
|
10135
|
+
if (root.has("default") && typeof root.get("default") !== "boolean")
|
|
10136
|
+
return fail("default must be true or false");
|
|
10137
|
+
if (root.has("agents") && typeof root.get("agents") !== "boolean")
|
|
10138
|
+
return fail("agents must be true or false");
|
|
10139
|
+
const topAgents = root.has("agents") ? root.get("agents") : true;
|
|
10140
|
+
const entries = root.get("steps");
|
|
10141
|
+
if (!Array.isArray(entries) || entries.length === 0)
|
|
10142
|
+
return fail("steps must be a non-empty list");
|
|
10143
|
+
const steps = [];
|
|
10144
|
+
for (const [i, entry] of entries.entries()) {
|
|
10145
|
+
const at = `steps[${i}]`;
|
|
10146
|
+
const type = entry instanceof Map && entry.size === 1 ? [...entry.keys()][0] : undefined;
|
|
10147
|
+
if (!TYPES.includes(type))
|
|
10148
|
+
return fail(`${at} must be one of ${TYPES.join(", ")}`);
|
|
10149
|
+
const t = type;
|
|
10150
|
+
const value = entry.get(t);
|
|
10151
|
+
if (value !== null && !(value instanceof Map))
|
|
10152
|
+
return fail(`${at}.${t} must be a map`);
|
|
10153
|
+
const given = value ?? new Map;
|
|
10154
|
+
const fields = new Map([["agents", bool2], ...FIELDS[t]]);
|
|
10155
|
+
for (const key of given.keys()) {
|
|
10156
|
+
if (typeof key !== "string" || !fields.has(key))
|
|
10157
|
+
return fail(`${at}.${t}.${String(key)} is not a field of ${t}`);
|
|
10158
|
+
}
|
|
10159
|
+
for (const [key, v] of given) {
|
|
10160
|
+
const rule = fields.get(key);
|
|
10161
|
+
if (!rule.test(v))
|
|
10162
|
+
return fail(`${at}.${t}.${String(key)} must be ${rule.text}`);
|
|
10163
|
+
}
|
|
10164
|
+
const agents = given.has("agents") ? given.get("agents") : topAgents;
|
|
10165
|
+
if (!agents) {
|
|
10166
|
+
for (const key of given.keys()) {
|
|
10167
|
+
if (MODELS.includes(key)) {
|
|
10168
|
+
return fail(`${at}.${t}.${String(key)} has no effect when the step runs inline (agents: false)`);
|
|
10169
|
+
}
|
|
10170
|
+
}
|
|
10171
|
+
}
|
|
10172
|
+
if (t === "agent") {
|
|
10173
|
+
for (const field of REQUIRED)
|
|
10174
|
+
if (!given.has(field))
|
|
10175
|
+
return fail(`${at}.agent.${field} is required`);
|
|
10176
|
+
}
|
|
10177
|
+
if (i === 0 && t !== "implement")
|
|
10178
|
+
return fail("steps[0] must be implement");
|
|
10179
|
+
if (i > 0 && t === "implement")
|
|
10180
|
+
return fail(`${at}: implement may appear only once`);
|
|
10181
|
+
if (t === "pr" && i !== entries.length - 1)
|
|
10182
|
+
return fail(`${at}: pr must be the last step`);
|
|
10183
|
+
const own = defaults2[t] ?? {};
|
|
10184
|
+
const step = { step: t, agents };
|
|
10185
|
+
for (const [field] of FIELDS[t]) {
|
|
10186
|
+
if (!agents && MODELS.includes(field))
|
|
10187
|
+
continue;
|
|
10188
|
+
const v = given.has(field) ? given.get(field) : own[field];
|
|
10189
|
+
step[field] = Array.isArray(v) ? [...v] : v;
|
|
10190
|
+
}
|
|
10191
|
+
if (t === "review") {
|
|
10192
|
+
const found = [];
|
|
10193
|
+
for (const lens of step.lenses) {
|
|
10194
|
+
const p = lensPath(d, lens);
|
|
10195
|
+
if (p === null) {
|
|
10196
|
+
return fail(`${at}.review lens '${lens}' has no file in ${searched(d, "lenses")}`);
|
|
10197
|
+
}
|
|
10198
|
+
found.push({ name: lens, path: p });
|
|
10199
|
+
}
|
|
10200
|
+
step.lenses = found;
|
|
10201
|
+
}
|
|
10202
|
+
steps.push(step);
|
|
10203
|
+
}
|
|
10204
|
+
return { workflow: { name: basename(path2, ".yaml"), file: path2, steps }, isDefault: root.get("default") === true };
|
|
10205
|
+
}
|
|
10206
|
+
function scan(d, dir) {
|
|
10207
|
+
let names;
|
|
10208
|
+
try {
|
|
10209
|
+
names = readdirSync5(dir);
|
|
10210
|
+
} catch {
|
|
10211
|
+
return [];
|
|
10212
|
+
}
|
|
10213
|
+
const out = [];
|
|
10214
|
+
for (const n of names.sort()) {
|
|
10215
|
+
if (!n.endsWith(".yaml") || n.endsWith(".default.yaml") || !isFile(join7(dir, n)))
|
|
10216
|
+
continue;
|
|
10217
|
+
if (!NAME.test(n.slice(0, -".yaml".length))) {
|
|
10218
|
+
process.stderr.write(`theway: warning: ${relative(d.home, join7(dir, n))}: not a valid workflow name; ignored
|
|
10219
|
+
`);
|
|
10220
|
+
continue;
|
|
10221
|
+
}
|
|
10222
|
+
out.push(n);
|
|
10223
|
+
}
|
|
10224
|
+
return out;
|
|
10225
|
+
}
|
|
10226
|
+
var joinAnd = (items) => items.length === 1 ? items[0] : `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
10227
|
+
function defaultOf(d, paths, defaults2) {
|
|
10228
|
+
const marked = [];
|
|
10229
|
+
for (const path2 of paths) {
|
|
10230
|
+
const result = validate(d, path2, defaults2);
|
|
10231
|
+
if ("error" in result)
|
|
10232
|
+
return result;
|
|
10233
|
+
if (result.isDefault)
|
|
10234
|
+
marked.push(result.workflow);
|
|
10235
|
+
}
|
|
10236
|
+
if (marked.length > 1) {
|
|
10237
|
+
return { error: `theway: ${joinAnd(marked.map((w) => relative(d.home, w.file)))} both set default: true` };
|
|
10238
|
+
}
|
|
10239
|
+
return marked.length === 1 ? { workflow: marked[0] } : null;
|
|
10240
|
+
}
|
|
10241
|
+
function byName(d, wanted, defaults2) {
|
|
10242
|
+
const own = join7(projectDir(d, "workflows"), `${wanted}.yaml`);
|
|
10243
|
+
const global = join7(globalDir(d, "workflows"), `${wanted}.yaml`);
|
|
10244
|
+
const path2 = d.own && isFile(own) ? own : isFile(global) ? global : null;
|
|
10245
|
+
if (path2 === null) {
|
|
10246
|
+
return { error: `theway: no workflow '${wanted}' in ${searched(d, "workflows")}` };
|
|
10247
|
+
}
|
|
10248
|
+
return validate(d, path2, defaults2);
|
|
10249
|
+
}
|
|
10250
|
+
function byDefault(d, defaults2) {
|
|
10251
|
+
const ownNames = d.own ? scan(d, projectDir(d, "workflows")) : [];
|
|
10252
|
+
const own = defaultOf(d, ownNames.map((n) => join7(projectDir(d, "workflows"), n)), defaults2);
|
|
10253
|
+
if (own !== null)
|
|
10254
|
+
return own;
|
|
10255
|
+
const globalNames = scan(d, globalDir(d, "workflows")).filter((n) => !ownNames.includes(n));
|
|
10256
|
+
const global = defaultOf(d, globalNames.map((n) => join7(globalDir(d, "workflows"), n)), defaults2);
|
|
10257
|
+
if (global !== null)
|
|
10258
|
+
return global;
|
|
10259
|
+
return byName(d, "develop", defaults2);
|
|
10260
|
+
}
|
|
10261
|
+
function cmdWorkflow(project, wanted) {
|
|
10262
|
+
if (invalidSegments([["project", project]]))
|
|
10263
|
+
return 1;
|
|
10264
|
+
if (wanted !== undefined && !NAME.test(wanted)) {
|
|
10265
|
+
const shown = wanted.replaceAll(`
|
|
10266
|
+
`, "\\n").replaceAll("\r", "\\r");
|
|
10267
|
+
process.stderr.write(`theway: invalid workflow name '${shown}'
|
|
10268
|
+
`);
|
|
10269
|
+
return 1;
|
|
10270
|
+
}
|
|
10271
|
+
const home = thewayHome();
|
|
10272
|
+
const loaded = loadConfig(home, project);
|
|
10273
|
+
if (loaded === null)
|
|
10274
|
+
return 1;
|
|
10275
|
+
const defaults2 = loaded.config.workflow.defaults;
|
|
10276
|
+
const d = { home, project, own: !isShared(project) };
|
|
10277
|
+
const result = wanted === undefined ? byDefault(d, defaults2) : byName(d, wanted, defaults2);
|
|
10278
|
+
if ("error" in result) {
|
|
10279
|
+
process.stderr.write(`${result.error}
|
|
10280
|
+
`);
|
|
10281
|
+
return 1;
|
|
10282
|
+
}
|
|
10283
|
+
const conventions = [];
|
|
10284
|
+
for (const file2 of CONVENTIONS) {
|
|
10285
|
+
const global = join7(home, "standards", file2);
|
|
10286
|
+
if (!isFile(global)) {
|
|
10287
|
+
process.stderr.write(`theway: ${global} not found; run npx --yes @pixelfactoryio/theway@latest install, then /reload-plugins
|
|
10288
|
+
`);
|
|
10289
|
+
return 1;
|
|
10290
|
+
}
|
|
10291
|
+
const own = join7(home, project, "standards", file2);
|
|
10292
|
+
conventions.push(d.own && isFile(own) ? own : global);
|
|
10293
|
+
}
|
|
10294
|
+
const { name: name2, file, steps } = result.workflow;
|
|
10295
|
+
const doc = { name: name2, file, commits: conventions[0], git_host: conventions[1], steps };
|
|
10296
|
+
process.stdout.write(`${JSON.stringify(doc, null, 2)}
|
|
10297
|
+
`);
|
|
10298
|
+
return 0;
|
|
10299
|
+
}
|
|
10300
|
+
|
|
10051
10301
|
// src/install.ts
|
|
10052
10302
|
import {
|
|
10053
10303
|
accessSync,
|
|
@@ -10068,7 +10318,7 @@ import {
|
|
|
10068
10318
|
writeFileSync as writeFileSync2
|
|
10069
10319
|
} from "node:fs";
|
|
10070
10320
|
import { homedir as homedir2 } from "node:os";
|
|
10071
|
-
import { delimiter, dirname, isAbsolute, join as
|
|
10321
|
+
import { delimiter, dirname, isAbsolute, join as join8, resolve as resolve3, sep } from "node:path";
|
|
10072
10322
|
import { fileURLToPath } from "node:url";
|
|
10073
10323
|
|
|
10074
10324
|
// node_modules/@clack/core/dist/index.mjs
|
|
@@ -11479,16 +11729,16 @@ ${i2}
|
|
|
11479
11729
|
// src/install.ts
|
|
11480
11730
|
var self = fileURLToPath(import.meta.url);
|
|
11481
11731
|
var pkgRoot = dirname(dirname(self));
|
|
11482
|
-
var plugin =
|
|
11483
|
-
var PLUGIN_DIRS = [".claude-plugin", "commands"];
|
|
11732
|
+
var plugin = join8(pkgRoot, "plugin");
|
|
11733
|
+
var PLUGIN_DIRS = [".claude-plugin", "commands", "workflows"];
|
|
11484
11734
|
var BINARY_MARKER = "theway-cli-binary:pixelfactoryio/theway";
|
|
11485
11735
|
function claudeHome() {
|
|
11486
11736
|
const dir = (process.env.CLAUDE_CONFIG_DIR ?? "").trim();
|
|
11487
|
-
return dir !== "" ? dir :
|
|
11737
|
+
return dir !== "" ? dir : join8(homedir2(), ".claude");
|
|
11488
11738
|
}
|
|
11489
11739
|
function installDir() {
|
|
11490
11740
|
const dir = process.env.THEWAY_INSTALL_DIR ?? "";
|
|
11491
|
-
return dir !== "" ? resolve3(dir) :
|
|
11741
|
+
return dir !== "" ? resolve3(dir) : join8(homedir2(), ".local", "bin");
|
|
11492
11742
|
}
|
|
11493
11743
|
function shownHome(home) {
|
|
11494
11744
|
return resolve3(home) === resolve3(defaultHome()) ? "~/.theway" : resolve3(home);
|
|
@@ -11588,15 +11838,15 @@ function invalidSettings(path2) {
|
|
|
11588
11838
|
return fail(`theway: ${path2} is not valid settings JSON; nothing was changed`);
|
|
11589
11839
|
}
|
|
11590
11840
|
function copyPlugin(home) {
|
|
11591
|
-
const tmp =
|
|
11592
|
-
const old =
|
|
11593
|
-
const dest =
|
|
11841
|
+
const tmp = join8(home, `.theway-install-${process.pid}`);
|
|
11842
|
+
const old = join8(home, `.theway-old-${process.pid}`);
|
|
11843
|
+
const dest = join8(home, "skills", "theway");
|
|
11594
11844
|
rmSync2(tmp, { recursive: true, force: true });
|
|
11595
11845
|
try {
|
|
11596
11846
|
for (const dir of PLUGIN_DIRS) {
|
|
11597
|
-
cpSync(
|
|
11847
|
+
cpSync(join8(plugin, dir), join8(tmp, dir), { recursive: true });
|
|
11598
11848
|
}
|
|
11599
|
-
mkdirSync3(
|
|
11849
|
+
mkdirSync3(join8(home, "skills"), { recursive: true });
|
|
11600
11850
|
if (existsSync3(dest))
|
|
11601
11851
|
renameSync3(dest, old);
|
|
11602
11852
|
renameSync3(tmp, dest);
|
|
@@ -11620,22 +11870,22 @@ function legacyText(path2, match) {
|
|
|
11620
11870
|
}
|
|
11621
11871
|
function removeLegacyBin(home) {
|
|
11622
11872
|
for (const h2 of new Set([defaultHome(), resolve3(home)])) {
|
|
11623
|
-
const bin =
|
|
11624
|
-
if (legacyText(
|
|
11873
|
+
const bin = join8(h2, "bin");
|
|
11874
|
+
if (legacyText(join8(bin, "theway"), (t2) => t2.startsWith(`#!/bin/sh
|
|
11625
11875
|
exec node `) && t2.endsWith(`theway.js' "$@"
|
|
11626
11876
|
`))) {
|
|
11627
|
-
rmSync2(
|
|
11877
|
+
rmSync2(join8(bin, "theway"), { force: true });
|
|
11628
11878
|
}
|
|
11629
|
-
if (legacyText(
|
|
11879
|
+
if (legacyText(join8(bin, "theway.js"), (t2) => t2.startsWith(`#!/usr/bin/env node
|
|
11630
11880
|
`))) {
|
|
11631
|
-
rmSync2(
|
|
11881
|
+
rmSync2(join8(bin, "theway.js"), { force: true });
|
|
11632
11882
|
}
|
|
11633
11883
|
removeIfEmpty2(bin);
|
|
11634
11884
|
}
|
|
11635
11885
|
}
|
|
11636
11886
|
function writeBinary(dir) {
|
|
11637
|
-
const dest =
|
|
11638
|
-
const tmp =
|
|
11887
|
+
const dest = join8(dir, "theway");
|
|
11888
|
+
const tmp = join8(dir, `.theway-${process.pid}`);
|
|
11639
11889
|
mkdirSync3(dir, { recursive: true });
|
|
11640
11890
|
try {
|
|
11641
11891
|
copyFileSync2(self, tmp);
|
|
@@ -11699,7 +11949,7 @@ function copiesOnPath() {
|
|
|
11699
11949
|
for (const dir of (process.env.PATH ?? "").split(delimiter)) {
|
|
11700
11950
|
if (dir === "")
|
|
11701
11951
|
continue;
|
|
11702
|
-
const candidate =
|
|
11952
|
+
const candidate = join8(dir, "theway");
|
|
11703
11953
|
if (!isFile(candidate))
|
|
11704
11954
|
continue;
|
|
11705
11955
|
try {
|
|
@@ -11795,7 +12045,7 @@ async function askStandards() {
|
|
|
11795
12045
|
return isCancel(answer) ? null : answer;
|
|
11796
12046
|
}
|
|
11797
12047
|
async function install(opts) {
|
|
11798
|
-
if (!existsSync3(
|
|
12048
|
+
if (!existsSync3(join8(plugin, ".claude-plugin"))) {
|
|
11799
12049
|
return fail("theway: run `npx --yes @pixelfactoryio/theway@latest install` to install or update theway");
|
|
11800
12050
|
}
|
|
11801
12051
|
let enabled2 = [];
|
|
@@ -11818,7 +12068,7 @@ async function install(opts) {
|
|
|
11818
12068
|
tHome = home;
|
|
11819
12069
|
} else {
|
|
11820
12070
|
const found = resolveHome();
|
|
11821
|
-
const neverInstalled = found.source === "default" && !existsSync3(
|
|
12071
|
+
const neverInstalled = found.source === "default" && !existsSync3(join8(defaultHome(), "config.yaml"));
|
|
11822
12072
|
if (neverInstalled && interactive()) {
|
|
11823
12073
|
const home = await askHome();
|
|
11824
12074
|
if (home === null)
|
|
@@ -11831,7 +12081,7 @@ async function install(opts) {
|
|
|
11831
12081
|
const previous = recordedHome();
|
|
11832
12082
|
const custom = tHome !== resolve3(defaultHome());
|
|
11833
12083
|
const dir = installDir();
|
|
11834
|
-
const settingsPath =
|
|
12084
|
+
const settingsPath = join8(cHome, "settings.json");
|
|
11835
12085
|
const unsafe = unsafeHomeReason(tHome, custom);
|
|
11836
12086
|
if (unsafe !== "") {
|
|
11837
12087
|
return fail(`theway: refusing data home ${resolve3(tHome)}: ${unsafe}; set THEWAY_HOME or --home to a dedicated folder`);
|
|
@@ -11842,11 +12092,11 @@ async function install(opts) {
|
|
|
11842
12092
|
const settings2 = readSettings(resolved.target);
|
|
11843
12093
|
if (settings2 === null)
|
|
11844
12094
|
return invalidSettings(settingsPath);
|
|
11845
|
-
const target =
|
|
12095
|
+
const target = join8(dir, "theway");
|
|
11846
12096
|
if (occupied(target) && !isThewayBinary(target)) {
|
|
11847
12097
|
return fail(`theway: ${target} exists and is not a theway binary; nothing was changed. Remove it, or set THEWAY_INSTALL_DIR to another folder`);
|
|
11848
12098
|
}
|
|
11849
|
-
const config =
|
|
12099
|
+
const config = join8(resolve3(tHome), "config.yaml");
|
|
11850
12100
|
const firstInstall = !existsSync3(config);
|
|
11851
12101
|
if (opts.standards !== undefined && !firstInstall) {
|
|
11852
12102
|
return fail(`theway: --standards applies only to a first install; ${config} exists, so set standards.<key>.enabled there instead; nothing was changed`);
|
|
@@ -11866,7 +12116,7 @@ async function install(opts) {
|
|
|
11866
12116
|
} catch (e) {
|
|
11867
12117
|
return fail(`theway: ${e.message}`);
|
|
11868
12118
|
}
|
|
11869
|
-
const status = init(
|
|
12119
|
+
const status = init(join8(plugin, "home"), tHome, enabled2);
|
|
11870
12120
|
if (status !== 0)
|
|
11871
12121
|
return status;
|
|
11872
12122
|
if (firstInstall && opts.standards === undefined && !asked) {
|
|
@@ -11895,7 +12145,7 @@ async function install(opts) {
|
|
|
11895
12145
|
writeSettings(resolved.target, settings2);
|
|
11896
12146
|
}
|
|
11897
12147
|
checkPath(dir, binary);
|
|
11898
|
-
const version = JSON.parse(readFileSync8(
|
|
12148
|
+
const version = JSON.parse(readFileSync8(join8(pkgRoot, "package.json"), "utf-8")).version;
|
|
11899
12149
|
process.stdout.write(`Installed theway ${version} to ${dest} (theway@skills-dir), ${binary} and ${tHome}. Start a new Claude Code session or run /reload-plugins.
|
|
11900
12150
|
`);
|
|
11901
12151
|
return 0;
|
|
@@ -11904,7 +12154,7 @@ function uninstall() {
|
|
|
11904
12154
|
const cHome = claudeHome();
|
|
11905
12155
|
const tHome = resolveHome().home;
|
|
11906
12156
|
const homes = [...new Set([tHome, recordedHome(), defaultHome()])];
|
|
11907
|
-
const settingsPath =
|
|
12157
|
+
const settingsPath = join8(cHome, "settings.json");
|
|
11908
12158
|
let settingsFile = settingsPath;
|
|
11909
12159
|
if (occupied(settingsPath)) {
|
|
11910
12160
|
const resolved = settingsTarget(settingsPath);
|
|
@@ -11912,8 +12162,8 @@ function uninstall() {
|
|
|
11912
12162
|
return unwritableSettings(settingsPath, resolved.error);
|
|
11913
12163
|
settingsFile = resolved.target;
|
|
11914
12164
|
}
|
|
11915
|
-
rmSync2(
|
|
11916
|
-
const binary =
|
|
12165
|
+
rmSync2(join8(cHome, "skills", "theway"), { recursive: true, force: true });
|
|
12166
|
+
const binary = join8(installDir(), "theway");
|
|
11917
12167
|
const removed = isThewayBinary(binary);
|
|
11918
12168
|
if (removed)
|
|
11919
12169
|
rmSync2(binary, { force: true });
|
|
@@ -11940,12 +12190,12 @@ function uninstall() {
|
|
|
11940
12190
|
}
|
|
11941
12191
|
|
|
11942
12192
|
// src/program.ts
|
|
11943
|
-
var
|
|
12193
|
+
var nonEmpty2 = (value) => {
|
|
11944
12194
|
if (value === "")
|
|
11945
12195
|
throw new InvalidArgumentError("must not be empty");
|
|
11946
12196
|
return value;
|
|
11947
12197
|
};
|
|
11948
|
-
var
|
|
12198
|
+
var positive2 = (value) => {
|
|
11949
12199
|
if (!/^[1-9][0-9]*$/.test(value))
|
|
11950
12200
|
throw new InvalidArgumentError("must be a positive integer");
|
|
11951
12201
|
return Number(value);
|
|
@@ -11955,16 +12205,17 @@ var exit = (code) => {
|
|
|
11955
12205
|
};
|
|
11956
12206
|
function buildProgram() {
|
|
11957
12207
|
const program2 = new Command("theway");
|
|
11958
|
-
program2.command("install").option("--home <path>", "",
|
|
12208
|
+
program2.command("install").option("--home <path>", "", nonEmpty2).option("--standards <keys>").action(async (o2) => exit(await install({ home: o2.home, standards: o2.standards })));
|
|
11959
12209
|
program2.command("uninstall").action(() => exit(uninstall()));
|
|
11960
|
-
program2.command("list").argument("<project>", "",
|
|
11961
|
-
program2.command("archive").argument("<project>", "",
|
|
12210
|
+
program2.command("list").argument("<project>", "", nonEmpty2).action((project) => exit(cmdList(project)));
|
|
12211
|
+
program2.command("archive").argument("<project>", "", nonEmpty2).argument("<change-id>", "", nonEmpty2).option("--force").action((project, change, o2) => exit(cmdArchive(project, change, o2.force === true)));
|
|
11962
12212
|
program2.command("path").argument("[project]").argument("[change-id]").option("--verbose").action((project, change, o2) => exit(cmdPath(project, change, o2.verbose === true)));
|
|
11963
12213
|
program2.command("config").argument("<project>").action((project) => exit(cmdConfig(project)));
|
|
11964
12214
|
program2.command("standards").argument("<project>").argument("<phase>").action((project, phase) => exit(cmdStandards(project, phase)));
|
|
11965
12215
|
program2.command("context").argument("<project>").argument("<phase>").argument("[change-id]").action((project, phase, change) => exit(cmdContext(project, phase, change)));
|
|
12216
|
+
program2.command("workflow").argument("<project>").argument("[name]").action((project, name2) => exit(cmdWorkflow(project, name2)));
|
|
11966
12217
|
program2.command("authority").action(() => exit(cmdAuthority()));
|
|
11967
|
-
program2.command("next-id").argument("<project>").argument("<series-id>").option("--count <n>", "",
|
|
12218
|
+
program2.command("next-id").argument("<project>").argument("<series-id>").option("--count <n>", "", positive2, 1).action((project, series, o2) => exit(cmdNextId(project, series, o2.count)));
|
|
11968
12219
|
program2.command("validate-id").argument("<id>").option("--series").action((id, o2) => exit(cmdValidateId(id, o2.series === true)));
|
|
11969
12220
|
return program2;
|
|
11970
12221
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "theway",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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",
|