@vincentt-xr/harness 0.4.0 → 1.0.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.
Files changed (43) hide show
  1. package/dist/client/HarnessProvider.d.ts +5 -0
  2. package/dist/client/HarnessProvider.js +11 -0
  3. package/dist/client/annotate.d.ts +34 -0
  4. package/dist/client/annotate.js +104 -0
  5. package/dist/client/index.d.ts +2 -0
  6. package/dist/client/index.js +1 -0
  7. package/dist/shared/events.d.ts +50 -0
  8. package/package.json +8 -34
  9. package/README.md +0 -87
  10. package/dist/cli/index.d.ts +0 -2
  11. package/dist/cli/index.js +0 -55
  12. package/dist/login/login.d.ts +0 -34
  13. package/dist/login/login.js +0 -148
  14. package/dist/mcp/backend.d.ts +0 -52
  15. package/dist/mcp/backend.js +0 -146
  16. package/dist/mcp/cli.d.ts +0 -2
  17. package/dist/mcp/cli.js +0 -10
  18. package/dist/mcp/diagnostics.d.ts +0 -13
  19. package/dist/mcp/diagnostics.js +0 -61
  20. package/dist/mcp/server.d.ts +0 -16
  21. package/dist/mcp/server.js +0 -239
  22. package/dist/preview/cloudflared.d.ts +0 -13
  23. package/dist/preview/cloudflared.js +0 -46
  24. package/dist/preview/index.d.ts +0 -3
  25. package/dist/preview/index.js +0 -6
  26. package/dist/preview/net.d.ts +0 -6
  27. package/dist/preview/net.js +0 -56
  28. package/dist/preview/proxy.d.ts +0 -4
  29. package/dist/preview/proxy.js +0 -49
  30. package/dist/preview/runner.d.ts +0 -45
  31. package/dist/preview/runner.js +0 -110
  32. package/dist/preview/tunnel.d.ts +0 -14
  33. package/dist/preview/tunnel.js +0 -28
  34. package/dist/relay/cli.d.ts +0 -2
  35. package/dist/relay/cli.js +0 -7
  36. package/dist/relay/server.d.ts +0 -12
  37. package/dist/relay/server.js +0 -85
  38. package/dist/relay/store.d.ts +0 -13
  39. package/dist/relay/store.js +0 -68
  40. package/dist/scaffold/index.d.ts +0 -26
  41. package/dist/scaffold/index.js +0 -85
  42. package/dist/shared/config.d.ts +0 -39
  43. package/dist/shared/config.js +0 -90
@@ -1,90 +0,0 @@
1
- // Config the lifecycle MCP verbs (project_create / project_publish) read to reach
2
- // a creator's Vincentt backend. Two homes, by sensitivity:
3
- // • ~/.vincentt/config.json — machine-global { apiUrl, pat }. The PAT is a
4
- // bearer credential, so it lives OUTSIDE any repo (never committed).
5
- // • <project>/.vincentt/project.json — the per-tree binding { projectId, slug }.
6
- // Gitignored: `git archive HEAD` (the remix path) must NOT carry it, or a
7
- // remixer would inherit — and publish over — the original's project.
8
- // Env vars (VINCENTT_API_URL / VINCENTT_PAT) override the file for local/dogfood
9
- // runs so a creator can point at a dev backend without editing the machine config.
10
- import { promises as fs } from "node:fs";
11
- import os from "node:os";
12
- import path from "node:path";
13
- export const MACHINE_CONFIG_PATH = path.join(os.homedir(), ".vincentt", "config.json");
14
- const BINDING_DIR = ".vincentt";
15
- const BINDING_FILE = "project.json";
16
- export function projectBindingPath(cwd) {
17
- return path.join(cwd, BINDING_DIR, BINDING_FILE);
18
- }
19
- async function readJsonIfExists(p) {
20
- try {
21
- return JSON.parse(await fs.readFile(p, "utf8"));
22
- }
23
- catch (err) {
24
- if (err.code === "ENOENT")
25
- return undefined;
26
- throw err;
27
- }
28
- }
29
- export async function loadMachineConfig() {
30
- return (await readJsonIfExists(MACHINE_CONFIG_PATH)) ?? {};
31
- }
32
- /**
33
- * Merge a patch into ~/.vincentt/config.json (used by `harness login` to persist
34
- * a freshly minted PAT). Preserves any other fields already present. The file
35
- * holds a bearer credential, so the dir/file get owner-only perms.
36
- */
37
- export async function writeMachineConfig(patch) {
38
- const next = { ...(await loadMachineConfig()), ...patch };
39
- await fs.mkdir(path.dirname(MACHINE_CONFIG_PATH), { recursive: true, mode: 0o700 });
40
- await fs.writeFile(MACHINE_CONFIG_PATH, JSON.stringify(next, null, 2) + "\n", {
41
- encoding: "utf8",
42
- mode: 0o600,
43
- });
44
- return MACHINE_CONFIG_PATH;
45
- }
46
- export async function loadProjectBinding(cwd) {
47
- return readJsonIfExists(projectBindingPath(cwd));
48
- }
49
- /**
50
- * Write the per-tree binding and make sure `.vincentt/` is gitignored (so the
51
- * secret-free-but-tenant-scoped binding never rides a commit or `git archive`).
52
- */
53
- export async function writeProjectBinding(cwd, binding) {
54
- await fs.mkdir(path.join(cwd, BINDING_DIR), { recursive: true });
55
- const p = projectBindingPath(cwd);
56
- await fs.writeFile(p, JSON.stringify(binding, null, 2) + "\n", "utf8");
57
- await ensureGitignored(cwd, `${BINDING_DIR}/`);
58
- return p;
59
- }
60
- /** Append a pattern to the repo's .gitignore if not already present (best-effort). */
61
- async function ensureGitignored(cwd, pattern) {
62
- const gitignore = path.join(cwd, ".gitignore");
63
- try {
64
- const current = await fs.readFile(gitignore, "utf8").catch(() => "");
65
- const has = current.split(/\r?\n/).some((l) => l.trim() === pattern.trim());
66
- if (has)
67
- return;
68
- const next = current && !current.endsWith("\n") ? `${current}\n${pattern}\n` : `${current}${pattern}\n`;
69
- await fs.writeFile(gitignore, next, "utf8");
70
- }
71
- catch {
72
- // A missing/unwritable .gitignore must not fail project creation.
73
- }
74
- }
75
- /**
76
- * Resolve the API URL + PAT for a machine call. Precedence: a project binding's
77
- * apiUrl wins for the URL; env vars override the machine-config file; the file is
78
- * the base. Throws a clear, actionable error when no PAT is configured.
79
- */
80
- export async function resolveConfig(cwd) {
81
- const machine = await loadMachineConfig();
82
- const binding = await loadProjectBinding(cwd);
83
- const apiUrl = binding?.apiUrl ?? process.env.VINCENTT_API_URL ?? machine.apiUrl ?? "http://localhost:5051";
84
- const pat = process.env.VINCENTT_PAT ?? machine.pat;
85
- if (!pat) {
86
- throw new Error(`No Vincentt access token found. Add {"apiUrl":"…","pat":"…"} to ${MACHINE_CONFIG_PATH}, ` +
87
- `or set the VINCENTT_PAT env var.`);
88
- }
89
- return { apiUrl: apiUrl.replace(/\/$/, ""), pat };
90
- }