opengstack 0.13.9 → 0.14.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 (152) hide show
  1. package/{skills/land-and-deploy/SKILL.md → commands/autoplan.md} +0 -16
  2. package/{skills/benchmark/SKILL.md → commands/benchmark.md} +0 -17
  3. package/{skills/browse/SKILL.md → commands/browse.md} +0 -17
  4. package/{skills/ship/SKILL.md → commands/canary.md} +0 -18
  5. package/{skills/careful/SKILL.md → commands/careful.md} +0 -20
  6. package/{skills/canary/SKILL.md → commands/codex.md} +0 -17
  7. package/{skills/connect-chrome/SKILL.md → commands/connect-chrome.md} +0 -15
  8. package/commands/cso.md +72 -0
  9. package/commands/design-consultation.md +72 -0
  10. package/commands/design-review.md +72 -0
  11. package/commands/design-shotgun.md +72 -0
  12. package/commands/document-release.md +72 -0
  13. package/{skills/freeze/SKILL.md → commands/freeze.md} +0 -26
  14. package/{skills/gstack-upgrade/SKILL.md → commands/gstack-upgrade.md} +0 -14
  15. package/{skills/guard/SKILL.md → commands/guard.md} +0 -31
  16. package/commands/investigate.md +72 -0
  17. package/commands/land-and-deploy.md +72 -0
  18. package/commands/office-hours.md +72 -0
  19. package/commands/plan-ceo-review.md +72 -0
  20. package/commands/plan-design-review.md +72 -0
  21. package/commands/plan-eng-review.md +72 -0
  22. package/commands/qa-only.md +72 -0
  23. package/commands/qa.md +72 -0
  24. package/commands/retro.md +72 -0
  25. package/commands/review.md +72 -0
  26. package/{skills/setup-browser-cookies/SKILL.md → commands/setup-browser-cookies.md} +0 -14
  27. package/commands/setup-deploy.md +72 -0
  28. package/commands/ship.md +72 -0
  29. package/{skills/unfreeze/SKILL.md → commands/unfreeze.md} +0 -12
  30. package/package.json +4 -4
  31. package/scripts/install-commands.js +45 -0
  32. package/scripts/install-skills.js +4 -7
  33. package/skills/autoplan/SKILL.md +0 -96
  34. package/skills/autoplan/SKILL.md.tmpl +0 -694
  35. package/skills/benchmark/SKILL.md.tmpl +0 -222
  36. package/skills/browse/SKILL.md.tmpl +0 -131
  37. package/skills/browse/bin/find-browse +0 -21
  38. package/skills/browse/bin/remote-slug +0 -14
  39. package/skills/browse/scripts/build-node-server.sh +0 -48
  40. package/skills/browse/src/activity.ts +0 -208
  41. package/skills/browse/src/browser-manager.ts +0 -959
  42. package/skills/browse/src/buffers.ts +0 -137
  43. package/skills/browse/src/bun-polyfill.cjs +0 -109
  44. package/skills/browse/src/cli.ts +0 -678
  45. package/skills/browse/src/commands.ts +0 -128
  46. package/skills/browse/src/config.ts +0 -150
  47. package/skills/browse/src/cookie-import-browser.ts +0 -625
  48. package/skills/browse/src/cookie-picker-routes.ts +0 -230
  49. package/skills/browse/src/cookie-picker-ui.ts +0 -688
  50. package/skills/browse/src/find-browse.ts +0 -61
  51. package/skills/browse/src/meta-commands.ts +0 -550
  52. package/skills/browse/src/platform.ts +0 -17
  53. package/skills/browse/src/read-commands.ts +0 -358
  54. package/skills/browse/src/server.ts +0 -1192
  55. package/skills/browse/src/sidebar-agent.ts +0 -280
  56. package/skills/browse/src/sidebar-utils.ts +0 -21
  57. package/skills/browse/src/snapshot.ts +0 -407
  58. package/skills/browse/src/url-validation.ts +0 -95
  59. package/skills/browse/src/write-commands.ts +0 -364
  60. package/skills/browse/test/activity.test.ts +0 -120
  61. package/skills/browse/test/adversarial-security.test.ts +0 -32
  62. package/skills/browse/test/browser-manager-unit.test.ts +0 -17
  63. package/skills/browse/test/bun-polyfill.test.ts +0 -72
  64. package/skills/browse/test/commands.test.ts +0 -2075
  65. package/skills/browse/test/compare-board.test.ts +0 -342
  66. package/skills/browse/test/config.test.ts +0 -316
  67. package/skills/browse/test/cookie-import-browser.test.ts +0 -519
  68. package/skills/browse/test/cookie-picker-routes.test.ts +0 -260
  69. package/skills/browse/test/file-drop.test.ts +0 -271
  70. package/skills/browse/test/find-browse.test.ts +0 -50
  71. package/skills/browse/test/findport.test.ts +0 -191
  72. package/skills/browse/test/fixtures/basic.html +0 -33
  73. package/skills/browse/test/fixtures/cursor-interactive.html +0 -22
  74. package/skills/browse/test/fixtures/dialog.html +0 -15
  75. package/skills/browse/test/fixtures/empty.html +0 -2
  76. package/skills/browse/test/fixtures/forms.html +0 -55
  77. package/skills/browse/test/fixtures/iframe.html +0 -30
  78. package/skills/browse/test/fixtures/network-idle.html +0 -30
  79. package/skills/browse/test/fixtures/qa-eval-checkout.html +0 -108
  80. package/skills/browse/test/fixtures/qa-eval-spa.html +0 -98
  81. package/skills/browse/test/fixtures/qa-eval.html +0 -51
  82. package/skills/browse/test/fixtures/responsive.html +0 -49
  83. package/skills/browse/test/fixtures/snapshot.html +0 -55
  84. package/skills/browse/test/fixtures/spa.html +0 -24
  85. package/skills/browse/test/fixtures/states.html +0 -17
  86. package/skills/browse/test/fixtures/upload.html +0 -25
  87. package/skills/browse/test/gstack-config.test.ts +0 -138
  88. package/skills/browse/test/gstack-update-check.test.ts +0 -514
  89. package/skills/browse/test/handoff.test.ts +0 -235
  90. package/skills/browse/test/path-validation.test.ts +0 -91
  91. package/skills/browse/test/platform.test.ts +0 -37
  92. package/skills/browse/test/server-auth.test.ts +0 -65
  93. package/skills/browse/test/sidebar-agent-roundtrip.test.ts +0 -226
  94. package/skills/browse/test/sidebar-agent.test.ts +0 -199
  95. package/skills/browse/test/sidebar-integration.test.ts +0 -320
  96. package/skills/browse/test/sidebar-unit.test.ts +0 -96
  97. package/skills/browse/test/snapshot.test.ts +0 -467
  98. package/skills/browse/test/state-ttl.test.ts +0 -35
  99. package/skills/browse/test/test-server.ts +0 -57
  100. package/skills/browse/test/url-validation.test.ts +0 -72
  101. package/skills/browse/test/watch.test.ts +0 -129
  102. package/skills/canary/SKILL.md.tmpl +0 -212
  103. package/skills/careful/SKILL.md.tmpl +0 -56
  104. package/skills/careful/bin/check-careful.sh +0 -112
  105. package/skills/codex/SKILL.md +0 -90
  106. package/skills/codex/SKILL.md.tmpl +0 -417
  107. package/skills/connect-chrome/SKILL.md.tmpl +0 -195
  108. package/skills/cso/ACKNOWLEDGEMENTS.md +0 -14
  109. package/skills/cso/SKILL.md +0 -93
  110. package/skills/cso/SKILL.md.tmpl +0 -606
  111. package/skills/design-consultation/SKILL.md +0 -94
  112. package/skills/design-consultation/SKILL.md.tmpl +0 -415
  113. package/skills/design-review/SKILL.md +0 -94
  114. package/skills/design-review/SKILL.md.tmpl +0 -290
  115. package/skills/design-shotgun/SKILL.md +0 -91
  116. package/skills/design-shotgun/SKILL.md.tmpl +0 -285
  117. package/skills/document-release/SKILL.md +0 -91
  118. package/skills/document-release/SKILL.md.tmpl +0 -359
  119. package/skills/freeze/SKILL.md.tmpl +0 -77
  120. package/skills/freeze/bin/check-freeze.sh +0 -79
  121. package/skills/gstack-upgrade/SKILL.md.tmpl +0 -222
  122. package/skills/guard/SKILL.md.tmpl +0 -77
  123. package/skills/investigate/SKILL.md +0 -105
  124. package/skills/investigate/SKILL.md.tmpl +0 -194
  125. package/skills/land-and-deploy/SKILL.md.tmpl +0 -881
  126. package/skills/office-hours/SKILL.md +0 -96
  127. package/skills/office-hours/SKILL.md.tmpl +0 -645
  128. package/skills/plan-ceo-review/SKILL.md +0 -94
  129. package/skills/plan-ceo-review/SKILL.md.tmpl +0 -811
  130. package/skills/plan-design-review/SKILL.md +0 -92
  131. package/skills/plan-design-review/SKILL.md.tmpl +0 -446
  132. package/skills/plan-eng-review/SKILL.md +0 -93
  133. package/skills/plan-eng-review/SKILL.md.tmpl +0 -303
  134. package/skills/qa/SKILL.md +0 -95
  135. package/skills/qa/SKILL.md.tmpl +0 -316
  136. package/skills/qa/references/issue-taxonomy.md +0 -85
  137. package/skills/qa/templates/qa-report-template.md +0 -126
  138. package/skills/qa-only/SKILL.md +0 -89
  139. package/skills/qa-only/SKILL.md.tmpl +0 -101
  140. package/skills/retro/SKILL.md +0 -89
  141. package/skills/retro/SKILL.md.tmpl +0 -820
  142. package/skills/review/SKILL.md +0 -92
  143. package/skills/review/SKILL.md.tmpl +0 -281
  144. package/skills/review/TODOS-format.md +0 -62
  145. package/skills/review/checklist.md +0 -220
  146. package/skills/review/design-checklist.md +0 -132
  147. package/skills/review/greptile-triage.md +0 -220
  148. package/skills/setup-browser-cookies/SKILL.md.tmpl +0 -81
  149. package/skills/setup-deploy/SKILL.md +0 -92
  150. package/skills/setup-deploy/SKILL.md.tmpl +0 -215
  151. package/skills/ship/SKILL.md.tmpl +0 -636
  152. package/skills/unfreeze/SKILL.md.tmpl +0 -36
@@ -1,128 +0,0 @@
1
- /**
2
- * Command registry — single source of truth for all browse commands.
3
- *
4
- * Dependency graph:
5
- * commands.ts ──▶ server.ts (runtime dispatch)
6
- * ──▶ gen-skill-docs.ts (doc generation)
7
- * ──▶ skill-parser.ts (validation)
8
- * ──▶ skill-check.ts (health reporting)
9
- *
10
- * Zero side effects. Safe to import from build scripts and tests.
11
- */
12
-
13
- export const READ_COMMANDS = new Set([
14
- 'text', 'html', 'links', 'forms', 'accessibility',
15
- 'js', 'eval', 'css', 'attrs',
16
- 'console', 'network', 'cookies', 'storage', 'perf',
17
- 'dialog', 'is',
18
- ]);
19
-
20
- export const WRITE_COMMANDS = new Set([
21
- 'goto', 'back', 'forward', 'reload',
22
- 'click', 'fill', 'select', 'hover', 'type', 'press', 'scroll', 'wait',
23
- 'viewport', 'cookie', 'cookie-import', 'cookie-import-browser', 'header', 'useragent',
24
- 'upload', 'dialog-accept', 'dialog-dismiss',
25
- ]);
26
-
27
- export const META_COMMANDS = new Set([
28
- 'tabs', 'tab', 'newtab', 'closetab',
29
- 'status', 'stop', 'restart',
30
- 'screenshot', 'pdf', 'responsive',
31
- 'chain', 'diff',
32
- 'url', 'snapshot',
33
- 'handoff', 'resume',
34
- 'connect', 'disconnect', 'focus',
35
- 'inbox',
36
- 'watch',
37
- 'state',
38
- 'frame',
39
- ]);
40
-
41
- export const ALL_COMMANDS = new Set([...READ_COMMANDS, ...WRITE_COMMANDS, ...META_COMMANDS]);
42
-
43
- export const COMMAND_DESCRIPTIONS: Record<string, { category: string; description: string; usage?: string }> = {
44
- // Navigation
45
- 'goto': { category: 'Navigation', description: 'Navigate to URL', usage: 'goto <url>' },
46
- 'back': { category: 'Navigation', description: 'History back' },
47
- 'forward': { category: 'Navigation', description: 'History forward' },
48
- 'reload': { category: 'Navigation', description: 'Reload page' },
49
- 'url': { category: 'Navigation', description: 'Print current URL' },
50
- // Reading
51
- 'text': { category: 'Reading', description: 'Cleaned page text' },
52
- 'html': { category: 'Reading', description: 'innerHTML of selector (throws if not found), or full page HTML if no selector given', usage: 'html [selector]' },
53
- 'links': { category: 'Reading', description: 'All links as "text → href"' },
54
- 'forms': { category: 'Reading', description: 'Form fields as JSON' },
55
- 'accessibility': { category: 'Reading', description: 'Full ARIA tree' },
56
- // Inspection
57
- 'js': { category: 'Inspection', description: 'Run JavaScript expression and return result as string', usage: 'js <expr>' },
58
- 'eval': { category: 'Inspection', description: 'Run JavaScript from file and return result as string (path must be under /tmp or cwd)', usage: 'eval <file>' },
59
- 'css': { category: 'Inspection', description: 'Computed CSS value', usage: 'css <sel> <prop>' },
60
- 'attrs': { category: 'Inspection', description: 'Element attributes as JSON', usage: 'attrs <sel|@ref>' },
61
- 'is': { category: 'Inspection', description: 'State check (visible/hidden/enabled/disabled/checked/editable/focused)', usage: 'is <prop> <sel>' },
62
- 'console': { category: 'Inspection', description: 'Console messages (--errors filters to error/warning)', usage: 'console [--clear|--errors]' },
63
- 'network': { category: 'Inspection', description: 'Network requests', usage: 'network [--clear]' },
64
- 'dialog': { category: 'Inspection', description: 'Dialog messages', usage: 'dialog [--clear]' },
65
- 'cookies': { category: 'Inspection', description: 'All cookies as JSON' },
66
- 'storage': { category: 'Inspection', description: 'Read all localStorage + sessionStorage as JSON, or set <key> <value> to write localStorage', usage: 'storage [set k v]' },
67
- 'perf': { category: 'Inspection', description: 'Page load timings' },
68
- // Interaction
69
- 'click': { category: 'Interaction', description: 'Click element', usage: 'click <sel>' },
70
- 'fill': { category: 'Interaction', description: 'Fill input', usage: 'fill <sel> <val>' },
71
- 'select': { category: 'Interaction', description: 'Select dropdown option by value, label, or visible text', usage: 'select <sel> <val>' },
72
- 'hover': { category: 'Interaction', description: 'Hover element', usage: 'hover <sel>' },
73
- 'type': { category: 'Interaction', description: 'Type into focused element', usage: 'type <text>' },
74
- 'press': { category: 'Interaction', description: 'Press key — Enter, Tab, Escape, ArrowUp/Down/Left/Right, Backspace, Delete, Home, End, PageUp, PageDown, or modifiers like Shift+Enter', usage: 'press <key>' },
75
- 'scroll': { category: 'Interaction', description: 'Scroll element into view, or scroll to page bottom if no selector', usage: 'scroll [sel]' },
76
- 'wait': { category: 'Interaction', description: 'Wait for element, network idle, or page load (timeout: 15s)', usage: 'wait <sel|--networkidle|--load>' },
77
- 'upload': { category: 'Interaction', description: 'Upload file(s)', usage: 'upload <sel> <file> [file2...]' },
78
- 'viewport':{ category: 'Interaction', description: 'Set viewport size', usage: 'viewport <WxH>' },
79
- 'cookie': { category: 'Interaction', description: 'Set cookie on current page domain', usage: 'cookie <name>=<value>' },
80
- 'cookie-import': { category: 'Interaction', description: 'Import cookies from JSON file', usage: 'cookie-import <json>' },
81
- 'cookie-import-browser': { category: 'Interaction', description: 'Import cookies from installed Chromium browsers (opens picker, or use --domain for direct import)', usage: 'cookie-import-browser [browser] [--domain d]' },
82
- 'header': { category: 'Interaction', description: 'Set custom request header (colon-separated, sensitive values auto-redacted)', usage: 'header <name>:<value>' },
83
- 'useragent': { category: 'Interaction', description: 'Set user agent', usage: 'useragent <string>' },
84
- 'dialog-accept': { category: 'Interaction', description: 'Auto-accept next alert/confirm/prompt. Optional text is sent as the prompt response', usage: 'dialog-accept [text]' },
85
- 'dialog-dismiss': { category: 'Interaction', description: 'Auto-dismiss next dialog' },
86
- // Visual
87
- 'screenshot': { category: 'Visual', description: 'Save screenshot (supports element crop via CSS/@ref, --clip region, --viewport)', usage: 'screenshot [--viewport] [--clip x,y,w,h] [selector|@ref] [path]' },
88
- 'pdf': { category: 'Visual', description: 'Save as PDF', usage: 'pdf [path]' },
89
- 'responsive': { category: 'Visual', description: 'Screenshots at mobile (375x812), tablet (768x1024), desktop (1280x720). Saves as {prefix}-mobile.png etc.', usage: 'responsive [prefix]' },
90
- 'diff': { category: 'Visual', description: 'Text diff between pages', usage: 'diff <url1> <url2>' },
91
- // Tabs
92
- 'tabs': { category: 'Tabs', description: 'List open tabs' },
93
- 'tab': { category: 'Tabs', description: 'Switch to tab', usage: 'tab <id>' },
94
- 'newtab': { category: 'Tabs', description: 'Open new tab', usage: 'newtab [url]' },
95
- 'closetab':{ category: 'Tabs', description: 'Close tab', usage: 'closetab [id]' },
96
- // Server
97
- 'status': { category: 'Server', description: 'Health check' },
98
- 'stop': { category: 'Server', description: 'Shutdown server' },
99
- 'restart': { category: 'Server', description: 'Restart server' },
100
- // Meta
101
- 'snapshot':{ category: 'Snapshot', description: 'Accessibility tree with @e refs for element selection. Flags: -i interactive only, -c compact, -d N depth limit, -s sel scope, -D diff vs previous, -a annotated screenshot, -o path output, -C cursor-interactive @c refs', usage: 'snapshot [flags]' },
102
- 'chain': { category: 'Meta', description: 'Run commands from JSON stdin. Format: [["cmd","arg1",...],...]' },
103
- // Handoff
104
- 'handoff': { category: 'Server', description: 'Open visible Chrome at current page for user takeover', usage: 'handoff [message]' },
105
- 'resume': { category: 'Server', description: 'Re-snapshot after user takeover, return control to AI', usage: 'resume' },
106
- // Headed mode
107
- 'connect': { category: 'Server', description: 'Launch headed Chromium with Chrome extension', usage: 'connect' },
108
- 'disconnect': { category: 'Server', description: 'Disconnect headed browser, return to headless mode' },
109
- 'focus': { category: 'Server', description: 'Bring headed browser window to foreground (macOS)', usage: 'focus [@ref]' },
110
- // Inbox
111
- 'inbox': { category: 'Meta', description: 'List messages from sidebar scout inbox', usage: 'inbox [--clear]' },
112
- // Watch
113
- 'watch': { category: 'Meta', description: 'Passive observation — periodic snapshots while user browses', usage: 'watch [stop]' },
114
- // State
115
- 'state': { category: 'Server', description: 'Save/load browser state (cookies + URLs)', usage: 'state save|load <name>' },
116
- // Frame
117
- 'frame': { category: 'Meta', description: 'Switch to iframe context (or main to return)', usage: 'frame <sel|@ref|--name n|--url pattern|main>' },
118
- };
119
-
120
- // Load-time validation: descriptions must cover exactly the command sets
121
- const allCmds = new Set([...READ_COMMANDS, ...WRITE_COMMANDS, ...META_COMMANDS]);
122
- const descKeys = new Set(Object.keys(COMMAND_DESCRIPTIONS));
123
- for (const cmd of allCmds) {
124
- if (!descKeys.has(cmd)) throw new Error(`COMMAND_DESCRIPTIONS missing entry for: ${cmd}`);
125
- }
126
- for (const key of descKeys) {
127
- if (!allCmds.has(key)) throw new Error(`COMMAND_DESCRIPTIONS has unknown command: ${key}`);
128
- }
@@ -1,150 +0,0 @@
1
- /**
2
- * Shared config for browse CLI + server.
3
- *
4
- * Resolution:
5
- * 1. BROWSE_STATE_FILE env → derive stateDir from parent
6
- * 2. git rev-parse --show-toplevel → projectDir/.gstack/
7
- * 3. process.cwd() fallback (non-git environments)
8
- *
9
- * The CLI computes the config and passes BROWSE_STATE_FILE to the
10
- * spawned server. The server derives all paths from that env var.
11
- */
12
-
13
- import * as fs from 'fs';
14
- import * as path from 'path';
15
-
16
- export interface BrowseConfig {
17
- projectDir: string;
18
- stateDir: string;
19
- stateFile: string;
20
- consoleLog: string;
21
- networkLog: string;
22
- dialogLog: string;
23
- }
24
-
25
- /**
26
- * Detect the git repository root, or null if not in a repo / git unavailable.
27
- */
28
- export function getGitRoot(): string | null {
29
- try {
30
- const proc = Bun.spawnSync(['git', 'rev-parse', '--show-toplevel'], {
31
- stdout: 'pipe',
32
- stderr: 'pipe',
33
- timeout: 2_000, // Don't hang if .git is broken
34
- });
35
- if (proc.exitCode !== 0) return null;
36
- return proc.stdout.toString().trim() || null;
37
- } catch {
38
- return null;
39
- }
40
- }
41
-
42
- /**
43
- * Resolve all browse config paths.
44
- *
45
- * If BROWSE_STATE_FILE is set (e.g. by CLI when spawning server, or by
46
- * tests for isolation), all paths are derived from it. Otherwise, the
47
- * project root is detected via git or cwd.
48
- */
49
- export function resolveConfig(
50
- env: Record<string, string | undefined> = process.env,
51
- ): BrowseConfig {
52
- let stateFile: string;
53
- let stateDir: string;
54
- let projectDir: string;
55
-
56
- if (env.BROWSE_STATE_FILE) {
57
- stateFile = env.BROWSE_STATE_FILE;
58
- stateDir = path.dirname(stateFile);
59
- projectDir = path.dirname(stateDir); // parent of .gstack/
60
- } else {
61
- projectDir = getGitRoot() || process.cwd();
62
- stateDir = path.join(projectDir, '.gstack');
63
- stateFile = path.join(stateDir, 'browse.json');
64
- }
65
-
66
- return {
67
- projectDir,
68
- stateDir,
69
- stateFile,
70
- consoleLog: path.join(stateDir, 'browse-console.log'),
71
- networkLog: path.join(stateDir, 'browse-network.log'),
72
- dialogLog: path.join(stateDir, 'browse-dialog.log'),
73
- };
74
- }
75
-
76
- /**
77
- * Create the .gstack/ state directory if it doesn't exist.
78
- * Throws with a clear message on permission errors.
79
- */
80
- export function ensureStateDir(config: BrowseConfig): void {
81
- try {
82
- fs.mkdirSync(config.stateDir, { recursive: true });
83
- } catch (err: any) {
84
- if (err.code === 'EACCES') {
85
- throw new Error(`Cannot create state directory ${config.stateDir}: permission denied`);
86
- }
87
- if (err.code === 'ENOTDIR') {
88
- throw new Error(`Cannot create state directory ${config.stateDir}: a file exists at that path`);
89
- }
90
- throw err;
91
- }
92
-
93
- // Ensure .gstack/ is in the project's .gitignore
94
- const gitignorePath = path.join(config.projectDir, '.gitignore');
95
- try {
96
- const content = fs.readFileSync(gitignorePath, 'utf-8');
97
- if (!content.match(/^\.gstack\/?$/m)) {
98
- const separator = content.endsWith('\n') ? '' : '\n';
99
- fs.appendFileSync(gitignorePath, `${separator}.gstack/\n`);
100
- }
101
- } catch (err: any) {
102
- if (err.code !== 'ENOENT') {
103
- // Write warning to server log (visible even in daemon mode)
104
- const logPath = path.join(config.stateDir, 'browse-server.log');
105
- try {
106
- fs.appendFileSync(logPath, `[${new Date().toISOString()}] Warning: could not update .gitignore at ${gitignorePath}: ${err.message}\n`);
107
- } catch {
108
- // stateDir write failed too — nothing more we can do
109
- }
110
- }
111
- // ENOENT (no .gitignore) — skip silently
112
- }
113
- }
114
-
115
- /**
116
- * Derive a slug from the git remote origin URL (owner-repo format).
117
- * Falls back to the directory basename if no remote is configured.
118
- */
119
- export function getRemoteSlug(): string {
120
- try {
121
- const proc = Bun.spawnSync(['git', 'remote', 'get-url', 'origin'], {
122
- stdout: 'pipe',
123
- stderr: 'pipe',
124
- timeout: 2_000,
125
- });
126
- if (proc.exitCode !== 0) throw new Error('no remote');
127
- const url = proc.stdout.toString().trim();
128
- // SSH: git@github.com:owner/repo.git → owner-repo
129
- // HTTPS: https://github.com/owner/repo.git → owner-repo
130
- const match = url.match(/[:/]([^/]+)\/([^/]+?)(?:\.git)?$/);
131
- if (match) return `${match[1]}-${match[2]}`;
132
- throw new Error('unparseable');
133
- } catch {
134
- const root = getGitRoot();
135
- return path.basename(root || process.cwd());
136
- }
137
- }
138
-
139
- /**
140
- * Read the binary version (git SHA) from browse/dist/.version.
141
- * Returns null if the file doesn't exist or can't be read.
142
- */
143
- export function readVersionHash(execPath: string = process.execPath): string | null {
144
- try {
145
- const versionFile = path.resolve(path.dirname(execPath), '.version');
146
- return fs.readFileSync(versionFile, 'utf-8').trim() || null;
147
- } catch {
148
- return null;
149
- }
150
- }