@wayai/cli 0.3.206 → 0.3.208
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/index.js +103 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15031,6 +15031,21 @@ var init_expected = __esm({
|
|
|
15031
15031
|
}
|
|
15032
15032
|
});
|
|
15033
15033
|
|
|
15034
|
+
// src/lib/terminal-output.ts
|
|
15035
|
+
import { stripVTControlCharacters } from "util";
|
|
15036
|
+
function sanitizeTerminalText(value) {
|
|
15037
|
+
const normalizedNewlines = value.replace(/\r\n?/g, "\n");
|
|
15038
|
+
return stripVTControlCharacters(normalizedNewlines).replace(
|
|
15039
|
+
/[\u0000-\u0009\u000b-\u001f\u007f-\u009f]/g,
|
|
15040
|
+
""
|
|
15041
|
+
);
|
|
15042
|
+
}
|
|
15043
|
+
var init_terminal_output = __esm({
|
|
15044
|
+
"src/lib/terminal-output.ts"() {
|
|
15045
|
+
"use strict";
|
|
15046
|
+
}
|
|
15047
|
+
});
|
|
15048
|
+
|
|
15034
15049
|
// src/lib/fs-safety.ts
|
|
15035
15050
|
import * as fs from "fs";
|
|
15036
15051
|
import * as path from "path";
|
|
@@ -15490,7 +15505,7 @@ function findEnclosingNewHubFolder(workspaceDir) {
|
|
|
15490
15505
|
return null;
|
|
15491
15506
|
}
|
|
15492
15507
|
function resolvePushTarget(workspaceDir, existingHubs, newHubs, selector) {
|
|
15493
|
-
if (selector) {
|
|
15508
|
+
if (selector !== void 0) {
|
|
15494
15509
|
const existingMatch = existingHubs.find(
|
|
15495
15510
|
(h) => h.hubId === selector || path3.basename(h.hubFolder) === selector
|
|
15496
15511
|
);
|
|
@@ -15510,7 +15525,7 @@ function resolvePushTarget(workspaceDir, existingHubs, newHubs, selector) {
|
|
|
15510
15525
|
return previewHubs.length === 1 ? { ok: true, target: { kind: "existing", hub: previewHubs[0] } } : { ok: true, target: { kind: "new", hub: newHubs[0] } };
|
|
15511
15526
|
}
|
|
15512
15527
|
function resolveNewHubForCreate(workspaceDir, existingHubs, newHubs, selector) {
|
|
15513
|
-
if (selector) {
|
|
15528
|
+
if (selector !== void 0) {
|
|
15514
15529
|
const newMatch = newHubs.find((h) => path3.basename(h.hubFolder) === selector);
|
|
15515
15530
|
if (newMatch) return { ok: true, hub: newMatch };
|
|
15516
15531
|
const existingMatch = existingHubs.find(
|
|
@@ -16084,6 +16099,38 @@ function shouldInterceptHelp(command2, args2, ownHelpCommands) {
|
|
|
16084
16099
|
if (ownHelpCommands.has(command2)) return false;
|
|
16085
16100
|
return wantsHelp(args2);
|
|
16086
16101
|
}
|
|
16102
|
+
function isDryRunToken(arg) {
|
|
16103
|
+
return /^--dry-run(=\S*)?$/.test(arg);
|
|
16104
|
+
}
|
|
16105
|
+
function unreadDryRunRefusal(invocation, token, readsBare) {
|
|
16106
|
+
const only = readsBare ? " (only a bare `--dry-run`)" : "";
|
|
16107
|
+
return `\`${invocation}\` does not read \`${sanitizeTerminalText(token)}\`${only}, so it is refused rather than run without it.`;
|
|
16108
|
+
}
|
|
16109
|
+
function entryFlagRefusal(command2, args2, dataNamespaces) {
|
|
16110
|
+
if (command2 === void 0 || ["help", "--help", "-h", "--version", "-v"].includes(command2)) return null;
|
|
16111
|
+
if (dataNamespaces.has(command2)) return null;
|
|
16112
|
+
const words = [command2];
|
|
16113
|
+
for (const arg of args2.slice(0, 2)) {
|
|
16114
|
+
if (!/^[a-z][a-z-]*$/.test(arg)) break;
|
|
16115
|
+
words.push(arg);
|
|
16116
|
+
}
|
|
16117
|
+
const invocation = `wayai ${words.join(" ")}`;
|
|
16118
|
+
let parsed;
|
|
16119
|
+
for (let n = words.length; n > 0 && parsed === void 0; n--) {
|
|
16120
|
+
parsed = PARSED_BY_THE_COMMAND.get(words.slice(0, n).join(" "));
|
|
16121
|
+
}
|
|
16122
|
+
if (parsed === "all") return null;
|
|
16123
|
+
const dryRuns = args2.filter(isDryRunToken);
|
|
16124
|
+
const readsBare = parsed === "bare --dry-run";
|
|
16125
|
+
const refused = readsBare ? dryRuns.find((token) => token !== "--dry-run") : dryRuns[0];
|
|
16126
|
+
if (refused !== void 0) return unreadDryRunRefusal(invocation, refused, readsBare);
|
|
16127
|
+
if (parsed === "selectors") return null;
|
|
16128
|
+
for (const { flag, noun } of SELECTOR_FLAGS) {
|
|
16129
|
+
const empty = args2.some((arg, i) => arg === `${flag}=` || arg === flag && (args2[i + 1] ?? "") === "");
|
|
16130
|
+
if (empty) return `\`${invocation} ${flag}\` needs ${noun}, and none followed it.`;
|
|
16131
|
+
}
|
|
16132
|
+
return null;
|
|
16133
|
+
}
|
|
16087
16134
|
function isNewerVersion(latest, current) {
|
|
16088
16135
|
const strip = (v) => v.replace(/[-+].*$/, "");
|
|
16089
16136
|
const l = strip(latest).split(".").map(Number);
|
|
@@ -16115,12 +16162,13 @@ function resolveSecretSource(source) {
|
|
|
16115
16162
|
}
|
|
16116
16163
|
return "prompt";
|
|
16117
16164
|
}
|
|
16118
|
-
var UUID_RE3, slugify2, OWN_HELP_COMMANDS;
|
|
16165
|
+
var UUID_RE3, slugify2, OWN_HELP_COMMANDS, PARSED_BY_THE_COMMAND, SELECTOR_FLAGS;
|
|
16119
16166
|
var init_utils = __esm({
|
|
16120
16167
|
"src/lib/utils.ts"() {
|
|
16121
16168
|
"use strict";
|
|
16122
16169
|
init_dist();
|
|
16123
16170
|
init_expected();
|
|
16171
|
+
init_terminal_output();
|
|
16124
16172
|
UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
16125
16173
|
slugify2 = slugifySkillName;
|
|
16126
16174
|
OWN_HELP_COMMANDS = /* @__PURE__ */ new Set([
|
|
@@ -16131,6 +16179,23 @@ var init_utils = __esm({
|
|
|
16131
16179
|
"alerts",
|
|
16132
16180
|
"communities"
|
|
16133
16181
|
]);
|
|
16182
|
+
PARSED_BY_THE_COMMAND = /* @__PURE__ */ new Map([
|
|
16183
|
+
["pull", "all"],
|
|
16184
|
+
["push", "all"],
|
|
16185
|
+
["communities", "all"],
|
|
16186
|
+
["sync-mcp", "bare --dry-run"],
|
|
16187
|
+
["admin hubs repair-team-orphans", "bare --dry-run"],
|
|
16188
|
+
["admin hubs repair-branching-orphans", "bare --dry-run"],
|
|
16189
|
+
["admin orgs repair-legacy-grants", "bare --dry-run"],
|
|
16190
|
+
["admin harness mass-destroy", "bare --dry-run"],
|
|
16191
|
+
["use", "selectors"],
|
|
16192
|
+
["unbind", "selectors"],
|
|
16193
|
+
["unlock", "selectors"]
|
|
16194
|
+
]);
|
|
16195
|
+
SELECTOR_FLAGS = [
|
|
16196
|
+
{ flag: "--hub", noun: "a hub" },
|
|
16197
|
+
{ flag: "--org", noun: "an organization" }
|
|
16198
|
+
];
|
|
16134
16199
|
}
|
|
16135
16200
|
});
|
|
16136
16201
|
|
|
@@ -19559,21 +19624,6 @@ var init_hub_materializer = __esm({
|
|
|
19559
19624
|
}
|
|
19560
19625
|
});
|
|
19561
19626
|
|
|
19562
|
-
// src/lib/terminal-output.ts
|
|
19563
|
-
import { stripVTControlCharacters } from "util";
|
|
19564
|
-
function sanitizeTerminalText(value) {
|
|
19565
|
-
const normalizedNewlines = value.replace(/\r\n?/g, "\n");
|
|
19566
|
-
return stripVTControlCharacters(normalizedNewlines).replace(
|
|
19567
|
-
/[\u0000-\u0009\u000b-\u001f\u007f-\u009f]/g,
|
|
19568
|
-
""
|
|
19569
|
-
);
|
|
19570
|
-
}
|
|
19571
|
-
var init_terminal_output = __esm({
|
|
19572
|
-
"src/lib/terminal-output.ts"() {
|
|
19573
|
-
"use strict";
|
|
19574
|
-
}
|
|
19575
|
-
});
|
|
19576
|
-
|
|
19577
19627
|
// src/lib/base-workspace.ts
|
|
19578
19628
|
import * as fs15 from "fs";
|
|
19579
19629
|
import * as path19 from "path";
|
|
@@ -19637,7 +19687,7 @@ function assertValidBaseSelector(selector, source = "base") {
|
|
|
19637
19687
|
}
|
|
19638
19688
|
function resolveBaseTarget(gitRoot, selector, cwd = process.cwd()) {
|
|
19639
19689
|
const basesDir = resolveBasesDir(gitRoot);
|
|
19640
|
-
if (selector) {
|
|
19690
|
+
if (selector !== void 0) {
|
|
19641
19691
|
const folder = folderForSelector(basesDir, selector);
|
|
19642
19692
|
if (!isUnder(basesDir, folder)) {
|
|
19643
19693
|
throw expected(`Refusing to target ${folder}: it is outside ${basesDir}.`);
|
|
@@ -19837,7 +19887,7 @@ function routeToSubtree(options) {
|
|
|
19837
19887
|
const cwd = options.cwd ?? process.cwd();
|
|
19838
19888
|
const tokens2 = parseRoutingTokens(args2);
|
|
19839
19889
|
const { hubFlag, baseFlag, communityFlag, positional, orgFlag } = tokens2;
|
|
19840
|
-
if (orgFlag !== void 0) {
|
|
19890
|
+
if (orgFlag !== void 0 || args2.includes("--org")) {
|
|
19841
19891
|
return {
|
|
19842
19892
|
ok: false,
|
|
19843
19893
|
refusal: [
|
|
@@ -19849,6 +19899,10 @@ function routeToSubtree(options) {
|
|
|
19849
19899
|
].join("\n")
|
|
19850
19900
|
};
|
|
19851
19901
|
}
|
|
19902
|
+
const valuedDryRun = args2.find((arg) => isDryRunToken(arg) && arg !== "--dry-run");
|
|
19903
|
+
if (valuedDryRun !== void 0) {
|
|
19904
|
+
return { ok: false, refusal: unreadDryRunRefusal(`wayai ${verb}`, valuedDryRun, true) };
|
|
19905
|
+
}
|
|
19852
19906
|
if (tokens2.takenAsValue) {
|
|
19853
19907
|
const { flag: flag2, by } = tokens2.takenAsValue;
|
|
19854
19908
|
return {
|
|
@@ -19869,7 +19923,23 @@ function routeToSubtree(options) {
|
|
|
19869
19923
|
if (flagged.length > 1) {
|
|
19870
19924
|
return { ok: false, refusal: mixedInvocationRefusal(verb, flagged) };
|
|
19871
19925
|
}
|
|
19926
|
+
if (positional === "") {
|
|
19927
|
+
return {
|
|
19928
|
+
ok: false,
|
|
19929
|
+
refusal: `\`wayai ${verb} ""\` names nothing, so it is refused rather than run on a folder it did not name.`
|
|
19930
|
+
};
|
|
19931
|
+
}
|
|
19872
19932
|
const fromPositional = positional !== void 0 ? resolveSelectorSubtree(layout, positional, cwd) : void 0;
|
|
19933
|
+
if (positional !== void 0 && fromPositional && fromPositional.kind !== "both" && fromPositional.kind !== "unknown" && fromPositional.target === "") {
|
|
19934
|
+
const { kind } = fromPositional;
|
|
19935
|
+
const { target, value } = SUBTREE_FLAGS.find(({ subtree }) => subtree === kind);
|
|
19936
|
+
const dir = `${SUBDIR[kind]}/`;
|
|
19937
|
+
return {
|
|
19938
|
+
ok: false,
|
|
19939
|
+
refusal: `\`wayai ${verb} ${sanitizeTerminalText(positional)}\` names ${dir}, not ${target} in it, so it is refused rather than run on a folder it did not name.
|
|
19940
|
+
wayai ${verb} ${dir}${value}`
|
|
19941
|
+
};
|
|
19942
|
+
}
|
|
19873
19943
|
if (fromPositional?.kind === "both") {
|
|
19874
19944
|
return {
|
|
19875
19945
|
ok: false,
|
|
@@ -19933,6 +20003,7 @@ var init_subtree_routing = __esm({
|
|
|
19933
20003
|
"use strict";
|
|
19934
20004
|
init_layout();
|
|
19935
20005
|
init_terminal_output();
|
|
20006
|
+
init_utils();
|
|
19936
20007
|
init_workspace_manifest();
|
|
19937
20008
|
init_workspace();
|
|
19938
20009
|
init_base_workspace();
|
|
@@ -24102,7 +24173,7 @@ async function pushSingleHub(client, hubId, hubFolder, autoConfirm, organization
|
|
|
24102
24173
|
return true;
|
|
24103
24174
|
}
|
|
24104
24175
|
function selectExistingHub(workspaceDir, allHubs, selector, wsLabel) {
|
|
24105
|
-
if (selector) {
|
|
24176
|
+
if (selector !== void 0) {
|
|
24106
24177
|
const match = allHubs.find(
|
|
24107
24178
|
(h) => h.hubId === selector || path28.basename(h.hubFolder) === selector
|
|
24108
24179
|
);
|
|
@@ -24287,7 +24358,7 @@ function resolveHubTarget(workspaceDir, selector) {
|
|
|
24287
24358
|
const gitRoot = findGitRoot();
|
|
24288
24359
|
const wsLabel = hubsDirLabel(gitRoot);
|
|
24289
24360
|
const allHubs = scanWorkspaceHubs(workspaceDir);
|
|
24290
|
-
if (selector) {
|
|
24361
|
+
if (selector !== void 0) {
|
|
24291
24362
|
const match = allHubs.find(
|
|
24292
24363
|
(h) => h.hubId === selector || path29.basename(h.hubFolder) === selector
|
|
24293
24364
|
);
|
|
@@ -24510,7 +24581,8 @@ var init_pull = __esm({
|
|
|
24510
24581
|
// src/commands/create.ts
|
|
24511
24582
|
var create_exports = {};
|
|
24512
24583
|
__export(create_exports, {
|
|
24513
|
-
createCommand: () => createCommand
|
|
24584
|
+
createCommand: () => createCommand,
|
|
24585
|
+
parseArgs: () => parseArgs8
|
|
24514
24586
|
});
|
|
24515
24587
|
import * as path30 from "path";
|
|
24516
24588
|
import * as fs22 from "fs";
|
|
@@ -24522,7 +24594,7 @@ function parseArgs8(args2) {
|
|
|
24522
24594
|
const arg = args2[i];
|
|
24523
24595
|
if (arg === "--yes" || arg === "-y") {
|
|
24524
24596
|
autoConfirm = true;
|
|
24525
|
-
} else if (arg === "--label"
|
|
24597
|
+
} else if (arg === "--label") {
|
|
24526
24598
|
label = args2[++i];
|
|
24527
24599
|
} else if (!arg.startsWith("-") && folderSelector === void 0) {
|
|
24528
24600
|
folderSelector = arg;
|
|
@@ -24672,6 +24744,7 @@ var init_diff = __esm({
|
|
|
24672
24744
|
// src/commands/replicate.ts
|
|
24673
24745
|
var replicate_exports = {};
|
|
24674
24746
|
__export(replicate_exports, {
|
|
24747
|
+
parseArgs: () => parseArgs10,
|
|
24675
24748
|
replicateCommand: () => replicateCommand
|
|
24676
24749
|
});
|
|
24677
24750
|
import * as fs23 from "fs";
|
|
@@ -24681,7 +24754,7 @@ function parseArgs10(args2) {
|
|
|
24681
24754
|
let hubSelector;
|
|
24682
24755
|
for (let i = 0; i < args2.length; i++) {
|
|
24683
24756
|
const arg = args2[i];
|
|
24684
|
-
if (arg === "--label"
|
|
24757
|
+
if (arg === "--label") {
|
|
24685
24758
|
label = args2[++i];
|
|
24686
24759
|
} else if (arg === "--hub" && args2[i + 1]) {
|
|
24687
24760
|
hubSelector = args2[++i];
|
|
@@ -37258,6 +37331,11 @@ async function main() {
|
|
|
37258
37331
|
await printHelp3();
|
|
37259
37332
|
return;
|
|
37260
37333
|
}
|
|
37334
|
+
const flagRefusal = entryFlagRefusal(command, args, new Set(DATA_NAMESPACES));
|
|
37335
|
+
if (flagRefusal) {
|
|
37336
|
+
console.error(flagRefusal);
|
|
37337
|
+
process.exit(1);
|
|
37338
|
+
}
|
|
37261
37339
|
if (command && !wantsHelp(args)) {
|
|
37262
37340
|
const { findGitRoot: findGitRoot2 } = await Promise.resolve().then(() => (init_workspace(), workspace_exports));
|
|
37263
37341
|
const { healSkillLinkForCommand: healSkillLinkForCommand2 } = await Promise.resolve().then(() => (init_skill_symlink(), skill_symlink_exports));
|