borgmcp 1.0.6 → 1.0.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.
Files changed (160) hide show
  1. package/README.md +5 -3
  2. package/dist/assimilate-cmd.js +39 -511
  3. package/dist/assimilate-deps.js +3 -177
  4. package/dist/assimilate-welcome.js +2 -24
  5. package/dist/auth-env.js +1 -107
  6. package/dist/auth.js +23 -612
  7. package/dist/claude.js +11 -281
  8. package/dist/cli-help.js +29 -50
  9. package/dist/cli-platform.js +4 -94
  10. package/dist/codex-app-server.js +4 -228
  11. package/dist/codex-app-wake.js +2 -122
  12. package/dist/codex-launch.js +1 -81
  13. package/dist/codex-remote.js +1 -250
  14. package/dist/config-utils.js +3 -385
  15. package/dist/config.js +1 -190
  16. package/dist/console-prefix.js +1 -86
  17. package/dist/cube-name.js +1 -65
  18. package/dist/cubes.js +4 -269
  19. package/dist/debug.js +1 -71
  20. package/dist/device-auth.js +1 -167
  21. package/dist/direct-log.js +1 -11
  22. package/dist/health-beat.js +1 -168
  23. package/dist/inbox-monitor.js +1 -129
  24. package/dist/index.js +26 -1378
  25. package/dist/lifecycle-log-guard.js +2 -93
  26. package/dist/list-roles-render.js +6 -39
  27. package/dist/log-audit.js +3 -186
  28. package/dist/log-stream.js +9 -848
  29. package/dist/name-validator.js +1 -22
  30. package/dist/parse-assimilate-args.js +1 -82
  31. package/dist/postinstall.js +8 -22
  32. package/dist/regen-format.js +11 -337
  33. package/dist/regen.js +5 -83
  34. package/dist/remote-client.d.ts +4 -7
  35. package/dist/remote-client.js +1 -695
  36. package/dist/role-resolver.js +1 -36
  37. package/dist/role-section.js +8 -208
  38. package/dist/roster-render.js +3 -96
  39. package/dist/setup.js +41 -251
  40. package/dist/shell-escape.js +1 -22
  41. package/dist/spawn.js +10 -29
  42. package/dist/stale-version-check.js +1 -102
  43. package/dist/stream-owner.js +2 -202
  44. package/dist/stream-status.js +3 -211
  45. package/dist/subscription-retry.js +1 -23
  46. package/dist/sync-roles-render.js +3 -118
  47. package/dist/sync.js +22 -286
  48. package/dist/templates.js +120 -626
  49. package/dist/terminal-title.js +1 -68
  50. package/dist/token-crypto.js +1 -91
  51. package/dist/token-store.js +1 -222
  52. package/dist/types.d.ts +0 -5
  53. package/dist/types.js +0 -5
  54. package/dist/version.js +2 -78
  55. package/dist/worktree-lifecycle.js +2 -173
  56. package/package.json +12 -2
  57. package/dist/assimilate-cmd.d.ts.map +0 -1
  58. package/dist/assimilate-cmd.js.map +0 -1
  59. package/dist/assimilate-deps.d.ts.map +0 -1
  60. package/dist/assimilate-deps.js.map +0 -1
  61. package/dist/assimilate-welcome.d.ts.map +0 -1
  62. package/dist/assimilate-welcome.js.map +0 -1
  63. package/dist/auth-env.d.ts.map +0 -1
  64. package/dist/auth-env.js.map +0 -1
  65. package/dist/auth.d.ts.map +0 -1
  66. package/dist/auth.js.map +0 -1
  67. package/dist/claude.d.ts.map +0 -1
  68. package/dist/claude.js.map +0 -1
  69. package/dist/cli-help.d.ts.map +0 -1
  70. package/dist/cli-help.js.map +0 -1
  71. package/dist/cli-platform.d.ts.map +0 -1
  72. package/dist/cli-platform.js.map +0 -1
  73. package/dist/codex-app-server.d.ts.map +0 -1
  74. package/dist/codex-app-server.js.map +0 -1
  75. package/dist/codex-app-wake.d.ts.map +0 -1
  76. package/dist/codex-app-wake.js.map +0 -1
  77. package/dist/codex-launch.d.ts.map +0 -1
  78. package/dist/codex-launch.js.map +0 -1
  79. package/dist/codex-remote.d.ts.map +0 -1
  80. package/dist/codex-remote.js.map +0 -1
  81. package/dist/config-utils.d.ts.map +0 -1
  82. package/dist/config-utils.js.map +0 -1
  83. package/dist/config.d.ts.map +0 -1
  84. package/dist/config.js.map +0 -1
  85. package/dist/console-prefix.d.ts.map +0 -1
  86. package/dist/console-prefix.js.map +0 -1
  87. package/dist/cube-name.d.ts.map +0 -1
  88. package/dist/cube-name.js.map +0 -1
  89. package/dist/cubes.d.ts.map +0 -1
  90. package/dist/cubes.js.map +0 -1
  91. package/dist/debug.d.ts.map +0 -1
  92. package/dist/debug.js.map +0 -1
  93. package/dist/device-auth.d.ts.map +0 -1
  94. package/dist/device-auth.js.map +0 -1
  95. package/dist/direct-log.d.ts.map +0 -1
  96. package/dist/direct-log.js.map +0 -1
  97. package/dist/health-beat.d.ts.map +0 -1
  98. package/dist/health-beat.js.map +0 -1
  99. package/dist/inbox-monitor.d.ts.map +0 -1
  100. package/dist/inbox-monitor.js.map +0 -1
  101. package/dist/index.d.ts.map +0 -1
  102. package/dist/index.js.map +0 -1
  103. package/dist/lifecycle-log-guard.d.ts.map +0 -1
  104. package/dist/lifecycle-log-guard.js.map +0 -1
  105. package/dist/list-roles-render.d.ts.map +0 -1
  106. package/dist/list-roles-render.js.map +0 -1
  107. package/dist/log-audit.d.ts.map +0 -1
  108. package/dist/log-audit.js.map +0 -1
  109. package/dist/log-stream.d.ts.map +0 -1
  110. package/dist/log-stream.js.map +0 -1
  111. package/dist/name-validator.d.ts.map +0 -1
  112. package/dist/name-validator.js.map +0 -1
  113. package/dist/parse-assimilate-args.d.ts.map +0 -1
  114. package/dist/parse-assimilate-args.js.map +0 -1
  115. package/dist/postinstall.d.ts.map +0 -1
  116. package/dist/postinstall.js.map +0 -1
  117. package/dist/regen-format.d.ts.map +0 -1
  118. package/dist/regen-format.js.map +0 -1
  119. package/dist/regen.d.ts.map +0 -1
  120. package/dist/regen.js.map +0 -1
  121. package/dist/remote-client.d.ts.map +0 -1
  122. package/dist/remote-client.js.map +0 -1
  123. package/dist/role-resolver.d.ts.map +0 -1
  124. package/dist/role-resolver.js.map +0 -1
  125. package/dist/role-section.d.ts.map +0 -1
  126. package/dist/role-section.js.map +0 -1
  127. package/dist/roster-render.d.ts.map +0 -1
  128. package/dist/roster-render.js.map +0 -1
  129. package/dist/setup.d.ts.map +0 -1
  130. package/dist/setup.js.map +0 -1
  131. package/dist/shell-escape.d.ts.map +0 -1
  132. package/dist/shell-escape.js.map +0 -1
  133. package/dist/spawn.d.ts.map +0 -1
  134. package/dist/spawn.js.map +0 -1
  135. package/dist/stale-version-check.d.ts.map +0 -1
  136. package/dist/stale-version-check.js.map +0 -1
  137. package/dist/stream-owner.d.ts.map +0 -1
  138. package/dist/stream-owner.js.map +0 -1
  139. package/dist/stream-status.d.ts.map +0 -1
  140. package/dist/stream-status.js.map +0 -1
  141. package/dist/subscription-retry.d.ts.map +0 -1
  142. package/dist/subscription-retry.js.map +0 -1
  143. package/dist/sync-roles-render.d.ts.map +0 -1
  144. package/dist/sync-roles-render.js.map +0 -1
  145. package/dist/sync.d.ts.map +0 -1
  146. package/dist/sync.js.map +0 -1
  147. package/dist/templates.d.ts.map +0 -1
  148. package/dist/templates.js.map +0 -1
  149. package/dist/terminal-title.d.ts.map +0 -1
  150. package/dist/terminal-title.js.map +0 -1
  151. package/dist/token-crypto.d.ts.map +0 -1
  152. package/dist/token-crypto.js.map +0 -1
  153. package/dist/token-store.d.ts.map +0 -1
  154. package/dist/token-store.js.map +0 -1
  155. package/dist/types.d.ts.map +0 -1
  156. package/dist/types.js.map +0 -1
  157. package/dist/version.d.ts.map +0 -1
  158. package/dist/version.js.map +0 -1
  159. package/dist/worktree-lifecycle.d.ts.map +0 -1
  160. package/dist/worktree-lifecycle.js.map +0 -1
package/dist/regen.js CHANGED
@@ -1,84 +1,6 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * borg-regen CLI
4
- *
5
- * Prints a markdown-formatted regen of the active cube to stdout.
6
- * Designed to be wired into a Claude Code SessionStart hook so that
7
- * each new session begins fully oriented to the cube.
8
- *
9
- * Behavior:
10
- * - No active cube: print a friendly notice to stdout, exit 0.
11
- * (A SessionStart hook should not block session start over a missing
12
- * cube — the user may not be using Borg in this directory.)
13
- * - Active cube + success: print regen markdown to stdout, exit 0.
14
- * - Active cube + HTTP/auth error: print one-line message to stderr,
15
- * exit non-zero so the hook surfaces the failure but doesn't drown
16
- * the session in a stack trace.
17
- */
18
- import { regen, listCubes } from './remote-client.js';
19
- import { getActiveCube } from './cubes.js';
20
- import { formatRegenMarkdown } from './regen-format.js';
21
- import { handleVersionFlag } from './version.js';
22
- async function main() {
23
- handleVersionFlag();
24
- const active = await getActiveCube();
25
- if (!active) {
26
- await emitUnassimilatedNotice();
27
- return;
28
- }
29
- const result = await regen(active.sessionToken, active.apiUrl);
30
- process.stdout.write(formatRegenMarkdown(result) + '\n');
31
- }
32
- /**
33
- * Render a discoverability stub for a session that's running with the
34
- * borg MCP server installed but no cube assimilated in this project.
35
- * Informs the user which cubes exist on their account. Written as a
36
- * status report TO THE USER, not as instructions to the drone — the
37
- * drone must wait for explicit user approval before calling
38
- * borg:assimilate or any other state-changing borg tool.
39
- */
40
- async function emitUnassimilatedNotice() {
41
- const lines = [];
42
- lines.push('# Borg MCP — not connected to a cube');
43
- lines.push('');
44
- lines.push('The borg MCP server is installed in this project but no cube has been joined here yet.');
45
- lines.push('');
46
- lines.push('**Drone instructions:**');
47
- lines.push('1. **Tell the user** which cubes exist on their account (see the list below) and ask them which one to join, or whether to create a new cube. This is the first thing you should surface in this session.');
48
- lines.push('2. **Do not** call `borg:assimilate`, `borg:create-cube`, or any other state-changing borg tool until the user has chosen.');
49
- lines.push('3. The user may also decline to use borg in this project at all — that\'s a valid choice; just stop suggesting it.');
50
- lines.push('');
51
- // Best-effort: list the user's cubes so the user can see what's
52
- // available if they decide to join one. Network failure or auth
53
- // issue here is non-fatal — the SessionStart hook should never
54
- // block session start.
55
- try {
56
- const { cubes } = await listCubes();
57
- if (cubes.length > 0) {
58
- lines.push('## Cubes on your account');
59
- for (const c of cubes) {
60
- lines.push(`- **${c.name}** (id: ${c.id})`);
61
- }
62
- }
63
- else {
64
- lines.push('## Cubes on your account');
65
- lines.push('_(none yet — offer to create one via `borg:create-cube` once the user confirms)_');
66
- }
67
- }
68
- catch (err) {
69
- lines.push('## Cubes on your account');
70
- lines.push('_(could not list — ' + (err?.message ?? String(err)) + ')_');
71
- }
72
- lines.push('');
73
- lines.push('## Tools you can call once the user has chosen');
74
- lines.push('- Join an existing cube: `borg:assimilate cube_name="<their choice>"`');
75
- lines.push('- Create a new cube: `borg:create-cube name="<name>" cube_directive="<markdown>"` (optionally `template="software-dev"`)');
76
- lines.push('- See available templates: `borg:list-templates`');
77
- process.stdout.write(lines.join('\n') + '\n');
78
- }
79
- main().catch((error) => {
80
- const msg = error?.message ?? String(error);
81
- process.stderr.write(`borg-regen: ${msg}\n`);
82
- process.exit(1);
83
- });
84
- //# sourceMappingURL=regen.js.map
2
+ import{regen as o,listCubes as n}from"./remote-client.js";import{getActiveCube as i}from"./cubes.js";import{formatRegenMarkdown as a}from"./regen-format.js";import{handleVersionFlag as r}from"./version.js";async function c(){r();const e=await i();if(!e){await u();return}const s=await o(e.sessionToken,e.apiUrl);process.stdout.write(a(s)+`
3
+ `)}async function u(){const e=[];e.push("# Borg MCP \u2014 not connected to a cube"),e.push(""),e.push("The borg MCP server is installed in this project but no cube has been joined here yet."),e.push(""),e.push("**Drone instructions:**"),e.push("1. **Tell the user** which cubes exist on their account (see the list below) and ask them which one to join, or whether to create a new cube. This is the first thing you should surface in this session."),e.push("2. **Do not** call `borg:assimilate`, `borg:create-cube`, or any other state-changing borg tool until the user has chosen."),e.push("3. The user may also decline to use borg in this project at all \u2014 that's a valid choice; just stop suggesting it."),e.push("");try{const{cubes:s}=await n();if(s.length>0){e.push("## Cubes on your account");for(const t of s)e.push(`- **${t.name}** (id: ${t.id})`)}else e.push("## Cubes on your account"),e.push("_(none yet \u2014 offer to create one via `borg:create-cube` once the user confirms)_")}catch(s){e.push("## Cubes on your account"),e.push("_(could not list \u2014 "+(s?.message??String(s))+")_")}e.push(""),e.push("## Tools you can call once the user has chosen"),e.push('- Join an existing cube: `borg:assimilate cube_name="<their choice>"`'),e.push('- Create a new cube: `borg:create-cube name="<name>" cube_directive="<markdown>"` (optionally `template="software-dev"`)'),e.push("- See available templates: `borg:list-templates`"),process.stdout.write(e.join(`
4
+ `)+`
5
+ `)}c().catch(e=>{const s=e?.message??String(e);process.stderr.write(`borg-regen: ${s}
6
+ `),process.exit(1)});
@@ -7,7 +7,6 @@
7
7
  * - Network failure handling with retry + exponential backoff
8
8
  * - Offline queue for pending operations
9
9
  */
10
- import type { RemoteResponse } from './types.js';
11
10
  import type { MessageTaxonomy, MessageTaxonomyClass } from './templates.js';
12
11
  export declare const API_URL: string;
13
12
  /**
@@ -25,6 +24,7 @@ export declare function parseRetryAfterMs(headerValue: string | null): number |
25
24
  * drones sharing one per-IP bucket don't retry in lockstep.
26
25
  */
27
26
  export declare function rateLimitWaitMs(retryAfterMs: number | null, attempt: number, capMs?: number, jitter?: () => number): number;
27
+ export declare function extractHttpErrorMessage(body: string): string;
28
28
  /**
29
29
  * Given an ALREADY-OBTAINED response, while it is a 429 and retries
30
30
  * remain, wait per `rateLimitWaitMs` (honoring the CURRENT response's
@@ -51,10 +51,6 @@ export declare function retryOn429(initialResponse: Response, doRequest: () => P
51
51
  * without duplicating the refresh-token plumbing.
52
52
  */
53
53
  export declare function getValidToken(): Promise<string>;
54
- /**
55
- * Call remote MCP tool with retry logic
56
- */
57
- export declare function callRemoteTool(toolName: string, args: Record<string, any>): Promise<RemoteResponse>;
58
54
  /**
59
55
  * Connect this client as a Drone to a Cube.
60
56
  *
@@ -358,8 +354,8 @@ export declare function reassignDrone(droneId: string, roleId: string): Promise<
358
354
  }>;
359
355
  /**
360
356
  * Fetch a cube's full detail: directive, roles (with detailed
361
- * descriptions, owner-only), and drones. Owner-scoped via the Bearer
362
- * token; no drone session needed.
357
+ * descriptions), and drones. Accessible to owners and active members via
358
+ * the Bearer token; no drone session needed.
363
359
  */
364
360
  export declare function getCube(cubeId: string): Promise<{
365
361
  id: string;
@@ -401,4 +397,5 @@ export declare function syncRoles(cubeId: string, templateName?: string, apply?:
401
397
  * Create subscription (returns checkout URL)
402
398
  */
403
399
  export declare function createSubscription(): Promise<string>;
400
+ export declare function createBillingPortalSession(): Promise<string>;
404
401
  //# sourceMappingURL=remote-client.d.ts.map