kaizen-agent 1.60.1 → 1.61.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/cli/knowledge.ts +1 -1
- package/cli/notes.test.ts +2 -1
- package/cli/onboarding.test.ts +70 -0
- package/cli/onboarding.ts +63 -0
- package/cli/pty.test.ts +15 -1
- package/cli/pty.ts +14 -3
- package/cli/shell-agent.test.ts +23 -0
- package/cli/state.test.ts +105 -1
- package/cli/state.ts +157 -19
- package/cli/web-decide.test.ts +41 -0
- package/cli/web.ts +145 -27
- package/package.json +1 -1
- package/web/board/add-project.ts +14 -4
- package/web/board/api.ts +37 -4
- package/web/board/approvals.ts +6 -6
- package/web/board/badge.ts +6 -2
- package/web/board/cards.ts +4 -2
- package/web/board/fixes.ts +1 -1
- package/web/board/git.ts +171 -97
- package/web/board/live.ts +2 -1
- package/web/board/main.ts +2 -0
- package/web/board/onboarding.ts +223 -0
- package/web/board/panel.ts +24 -14
- package/web/board/run-view.ts +86 -7
- package/web/board/settings-pages.test.ts +19 -0
- package/web/board/settings-pages.ts +44 -0
- package/web/board/settings.ts +118 -62
- package/web/board/store.ts +4 -0
- package/web/board/update.ts +1 -1
- package/web/board/views.ts +5 -1
- package/web/board/workspace.ts +92 -3
- package/web/board/ws-name.test.ts +10 -0
- package/web/board/ws-tabs.test.ts +14 -1
- package/web/board/ws-tabs.ts +12 -1
- package/web/board.html +165 -21
- package/web/board.js +107 -104
- package/web/notebook.js +29 -24
- package/web/notebook.ts +1 -0
- package/web/notes.html +28 -10
- package/web/popup.html +2 -2
- package/web/term.js +20 -20
- package/web/term.ts +8 -3
- package/web/video.html +28 -10
- package/web/video.js +56 -51
package/web/board/views.ts
CHANGED
|
@@ -38,6 +38,7 @@ export function go(v, push) {
|
|
|
38
38
|
markView(v);
|
|
39
39
|
document.body.classList.toggle("paged", v !== "board");
|
|
40
40
|
document.body.classList.toggle("ice", v === "sources");
|
|
41
|
+
document.body.classList.toggle("setv", v === "settings");
|
|
41
42
|
document.body.classList.toggle("termv", v === "terminal");
|
|
42
43
|
const ph = isPhone() && v === "home";
|
|
43
44
|
document.body.classList.toggle("homev", (v === "home" && !ph) || v === "chat");
|
|
@@ -98,7 +99,10 @@ export function initViews() {
|
|
|
98
99
|
a.onclick = (e) => {
|
|
99
100
|
if (e.ctrlKey || e.metaKey || e.shiftKey || e.button) return;
|
|
100
101
|
e.preventDefault();
|
|
101
|
-
if (a.dataset.view === "settings")
|
|
102
|
+
if (a.dataset.view === "settings") {
|
|
103
|
+
store.setQ = "";
|
|
104
|
+
store.setBack = view !== "settings";
|
|
105
|
+
}
|
|
102
106
|
vt(() => go(a.dataset.view, true));
|
|
103
107
|
};
|
|
104
108
|
});
|
package/web/board/workspace.ts
CHANGED
|
@@ -84,6 +84,73 @@ const folded: Set<string> = (() => {
|
|
|
84
84
|
return new Set();
|
|
85
85
|
}
|
|
86
86
|
})();
|
|
87
|
+
// Pinned worktrees (dir\0ws), kept per browser.
|
|
88
|
+
const pins: Set<string> = (() => {
|
|
89
|
+
try {
|
|
90
|
+
return new Set(JSON.parse(localStorage.getItem("kz-ws-pins") || "[]"));
|
|
91
|
+
} catch {
|
|
92
|
+
return new Set();
|
|
93
|
+
}
|
|
94
|
+
})();
|
|
95
|
+
// The right-click menu on a worktree row: update, copy path, copy name, pin, delete.
|
|
96
|
+
function wsMenu(e: MouseEvent, a: HTMLElement) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
document.getElementById("wsmenu")?.remove();
|
|
99
|
+
const dir = a.dataset.dir!, ws = a.dataset.ws!, key = dir + "\0" + ws;
|
|
100
|
+
const w = last.projects?.find((p) => p.dir === dir)?.workspaces?.find((x) => x.path === ws);
|
|
101
|
+
if (!w) return;
|
|
102
|
+
const name = wsLabel(w);
|
|
103
|
+
const say = (m: string) => {
|
|
104
|
+
const t = $("toast");
|
|
105
|
+
t.textContent = m;
|
|
106
|
+
t.classList.add("on");
|
|
107
|
+
setTimeout(() => t.classList.remove("on"), 4000);
|
|
108
|
+
};
|
|
109
|
+
const copy = (text: string) => navigator.clipboard.writeText(text).then(() => say("Copied"), () => say("Could not copy"));
|
|
110
|
+
const op = async (o: string) => {
|
|
111
|
+
say(o === "update" ? "Updating…" : "Deleting…");
|
|
112
|
+
const r = await fetch("/workspace", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dir, ws, op: o }) }).catch(() => null);
|
|
113
|
+
const j = await r?.json().catch(() => ({}));
|
|
114
|
+
say(r?.ok ? (o === "update" ? j.out || "Updated" : "Deleted") : j?.error || j?.why || "Failed");
|
|
115
|
+
};
|
|
116
|
+
const items: [string, () => void][] = [
|
|
117
|
+
...(w.main ? [] : ([["Update", () => op("update")]] as [string, () => void][])),
|
|
118
|
+
["Copy path", () => copy(ws)],
|
|
119
|
+
["Copy worktree name", () => copy(name)],
|
|
120
|
+
[pins.has(key) ? "Unpin" : "Pin", () => {
|
|
121
|
+
pins.has(key) ? pins.delete(key) : pins.add(key);
|
|
122
|
+
try {
|
|
123
|
+
localStorage.setItem("kz-ws-pins", JSON.stringify([...pins]));
|
|
124
|
+
} catch {}
|
|
125
|
+
drawList();
|
|
126
|
+
}],
|
|
127
|
+
...(w.main ? [] : ([["Delete", async () => {
|
|
128
|
+
const dl = modal(html`<div class="gdis" style="display:flex;flex-direction:column;gap:12px">
|
|
129
|
+
<b>Delete worktree "${name}"?</b>
|
|
130
|
+
<p>Removes the folder. Refused while it has uncommitted changes. The branch stays.</p>
|
|
131
|
+
<div class="gpath" style="font:12px monospace;overflow-wrap:anywhere">${ws}</div>
|
|
132
|
+
<div class="row"><button class="btn" value="no">Cancel</button><button class="btn danger" value="yes">Delete</button></div>
|
|
133
|
+
</div>`);
|
|
134
|
+
dl.addEventListener("close", () => dl.returnValue === "yes" && op("delete"));
|
|
135
|
+
}]] as [string, () => void][])),
|
|
136
|
+
];
|
|
137
|
+
const m = document.createElement("div");
|
|
138
|
+
m.id = "wsmenu";
|
|
139
|
+
m.style.cssText = `position:fixed;left:${Math.min(e.clientX, innerWidth - 190)}px;top:${Math.min(e.clientY, innerHeight - items.length * 34 - 16)}px;z-index:50;min-width:170px;padding:6px;background:var(--bg-2);border:1px solid var(--line);border-radius:var(--r);box-shadow:0 8px 24px #0004;display:flex;flex-direction:column`;
|
|
140
|
+
for (const [label, fn] of items) {
|
|
141
|
+
const b = document.createElement("button");
|
|
142
|
+
b.type = "button";
|
|
143
|
+
b.textContent = label;
|
|
144
|
+
b.style.cssText = "text-align:left;padding:7px 10px;font-size:13px;color:var(--ink);border-radius:var(--r-s)";
|
|
145
|
+
b.onmouseenter = () => (b.style.background = "var(--hover)");
|
|
146
|
+
b.onmouseleave = () => (b.style.background = "");
|
|
147
|
+
b.onclick = () => (m.remove(), fn());
|
|
148
|
+
m.append(b);
|
|
149
|
+
}
|
|
150
|
+
document.body.append(m);
|
|
151
|
+
const off = () => (m.remove(), removeEventListener("click", off), removeEventListener("keydown", off));
|
|
152
|
+
setTimeout(() => (addEventListener("click", off), addEventListener("keydown", off)));
|
|
153
|
+
}
|
|
87
154
|
// Workspace cards with their agent list open (dir\0ws -> true), kept per browser.
|
|
88
155
|
const wsOpen: Record<string, true> = (() => {
|
|
89
156
|
try {
|
|
@@ -106,6 +173,16 @@ function fold(dir: string) {
|
|
|
106
173
|
} catch {}
|
|
107
174
|
drawList();
|
|
108
175
|
}
|
|
176
|
+
const svg = (d: string) => `<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
177
|
+
const FA_OPEN = svg("M4 3l4 3 4-3M4 13l4-3 4 3");
|
|
178
|
+
const FA_SHUT = svg("M4 6l4-3 4 3M4 10l4 3 4-3");
|
|
179
|
+
const foldAll = (shut: boolean) => {
|
|
180
|
+
for (const d of last.projects?.map((p) => p.dir) ?? []) shut ? folded.add(d) : folded.delete(d);
|
|
181
|
+
try {
|
|
182
|
+
localStorage.setItem("kz-rail-folded", JSON.stringify([...folded]));
|
|
183
|
+
} catch {}
|
|
184
|
+
drawList();
|
|
185
|
+
};
|
|
109
186
|
// A card's workspace row: its own (a run's worktree) when the project lists it, else the
|
|
110
187
|
// main checkout's, so a run whose worktree is gone, an idea or an old run never vanishes.
|
|
111
188
|
export function wsOfCard(c, projects = last.projects) {
|
|
@@ -116,6 +193,7 @@ export const wsHref = (dir, ws) => `/?view=ws&dir=${encodeURIComponent(dir)}&ws=
|
|
|
116
193
|
export const RANK = { wait: 0, plan: 1, build: 2, review: 3, stalled: 4, idle: 5, done: 6, aband: 7 };
|
|
117
194
|
export const folderOf = (w) => w.path.split(/[\\/]/).pop() || w.path;
|
|
118
195
|
// A worktree's mark on line 2 of its card.
|
|
196
|
+
const PIN = html`<svg viewBox="0 0 24 24" aria-label="Pinned" style="width:12px;height:12px;flex:none;margin-left:4px;color:var(--accent)"><path d="M12 17v5M9 3h6l-1 6 3 3v2H7v-2l3-3z" fill="currentColor" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/></svg>`;
|
|
119
197
|
const WT = html`<svg viewBox="0 0 24 24" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="8" r="2"/><path d="M6 8v8M18 10c0 4-6 3-12 6"/></g></svg>`;
|
|
120
198
|
let settleT: ReturnType<typeof setTimeout> | undefined;
|
|
121
199
|
let drawn = "";
|
|
@@ -140,7 +218,9 @@ function drawList() {
|
|
|
140
218
|
const rows = p.workspaces
|
|
141
219
|
.map((w) => ({ w, cs: by.get(p.dir + "\0" + w.path) ?? [] }))
|
|
142
220
|
// An empty workspace or one with a run going is active; one holding only finished runs is done.
|
|
143
|
-
.filter(({ cs }) => filt[cs.length && cs.every((c) => kindOf(c) === "done") ? "done" : "active"])
|
|
221
|
+
.filter(({ cs }) => filt[cs.length && cs.every((c) => kindOf(c) === "done") ? "done" : "active"])
|
|
222
|
+
// Pinned worktrees first (a stable sort keeps the rest in git's order).
|
|
223
|
+
.sort((a, b) => +pins.has(p.dir + "\0" + b.w.path) - +pins.has(p.dir + "\0" + a.w.path));
|
|
144
224
|
return { p, rows, top: Math.min(9, ...rows.map((r) => top(r.cs))) };
|
|
145
225
|
})
|
|
146
226
|
.filter((g) => g.rows.length)
|
|
@@ -171,13 +251,17 @@ function drawList() {
|
|
|
171
251
|
const st0 = cs.length ? stateOf([...cs].sort((a, b) => RANK[stateOf(a)] - RANK[stateOf(b)])[0]) : "";
|
|
172
252
|
const st = st0 === "wait" || rows[0]?.st === "asking" ? "wait" : rows.some((r) => r.st === "working") ? "build" : st0 || (rows.length ? "done" : "");
|
|
173
253
|
// The agent buttons are siblings of the link (a button inside a link is invalid).
|
|
174
|
-
return html`<div class="wsr wsc"><a class="row ws" href="${wsHref(dir, w.path)}" data-dir="${dir}" data-ws="${w.path}" title="${w.path}"><span class="si ${st || "none"}"></span><div class="wl"><span class="l1"><b>${wsLabel(w)}</b
|
|
254
|
+
return html`<div class="wsr wsc"><a class="row ws" href="${wsHref(dir, w.path)}" data-dir="${dir}" data-ws="${w.path}" title="${w.path}"><span class="si ${st || "none"}"></span><div class="wl"><span class="l1"><b>${wsLabel(w)}</b>${pins.has(dir + "\0" + w.path) ? PIN : ""}</span><span class="l2"><span>${folderOf(w)}</span>${w.main ? "" : WT}</span></div></a>${agentsHtml(rows, now, !!wsOpen[dir + "\0" + w.path], dir, w.path)}</div>`;
|
|
175
255
|
})}`;
|
|
176
256
|
})
|
|
177
257
|
.join("") || `<div class="none">No projects</div>`;
|
|
178
258
|
// The same markup is not written again: hover and focus stay, and a tick that changed nothing costs no layout.
|
|
179
259
|
if (out !== drawn) box.innerHTML = drawn = out;
|
|
180
260
|
markCurrent();
|
|
261
|
+
box.oncontextmenu = (e) => {
|
|
262
|
+
const a = (e.target as HTMLElement).closest<HTMLElement>("a.row.ws");
|
|
263
|
+
if (a) wsMenu(e, a);
|
|
264
|
+
};
|
|
181
265
|
box.onclick = (e) => {
|
|
182
266
|
const t = e.target as HTMLElement;
|
|
183
267
|
const term = t.closest<HTMLElement>("[data-term]");
|
|
@@ -252,15 +336,20 @@ function drawPop(all: Set<string>) {
|
|
|
252
336
|
const dirs = [...all];
|
|
253
337
|
const shown = dirs.filter((d) => projName(d, last.projects).toLowerCase().includes(pq.toLowerCase()));
|
|
254
338
|
const box = (on: boolean, attrs: string, label) => html`<label class="pfrow"><input type="checkbox" ${raw(attrs)}${on ? raw(" checked") : ""}>${label}</label>`;
|
|
339
|
+
const allShut = dirs.length > 0 && dirs.every((d) => folded.has(d));
|
|
255
340
|
const had = document.activeElement?.id;
|
|
256
341
|
p.innerHTML = String(
|
|
257
|
-
html`${dirs.length > 6 ? html`<input class="sel" id="pfq" placeholder="Search projects…" aria-label="Search projects" value="${pq}" autocomplete="off" spellcheck="false">` : ""}
|
|
342
|
+
html`${dirs.length > 6 ? html`<input class="sel" id="pfq" placeholder="Search projects…" aria-label="Search projects" value="${pq}" autocomplete="off" spellcheck="false">` : ""}<div class="pfall">${box(!filt.dirs.length, 'data-all="1"', "All projects")}<button type="button" class="pfb" data-fa="${allShut ? "0" : "1"}" title="${allShut ? "Expand all" : "Collapse all"}" aria-label="${allShut ? "Expand all projects" : "Collapse all projects"}">${raw(allShut ? FA_OPEN : FA_SHUT)}</button></div>${shown.map((d) => box(filt.dirs.includes(d), `data-dir="${encodeURIComponent(d)}"`, html`${logo(d, projName(d, last.projects), last.projects)}<span>${projName(d, last.projects)}</span>`))}<div class="pfh">Show</div>${(["active", "done"] as const).map((k) => box(filt[k], `data-k="${k}"`, { active: "Active runs", done: "Done (last day)" }[k]))}`,
|
|
258
343
|
);
|
|
259
344
|
if (had === "pfq") {
|
|
260
345
|
const q = $("pfq") as HTMLInputElement;
|
|
261
346
|
q.focus();
|
|
262
347
|
q.setSelectionRange(pq.length, pq.length);
|
|
263
348
|
}
|
|
349
|
+
p.onclick = (e) => {
|
|
350
|
+
const b = (e.target as HTMLElement).closest("[data-fa]") as HTMLElement | null;
|
|
351
|
+
if (b) foldAll(b.dataset.fa === "1");
|
|
352
|
+
};
|
|
264
353
|
p.oninput = (e) => {
|
|
265
354
|
const t = e.target as HTMLInputElement;
|
|
266
355
|
if (t.id === "pfq") pq = t.value;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { branchSlug } from "./ws-tabs.ts";
|
|
3
|
+
|
|
4
|
+
test("branchSlug turns plain words into a branch name git accepts", () => {
|
|
5
|
+
for (const [input, want] of [["Fix login bug!", "fix-login-bug"], ["feature/My Thing", "feature/my-thing"], [" ..a..b. ", "a.b"], ["--x--", "x"], ["日本語", ""], ["a.lock", "a-lock"], ["a//b/", "a/b"]]) expect(branchSlug(input)).toBe(want);
|
|
6
|
+
for (const s of ["x".repeat(59) + " y z", "a/.b", "a-/b"]) {
|
|
7
|
+
const r = Bun.spawnSync(["git", "check-ref-format", "--branch", branchSlug(s)]);
|
|
8
|
+
expect(r.exitCode).toBe(0);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expect, test } from "bun:test";
|
|
2
|
-
import { agentStatus, agentsHtml, forgetAgents, lineOf, settleIn, toggleOpen, wsAgents, SETTLE_MS, awaiting, dueWord, chosen, loopbackUrl, toOpen, stageKeys, stageTabs, finished, historyOf, liveIn, migrate, pickable, prune, wsKey } from "./ws-tabs.ts";
|
|
2
|
+
import { agentStatus, agentsHtml, forgetAgents, lineOf, settleIn, toggleOpen, wsAgents, SETTLE_MS, awaiting, dueWord, chosen, newRun, loopbackUrl, toOpen, stageKeys, stageTabs, finished, historyOf, liveIn, migrate, pickable, prune, wsKey } from "./ws-tabs.ts";
|
|
3
3
|
|
|
4
4
|
const run = (id: string, status: string, o: any = {}) => ({ kind: "run", state: "/p/.kaizen", id, status, moved: 1, ws: "/p", ...o });
|
|
5
5
|
const wsOf = (c) => c.ws;
|
|
@@ -90,6 +90,13 @@ test("pickable: waiting first, then newest; done+approved, abandoned, archived a
|
|
|
90
90
|
expect(pickable(cs, "/p/.kaizen", "/p/.kaizen/wt/x", wsOf).map((c) => c.id)).toEqual(["f"]);
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
+
test("newRun: only a listed run not seen yet, first in picker order", () => {
|
|
94
|
+
const live = [run("w", "waiting"), run("b", "building")];
|
|
95
|
+
expect(newRun(live, new Set(["w", "b"]))).toBeUndefined();
|
|
96
|
+
expect(newRun(live, new Set(["w"]))?.id).toBe("b");
|
|
97
|
+
expect(newRun(live, new Set())?.id).toBe("w");
|
|
98
|
+
});
|
|
99
|
+
|
|
93
100
|
test("chosen: the pick stays while pickable or History, else the first, else none", () => {
|
|
94
101
|
const live = [run("w", "waiting"), run("b", "building")],
|
|
95
102
|
hist = [run("d", "done")];
|
|
@@ -179,3 +186,9 @@ test("prune keeps a split node it drops nothing from, so a gutter drag writes to
|
|
|
179
186
|
expect(cut.kids).toEqual(["a", "b"]);
|
|
180
187
|
expect(cut.sizes).toEqual([2, 1]);
|
|
181
188
|
});
|
|
189
|
+
|
|
190
|
+
test("a terminal that carried plan and build is named for the run's stage", () => {
|
|
191
|
+
const c = { kind: "run", column: 2, pty: { all: ["a"], stages: { plan: "a", impl: "a" } } };
|
|
192
|
+
expect(stageTabs(c, "Claude")).toEqual([{ key: "a", title: "Build · Claude" }]);
|
|
193
|
+
expect(stageTabs({ ...c, column: 3 }, "Claude")[0].title).toBe("Review · Claude");
|
|
194
|
+
});
|
package/web/board/ws-tabs.ts
CHANGED
|
@@ -76,6 +76,8 @@ export const pickable = (cards: any[], dir: string, ws: string, wsOfCard) =>
|
|
|
76
76
|
// waiting/newest, else none.
|
|
77
77
|
export const chosen = (live: any[], hist: any[], picked?: string | null, keyOf: (c) => string = (c) => c.id) =>
|
|
78
78
|
[...live, ...hist].find((c) => keyOf(c) === picked) ?? live[0] ?? null;
|
|
79
|
+
// A run the picker lists that this visit has not seen yet: it was just created.
|
|
80
|
+
export const newRun = (live: any[], seen: Set<string>, keyOf: (c) => string = (c) => c.id) => live.find((c) => !seen.has(keyOf(c)));
|
|
79
81
|
|
|
80
82
|
// The terminal the board launched for each stage of a run: plan/impl/review sub-tab -> pty key.
|
|
81
83
|
// plan, impl and review are recorded when the board launches them (the idea's agent once its run
|
|
@@ -102,7 +104,11 @@ export function stageTabs(c, agent: string): { key: string; title: string }[] {
|
|
|
102
104
|
const word = { plan: "Plan", impl: "Build", review: "Review" },
|
|
103
105
|
all: string[] = c?.pty ? c.pty.all ?? [c.pty.key] : [],
|
|
104
106
|
by = new Map(Object.entries(stageKeys(c)).map(([s, k]) => [k, word[s]])),
|
|
105
|
-
free = all.filter((k) => !by.has(k))
|
|
107
|
+
free = all.filter((k) => !by.has(k)),
|
|
108
|
+
now = word[{ 1: "plan", 2: "impl", 3: "review" }[c?.column as number] ?? ""],
|
|
109
|
+
last = all.at(-1);
|
|
110
|
+
// One terminal can carry several stages: the newest staged one is named for where the run is now.
|
|
111
|
+
if (now && last && by.has(last)) by.set(last, now);
|
|
106
112
|
return all.map((key) => ({ key, title: by.has(key) ? `${by.get(key)} · ${agent}` : agent + (free.length > 1 ? " " + (free.indexOf(key) + 1) : "") }));
|
|
107
113
|
}
|
|
108
114
|
|
|
@@ -171,3 +177,8 @@ export function agentsHtml(rows: ARow[], now: number, open: boolean, dir: string
|
|
|
171
177
|
const chips = (["asking", "working", "done"] as Status[]).map((st) => ({ st, rs: rows.filter((r) => r.st === st) })).filter((g) => g.rs.length);
|
|
172
178
|
return html`<div class="wag"><span class="chips">${chips.map((g) => html`<span class="chip">${dot(g.st)}${g.rs.map((r) => html`<button type="button" class="amark" data-term="${r.a.key}" ${at} title="${r.a.name} - ${WORD[g.st]}: open its terminal" aria-label="${r.a.name} - ${WORD[g.st]}: open its terminal">${mark(r.a)}</button>`)}</span>`)}</span>${chev}</div>`;
|
|
173
179
|
}
|
|
180
|
+
|
|
181
|
+
/** A branch name from plain words; empty when nothing usable is left (the caller picks a name). */
|
|
182
|
+
export function branchSlug(text: string): string {
|
|
183
|
+
return text.toLowerCase().trim().replace(/[^a-z0-9/._-]+/g, "-").replace(/\.{2,}/g, ".").replace(/\/{2,}/g, "/").replace(/(^|\/)[-.]+/g, "$1").slice(0, 60).replace(/[-./]+(\/|$)/g, "$1").replace(/\/$/, "").replace(/\.lock(\/|$)/g, "-lock$1");
|
|
184
|
+
}
|