@ascenda-one/claude-code-hooks 0.1.27 → 0.1.33
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/README.md +138 -29
- package/dist/ascendaClient.js +5 -0
- package/dist/ascendaClient.js.map +1 -1
- package/dist/cli.js +2498 -542
- package/dist/cli.js.map +1 -1
- package/dist/config.js +34 -1
- package/dist/config.js.map +1 -1
- package/dist/liveEvent.js +87 -0
- package/dist/liveEvent.js.map +1 -0
- package/dist/mapClaudeEvent.js +112 -4
- package/dist/mapClaudeEvent.js.map +1 -1
- package/dist/paths.js +20 -1
- package/dist/paths.js.map +1 -1
- package/dist/setup.js +271 -48
- package/dist/setup.js.map +1 -1
- package/dist/types.js +12 -1
- package/dist/types.js.map +1 -1
- package/dist/usageLimitReset.js +207 -0
- package/dist/usageLimitReset.js.map +1 -0
- package/examples/settings.local.json +13 -9
- package/package.json +2 -2
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
/**
|
|
5
|
+
* When a usage limit lifts, for the `resumesAt` on a rate-limited `halted`
|
|
6
|
+
* (P-D64.2). Claude Code says it only in prose, "resets 4:30pm
|
|
7
|
+
* (Asia/Nicosia)", so the time is read out of that sentence here, in memory,
|
|
8
|
+
* and only the number leaves. The sentence itself is never stored, logged or
|
|
9
|
+
* sent.
|
|
10
|
+
*
|
|
11
|
+
* Everything here answers `undefined` when unsure. A wrong time would hold a
|
|
12
|
+
* Mac awake for nothing, and a missing one just means the app treats the
|
|
13
|
+
* halt like any other.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The furthest ahead a reset may be and still be sent. The session limit
|
|
17
|
+
* resets within five hours; anything later is a weekly limit, which nobody
|
|
18
|
+
* should keep a Mac awake for.
|
|
19
|
+
*/
|
|
20
|
+
export const MAX_RESUME_AHEAD_MS = 6 * 60 * 60 * 1000;
|
|
21
|
+
const MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
22
|
+
// "resets 4:30pm", "reset at 4pm", "resets Oct 9, 4pm", "resets 16:30",
|
|
23
|
+
// each optionally followed by "(Area/City)". Matched case-insensitively.
|
|
24
|
+
const RESET_CLAUSE = new RegExp("\\bresets?(?:\\s+at)?\\s+" +
|
|
25
|
+
// An optional date: "Oct 9", "Oct 9,", "October 9 at".
|
|
26
|
+
"(?:([a-z]{3,9})\\.?\\s+(\\d{1,2})(?:st|nd|rd|th)?,?\\s+(?:at\\s+)?)?" +
|
|
27
|
+
// The time: "4", "4:30", "16:30", then an optional am/pm.
|
|
28
|
+
"(\\d{1,2})(?::(\\d{2}))?\\s*(am|pm|a\\.m\\.|p\\.m\\.)?" +
|
|
29
|
+
// An optional zone in brackets.
|
|
30
|
+
"(?:\\s*\\(([^)]+)\\))?", "i");
|
|
31
|
+
// Older Claude Code builds put the reset epoch straight after a pipe:
|
|
32
|
+
// "Claude AI usage limit reached|1760000000".
|
|
33
|
+
const PIPE_EPOCH = /usage limit reached\|(\d{10,13})\b/i;
|
|
34
|
+
/**
|
|
35
|
+
* The reset instant named in `text`, in epoch milliseconds, or `undefined`
|
|
36
|
+
* if there isn't one this can read with confidence.
|
|
37
|
+
*
|
|
38
|
+
* A time with no date is the next one: earlier than now today means
|
|
39
|
+
* tomorrow. A month name without a year means this year, or next year when
|
|
40
|
+
* that date has already gone. A weekday name ("resets Thu 4pm") isn't read.
|
|
41
|
+
* The zone in brackets wins; without one the time is this machine's.
|
|
42
|
+
*/
|
|
43
|
+
export function parseUsageLimitReset(text, now, localZone) {
|
|
44
|
+
const piped = PIPE_EPOCH.exec(text);
|
|
45
|
+
if (piped) {
|
|
46
|
+
const raw = Number(piped[1]);
|
|
47
|
+
return piped[1].length > 10 ? raw : raw * 1000;
|
|
48
|
+
}
|
|
49
|
+
const match = RESET_CLAUSE.exec(text);
|
|
50
|
+
if (!match)
|
|
51
|
+
return undefined;
|
|
52
|
+
const [, monthWord, dayText, hourText, minuteText, meridiem, zoneText] = match;
|
|
53
|
+
const hour = to24Hour(Number(hourText), meridiem, minuteText !== undefined);
|
|
54
|
+
if (hour === undefined)
|
|
55
|
+
return undefined;
|
|
56
|
+
const minute = minuteText === undefined ? 0 : Number(minuteText);
|
|
57
|
+
if (minute > 59)
|
|
58
|
+
return undefined;
|
|
59
|
+
const zone = zoneText?.trim() || localZone || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
60
|
+
const today = wallDate(now, zone);
|
|
61
|
+
if (!today)
|
|
62
|
+
return undefined;
|
|
63
|
+
if (monthWord !== undefined) {
|
|
64
|
+
const month = MONTHS.indexOf(monthWord.slice(0, 3).toLowerCase());
|
|
65
|
+
if (month < 0 || !matchesMonthName(monthWord, month))
|
|
66
|
+
return undefined;
|
|
67
|
+
const day = Number(dayText);
|
|
68
|
+
if (day < 1 || day > 31)
|
|
69
|
+
return undefined;
|
|
70
|
+
let at = zonedToEpoch({ year: today.year, month: month + 1, day, hour, minute }, zone);
|
|
71
|
+
if (at !== undefined && at <= now.getTime()) {
|
|
72
|
+
at = zonedToEpoch({ year: today.year + 1, month: month + 1, day, hour, minute }, zone);
|
|
73
|
+
}
|
|
74
|
+
return at;
|
|
75
|
+
}
|
|
76
|
+
const sameDay = zonedToEpoch({ ...today, hour, minute }, zone);
|
|
77
|
+
if (sameDay === undefined)
|
|
78
|
+
return undefined;
|
|
79
|
+
if (sameDay > now.getTime())
|
|
80
|
+
return sameDay;
|
|
81
|
+
return zonedToEpoch({ ...nextDay(today), hour, minute }, zone);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The `resumesAt` for a rate-limited halt: epoch seconds on the minute, or
|
|
85
|
+
* `undefined` when the text names no reset, or one more than
|
|
86
|
+
* {@link MAX_RESUME_AHEAD_MS} away.
|
|
87
|
+
*/
|
|
88
|
+
export function resumesAtFor(text, now, localZone) {
|
|
89
|
+
if (!text)
|
|
90
|
+
return undefined;
|
|
91
|
+
const at = parseUsageLimitReset(text, now, localZone);
|
|
92
|
+
if (at === undefined)
|
|
93
|
+
return undefined;
|
|
94
|
+
const ahead = at - now.getTime();
|
|
95
|
+
if (ahead <= 0 || ahead > MAX_RESUME_AHEAD_MS)
|
|
96
|
+
return undefined;
|
|
97
|
+
return Math.round(at / 60_000) * 60;
|
|
98
|
+
}
|
|
99
|
+
/** Hours 1–12 with am/pm, or 0–23 written with minutes ("16:30"). */
|
|
100
|
+
function to24Hour(hour, meridiem, hasMinutes) {
|
|
101
|
+
if (meridiem === undefined) {
|
|
102
|
+
// A bare "resets 4" is too thin to trust; "resets 16:30" is a clock.
|
|
103
|
+
if (!hasMinutes || hour > 23)
|
|
104
|
+
return undefined;
|
|
105
|
+
return hour;
|
|
106
|
+
}
|
|
107
|
+
if (hour < 1 || hour > 12)
|
|
108
|
+
return undefined;
|
|
109
|
+
const pm = meridiem.toLowerCase().startsWith("p");
|
|
110
|
+
if (hour === 12)
|
|
111
|
+
return pm ? 12 : 0;
|
|
112
|
+
return pm ? hour + 12 : hour;
|
|
113
|
+
}
|
|
114
|
+
/** "Oct", "Oct.", "October" are October; "Octopus" isn't. */
|
|
115
|
+
function matchesMonthName(word, month) {
|
|
116
|
+
const full = new Date(Date.UTC(2000, month, 1)).toLocaleString("en-US", { month: "long", timeZone: "UTC" }).toLowerCase();
|
|
117
|
+
return full.startsWith(word.toLowerCase());
|
|
118
|
+
}
|
|
119
|
+
/** The calendar date `instant` falls on in `zone`, or undefined for an unknown zone. */
|
|
120
|
+
function wallDate(instant, zone) {
|
|
121
|
+
const parts = wallParts(instant.getTime(), zone);
|
|
122
|
+
return parts && { year: parts.year, month: parts.month, day: parts.day };
|
|
123
|
+
}
|
|
124
|
+
function nextDay(date) {
|
|
125
|
+
const next = new Date(Date.UTC(date.year, date.month - 1, date.day + 1));
|
|
126
|
+
return { year: next.getUTCFullYear(), month: next.getUTCMonth() + 1, day: next.getUTCDate() };
|
|
127
|
+
}
|
|
128
|
+
function wallParts(epochMs, zone) {
|
|
129
|
+
let format;
|
|
130
|
+
try {
|
|
131
|
+
format = new Intl.DateTimeFormat("en-US", {
|
|
132
|
+
timeZone: zone, hourCycle: "h23",
|
|
133
|
+
year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric"
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
const value = (type) => Number(format.formatToParts(epochMs).find((part) => part.type === type)?.value);
|
|
140
|
+
return { year: value("year"), month: value("month"), day: value("day"), hour: value("hour"), minute: value("minute") };
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The instant a wall-clock time in `zone` names. Two passes, so a time
|
|
144
|
+
* either side of a daylight-saving change lands on the right offset. A date
|
|
145
|
+
* that doesn't exist (31 February) is refused.
|
|
146
|
+
*/
|
|
147
|
+
function zonedToEpoch(time, zone) {
|
|
148
|
+
const asUtc = Date.UTC(time.year, time.month - 1, time.day, time.hour, time.minute);
|
|
149
|
+
const check = new Date(asUtc);
|
|
150
|
+
if (check.getUTCDate() !== time.day)
|
|
151
|
+
return undefined;
|
|
152
|
+
let guess = asUtc;
|
|
153
|
+
for (let pass = 0; pass < 2; pass += 1) {
|
|
154
|
+
const seen = wallParts(guess, zone);
|
|
155
|
+
if (!seen)
|
|
156
|
+
return undefined;
|
|
157
|
+
const seenUtc = Date.UTC(seen.year, seen.month - 1, seen.day, seen.hour, seen.minute);
|
|
158
|
+
guess += asUtc - seenUtc;
|
|
159
|
+
}
|
|
160
|
+
return guess;
|
|
161
|
+
}
|
|
162
|
+
/** Where Claude Code's managed settings live on this platform. */
|
|
163
|
+
export function managedSettingsPath() {
|
|
164
|
+
if (process.env.ASCENDA_CLAUDE_MANAGED_SETTINGS)
|
|
165
|
+
return process.env.ASCENDA_CLAUDE_MANAGED_SETTINGS;
|
|
166
|
+
if (process.platform === "darwin")
|
|
167
|
+
return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
168
|
+
if (process.platform === "win32")
|
|
169
|
+
return "C:\\Program Files\\ClaudeCode\\managed-settings.json";
|
|
170
|
+
return "/etc/claude-code/managed-settings.json";
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Whether Claude Code will carry on by itself when the limit lifts:
|
|
174
|
+
* `autoContinueAtUsageLimit` read with Claude Code's own precedence,
|
|
175
|
+
* managed, then project-local, then project, then user. The first file that
|
|
176
|
+
* sets the key decides, so a managed `false` beats a user `true`. Only a
|
|
177
|
+
* literal `true` turns it on. A file that's missing or isn't JSON is
|
|
178
|
+
* skipped.
|
|
179
|
+
*/
|
|
180
|
+
export function autoContinueEnabled(sources = {}) {
|
|
181
|
+
const home = sources.home ?? os.homedir();
|
|
182
|
+
const files = [
|
|
183
|
+
sources.managedPath ?? managedSettingsPath(),
|
|
184
|
+
...(sources.projectDir
|
|
185
|
+
? [path.join(sources.projectDir, ".claude", "settings.local.json"), path.join(sources.projectDir, ".claude", "settings.json")]
|
|
186
|
+
: []),
|
|
187
|
+
path.join(home, ".claude", "settings.json")
|
|
188
|
+
];
|
|
189
|
+
for (const file of files) {
|
|
190
|
+
const value = readSetting(file, "autoContinueAtUsageLimit");
|
|
191
|
+
if (value !== undefined)
|
|
192
|
+
return value === true;
|
|
193
|
+
}
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
function readSetting(file, key) {
|
|
197
|
+
try {
|
|
198
|
+
const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
199
|
+
if (parsed && typeof parsed === "object" && key in parsed)
|
|
200
|
+
return parsed[key];
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// Missing, unreadable or not JSON: says nothing either way.
|
|
204
|
+
}
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=usageLimitReset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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+1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"hooks": {
|
|
3
|
-
"SessionStart": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks SessionStart" }] }],
|
|
4
|
-
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks UserPromptSubmit" }] }],
|
|
5
|
-
"PreToolUse": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PreToolUse" }] }],
|
|
6
|
-
"PostToolUse": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostToolUse" }] }],
|
|
7
|
-
"PostToolUseFailure": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostToolUseFailure" }] }],
|
|
8
|
-
"PreCompact": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PreCompact" }] }],
|
|
9
|
-
"PostCompact": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostCompact" }] }],
|
|
10
|
-
"Stop": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks Stop" }] }],
|
|
11
|
-
"
|
|
3
|
+
"SessionStart": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks SessionStart --hook-set 3", "timeout": 5 }] }],
|
|
4
|
+
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks UserPromptSubmit --hook-set 3", "timeout": 5 }] }],
|
|
5
|
+
"PreToolUse": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PreToolUse --hook-set 3", "timeout": 5 }] }],
|
|
6
|
+
"PostToolUse": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostToolUse --hook-set 3", "timeout": 5 }] }],
|
|
7
|
+
"PostToolUseFailure": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostToolUseFailure --hook-set 3", "timeout": 5 }] }],
|
|
8
|
+
"PreCompact": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PreCompact --hook-set 3", "timeout": 5 }] }],
|
|
9
|
+
"PostCompact": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks PostCompact --hook-set 3", "timeout": 5 }] }],
|
|
10
|
+
"Stop": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks Stop --hook-set 3", "timeout": 5 }] }],
|
|
11
|
+
"StopFailure": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks StopFailure --hook-set 3", "timeout": 5 }] }],
|
|
12
|
+
"Notification": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks Notification --hook-set 3", "timeout": 5 }] }],
|
|
13
|
+
"SessionEnd": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks SessionEnd --hook-set 3", "timeout": 5 }] }],
|
|
14
|
+
"SubagentStart": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks SubagentStart --hook-set 3", "timeout": 5 }] }],
|
|
15
|
+
"SubagentStop": [{ "hooks": [{ "type": "command", "command": "npx -y @ascenda-one/claude-code-hooks SubagentStop --hook-set 3", "timeout": 5 }] }]
|
|
12
16
|
}
|
|
13
17
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"publishConfig": { "access": "public" },
|
|
3
3
|
"name": "@ascenda-one/claude-code-hooks",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.33",
|
|
5
5
|
"description": "Claude Code hooks adapter for Ascenda AI workload telemetry.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"test:sample": "npm run build && cat examples/sample-post-tool-use-edit.json | node dist/cli.js PostToolUse",
|
|
20
20
|
"test:failure": "npm run build && cat examples/sample-post-tool-use-failure.json | node dist/cli.js PostToolUseFailure",
|
|
21
21
|
"test:compact": "npm run build && cat examples/sample-pre-compact-auto.json | node dist/cli.js PreCompact",
|
|
22
|
-
"bundle": "esbuild src/cli.ts --bundle --platform=node --format=esm --banner:js=\"import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);\" --outfile=dist/cli.js",
|
|
22
|
+
"bundle": "node ../scripts/esbuild-collector.mjs src/cli.ts --bundle --platform=node --format=esm --banner:js=\"import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);\" --outfile=dist/cli.js",
|
|
23
23
|
"test": "node --test --require ./tests/isolateHome.cjs"
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|