mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-17 21:54:30 +01:00
* Keep the scroll selector when --wait is absent Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Skip a PATH browse that links to another program such as xdg-open Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Give each project its own browse slug on installs without ~/.claude Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Keep a question marker when its signal hint is malformed Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Read the lowercased question id in the never-ask preference hook Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Keep a marker's tail in the one-way door check Review-Finding: p1/targeted#1 reader=targeted Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Keep a marker's tail apart from the next word in the one-way door check Review-Finding: p2/outside-voice#1 reader=outside-voice Review-Finding: p2/adversarial-native#1 reader=adversarial-native Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Say where old domain skills live and narrow the marker note in the changelog Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> * Say how the browse daemon picks a project's domain skill file Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --------- Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
/**
|
|
* Project slug resolution for the browse daemon.
|
|
*
|
|
* Used by domain-skills (per-project storage) and sidebar prompt-context
|
|
* injection. Cached after first call — slug is derived from the daemon's
|
|
* git remote (or env override) and doesn't change between commands.
|
|
*
|
|
* gstack-slug is read from the checkout this daemon runs from first, then
|
|
* from the Claude Code install. Codex, repo-local and other host installs
|
|
* have no ~/.claude copy; when no gstack-slug runs, the slug comes from the
|
|
* same remote rule (getRemoteSlug) instead of one shared "unknown" bucket
|
|
* that would mix every project's domain skills.
|
|
*/
|
|
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import * as os from 'os';
|
|
import { execFileSync } from 'child_process';
|
|
import { getRemoteSlug } from './config';
|
|
|
|
let cachedSlug: string | null = null;
|
|
|
|
export function getCurrentProjectSlug(): string {
|
|
if (cachedSlug) return cachedSlug;
|
|
const explicit = process.env.GSTACK_PROJECT_SLUG;
|
|
if (explicit) {
|
|
cachedSlug = explicit;
|
|
return explicit;
|
|
}
|
|
const candidates = [
|
|
path.resolve(import.meta.dir, '../../bin/gstack-slug'),
|
|
path.join(os.homedir(), '.claude/skills/gstack/bin/gstack-slug'),
|
|
];
|
|
for (const slugBin of candidates) {
|
|
if (!fs.existsSync(slugBin)) continue;
|
|
try {
|
|
const out = execFileSync(slugBin, [], { encoding: 'utf8', timeout: 2000, windowsHide: true }).trim();
|
|
const m = out.match(/SLUG="?([^"\n]+)"?/);
|
|
if (m) {
|
|
cachedSlug = m[1]!;
|
|
return cachedSlug;
|
|
}
|
|
} catch {
|
|
// next candidate
|
|
}
|
|
}
|
|
cachedSlug = getRemoteSlug() || 'unknown';
|
|
return cachedSlug;
|
|
}
|
|
|
|
/** Reset cache; for tests only. */
|
|
export function _resetProjectSlugCache(): void {
|
|
cachedSlug = null;
|
|
}
|