@glassly/cli 2.0.8-dev.0 → 2.0.9-dev.0

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 CHANGED
@@ -56,6 +56,17 @@ glassly media add <packageName> ./store/screenshots/01.png
56
56
 
57
57
  Run `glassly <command> --help` for the full option set.
58
58
 
59
+ ## Report a gap or bug
60
+
61
+ ```bash
62
+ glassly feedback "No simulator for the R1 ring"
63
+ ```
64
+
65
+ Sends your text to the Glassly team with the CLI, SDK, and runtime versions and
66
+ the miniapp package name attached. No login needed; when signed in, the report
67
+ carries your account. Coding agents: use it when you hit a missing feature or a
68
+ docs/source mismatch. See https://docs.glassly.ai/app-devs/reference/feedback.
69
+
59
70
  ## Backend selection
60
71
 
61
72
  The CLI talks to the production Glassly backend and Developer Console by
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glassly/cli",
3
- "version": "2.0.8-dev.0",
3
+ "version": "2.0.9-dev.0",
4
4
  "description": "The glassly command: develop, pack, release, and publish Glassly miniapps. Bun-only.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,7 +22,7 @@
22
22
  "typecheck": "tsc --noEmit"
23
23
  },
24
24
  "dependencies": {
25
- "@glassly/miniapp-cli": "0.1.7-dev.0",
25
+ "@glassly/miniapp-cli": "0.1.8-dev.0",
26
26
  "commander": "^15.1.0",
27
27
  "qrcode": "^1.5.4"
28
28
  },
@@ -41,8 +41,8 @@
41
41
  "url": "git+https://github.com/tetramo-labs/glassly.git",
42
42
  "directory": "sdk/cli"
43
43
  },
44
- "homepage": "https://github.com/tetramo-labs/glassly/tree/dev/sdk/cli#readme",
44
+ "homepage": "https://docs.glassly.ai/app-devs/reference/cli",
45
45
  "bugs": {
46
- "url": "https://github.com/tetramo-labs/glassly/issues"
46
+ "url": "https://docs.glassly.ai/app-devs/reference/feedback"
47
47
  }
48
48
  }
package/src/api.ts CHANGED
@@ -433,6 +433,25 @@ export async function submitRelease(
433
433
  );
434
434
  }
435
435
 
436
+ export async function submitFeedback(
437
+ config: CliConfig,
438
+ input: { message: string; context: Record<string, unknown> },
439
+ options: { token: string | null; cliVersion: string },
440
+ ): Promise<{ reportId: string }> {
441
+ const response = await fetch(`${config.coreUrl}/api/developer/feedback`, {
442
+ method: "POST",
443
+ headers: {
444
+ accept: "application/json",
445
+ "content-type": "application/json",
446
+ "user-agent": `glassly-cli/${options.cliVersion}`,
447
+ ...(options.token ? { authorization: `Bearer ${options.token}` } : {}),
448
+ },
449
+ body: JSON.stringify(input),
450
+ });
451
+ if (!response.ok) throw new Error(await errorMessage(response));
452
+ return await response.json() as { reportId: string };
453
+ }
454
+
436
455
  async function coreRequest<T>(
437
456
  credentials: CliCredentials,
438
457
  path: string,
@@ -0,0 +1,49 @@
1
+ import { afterEach, describe, expect, test } from "bun:test";
2
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+
6
+ import { collectFeedbackContext } from "./feedback";
7
+
8
+ let root: string;
9
+
10
+ afterEach(() => {
11
+ rmSync(root, { recursive: true, force: true });
12
+ });
13
+
14
+ function project(): string {
15
+ root = mkdtempSync(join(tmpdir(), "glassly-feedback-"));
16
+ writeFileSync(join(root, "miniapp.json"), JSON.stringify({ packageName: "com.acme.demo" }));
17
+ mkdirSync(join(root, "node_modules", "@glassly", "miniapp"), { recursive: true });
18
+ writeFileSync(join(root, "node_modules", "@glassly", "miniapp", "package.json"), JSON.stringify({ version: "0.4.1" }));
19
+ mkdirSync(join(root, "src", "ui"), { recursive: true });
20
+ return root;
21
+ }
22
+
23
+ describe("collectFeedbackContext", () => {
24
+ test("finds the manifest and installed SDK from a nested directory", () => {
25
+ const dir = project();
26
+ const context = collectFeedbackContext({ cwd: join(dir, "src", "ui"), cliVersion: "2.0.7" });
27
+
28
+ expect(context).toMatchObject({
29
+ source: "glassly-cli",
30
+ packageName: "com.acme.demo",
31
+ cli: { version: "2.0.7" },
32
+ sdk: { version: "0.4.1" },
33
+ });
34
+ expect(context.miniappCli.version).toEqual(expect.any(String));
35
+ expect(context.runtime.bun).toBe(Bun.version);
36
+ });
37
+
38
+ test("an explicit package name wins over the manifest", () => {
39
+ const context = collectFeedbackContext({ cwd: project(), cliVersion: "2.0.7", packageName: "com.other.app" });
40
+ expect(context.packageName).toBe("com.other.app");
41
+ });
42
+
43
+ test("reports nulls outside a miniapp project", () => {
44
+ root = mkdtempSync(join(tmpdir(), "glassly-feedback-"));
45
+ const context = collectFeedbackContext({ cwd: root, cliVersion: "2.0.7" });
46
+ expect(context.packageName).toBeNull();
47
+ expect(context.sdk.version).toBeNull();
48
+ });
49
+ });
@@ -0,0 +1,77 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import { arch, platform, release } from "node:os";
4
+ import { dirname, join } from "node:path";
5
+
6
+ export interface FeedbackContext extends Record<string, unknown> {
7
+ source: "glassly-cli";
8
+ packageName: string | null;
9
+ cli: { version: string };
10
+ miniappCli: { version: string | null };
11
+ sdk: { version: string | null };
12
+ runtime: { platform: string; arch: string; osRelease: string; bun: string | null };
13
+ }
14
+
15
+ export function collectFeedbackContext(options: {
16
+ cwd: string;
17
+ cliVersion: string;
18
+ packageName?: string;
19
+ }): FeedbackContext {
20
+ const manifestPath = findUp(options.cwd, "miniapp.json");
21
+ const projectDir = manifestPath ? dirname(manifestPath) : options.cwd;
22
+ return {
23
+ source: "glassly-cli",
24
+ packageName: options.packageName ?? (manifestPath ? manifestPackageName(manifestPath) : null),
25
+ cli: { version: options.cliVersion },
26
+ miniappCli: { version: miniappCliVersion() },
27
+ sdk: { version: installedVersion(projectDir, "@glassly/miniapp") },
28
+ runtime: {
29
+ platform: platform(),
30
+ arch: arch(),
31
+ osRelease: release(),
32
+ bun: typeof Bun === "undefined" ? null : Bun.version,
33
+ },
34
+ };
35
+ }
36
+
37
+ function manifestPackageName(path: string): string | null {
38
+ try {
39
+ const manifest = JSON.parse(readFileSync(path, "utf8")) as { packageName?: unknown };
40
+ return typeof manifest.packageName === "string" && manifest.packageName ? manifest.packageName : null;
41
+ } catch {
42
+ return null;
43
+ }
44
+ }
45
+
46
+ function miniappCliVersion(): string | null {
47
+ try {
48
+ const pkg = createRequire(import.meta.url)("@glassly/miniapp-cli/package.json") as { version?: unknown };
49
+ return typeof pkg.version === "string" ? pkg.version : null;
50
+ } catch {
51
+ return null;
52
+ }
53
+ }
54
+
55
+ // @glassly/miniapp does not export its package.json, so read it off disk the
56
+ // way Node resolution would find it from the project.
57
+ function installedVersion(fromDir: string, name: string): string | null {
58
+ const path = findUp(fromDir, join("node_modules", name, "package.json"));
59
+ if (!path) return null;
60
+ try {
61
+ const pkg = JSON.parse(readFileSync(path, "utf8")) as { version?: unknown };
62
+ return typeof pkg.version === "string" ? pkg.version : null;
63
+ } catch {
64
+ return null;
65
+ }
66
+ }
67
+
68
+ function findUp(fromDir: string, relativePath: string): string | null {
69
+ let dir = fromDir;
70
+ while (true) {
71
+ const candidate = join(dir, relativePath);
72
+ if (existsSync(candidate)) return candidate;
73
+ const parent = dirname(dir);
74
+ if (parent === dir) return null;
75
+ dir = parent;
76
+ }
77
+ }
package/src/index.ts CHANGED
@@ -39,6 +39,7 @@ import {
39
39
  pollLoginToken,
40
40
  refreshLoginToken,
41
41
  startLogin,
42
+ submitFeedback,
42
43
  submitRelease,
43
44
  updateListing,
44
45
  upsertOrg,
@@ -51,6 +52,7 @@ import {
51
52
  } from "./api";
52
53
  import { deviceLoginUrl, getConfig } from "./config";
53
54
  import { clearCredentials, loadCredentials, saveCredentials, type CliCredentials } from "./credentials";
55
+ import { collectFeedbackContext } from "./feedback";
54
56
  import { openBrowser } from "./open-browser";
55
57
  import { encodeDevAttestation, ensureSigningKey, signBundleMetadata, signDevAttestation } from "./signing";
56
58
 
@@ -894,6 +896,53 @@ program
894
896
  }
895
897
  });
896
898
 
899
+ program
900
+ .command("feedback")
901
+ .description("Report a gap, bug, or docs mismatch to the Glassly team (no login needed)")
902
+ .argument("[message...]", "what is missing or wrong; read from stdin when omitted")
903
+ .option("--package <name>", "miniapp package name (default: packageName from the nearest miniapp.json)")
904
+ .option("--cwd <path>", "miniapp project directory", process.cwd())
905
+ .option("--dry-run", "print the report without sending it")
906
+ .option("--json", "print the result as JSON")
907
+ .addHelpText(
908
+ "after",
909
+ `
910
+ Sends your text plus the CLI, SDK, and runtime versions and the miniapp package
911
+ name. Signed in (glassly login or CLI_TOKEN), the report carries your account;
912
+ otherwise it is anonymous. Coding agents: use this when you hit a missing
913
+ feature or a docs/source mismatch instead of working around it silently.
914
+
915
+ Examples:
916
+ glassly feedback "No simulator for the R1 ring, so ring input can't be tested"
917
+ git diff | glassly feedback`,
918
+ )
919
+ .action(async (words: string[], options: { package?: string; cwd: string; dryRun?: boolean; json?: boolean }) => {
920
+ try {
921
+ let message = words.join(" ").trim();
922
+ if (!message && !process.stdin.isTTY) message = (await Bun.stdin.text()).trim();
923
+ if (!message) throw new Error('Nothing to send. Usage: glassly feedback "<what is missing or wrong>"');
924
+
925
+ const config = getConfig();
926
+ const context = collectFeedbackContext({ cwd: resolve(options.cwd), cliVersion, packageName: options.package });
927
+ if (options.dryRun) {
928
+ console.log(JSON.stringify({ url: `${config.coreUrl}/api/developer/feedback`, message, context }, null, 2));
929
+ return;
930
+ }
931
+
932
+ const creds = await loadCredentials(config.coreUrl);
933
+ const token = creds && !shouldRefresh(creds) ? creds.token : null;
934
+ const { reportId } = await submitFeedback(config, { message, context }, { token, cliVersion });
935
+ if (options.json) {
936
+ console.log(JSON.stringify({ reportId, anonymous: token === null }));
937
+ return;
938
+ }
939
+ console.log(`Sent ${reportId}. Thanks, the Glassly team reads every report.`);
940
+ if (!token) console.log("Sent anonymously. Run `glassly login` first to attach your account.");
941
+ } catch (error) {
942
+ fail(error);
943
+ }
944
+ });
945
+
897
946
  program
898
947
  .command("logout")
899
948
  .description("Clear the current CLI login")