@nodii/dev 0.6.7 → 0.6.8

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/doctor.js CHANGED
@@ -4,6 +4,7 @@ import { join } from "node:path";
4
4
  import { devRequest, encode, isOAuthConfig, query, setAuthProvider } from "./core.js";
5
5
  import { OAuthAuthProvider, decodeClaims, loadRefreshToken } from "./oauth.js";
6
6
  import { inferGitContext, repoName } from "./lanes.js";
7
+ import { figmaFileKey, notRegisteredHint } from "./figma.js";
7
8
 
8
9
  /**
9
10
  * What a lane's commands need, in Dev's route policy (staffRuleFor in Dev's
@@ -21,8 +22,8 @@ export const LANE_PERMISSIONS = [
21
22
  { key: "devops.agents.read", for: "whoami, reading this agent" },
22
23
  { key: "devops.agents.write", for: "agent register|heartbeat" },
23
24
  { key: "devops.machines.manage", for: "machine show (this agent's machine and coordinator)" },
24
- { key: "devops.decisions.read", for: "figma check" },
25
- { key: "devops.decisions.write", for: "figma lock|log-write|submit|apply|published|abandon|withdraw" },
25
+ { key: "devops.decisions.read", for: "figma check, doctor --figma-file" },
26
+ { key: "devops.decisions.write", for: "figma lock|file add|log-write|submit|apply|published|abandon|withdraw" },
26
27
  { key: "devops.decisions.lock", for: "figma release" },
27
28
  { key: "devops.rulebook.read", for: "rulebook show" },
28
29
  ];
@@ -225,6 +226,26 @@ export async function doctorCommand(deps = {}) {
225
226
  }
226
227
  }
227
228
 
229
+ // 8. Given a Figma file (the brief's target), whether Dev has it registered,
230
+ // so a lock can't fail later with DESIGN_FILE_NOT_FOUND (MW1-38.9).
231
+ const figmaInput = deps.figmaFile ?? env.NODII_DEV_FIGMA_FILE;
232
+ if (figmaInput) {
233
+ const fileKey = figmaFileKey(figmaInput);
234
+ if (!signedIn) checks.push(cannot("figma_file", "needs a sign-in", { fileKey }));
235
+ else {
236
+ try {
237
+ const file = (await request("GET", `/api/v1/design/files/${encode(fileKey)}`)).data;
238
+ checks.push(ok("figma_file", `${fileKey} is registered: ${file.name} (${file.kind}${file.module ? `, ${file.module}` : ""})`,
239
+ { fileKey, registered: true }));
240
+ } catch (error) {
241
+ if (error?.code === "DESIGN_FILE_NOT_FOUND")
242
+ checks.push(missing("figma_file", `${fileKey} is NOT registered: run figma file add; figma lock fails with DESIGN_FILE_NOT_FOUND`,
243
+ `${prefix}${notRegisteredHint(fileKey).replace(/^.*?: run /, "")}`, { fileKey, registered: false }));
244
+ else checks.push(cannot("figma_file", `getDesignFile failed (${devReason(error)})`, { fileKey }));
245
+ }
246
+ }
247
+ }
248
+
228
249
  const ready = checks.every((x) => x.status === "ok");
229
250
  const width = Math.max(...checks.map((x) => x.key.length));
230
251
  const human = (p) => [
package/dist/figma.js ADDED
@@ -0,0 +1,15 @@
1
+ import { CliError } from "./core.js";
2
+
3
+ /** A Figma file key, or the key inside a figma.com file link (a branch link's branch key). */
4
+ export function figmaFileKey(value) {
5
+ // A flag given without a value parses as `true`: that is a missing key.
6
+ const text = typeof value === "string" ? value : "";
7
+ const link = text.match(/figma\.com\/(?:design|file|board|proto|slides)\/([A-Za-z0-9]+)(?:\/branch\/([A-Za-z0-9]+))?/);
8
+ const key = link ? (link[2] ?? link[1]) : text;
9
+ if (!key) throw new CliError("USAGE", "a Figma file key is required", 2);
10
+ return key;
11
+ }
12
+
13
+ /** What to run when Dev has no row for a Figma file (DESIGN_FILE_NOT_FOUND). */
14
+ export const notRegisteredHint = (key) =>
15
+ `${key} is NOT registered in Dev: run nodii-dev figma file add ${key} --name NAME --kind design-system|surfaces|prototype [--module M]`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {