@codyn06/cboard 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/README.md +6 -2
- package/kit/cboard-connect.js +41 -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
|
|
@@ -569,8 +570,8 @@ export function connect(options = {}) {
|
|
|
569
570
|
if (options.codex) {
|
|
570
571
|
lines.push(
|
|
571
572
|
"",
|
|
572
|
-
"Codex (~/.codex/config.toml;
|
|
573
|
-
"
|
|
573
|
+
"Codex (~/.codex/config.toml; load the repository token into the environment before starting Codex,",
|
|
574
|
+
"using the bearer_token_env_var below):",
|
|
574
575
|
" [mcp_servers.cboard]",
|
|
575
576
|
` url = "${server}/mcp"`,
|
|
576
577
|
` bearer_token_env_var = "${config.tokenEnv}"`,
|
|
@@ -586,24 +587,24 @@ export function connect(options = {}) {
|
|
|
586
587
|
};
|
|
587
588
|
}
|
|
588
589
|
|
|
589
|
-
/**
|
|
590
|
-
async function tokenUsable({ repo, env, server, tokenRel, fetchImpl }) {
|
|
590
|
+
/** Distinguishes missing and rejected tokens; a network failure is not a rejection. */
|
|
591
|
+
async function tokenUsable({ repo, env, server, tokenRel, project, fetchImpl }) {
|
|
591
592
|
let config;
|
|
592
593
|
try {
|
|
593
594
|
// CBOARD_GRAPH_URL stands in for the target server; the trust check below replaces resolveConfig's.
|
|
594
595
|
config = resolveConfig({ ...env, CBOARD_GRAPH_URL: server }, repo);
|
|
595
596
|
} catch {
|
|
596
|
-
return
|
|
597
|
+
return "usable"; // connect() reports the configuration problem as it always did.
|
|
597
598
|
}
|
|
598
599
|
const token =
|
|
599
600
|
readToken(config, env) || readToken({ ...config, tokenFile: join(repo, tokenRel) }, env);
|
|
600
|
-
if (!token) return
|
|
601
|
+
if (!token) return "missing";
|
|
601
602
|
// Never send a token to a server the user has not trusted; assume it works.
|
|
602
603
|
if (config.hosted && !isTrustedServer(server, { ...env, CBOARD_GRAPH_URL: undefined })) {
|
|
603
|
-
return
|
|
604
|
+
return "usable";
|
|
604
605
|
}
|
|
605
606
|
try {
|
|
606
|
-
await retryWake(
|
|
607
|
+
const listed = await retryWake(
|
|
607
608
|
(attemptMs) =>
|
|
608
609
|
mcpCall({
|
|
609
610
|
api: config.api,
|
|
@@ -614,14 +615,22 @@ async function tokenUsable({ repo, env, server, tokenRel, fetchImpl }) {
|
|
|
614
615
|
}),
|
|
615
616
|
{ budgetMs: config.hosted ? 60_000 : 0 },
|
|
616
617
|
);
|
|
618
|
+
if (
|
|
619
|
+
project &&
|
|
620
|
+
UUID.test(project) &&
|
|
621
|
+
Array.isArray(listed?.data) &&
|
|
622
|
+
!listed.data.some((entry) => entry?.id === project.toLowerCase())
|
|
623
|
+
) {
|
|
624
|
+
return "wrong_project";
|
|
625
|
+
}
|
|
617
626
|
} catch (error) {
|
|
618
|
-
return
|
|
627
|
+
return error instanceof McpError && error.kind === "unauthorized" ? "rejected" : "usable";
|
|
619
628
|
}
|
|
620
|
-
return
|
|
629
|
+
return "usable";
|
|
621
630
|
}
|
|
622
631
|
|
|
623
632
|
/**
|
|
624
|
-
* `connect`, preceded by the browser (device) login when
|
|
633
|
+
* `connect`, preceded by the browser (device) login when there is no usable token and no --project.
|
|
625
634
|
* The token is written to the repository's token file before `connect` runs, so `connect` keeps it
|
|
626
635
|
* out of Git. `login` injects the network, browser and clock for tests.
|
|
627
636
|
* `noLogin` skips the token check and the login (the pre-login behaviour).
|
|
@@ -655,9 +664,27 @@ export async function connectWithLogin(options = {}) {
|
|
|
655
664
|
} catch (error) {
|
|
656
665
|
throw new ConnectError(error instanceof Error ? error.message : String(error));
|
|
657
666
|
}
|
|
658
|
-
|
|
667
|
+
const tokenStatus = await tokenUsable({
|
|
668
|
+
repo,
|
|
669
|
+
env,
|
|
670
|
+
server,
|
|
671
|
+
tokenRel,
|
|
672
|
+
project: options.project,
|
|
673
|
+
fetchImpl: login.fetchImpl,
|
|
674
|
+
});
|
|
675
|
+
if (tokenStatus === "usable") {
|
|
659
676
|
return connect(rest);
|
|
660
677
|
}
|
|
678
|
+
if (options.project) {
|
|
679
|
+
const reason = {
|
|
680
|
+
missing: "is missing",
|
|
681
|
+
rejected: "was rejected by the server",
|
|
682
|
+
wrong_project: `does not have access to project ${options.project}`,
|
|
683
|
+
}[tokenStatus];
|
|
684
|
+
throw new ConnectError(
|
|
685
|
+
`--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`,
|
|
686
|
+
);
|
|
687
|
+
}
|
|
661
688
|
const interactive = login.interactive ?? (Boolean(process.stdout.isTTY) && !env.CI);
|
|
662
689
|
const granted = await deviceLogin({
|
|
663
690
|
server,
|
|
@@ -679,11 +706,6 @@ export async function connectWithLogin(options = {}) {
|
|
|
679
706
|
rmSync(tokenFile, { force: true });
|
|
680
707
|
throw error;
|
|
681
708
|
}
|
|
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
709
|
return {
|
|
688
710
|
...result,
|
|
689
711
|
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
|
}
|