dsh-claude-style 0.22.0 → 0.22.1-dev.72

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 (37) hide show
  1. package/README.en.md +2 -51
  2. package/README.md +3 -9
  3. package/docs/CHANGELOG.md +46 -0
  4. package/docs/STYLE.md +79 -123
  5. package/lib/assets/50b688b6be5e.js.br +0 -0
  6. package/lib/assets/6e78c8b8bf54.js.br +0 -0
  7. package/lib/assets/81a4513f0644.js.br +0 -0
  8. package/lib/assets/924e7970966c.js.br +0 -0
  9. package/lib/assets/b0f93b820492.js.br +0 -0
  10. package/lib/assets/b39af598e794.js.br +0 -0
  11. package/lib/assets/c8b5374edd16.js.br +0 -0
  12. package/lib/assets/manifest.json +28 -28
  13. package/lib/client.js +15 -15
  14. package/lib/host/appearance-overlays.js +46 -12
  15. package/lib/host/rewind-peer.js +17 -0
  16. package/lib/host/routes.js +46 -22
  17. package/lib/host/session-cost.js +1 -1
  18. package/lib/host/session-panel-event.js +14 -0
  19. package/lib/host/session-panel-round.js +1 -1
  20. package/lib/host/session-panel.js +6 -206
  21. package/lib/host/session-rewind.js +5 -0
  22. package/lib/host/settings.js +46 -12
  23. package/lib/host/usage.js +46 -12
  24. package/lib/model-descriptions.json +487 -175
  25. package/lib/peakrate-catalog.json +46 -1
  26. package/lib/prices.json +81 -54
  27. package/package.json +1 -1
  28. package/lib/assets/24de8bb53fb7.js.br +0 -0
  29. package/lib/assets/2bb184bdab84.js.br +0 -0
  30. package/lib/assets/4482f7143b49.js.br +0 -0
  31. package/lib/assets/532023863a65.js.br +0 -0
  32. package/lib/assets/64ec137f17cd.js.br +0 -0
  33. package/lib/assets/b46c83caaec5.js.br +0 -0
  34. package/lib/assets/be2ab9259df0.js.br +0 -0
  35. package/lib/host/checkout.js +0 -99
  36. package/lib/host/session-panel-call.js +0 -27
  37. package/lib/host/session-panel-log.js +0 -140
@@ -1,99 +0,0 @@
1
- // packages/host/src/checkout.ts
2
- import { execFile } from "node:child_process";
3
- import { homedir, userInfo } from "node:os";
4
- import { resolve } from "node:path";
5
- import { promisify } from "node:util";
6
-
7
- // packages/contracts/src/session-panel.ts
8
- function repositorySlug(remote) {
9
- if (remote === null) return null;
10
- let path = remote.trim();
11
- if (path === "") return null;
12
- const scp = path.match(/^[^@/\s]+@[^:/\s]+:(.+)$/);
13
- if (scp !== null) path = scp[1];
14
- else {
15
- let parsed;
16
- try {
17
- parsed = new URL(path);
18
- } catch {
19
- return null;
20
- }
21
- if (!["http:", "https:", "ssh:", "git:"].includes(parsed.protocol)) return null;
22
- path = parsed.pathname;
23
- }
24
- const parts = path.replace(/\.git$/i, "").split("/").filter((segment) => segment !== "");
25
- if (parts.length < 2) return null;
26
- return `${parts[parts.length - 2]}/${parts[parts.length - 1]}`;
27
- }
28
-
29
- // packages/host/src/checkout.ts
30
- var run = promisify(execFile);
31
- var GIT_TIMEOUT_MS = 2500;
32
- var GIT_MAX_OUTPUT = 256 * 1024;
33
- var CHECKOUT_TTL_MS = 5e3;
34
- async function git(directory, args) {
35
- try {
36
- const { stdout } = await run("git", ["--no-optional-locks", "-C", directory, ...args], {
37
- timeout: GIT_TIMEOUT_MS,
38
- maxBuffer: GIT_MAX_OUTPUT,
39
- windowsHide: true,
40
- encoding: "utf8"
41
- });
42
- const text = stdout.trim();
43
- return text === "" ? null : text;
44
- } catch {
45
- return null;
46
- }
47
- }
48
- async function checkoutOf(directory) {
49
- const root = await git(directory, ["rev-parse", "--show-toplevel"]);
50
- if (root === null) return null;
51
- const [branch, commit, commonDir, remote] = await Promise.all([
52
- git(directory, ["symbolic-ref", "--short", "-q", "HEAD"]),
53
- git(directory, ["rev-parse", "--short", "HEAD"]),
54
- git(directory, ["rev-parse", "--git-common-dir"]),
55
- git(directory, ["config", "--get", "remote.origin.url"])
56
- ]);
57
- return {
58
- root,
59
- branch,
60
- commit,
61
- // A linked worktree's common directory is the source checkout's `.git`,
62
- // which differs from the worktree's own root-relative one.
63
- linked: commonDir !== null && resolve(directory, commonDir) !== resolve(root, ".git"),
64
- repository: repositorySlug(remote)
65
- };
66
- }
67
- async function panelEnvironment(directory) {
68
- const home = homedir();
69
- const resolved = directory === null || directory.trim() === "" ? null : resolve(directory);
70
- const target = resolved ?? home;
71
- let user = "";
72
- try {
73
- user = userInfo().username;
74
- } catch {
75
- user = "";
76
- }
77
- const cached = environments.get(target);
78
- if (cached !== void 0 && Date.now() - cached.at < CHECKOUT_TTL_MS) return { ...cached.value, user };
79
- let checkout = null;
80
- try {
81
- checkout = await checkoutOf(target);
82
- } catch {
83
- checkout = null;
84
- }
85
- const value = { home, user, directory: target, checkout };
86
- environments.set(target, { value, at: Date.now() });
87
- prune();
88
- return value;
89
- }
90
- var environments = /* @__PURE__ */ new Map();
91
- var ENVIRONMENT_LIMIT = 16;
92
- function prune() {
93
- if (environments.size <= ENVIRONMENT_LIMIT) return;
94
- const oldest = [...environments.entries()].sort((left, right) => left[1].at - right[1].at)[0];
95
- if (oldest !== void 0) environments.delete(oldest[0]);
96
- }
97
- export {
98
- panelEnvironment
99
- };
@@ -1,27 +0,0 @@
1
- // packages/host/src/session-panel-call.ts
2
- var COMMAND_TOOLS = /* @__PURE__ */ new Set(["bash", "pwsh", "terminal_send"]);
3
- var PROCESS_KINDS = /* @__PURE__ */ new Set(["bash", "pwsh", "pty-send"]);
4
- function panelArguments(value) {
5
- if (typeof value !== "string" || value === "") return null;
6
- let parsed;
7
- try {
8
- parsed = JSON.parse(value);
9
- } catch {
10
- return null;
11
- }
12
- return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : null;
13
- }
14
- function panelInvocation(name, value) {
15
- const args = panelArguments(value);
16
- const process = typeof name === "string" && COMMAND_TOOLS.has(name);
17
- const label = [args?.description, args?.command, args?.text].find((part) => typeof part === "string" && part !== "");
18
- return { process, background: args?.run_in_background === true, label: typeof label === "string" ? label : "" };
19
- }
20
- function isPanelProcess(id, kind, invocation) {
21
- return invocation?.process === true || (typeof kind === "string" ? PROCESS_KINDS.has(kind) : /^(?:bash|pwsh|pty-send)-/.test(id));
22
- }
23
- export {
24
- isPanelProcess,
25
- panelArguments,
26
- panelInvocation
27
- };
@@ -1,140 +0,0 @@
1
- // packages/host/src/session-panel-log.ts
2
- import { createHash } from "node:crypto";
3
- import { isPanelProcess, panelInvocation } from "./session-panel-call.js";
4
- var JOB_OUTPUT_MAX = 8e3;
5
- function linkJobCall(state, callId, jobId) {
6
- let ids = state.jobCalls.get(callId);
7
- if (ids === void 0) {
8
- ids = /* @__PURE__ */ new Set();
9
- state.jobCalls.set(callId, ids);
10
- }
11
- ids.add(jobId);
12
- }
13
- function text(value) {
14
- return typeof value === "string" && value !== "" ? value : null;
15
- }
16
- function number(value) {
17
- return typeof value === "number" && Number.isFinite(value) ? value : null;
18
- }
19
- function messageText(content) {
20
- if (!Array.isArray(content)) return "";
21
- let out = "";
22
- for (const block of content) {
23
- if (block?.type === "text" && typeof block.text === "string") out += block.text;
24
- }
25
- return out;
26
- }
27
- function rememberJobOutput(state, jobId, text2) {
28
- if (text2 === "") return;
29
- const capped = text2.length > JOB_OUTPUT_MAX ? text2.slice(text2.length - JOB_OUTPUT_MAX) : text2;
30
- state.jobOutputs.set(jobId, { text: capped, lossy: text2.length > JOB_OUTPUT_MAX, status: state.jobs.get(jobId)?.status ?? "" });
31
- }
32
- function foldJobs(state, events) {
33
- for (const event of events) {
34
- const data = event.data;
35
- if (data === void 0) continue;
36
- if (event.type === "tool/call") {
37
- const callId = text(data.callId);
38
- if (callId === null) continue;
39
- const invocation = panelInvocation(data.name, data.arguments);
40
- state.jobInvocations.set(callId, invocation);
41
- if (!invocation.process) continue;
42
- const id = `call-${createHash("sha256").update(callId).digest("hex").slice(0, 24)}`;
43
- linkJobCall(state, callId, id);
44
- state.jobOrigins.set(id, callId);
45
- state.jobs.set(id, {
46
- id,
47
- label: invocation.label,
48
- category: "process",
49
- execution: invocation.background ? "background" : "foreground",
50
- controllable: false,
51
- status: "running",
52
- startedAt: event.time ?? 0
53
- });
54
- continue;
55
- }
56
- if (event.type === "job/registered" || event.type === "job/settled") {
57
- const id = text(data.jobId);
58
- if (id === null) continue;
59
- if (event.type === "job/registered") {
60
- const callId = text(data.toolCall?.callId);
61
- const rootId = text(data.toolCall?.rootCallId) ?? callId;
62
- const invocation = (callId === null ? void 0 : state.jobInvocations.get(callId)) ?? (rootId === null ? void 0 : state.jobInvocations.get(rootId));
63
- const temporary = callId === null ? void 0 : [...state.jobCalls.get(callId) ?? []].find((candidate) => state.jobs.get(candidate)?.controllable === false);
64
- const called = temporary === void 0 ? void 0 : state.jobs.get(temporary);
65
- if (called?.controllable === false) {
66
- state.jobs.delete(called.id);
67
- state.jobOrigins.delete(called.id);
68
- state.jobCalls.get(callId).delete(called.id);
69
- }
70
- const known2 = state.jobs.get(id);
71
- state.jobs.set(id, {
72
- id,
73
- label: called?.label || known2?.label || text(data.label) || "",
74
- category: isPanelProcess(id, data.kind, invocation) ? "process" : "task",
75
- execution: invocation?.background === true ? "background" : invocation?.process === true ? "foreground" : "unknown",
76
- controllable: true,
77
- status: "running",
78
- startedAt: number(data.startedAt) ?? known2?.startedAt ?? 0
79
- });
80
- if (callId !== null) {
81
- linkJobCall(state, callId, id);
82
- state.jobOrigins.set(id, callId);
83
- }
84
- if (rootId !== null) linkJobCall(state, rootId, id);
85
- continue;
86
- }
87
- const known = state.jobs.get(id);
88
- state.jobs.set(id, {
89
- id,
90
- label: known?.label ?? text(data.label) ?? "",
91
- category: known?.category ?? (isPanelProcess(id, data.kind) ? "process" : "task"),
92
- execution: known?.execution ?? "unknown",
93
- controllable: true,
94
- status: text(data.status) ?? "completed",
95
- startedAt: number(data.startedAt) ?? known?.startedAt ?? 0,
96
- finishedAt: number(data.finishedAt) ?? void 0,
97
- detail: text(data.detail) ?? void 0
98
- });
99
- continue;
100
- }
101
- if (event.type === "tool/result") {
102
- const callId = text(data.message?.source?.callId);
103
- if (callId === null) continue;
104
- const output = messageText(data.message?.content);
105
- for (const jobId of state.jobCalls.get(callId) ?? []) {
106
- const known = state.jobs.get(jobId);
107
- const handedOut = output.includes(`started background job ${jobId}`) || output.includes(`moved to background job ${jobId}]`);
108
- const live = known.status === "running" || known.status === "stopping";
109
- const execution = known.execution === "background" || handedOut || known.controllable && live && data.message?.isError !== true ? "background" : known.execution;
110
- const settled = !known.controllable;
111
- state.jobs.set(jobId, {
112
- ...known,
113
- execution,
114
- ...settled ? { status: data.message?.isError === true ? "failed" : "completed", finishedAt: event.time ?? known.startedAt } : {}
115
- });
116
- if ((settled || !live) && state.jobOrigins.get(jobId) === callId) rememberJobOutput(state, jobId, output);
117
- }
118
- continue;
119
- }
120
- if (event.type === "user/message") {
121
- const message = data.message ?? data;
122
- if (message.source?.kind !== "job") continue;
123
- const notice = messageText(message.content);
124
- const match = notice.match(/background job ([A-Za-z0-9_-]+)/);
125
- if (match === null) continue;
126
- const known = state.jobs.get(match[1]);
127
- if (known === void 0) continue;
128
- state.jobs.set(known.id, { ...known, execution: "background" });
129
- const at = notice.indexOf("Output:");
130
- const output = at === -1 ? "" : notice.slice(at + "Output:".length).replace(/^\s*/, "");
131
- if (output !== "") rememberJobOutput(state, match[1], output);
132
- }
133
- }
134
- }
135
- export {
136
- JOB_OUTPUT_MAX,
137
- foldJobs,
138
- messageText,
139
- rememberJobOutput
140
- };