@codyn06/cboard 0.3.0 → 0.3.2
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/README.md +6 -2
- package/kit/cboard-connect.js +42 -19
- package/kit/cboard-kit/connect-check.js +7 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ graph, and checks that the connection works.
|
|
|
7
7
|
Requires Node 20 or newer. No native modules and no install scripts.
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npx @codyn06/cboard connect
|
|
10
|
+
npx @codyn06/cboard connect # browser login and project selection
|
|
11
11
|
npx @codyn06/cboard sync # sync the committed code to the graph
|
|
12
12
|
npx @codyn06/cboard check # is the token accepted, is the project visible?
|
|
13
13
|
npx @codyn06/cboard connect --goal "<one line>" # record the project goal as a requirement node
|
|
@@ -19,7 +19,7 @@ Or install it once and use the `cboard` command directly:
|
|
|
19
19
|
|
|
20
20
|
```sh
|
|
21
21
|
npm install --global @codyn06/cboard
|
|
22
|
-
cboard connect
|
|
22
|
+
cboard connect
|
|
23
23
|
cboard sync
|
|
24
24
|
cboard check
|
|
25
25
|
```
|
|
@@ -39,6 +39,10 @@ changed. `cboard connect` also keeps the generated files on LF with a marked `#
|
|
|
39
39
|
|
|
40
40
|
## The token
|
|
41
41
|
|
|
42
|
+
`cboard connect` opens browser device login and saves the token to the repository's ignored
|
|
43
|
+
`.cboard/token` file. To configure a repository before signing in, use
|
|
44
|
+
`cboard connect --project <project-uuid> --no-login`, then save a token manually.
|
|
45
|
+
|
|
42
46
|
Create a token in the cboard web app (the "Agent tokens" button in the project header; members pick
|
|
43
47
|
`graph:read`, `graph:contribute` and `graph:context`, viewers are read-only) and save it to `.cboard/token` in the repository
|
|
44
48
|
(`connect` adds it to `.gitignore`), or export it as `CBOARD_PAT`. The repository's token file takes
|
package/kit/cboard-connect.js
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
// `.claude/settings.json`, adds a marked block to AGENTS.md, installs the `cboard-graph` Claude Code
|
|
10
10
|
// skill (`.claude/skills/cboard-graph/SKILL.md`), keeps the token file out of Git, and keeps the
|
|
11
11
|
// generated files on LF line endings with a marked block in `.gitattributes`.
|
|
12
|
-
// Without a usable token
|
|
13
|
-
//
|
|
12
|
+
// Without a usable token, omit --project to log in in the browser (device flow; the project is
|
|
13
|
+
// chosen there), or pass --no-login to write configuration only. It never prints a token.
|
|
14
|
+
// Rerunning with the same arguments changes nothing.
|
|
14
15
|
//
|
|
15
16
|
// Merge policy for an existing `mcpServers.cboard` entry in `.mcp.json`: other servers, other keys
|
|
16
17
|
// and key order are untouched. Extra keys a user added to the cboard entry are kept. `type` is set
|
|
@@ -85,6 +86,7 @@ export function kitVersion() {
|
|
|
85
86
|
export const KIT_FILES = [
|
|
86
87
|
"config.js",
|
|
87
88
|
"mcp.js",
|
|
89
|
+
"wait.js",
|
|
88
90
|
"headers.js",
|
|
89
91
|
"connect-check.js",
|
|
90
92
|
"brief.js",
|
|
@@ -569,8 +571,8 @@ export function connect(options = {}) {
|
|
|
569
571
|
if (options.codex) {
|
|
570
572
|
lines.push(
|
|
571
573
|
"",
|
|
572
|
-
"Codex (~/.codex/config.toml;
|
|
573
|
-
"
|
|
574
|
+
"Codex (~/.codex/config.toml; load the repository token into the environment before starting Codex,",
|
|
575
|
+
"using the bearer_token_env_var below):",
|
|
574
576
|
" [mcp_servers.cboard]",
|
|
575
577
|
` url = "${server}/mcp"`,
|
|
576
578
|
` bearer_token_env_var = "${config.tokenEnv}"`,
|
|
@@ -586,24 +588,24 @@ export function connect(options = {}) {
|
|
|
586
588
|
};
|
|
587
589
|
}
|
|
588
590
|
|
|
589
|
-
/**
|
|
590
|
-
async function tokenUsable({ repo, env, server, tokenRel, fetchImpl }) {
|
|
591
|
+
/** Distinguishes missing and rejected tokens; a network failure is not a rejection. */
|
|
592
|
+
async function tokenUsable({ repo, env, server, tokenRel, project, fetchImpl }) {
|
|
591
593
|
let config;
|
|
592
594
|
try {
|
|
593
595
|
// CBOARD_GRAPH_URL stands in for the target server; the trust check below replaces resolveConfig's.
|
|
594
596
|
config = resolveConfig({ ...env, CBOARD_GRAPH_URL: server }, repo);
|
|
595
597
|
} catch {
|
|
596
|
-
return
|
|
598
|
+
return "usable"; // connect() reports the configuration problem as it always did.
|
|
597
599
|
}
|
|
598
600
|
const token =
|
|
599
601
|
readToken(config, env) || readToken({ ...config, tokenFile: join(repo, tokenRel) }, env);
|
|
600
|
-
if (!token) return
|
|
602
|
+
if (!token) return "missing";
|
|
601
603
|
// Never send a token to a server the user has not trusted; assume it works.
|
|
602
604
|
if (config.hosted && !isTrustedServer(server, { ...env, CBOARD_GRAPH_URL: undefined })) {
|
|
603
|
-
return
|
|
605
|
+
return "usable";
|
|
604
606
|
}
|
|
605
607
|
try {
|
|
606
|
-
await retryWake(
|
|
608
|
+
const listed = await retryWake(
|
|
607
609
|
(attemptMs) =>
|
|
608
610
|
mcpCall({
|
|
609
611
|
api: config.api,
|
|
@@ -614,14 +616,22 @@ async function tokenUsable({ repo, env, server, tokenRel, fetchImpl }) {
|
|
|
614
616
|
}),
|
|
615
617
|
{ budgetMs: config.hosted ? 60_000 : 0 },
|
|
616
618
|
);
|
|
619
|
+
if (
|
|
620
|
+
project &&
|
|
621
|
+
UUID.test(project) &&
|
|
622
|
+
Array.isArray(listed?.data) &&
|
|
623
|
+
!listed.data.some((entry) => entry?.id === project.toLowerCase())
|
|
624
|
+
) {
|
|
625
|
+
return "wrong_project";
|
|
626
|
+
}
|
|
617
627
|
} catch (error) {
|
|
618
|
-
return
|
|
628
|
+
return error instanceof McpError && error.kind === "unauthorized" ? "rejected" : "usable";
|
|
619
629
|
}
|
|
620
|
-
return
|
|
630
|
+
return "usable";
|
|
621
631
|
}
|
|
622
632
|
|
|
623
633
|
/**
|
|
624
|
-
* `connect`, preceded by the browser (device) login when
|
|
634
|
+
* `connect`, preceded by the browser (device) login when there is no usable token and no --project.
|
|
625
635
|
* The token is written to the repository's token file before `connect` runs, so `connect` keeps it
|
|
626
636
|
* out of Git. `login` injects the network, browser and clock for tests.
|
|
627
637
|
* `noLogin` skips the token check and the login (the pre-login behaviour).
|
|
@@ -655,9 +665,27 @@ export async function connectWithLogin(options = {}) {
|
|
|
655
665
|
} catch (error) {
|
|
656
666
|
throw new ConnectError(error instanceof Error ? error.message : String(error));
|
|
657
667
|
}
|
|
658
|
-
|
|
668
|
+
const tokenStatus = await tokenUsable({
|
|
669
|
+
repo,
|
|
670
|
+
env,
|
|
671
|
+
server,
|
|
672
|
+
tokenRel,
|
|
673
|
+
project: options.project,
|
|
674
|
+
fetchImpl: login.fetchImpl,
|
|
675
|
+
});
|
|
676
|
+
if (tokenStatus === "usable") {
|
|
659
677
|
return connect(rest);
|
|
660
678
|
}
|
|
679
|
+
if (options.project) {
|
|
680
|
+
const reason = {
|
|
681
|
+
missing: "is missing",
|
|
682
|
+
rejected: "was rejected by the server",
|
|
683
|
+
wrong_project: `does not have access to project ${options.project}`,
|
|
684
|
+
}[tokenStatus];
|
|
685
|
+
throw new ConnectError(
|
|
686
|
+
`--project needs a usable token: token ${reason} (${tokenRel.replaceAll("\\", "/")} or $CBOARD_PAT); rerun without --project to log in in the browser, or pass --no-login to write the configuration only`,
|
|
687
|
+
);
|
|
688
|
+
}
|
|
661
689
|
const interactive = login.interactive ?? (Boolean(process.stdout.isTTY) && !env.CI);
|
|
662
690
|
const granted = await deviceLogin({
|
|
663
691
|
server,
|
|
@@ -679,11 +707,6 @@ export async function connectWithLogin(options = {}) {
|
|
|
679
707
|
rmSync(tokenFile, { force: true });
|
|
680
708
|
throw error;
|
|
681
709
|
}
|
|
682
|
-
if (options.project && options.project !== granted.projectId) {
|
|
683
|
-
result.warnings.push(
|
|
684
|
-
`you approved project ${granted.projectId} in the browser, not the --project ${options.project} you passed`,
|
|
685
|
-
);
|
|
686
|
-
}
|
|
687
710
|
return {
|
|
688
711
|
...result,
|
|
689
712
|
lines: [
|
|
@@ -66,7 +66,7 @@ async function checkMain(config, env, { fetchImpl, timeoutMs, wake }) {
|
|
|
66
66
|
if (config.projectId && !projects.some((p) => p.id === config.projectId)) {
|
|
67
67
|
return {
|
|
68
68
|
code: 1,
|
|
69
|
-
message: `connected to ${config.api}, but project ${config.projectId} is not visible to this token; ${tokenFix(config)}`,
|
|
69
|
+
message: `connected to ${config.api}, but project ${config.projectId} is not visible to this token: project not found or deleted; ${tokenFix(config)}`,
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
// Optional: an older server lacks whoami; any failure keeps the plain message. One short try only.
|
|
@@ -80,9 +80,12 @@ async function checkMain(config, env, { fetchImpl, timeoutMs, wake }) {
|
|
|
80
80
|
}),
|
|
81
81
|
);
|
|
82
82
|
const info = me ? describeWhoami(me) : null;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
const archived = projects.some((p) => p.id === config.projectId && p.archived === true);
|
|
84
|
+
const head = archived
|
|
85
|
+
? "CONNECTED (archived, read-only)"
|
|
86
|
+
: info?.readOnly
|
|
87
|
+
? "CONNECTED (read-only): you can query, not contribute"
|
|
88
|
+
: "CONNECTED";
|
|
86
89
|
const tail = info?.warning ? `; ${info.warning}` : "";
|
|
87
90
|
return { code: 0, message: `${head} (${config.api}/mcp)${tail}` };
|
|
88
91
|
}
|