@indigoai-us/hq-cli 5.315.0 → 5.317.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.
- package/CHANGELOG.md +13 -0
- package/assets/scaffold/core/scripts/detect-stale-review-base.sh +199 -0
- package/assets/scaffold/core/scripts/repo-run-registry.sh +408 -0
- package/assets/scaffold/core/scripts/session-journal.sh +301 -0
- package/assets/scaffold/core/scripts/session-project.sh +800 -0
- package/assets/scaffold/core/scripts/session-title-config.sh +76 -0
- package/assets/scaffold/core/scripts/session-title.sh +305 -0
- package/assets/scaffold/core/scripts/share-suggestion-state.sh +541 -0
- package/dist/command-catalog.generated.d.ts +97 -0
- package/dist/command-catalog.generated.js +120 -0
- package/dist/commands/bot-jobs.d.ts +5 -1
- package/dist/commands/bot-jobs.js +24 -4
- package/dist/commands/core-detect-stale-review-base-native.d.ts +23 -0
- package/dist/commands/core-detect-stale-review-base-native.js +178 -0
- package/dist/commands/core-hook-state-helpers-native.d.ts +11 -0
- package/dist/commands/core-hook-state-helpers-native.js +74 -0
- package/dist/commands/core-repo-run-registry-native.d.ts +19 -0
- package/dist/commands/core-repo-run-registry-native.js +357 -0
- package/dist/commands/core-session-helper-runtime.d.ts +10 -0
- package/dist/commands/core-session-helper-runtime.js +7 -0
- package/dist/commands/core-session-journal-native.d.ts +4 -0
- package/dist/commands/core-session-journal-native.js +327 -0
- package/dist/commands/core-session-project-native.d.ts +3 -0
- package/dist/commands/core-session-project-native.js +855 -0
- package/dist/commands/core-session-title-config-native.d.ts +4 -0
- package/dist/commands/core-session-title-config-native.js +77 -0
- package/dist/commands/core-session-title-native.d.ts +3 -0
- package/dist/commands/core-session-title-native.js +306 -0
- package/dist/commands/core-share-suggestion-state-native.d.ts +18 -0
- package/dist/commands/core-share-suggestion-state-native.js +445 -0
- package/dist/commands/core.js +66 -0
- package/dist/commands/lanes.js +35 -5
- package/dist/fast-core.d.ts +1 -0
- package/dist/fast-core.js +10 -6
- package/dist/fast-scaffold.js +33 -0
- package/dist/lib/bot/job-quiet-flag.d.ts +4 -0
- package/dist/lib/bot/job-quiet-flag.js +14 -0
- package/dist/lib/bot/job-run.d.ts +5 -0
- package/dist/lib/bot/job-run.js +23 -3
- package/dist/lib/bot/run.d.ts +2 -0
- package/dist/lib/bot/run.js +15 -3
- package/dist/lib/core-utils/common.d.ts +0 -1
- package/dist/lib/core-utils/common.js +0 -9
- package/dist/lib/lanes/autopilot.d.ts +5 -1
- package/dist/lib/lanes/autopilot.js +72 -3
- package/dist/lib/lanes/disk-guard.d.ts +3 -4
- package/dist/lib/lanes/disk-guard.js +2 -2
- package/dist/lib/lanes/flag-keys.d.ts +3 -0
- package/dist/lib/lanes/flag-keys.js +3 -0
- package/dist/lib/lanes/hooks-install.js +78 -2
- package/dist/lib/lanes/keep-alive-audit.d.ts +6 -5
- package/dist/lib/lanes/outpost-dispatch.d.ts +9 -0
- package/dist/lib/lanes/outpost-dispatch.js +22 -0
- package/dist/utils/version-gate.js +8 -7
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type SessionHelperRuntimeOverrides } from "./core-session-helper-runtime.js";
|
|
2
|
+
/** Port of the flat grep/sed settings helper; the hook still parses its own YAML. */
|
|
3
|
+
export declare function runSessionTitleConfigFast(args: readonly string[], _stdin: string, cwd: string, hqRoot: string | undefined, dependencies?: SessionHelperRuntimeOverrides): number;
|
|
4
|
+
//# sourceMappingURL=core-session-title-config-native.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { resolveSessionHelperRuntime } from "./core-session-helper-runtime.js";
|
|
4
|
+
const C_SPACE = " \\t\\r\\n\\v\\f";
|
|
5
|
+
function yamlScalar(file, key) {
|
|
6
|
+
let text;
|
|
7
|
+
try {
|
|
8
|
+
if (!fs.statSync(file).isFile())
|
|
9
|
+
return undefined;
|
|
10
|
+
text = fs.readFileSync(file, "utf8");
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const line = text.split(/\r?\n/).find((item) => new RegExp(`^${key}:[${C_SPACE}]*`).test(item));
|
|
16
|
+
if (line === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
const value = line.slice(line.indexOf(":") + 1)
|
|
19
|
+
.replace(new RegExp(`[${C_SPACE}]*#.*$`), "")
|
|
20
|
+
.replace(new RegExp(`^[${C_SPACE}]+`), "")
|
|
21
|
+
.replace(new RegExp(`[${C_SPACE}]+$`), "")
|
|
22
|
+
.replace(/^['"]/, "")
|
|
23
|
+
.replace(/['"]$/, "");
|
|
24
|
+
return value || undefined;
|
|
25
|
+
}
|
|
26
|
+
function resolveSettings(root, env) {
|
|
27
|
+
const settings = {
|
|
28
|
+
enabled: "true",
|
|
29
|
+
mode: "full",
|
|
30
|
+
desktopAutoname: "ignore-first",
|
|
31
|
+
};
|
|
32
|
+
for (const file of [
|
|
33
|
+
path.join(root, "core/settings/session-title.yaml"),
|
|
34
|
+
path.join(root, "personal/settings/session-title.yaml"),
|
|
35
|
+
]) {
|
|
36
|
+
settings.enabled = yamlScalar(file, "enabled") || settings.enabled;
|
|
37
|
+
settings.mode = yamlScalar(file, "mode") || settings.mode;
|
|
38
|
+
settings.desktopAutoname = yamlScalar(file, "desktop_autoname") || settings.desktopAutoname;
|
|
39
|
+
}
|
|
40
|
+
settings.enabled = ["0", "false", "FALSE", "False", "off", "OFF", "no", "NO"].includes(settings.enabled)
|
|
41
|
+
? "false" : "true";
|
|
42
|
+
settings.mode = ["auto", "AUTO", "hook", "deterministic"].includes(settings.mode) ? "auto" : "full";
|
|
43
|
+
settings.desktopAutoname = ["respect", "RESPECT", "off", "OFF", "false", "FALSE", "no", "NO"].includes(settings.desktopAutoname)
|
|
44
|
+
? "respect" : "ignore-first";
|
|
45
|
+
switch (env.HQ_SESSION_TITLE ?? "") {
|
|
46
|
+
case "0":
|
|
47
|
+
case "false":
|
|
48
|
+
case "FALSE":
|
|
49
|
+
case "off":
|
|
50
|
+
case "OFF":
|
|
51
|
+
case "no":
|
|
52
|
+
case "NO":
|
|
53
|
+
settings.enabled = "false";
|
|
54
|
+
break;
|
|
55
|
+
case "auto":
|
|
56
|
+
case "AUTO":
|
|
57
|
+
settings.mode = "auto";
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if ((env.HQ_DISABLED_HOOKS ?? "").includes("session-title"))
|
|
61
|
+
settings.enabled = "false";
|
|
62
|
+
return settings;
|
|
63
|
+
}
|
|
64
|
+
/** Port of the flat grep/sed settings helper; the hook still parses its own YAML. */
|
|
65
|
+
export function runSessionTitleConfigFast(args, _stdin, cwd, hqRoot, dependencies = {}) {
|
|
66
|
+
let root = hqRoot ?? cwd;
|
|
67
|
+
for (let i = 0; i < args.length; i++) {
|
|
68
|
+
if (args[i] === "--root") {
|
|
69
|
+
root = args[i + 1] ?? root;
|
|
70
|
+
i++;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const settings = resolveSettings(root, resolveSessionHelperRuntime(dependencies).env);
|
|
74
|
+
process.stdout.write(`enabled=${settings.enabled}\nmode=${settings.mode}\ndesktop_autoname=${settings.desktopAutoname}\n`);
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=core-session-title-config-native.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type SessionHelperRuntimeOverrides } from "./core-session-helper-runtime.js";
|
|
2
|
+
export declare function runSessionTitleFast(args: readonly string[], _stdin: string, processCwd: string, root: string | undefined, dependencies?: SessionHelperRuntimeOverrides): number;
|
|
3
|
+
//# sourceMappingURL=core-session-title-native.d.ts.map
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { resolveSessionHelperRuntime } from "./core-session-helper-runtime.js";
|
|
4
|
+
// The legacy helper's compute body is kept as in-process TypeScript.
|
|
5
|
+
export function runSessionTitleFast(args, _stdin, processCwd, root, dependencies = {}) {
|
|
6
|
+
const { now } = resolveSessionHelperRuntime(dependencies);
|
|
7
|
+
let sessionId = "default";
|
|
8
|
+
let commandArg = "";
|
|
9
|
+
let sessionCwd = "";
|
|
10
|
+
for (let i = 0; i < args.length; i++) {
|
|
11
|
+
switch (args[i]) {
|
|
12
|
+
case "--session-id":
|
|
13
|
+
sessionId = args[i + 1] ?? "default";
|
|
14
|
+
i++;
|
|
15
|
+
break;
|
|
16
|
+
case "--command":
|
|
17
|
+
commandArg = args[i + 1] ?? "";
|
|
18
|
+
i++;
|
|
19
|
+
break;
|
|
20
|
+
case "--cwd":
|
|
21
|
+
sessionCwd = args[i + 1] ?? "";
|
|
22
|
+
i++;
|
|
23
|
+
break;
|
|
24
|
+
default: break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const resolvedRoot = root ?? processCwd;
|
|
28
|
+
const hq = resolvedRoot;
|
|
29
|
+
const sid = sessionId;
|
|
30
|
+
let command = (commandArg || "").trim().replace(/^\/+/, "");
|
|
31
|
+
const key = sid.replace(/[^A-Za-z0-9._-]/g, "_") || "default";
|
|
32
|
+
const state = path.join(hq, ".claude", "state");
|
|
33
|
+
const firstLine = (p) => {
|
|
34
|
+
try {
|
|
35
|
+
for (let line of fs.readFileSync(p, "utf8").split(/\r?\n/)) {
|
|
36
|
+
line = line.trim();
|
|
37
|
+
if (line)
|
|
38
|
+
return line;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch { /* the manifest is optional */ }
|
|
42
|
+
return "";
|
|
43
|
+
};
|
|
44
|
+
// --- resolve active project path (session-scoped, then global fallback) ---
|
|
45
|
+
// Session-scoped ONLY. There used to be a fallback to the machine-global
|
|
46
|
+
// .claude/state/active-session-project here; it made every session without its
|
|
47
|
+
// own entry inherit whatever project was last active anywhere on the box (142
|
|
48
|
+
// unrelated sessions all named "learn-policies-only · chat"). Session-scoped
|
|
49
|
+
// state must fail to empty, never to a shared global.
|
|
50
|
+
const projPath = firstLine(path.join(state, "auto-session-project-" + key));
|
|
51
|
+
let company = "";
|
|
52
|
+
let project = "";
|
|
53
|
+
if (projPath) {
|
|
54
|
+
let rel = projPath;
|
|
55
|
+
try {
|
|
56
|
+
const resolved = fs.realpathSync(projPath);
|
|
57
|
+
const hqResolved = fs.realpathSync(hq);
|
|
58
|
+
const r = path.relative(hqResolved, resolved);
|
|
59
|
+
if (r === "" || r.startsWith("..") || path.isAbsolute(r))
|
|
60
|
+
throw new Error("outside hq");
|
|
61
|
+
rel = r;
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
rel = projPath.split(hq.replace(/\/+$/, "") + "/").join("");
|
|
65
|
+
}
|
|
66
|
+
const parts = rel.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "").split("/").filter(Boolean);
|
|
67
|
+
if (parts.length >= 2 && parts[0] === "companies") {
|
|
68
|
+
company = parts[1];
|
|
69
|
+
project = parts[parts.length - 1];
|
|
70
|
+
}
|
|
71
|
+
else if (parts.length && parts[0] === "personal") {
|
|
72
|
+
company = "personal"; // rendered as the "ME" org token
|
|
73
|
+
project = parts[parts.length - 1];
|
|
74
|
+
}
|
|
75
|
+
else if (parts.length) {
|
|
76
|
+
project = parts[parts.length - 1];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// --- company fallbacks when no project resolved ---
|
|
80
|
+
if (!company && command === "hqwork")
|
|
81
|
+
company = "hq-core";
|
|
82
|
+
if (!company && !project) {
|
|
83
|
+
const manifest = path.join(hq, "companies", "manifest.yaml");
|
|
84
|
+
const slugs = [];
|
|
85
|
+
try {
|
|
86
|
+
let inCompanies = false;
|
|
87
|
+
for (const line of fs.readFileSync(manifest, "utf8").split(/\r?\n/)) {
|
|
88
|
+
if (!line.trim() || line.trimStart().startsWith("#"))
|
|
89
|
+
continue;
|
|
90
|
+
if (inCompanies && /^[^\s#]/.test(line))
|
|
91
|
+
break;
|
|
92
|
+
if (/^companies:\s*$/.test(line)) {
|
|
93
|
+
inCompanies = true;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (inCompanies) {
|
|
97
|
+
const m = line.match(/^\x20{2}([a-z][a-z0-9_-]*):\s*$/);
|
|
98
|
+
if (m && m[1] !== "_template")
|
|
99
|
+
slugs.push(m[1]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch { /* orchestrator state is optional */ }
|
|
104
|
+
if (slugs.length === 1)
|
|
105
|
+
company = slugs[0];
|
|
106
|
+
}
|
|
107
|
+
// --- status emoji from the orchestrator ---
|
|
108
|
+
let emoji = "";
|
|
109
|
+
const orch = path.join(hq, "workspace", "orchestrator", "state.json");
|
|
110
|
+
if (project) {
|
|
111
|
+
try {
|
|
112
|
+
const data = JSON.parse(fs.readFileSync(orch, "utf8"));
|
|
113
|
+
for (const p of data.projects || []) {
|
|
114
|
+
const nm = p.name || "";
|
|
115
|
+
const prd = String(p.prdPath || "").replace(/\\/g, "/");
|
|
116
|
+
const expectedProjectPath = company === "personal"
|
|
117
|
+
? `personal/projects/${project}/`
|
|
118
|
+
: company ? `companies/${company}/projects/${project}/` : "";
|
|
119
|
+
const matchesProject = prd
|
|
120
|
+
? expectedProjectPath
|
|
121
|
+
? prd.replace(/^\/+/, "").includes(expectedProjectPath)
|
|
122
|
+
: nm === project || prd.includes("/" + project + "/")
|
|
123
|
+
: nm === project;
|
|
124
|
+
if (matchesProject) {
|
|
125
|
+
const st = p.state || "";
|
|
126
|
+
if (st === "IN_PROGRESS") {
|
|
127
|
+
emoji = "▶️";
|
|
128
|
+
}
|
|
129
|
+
else if (st === "COMPLETED") {
|
|
130
|
+
const ts = p.updatedAt || p.updated_at || "";
|
|
131
|
+
const t = new Date(ts);
|
|
132
|
+
if (!isNaN(t.getTime()) && (now().getTime() - t.getTime()) / 1000 < 86400) {
|
|
133
|
+
emoji = "✅"; // only recent completions
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch { /* orchestrator state is optional */ }
|
|
141
|
+
}
|
|
142
|
+
// --- mode ---
|
|
143
|
+
// The emoji encodes what the session IS DOING, not what domain it belongs to.
|
|
144
|
+
// State is what a human scans a sidebar for ("does this need me?"); domain is
|
|
145
|
+
// already implied by the subject line. Keyed on the active slash command,
|
|
146
|
+
// which the wrapper hook already tracks turn to turn.
|
|
147
|
+
//
|
|
148
|
+
// Exactly ONE glyph, never two — a second glyph beside the first reads as a
|
|
149
|
+
// badge pair and makes the left edge busier without making it more scannable.
|
|
150
|
+
// The single slot shows the most USEFUL thing about the session right now,
|
|
151
|
+
// picked by the precedence ladder in hq-session-title-grammar: work that needs
|
|
152
|
+
// the user or has terminated outranks the session kind, which outranks the
|
|
153
|
+
// workflow stage, which outranks the craft.
|
|
154
|
+
//
|
|
155
|
+
// This script only ever emits a stage or kind glyph. It never emits 🙋 (needs
|
|
156
|
+
// the user) — it cannot know that — and never a craft glyph, since its only
|
|
157
|
+
// subject is a directory slug and any keyword match against that slug is
|
|
158
|
+
// redundant with the slug by construction. Both are the model's job.
|
|
159
|
+
//
|
|
160
|
+
// A handoff has two moments and they are different rows in a sidebar:
|
|
161
|
+
// 📝 the handoff is being written (the session is wrapping up) and 📤 it is
|
|
162
|
+
// ready (the session is closed; resume from the thread). This script emits 📝
|
|
163
|
+
// while /handoff runs; only the model can know when it finished, so it sets 📤.
|
|
164
|
+
// Both are distinct from ✅ "the work shipped" and 🤝 "a person owns it now".
|
|
165
|
+
const MODES = [
|
|
166
|
+
[/^(brainstorm|idea|dream|discover|strategize)$/, "💭"],
|
|
167
|
+
[/^(plan|prd|deep-plan|storyboard|architect|review-plan|codebase-design)$/, "📐"],
|
|
168
|
+
[/^(run-project|execute-task|ship|land|land-batch|run-pipeline|orchestrate|tdd|deploy)$/, "⚡"],
|
|
169
|
+
[/^(review|code-review|security-review)$/, "👀"],
|
|
170
|
+
[/^(quality-gate|smoke|verify|diagnose|investigate)$/, "🧪"],
|
|
171
|
+
[/^(handoff|checkpoint-handoff|retro)$/, "📝"],
|
|
172
|
+
[/^(delegate|new-hire|new-agent|promote)$/, "🤝"],
|
|
173
|
+
[/^(dm|hq-slack|meeting-notes|work-broadcast|signals|hq-share)$/, "💬"],
|
|
174
|
+
[/^(schedule|job|loop)$/, "🔁"],
|
|
175
|
+
];
|
|
176
|
+
const modeFor = (word) => {
|
|
177
|
+
for (const [re, ic] of MODES)
|
|
178
|
+
if (re.test(word))
|
|
179
|
+
return ic;
|
|
180
|
+
return "";
|
|
181
|
+
};
|
|
182
|
+
if (!command)
|
|
183
|
+
command = "chat";
|
|
184
|
+
// Precedence: a finished or running project outranks the command word — "it
|
|
185
|
+
// shipped" and "it is executing right now" beat "you typed /plan an hour ago".
|
|
186
|
+
// `emoji` is set above from orchestrator state (✅ recent completion, ▶️ running).
|
|
187
|
+
const mode = emoji === "▶️" ? "⚡" : (emoji || modeFor(command));
|
|
188
|
+
// --- company ---
|
|
189
|
+
// Always the first text token. Long slugs get an explicit short form from the
|
|
190
|
+
// settings `aliases:` block rather than a mid-word truncation — a single-word
|
|
191
|
+
// slug sliced at 8 characters is unreadable.
|
|
192
|
+
// Built-ins only. Company short forms are USER data — a release-shipped file
|
|
193
|
+
// must never carry tenant slugs (enforced by the slug-scan / denylist-scan CI
|
|
194
|
+
// gates). Users map their own long slugs in personal/settings/session-title.yaml:
|
|
195
|
+
//
|
|
196
|
+
// aliases:
|
|
197
|
+
// some-long-company-slug: SHORT
|
|
198
|
+
//
|
|
199
|
+
const ALIASES = { personal: "ME", "hq-core": "HQ" };
|
|
200
|
+
// Merge user aliases from the settings files, lowest precedence first.
|
|
201
|
+
const readAliases = (file) => {
|
|
202
|
+
let text = "";
|
|
203
|
+
try {
|
|
204
|
+
text = fs.readFileSync(file, "utf8");
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
let inBlock = false;
|
|
210
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
211
|
+
const line = raw.replace(/#.*$/, "").replace(/\s+$/, "");
|
|
212
|
+
if (!line.trim())
|
|
213
|
+
continue;
|
|
214
|
+
if (/^aliases:\s*$/.test(line)) {
|
|
215
|
+
inBlock = true;
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (!/^\s/.test(line)) {
|
|
219
|
+
inBlock = false;
|
|
220
|
+
continue;
|
|
221
|
+
} // any new top-level key ends it
|
|
222
|
+
if (!inBlock)
|
|
223
|
+
continue;
|
|
224
|
+
const m = line.match(/^\s+["']?([A-Za-z0-9._-]+)["']?:\s*["']?([^"'\s]+)["']?\s*$/);
|
|
225
|
+
if (m)
|
|
226
|
+
ALIASES[m[1]] = m[2];
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
readAliases(path.join(hq, "core", "settings", "session-title.yaml"));
|
|
230
|
+
readAliases(path.join(hq, "personal", "settings", "session-title.yaml"));
|
|
231
|
+
let org = "";
|
|
232
|
+
if (company) {
|
|
233
|
+
org = ALIASES[company];
|
|
234
|
+
if (!org) {
|
|
235
|
+
const head = company.split("-")[0].toUpperCase();
|
|
236
|
+
org = head.length <= 8 ? head : head.slice(0, 8);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// --- compose ---
|
|
240
|
+
// Grammar: {glyph} {COMPANY} · {Product} · {subject}
|
|
241
|
+
//
|
|
242
|
+
// Every rendered glyph must mean something. When the mode is unknown the title
|
|
243
|
+
// simply starts with the company — a placeholder icon (the old "🟦") is worse
|
|
244
|
+
// than nothing, because it trains the eye to ignore the emoji column.
|
|
245
|
+
//
|
|
246
|
+
// The hook can only ever put a directory slug in the subject slot. A session
|
|
247
|
+
// that knows what it is actually about should overwrite this via
|
|
248
|
+
// set_session_title, keeping the same grammar.
|
|
249
|
+
// --- product / repo ---
|
|
250
|
+
// The repo or product the session is working in, rendered between the company
|
|
251
|
+
// and the subject so identity survives a narrow sidebar's truncation. Derived
|
|
252
|
+
// from the session cwd when it sits inside repos/; otherwise left to the model.
|
|
253
|
+
//
|
|
254
|
+
// A leading company prefix is stripped, because the company token already said
|
|
255
|
+
// it: repos/public/hq-work under company HQ renders as "Work", not "Hq-work".
|
|
256
|
+
let product = "";
|
|
257
|
+
const cwd = sessionCwd;
|
|
258
|
+
if (cwd) {
|
|
259
|
+
const rel = cwd.split(/[\\/]/).filter(Boolean);
|
|
260
|
+
const i = rel.lastIndexOf("repos");
|
|
261
|
+
if (i !== -1 && rel.length > i + 1) {
|
|
262
|
+
// repos/<public|private>/<repo>/... or repos/<repo>/...
|
|
263
|
+
let name = rel[i + 1];
|
|
264
|
+
if ((name === "public" || name === "private") && rel.length > i + 2)
|
|
265
|
+
name = rel[i + 2];
|
|
266
|
+
if (name) {
|
|
267
|
+
// "hq-work" -> ["HQ", "Work"]. Two-letter tokens are acronyms, not words.
|
|
268
|
+
let words = name.split("-").filter(Boolean).map((w) => w.length <= 2 ? w.toUpperCase() : w.charAt(0).toUpperCase() + w.slice(1));
|
|
269
|
+
// Drop a leading word the company token already said: under company HQ,
|
|
270
|
+
// "hq-work" is "Work", not "HQ Work".
|
|
271
|
+
if (org && words.length > 1 && words[0].toUpperCase() === org.toUpperCase()) {
|
|
272
|
+
words = words.slice(1);
|
|
273
|
+
}
|
|
274
|
+
product = words.join(" ");
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const subject = project || "";
|
|
279
|
+
// --- stub suppression -------------------------------------------------------
|
|
280
|
+
// With no project AND no repo/product, every remaining ingredient is
|
|
281
|
+
// information-free: a bare command word ("chat", "startwork") or a lone org
|
|
282
|
+
// token ("HQ"). Emitting one of those is actively harmful — it is not merely
|
|
283
|
+
// useless, it OVERWRITES the host's written summary ("HQ core skill cloning")
|
|
284
|
+
// with a word that distinguishes nothing, and because the stub never changes,
|
|
285
|
+
// the wrapper's change-only cadence then goes silent for the rest of the
|
|
286
|
+
// session. Sessions were sitting on 1281 prompts still titled "chat".
|
|
287
|
+
//
|
|
288
|
+
// Printing nothing makes the wrapper exit before it emits or records anything,
|
|
289
|
+
// so the host's own title stands. The moment a project or repo does resolve,
|
|
290
|
+
// the normal path takes the title back.
|
|
291
|
+
if (!project && !product)
|
|
292
|
+
return 0;
|
|
293
|
+
const parts = [org, product, subject].filter(Boolean);
|
|
294
|
+
if (!parts.length)
|
|
295
|
+
parts.push(command);
|
|
296
|
+
const compose = (ps) => (mode ? mode + " " : "") + ps.join(" · ");
|
|
297
|
+
const MAX = 56;
|
|
298
|
+
let title = compose(parts);
|
|
299
|
+
if (title.length > MAX && parts.length > 1)
|
|
300
|
+
title = compose([parts[parts.length - 1]]);
|
|
301
|
+
if (title.length > MAX)
|
|
302
|
+
title = title.slice(0, MAX - 1).replace(/\s+$/, "") + "…";
|
|
303
|
+
process.stdout.write(title + "\n");
|
|
304
|
+
return 0;
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=core-session-title-native.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Native port of share-suggestion-state.sh; kept dependency-light for hooks. */
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
export declare const SHARE_SUGGESTION_STATE_ASSET = "core/scripts/share-suggestion-state.sh";
|
|
4
|
+
export type HookHelperOutput = {
|
|
5
|
+
code: number;
|
|
6
|
+
stdout: string;
|
|
7
|
+
stderr: string;
|
|
8
|
+
};
|
|
9
|
+
export type ShareSuggestionDependencies = {
|
|
10
|
+
root: string;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
env?: NodeJS.ProcessEnv;
|
|
13
|
+
fs?: Pick<typeof fs, "existsSync" | "statSync" | "readFileSync" | "writeFileSync" | "appendFileSync" | "renameSync" | "unlinkSync" | "mkdirSync">;
|
|
14
|
+
now?: () => Date;
|
|
15
|
+
stdinIsTty?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function runShareSuggestionState(args: readonly string[], stdin: string, deps: ShareSuggestionDependencies): HookHelperOutput;
|
|
18
|
+
//# sourceMappingURL=core-share-suggestion-state-native.d.ts.map
|