@bridge-ds/cli 0.3.0 → 0.3.1
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 +30 -8
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { existsSync as existsSync5 } from "node:fs";
|
|
5
5
|
import { readFile as readFile5, writeFile as writeFile4 } from "node:fs/promises";
|
|
6
|
-
import { join as join5, relative as relative4, resolve as resolve3 } from "node:path";
|
|
6
|
+
import { isAbsolute, join as join5, relative as relative4, resolve as resolve3 } from "node:path";
|
|
7
7
|
|
|
8
8
|
// ../core/src/audit/types.ts
|
|
9
9
|
var AUDIT_SCHEMA_VERSION = 1;
|
|
@@ -2865,6 +2865,25 @@ var GitHubClient = class _GitHubClient {
|
|
|
2865
2865
|
throw new GitHubError(422, `GitHub refused to mark #${n} ready for review${detail ? `: ${detail}` : "."} Use "Ready for review" on GitHub instead.`, detail);
|
|
2866
2866
|
}
|
|
2867
2867
|
}
|
|
2868
|
+
/**
|
|
2869
|
+
* Turns an open pull request back into a draft: the GraphQL mutation convertPullRequestToDraft (REST cannot set
|
|
2870
|
+
* `draft` either), same token. No-op when it is already a draft.
|
|
2871
|
+
*/
|
|
2872
|
+
async convertToDraft(n) {
|
|
2873
|
+
this.assertToken("Turning a pull request back into a draft");
|
|
2874
|
+
const pr = await this.request("GET", `${this.repoPath}/pulls/${n}`);
|
|
2875
|
+
if (pr.draft === true) return;
|
|
2876
|
+
if (pr.state && pr.state !== "open") throw new GitHubError(422, `Pull request #${n} is ${pr.state}: only an open one can go back to draft.`);
|
|
2877
|
+
if (!pr.node_id) throw new GitHubError(422, `Pull request #${n} has no node id: convert it to draft on GitHub.`);
|
|
2878
|
+
const r = await this.request("POST", "/graphql", {
|
|
2879
|
+
query: "mutation($id: ID!) { convertPullRequestToDraft(input: { pullRequestId: $id }) { pullRequest { number isDraft } } }",
|
|
2880
|
+
variables: { id: pr.node_id }
|
|
2881
|
+
});
|
|
2882
|
+
if (r?.errors?.length) {
|
|
2883
|
+
const detail = r.errors.map((e) => e.message).filter(Boolean).join(" ");
|
|
2884
|
+
throw new GitHubError(422, `GitHub refused to turn #${n} back into a draft${detail ? `: ${detail}` : "."} Use "Convert to draft" on GitHub instead.`, detail);
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2868
2887
|
async createPullRequest(input) {
|
|
2869
2888
|
this.assertWritableBranch(input.head, input.base);
|
|
2870
2889
|
const r = await this.request(
|
|
@@ -4747,6 +4766,7 @@ async function context2(root, io) {
|
|
|
4747
4766
|
const token = io.env.BRIDGE_GITHUB_TOKEN || io.env.GITHUB_TOKEN || io.ghToken();
|
|
4748
4767
|
return BridgeContext3.create({ root, ...token ? { token } : {}, ...io.fetch ? { fetch: io.fetch } : {} });
|
|
4749
4768
|
}
|
|
4769
|
+
var exploreSource = (env) => ({ source: "cli", ...env.CLAUDECODE ? { agent: "claude" } : {} });
|
|
4750
4770
|
var date = (iso) => iso ? iso.slice(0, 10) : "";
|
|
4751
4771
|
async function runExplore(a, root, io = defaultIO()) {
|
|
4752
4772
|
const sub = a._[1];
|
|
@@ -4762,7 +4782,7 @@ async function runExplore(a, root, io = defaultIO()) {
|
|
|
4762
4782
|
if (!name || !purpose) throw new RequestUsageError('Usage: bridge explore start <name> --purpose "What you want to learn"');
|
|
4763
4783
|
const useCase = flag2(a, "use-case");
|
|
4764
4784
|
const ctx = await context2(root, io);
|
|
4765
|
-
const r = await explorations.startExploration(ctx, { name, purpose, ...useCase ? { useCase } : {}, ...a.flags.experimental ? { experimental: a.flags.experimental } : {}, dryRun: has2(a, "dry-run") });
|
|
4785
|
+
const r = await explorations.startExploration(ctx, { name, purpose, ...exploreSource(io.env), ...useCase ? { useCase } : {}, ...a.flags.experimental ? { experimental: a.flags.experimental } : {}, dryRun: has2(a, "dry-run") });
|
|
4766
4786
|
if (json) return io.print(JSON.stringify(r, null, 2)), 0;
|
|
4767
4787
|
if (r.status === "dry-run") {
|
|
4768
4788
|
io.print(`Dry run, nothing written.
|
|
@@ -4865,6 +4885,7 @@ async function rolesReport(opts) {
|
|
|
4865
4885
|
|
|
4866
4886
|
// src/index.ts
|
|
4867
4887
|
import { brand, BridgeContext as BridgeContext4, CONFIG_FILE as CONFIG_FILE2, core, detectConfig, GitRefSource, history as hist, LocalSource, ops, optionsFromArgv, serveStdio, toConfigJson, VERSION } from "@bridge-ds/mcp";
|
|
4888
|
+
var MCP_PACKAGE = "@bridge-ds/mcp";
|
|
4868
4889
|
var HELP = `bridge ${VERSION}: design system as code, for you and your Claude
|
|
4869
4890
|
|
|
4870
4891
|
Usage:
|
|
@@ -4970,18 +4991,19 @@ async function init(a, root) {
|
|
|
4970
4991
|
}
|
|
4971
4992
|
const serverJs = fileURLToPath(new URL("./index.js", import.meta.resolve("@bridge-ds/mcp")));
|
|
4972
4993
|
const relServer = relative4(root, serverJs);
|
|
4973
|
-
const inRepo = !relServer.startsWith("..");
|
|
4994
|
+
const inRepo = !relServer.startsWith("..") && !isAbsolute(relServer);
|
|
4995
|
+
const server = (dir) => inRepo ? { command: "node", args: [relServer, "--root", dir] } : { command: "npx", args: ["-y", MCP_PACKAGE, "--root", dir] };
|
|
4974
4996
|
const mcpPath = join5(root, ".mcp.json");
|
|
4975
4997
|
const existing = existsSync5(mcpPath) ? JSON.parse(await readFile5(mcpPath, "utf8")) : {};
|
|
4976
|
-
existing.mcpServers = { ...existing.mcpServers ?? {}, bridge:
|
|
4998
|
+
existing.mcpServers = { ...existing.mcpServers ?? {}, bridge: server(".") };
|
|
4977
4999
|
await writeFile4(mcpPath, `${JSON.stringify(existing, null, 2)}
|
|
4978
5000
|
`);
|
|
4979
5001
|
print(`Wrote .mcp.json: Claude Code picks up the "bridge" server next time it starts in ${root}.`);
|
|
5002
|
+
const desktop = inRepo ? { command: "node", args: [serverJs, "--root", root] } : server(root);
|
|
4980
5003
|
print("\nClaude Desktop: add this to claude_desktop_config.json (Settings > Developer > Edit config):");
|
|
4981
|
-
print(JSON.stringify({ mcpServers: { bridge:
|
|
5004
|
+
print(JSON.stringify({ mcpServers: { bridge: desktop } }, null, 2));
|
|
4982
5005
|
print("\nOr with the Claude Code CLI:");
|
|
4983
|
-
print(` claude mcp add bridge --
|
|
4984
|
-
print("(Once @bridge-ds/mcp is published: claude mcp add bridge -- npx -y @bridge-ds/mcp)");
|
|
5006
|
+
print(` claude mcp add bridge -- ${desktop.command} ${desktop.args.join(" ")}`);
|
|
4985
5007
|
}
|
|
4986
5008
|
async function check(a, root) {
|
|
4987
5009
|
const ctx = await BridgeContext4.create({ root });
|
|
@@ -5387,7 +5409,7 @@ async function main() {
|
|
|
5387
5409
|
if (cmd === "explore") return runExplore(a, root);
|
|
5388
5410
|
if (!cmd || has3(a, "help") || cmd === "help") {
|
|
5389
5411
|
print(HELP);
|
|
5390
|
-
return cmd ? 0 : 2;
|
|
5412
|
+
return cmd || has3(a, "help") ? 0 : 2;
|
|
5391
5413
|
}
|
|
5392
5414
|
if (cmd === "--version" || cmd === "version") return print(VERSION), 0;
|
|
5393
5415
|
switch (cmd) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bridge-ds/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "bridge CLI: set up Bridge in a design system repo, check tokens in CI, search and diff tokens, propose changes, start the MCP server.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"build:package": "node ../../scripts/build-packages.mjs cli"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@bridge-ds/mcp": "^0.3.
|
|
47
|
-
"@bridge-ds/visual": "^0.2.
|
|
46
|
+
"@bridge-ds/mcp": "^0.3.1",
|
|
47
|
+
"@bridge-ds/visual": "^0.2.2",
|
|
48
48
|
"typescript": "5.9.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|