Sed-pipeline (16 patterns, longest-match-first) sweeper residuelle ultra*-treff i prose, command-narrativ, agent-prompts, hook-kommentarer, doc-prosa. Pipeline-utvidelser fra V4-prompten: - BSD-syntax [[:<:]]ultra[[:>:]] istedenfor \bultra\b (BSD sed mangler \b) - 6 compound-patterns for ultraplan/ultraexecute/ultraresearch/ultrabrief/ ultrareview/ultracontinue uten -local-suffiks - ultra*-stats glob -> trek*-stats glob - Linje-eksklusjon redusert til ultra-cc-architect (Q8); session-state- eksklusjonen var over-protektiv - File-eksklusjon utvidet til settings.json, package.json, plugin.json, hele .claude/-treet (gitignored + V5-territorium) Q8-undantak holdt: architecture-discovery.mjs + project-discovery.mjs urort. Filnavn-konvensjon holdt: .session-state.local.json + *.local.* preservert. Manuell narrative-fix: tests/lib/agent-frontmatter.test.mjs linje 10 mangled "/ultra*-local" til "/voyage*-local" (ingen slik kommando finnes); korrigert til "/trek*". Residualer utenfor scope (V5 handterer): package.json + .claude-plugin/ plugin.json (Step 12-14 versjons-bump). .claude/* er gitignored spec-historikk med tilsiktet BEFORE/AFTER-narrativ. Part of voyage-rebrand session 3 (Wave 4 / Step 10). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
89 lines
2.4 KiB
JavaScript
Executable file
89 lines
2.4 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
// session-title.mjs — UserPromptSubmit hook (CC v2.1.94+)
|
|
//
|
|
// Sets a sessionTitle when the user invokes one of the four voyage commands,
|
|
// so multi-session headless runs are easy to identify in process lists and
|
|
// session pickers.
|
|
//
|
|
// Title format: voyage:<command>:<slug>
|
|
// - <command> ∈ {brief, research, plan, execute, review}
|
|
// - <slug> ∈ first 30 chars of project slug, or "ad-hoc" when no
|
|
// --project / --brief context is detected
|
|
//
|
|
// Fail-open invariant: any error → exit 0 with no output. We never block
|
|
// the user's prompt.
|
|
|
|
import { stdin } from 'node:process';
|
|
import { resolve, basename } from 'node:path';
|
|
|
|
const COMMANDS = {
|
|
'/trekbrief': 'brief',
|
|
'/trekresearch': 'research',
|
|
'/trekplan': 'plan',
|
|
'/trekexecute': 'execute',
|
|
'/trekreview': 'review',
|
|
'/trekcontinue': 'continue',
|
|
'/trekendsession': 'endsession',
|
|
};
|
|
|
|
function slugify(s) {
|
|
return String(s)
|
|
.toLowerCase()
|
|
.replace(/[^a-z0-9]+/g, '-')
|
|
.replace(/^-+|-+$/g, '')
|
|
.slice(0, 30) || 'ad-hoc';
|
|
}
|
|
|
|
function detectSlug(prompt) {
|
|
const projectMatch = prompt.match(/--project[=\s]+(\S+)/);
|
|
if (projectMatch) {
|
|
const dir = projectMatch[1].replace(/['"]/g, '');
|
|
const base = basename(resolve(dir));
|
|
const dateStripped = base.replace(/^\d{4}-\d{2}-\d{2}-/, '');
|
|
return slugify(dateStripped);
|
|
}
|
|
const briefMatch = prompt.match(/--brief[=\s]+(\S+)/);
|
|
if (briefMatch) {
|
|
const file = briefMatch[1].replace(/['"]/g, '');
|
|
return slugify(basename(file, '.md'));
|
|
}
|
|
return 'ad-hoc';
|
|
}
|
|
|
|
async function readStdin() {
|
|
let data = '';
|
|
for await (const chunk of stdin) data += chunk;
|
|
return data;
|
|
}
|
|
|
|
(async () => {
|
|
try {
|
|
const raw = await readStdin();
|
|
if (!raw.trim()) return;
|
|
const payload = JSON.parse(raw);
|
|
const prompt = String(payload.prompt || '').trim();
|
|
if (!prompt) return;
|
|
|
|
let matchedCmd = null;
|
|
for (const [cmd, short] of Object.entries(COMMANDS)) {
|
|
if (prompt.startsWith(cmd)) {
|
|
matchedCmd = short;
|
|
break;
|
|
}
|
|
}
|
|
if (!matchedCmd) return;
|
|
|
|
const slug = detectSlug(prompt);
|
|
const title = `voyage:${matchedCmd}:${slug}`;
|
|
|
|
const out = {
|
|
hookSpecificOutput: {
|
|
hookEventName: 'UserPromptSubmit',
|
|
sessionTitle: title,
|
|
},
|
|
};
|
|
process.stdout.write(JSON.stringify(out) + '\n');
|
|
} catch {
|
|
// fail open
|
|
}
|
|
})();
|