@dzhechkov/harness-core 0.4.2 → 0.4.4
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/.dz-manifest.json +104 -28
- package/README.md +15 -4
- package/dist/backlog.d.ts +35 -0
- package/dist/backlog.d.ts.map +1 -1
- package/dist/backlog.js +167 -3
- package/dist/backlog.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/loop-blobs.generated.d.ts.map +1 -1
- package/dist/loop-blobs.generated.js +1 -0
- package/dist/loop-blobs.generated.js.map +1 -1
- package/dist/loop-lint.d.ts +6 -2
- package/dist/loop-lint.d.ts.map +1 -1
- package/dist/loop-lint.js +54 -0
- package/dist/loop-lint.js.map +1 -1
- package/dist/loop-plan-graph.d.ts +49 -0
- package/dist/loop-plan-graph.d.ts.map +1 -0
- package/dist/loop-plan-graph.js +128 -0
- package/dist/loop-plan-graph.js.map +1 -0
- package/dist/loop-plan.d.ts +17 -0
- package/dist/loop-plan.d.ts.map +1 -1
- package/dist/loop-plan.js +18 -15
- package/dist/loop-plan.js.map +1 -1
- package/dist/loop-render.d.ts.map +1 -1
- package/dist/loop-render.js +8 -0
- package/dist/loop-render.js.map +1 -1
- package/dist/model-recommender.d.ts +91 -0
- package/dist/model-recommender.d.ts.map +1 -0
- package/dist/model-recommender.js +186 -0
- package/dist/model-recommender.js.map +1 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +4 -1
- package/dist/registry.js.map +1 -1
- package/dist/skills-verify.d.ts +40 -0
- package/dist/skills-verify.d.ts.map +1 -1
- package/dist/skills-verify.js +80 -10
- package/dist/skills-verify.js.map +1 -1
- package/dist/trace-bundle.d.ts +209 -0
- package/dist/trace-bundle.d.ts.map +1 -0
- package/dist/trace-bundle.js +601 -0
- package/dist/trace-bundle.js.map +1 -0
- package/dist/usage.d.ts +7 -0
- package/dist/usage.d.ts.map +1 -1
- package/dist/usage.js +30 -2
- package/dist/usage.js.map +1 -1
- package/package.json +18 -18
- package/sbom.json +217 -27
- package/src/backlog.ts +176 -3
- package/src/index.ts +3 -0
- package/src/loop-blobs.generated.ts +1 -0
- package/src/loop-lint.ts +55 -1
- package/src/loop-plan-graph.ts +132 -0
- package/src/loop-plan.ts +35 -15
- package/src/loop-render.ts +8 -0
- package/src/model-recommender.ts +228 -0
- package/src/registry.ts +4 -1
- package/src/skills-verify.ts +108 -10
- package/src/trace-bundle.ts +743 -0
- package/src/usage.ts +42 -2
- package/LICENSE +0 -21
package/src/usage.ts
CHANGED
|
@@ -128,6 +128,13 @@ export interface WeeklyResetAnchor {
|
|
|
128
128
|
readonly weekday: number; // local Date#getDay(): Sun=0, Mon=1, ...
|
|
129
129
|
readonly hour: number;
|
|
130
130
|
readonly minute: number;
|
|
131
|
+
/** Explicit UTC offset in minutes (e.g. `+03:00` → 180). When present, the boundary is an
|
|
132
|
+
* ABSOLUTE instant, immune to the server's timezone. When absent (legacy `Wed 08:59`), the
|
|
133
|
+
* boundary is computed in server-local time — PROVEN wrong when the machine's tz differs from
|
|
134
|
+
* the account's reset tz (idea c8513be9: the same wall-clock instant produced window starts a
|
|
135
|
+
* WEEK apart under UTC vs Europe/Moscow, so the counter held the old week for hours after the
|
|
136
|
+
* real reset while printing the "correct" clock time). */
|
|
137
|
+
readonly offsetMinutes?: number;
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
/** Optional, plan-dependent calibration limits from `.dz/config.json`. Absent ⇒ pct is `null`. */
|
|
@@ -231,17 +238,31 @@ function hasOwn(obj: object, key: string): boolean {
|
|
|
231
238
|
}
|
|
232
239
|
|
|
233
240
|
function canonicalWeeklyResetAnchor(anchor: WeeklyResetAnchor): string {
|
|
234
|
-
|
|
241
|
+
const base = `${DAY_TO_WEEKDAY[anchor.weekday] ?? 'Wed'} ${String(anchor.hour).padStart(2, '0')}:${String(anchor.minute).padStart(2, '0')}`;
|
|
242
|
+
// The offset MUST survive canonicalization: this function silently dropped it on first
|
|
243
|
+
// implementation, degrading a pinned absolute instant back to the server-tz form the offset
|
|
244
|
+
// exists to escape (idea c8513be9 — caught live: the pin landed, the warning kept firing).
|
|
245
|
+
if (anchor.offsetMinutes === undefined) return base;
|
|
246
|
+
const sign = anchor.offsetMinutes < 0 ? '-' : '+';
|
|
247
|
+
const abs = Math.abs(anchor.offsetMinutes);
|
|
248
|
+
return `${base} ${sign}${String(Math.floor(abs / 60)).padStart(2, '0')}:${String(abs % 60).padStart(2, '0')}`;
|
|
235
249
|
}
|
|
236
250
|
|
|
237
251
|
export function parseWeeklyResetAnchor(anchor: string): WeeklyResetAnchor | null {
|
|
238
|
-
const m = /^\s*(sun|mon|tue|wed|thu|fri|sat)\s+(\d{1,2}):(\d{2})\s*$/i.exec(anchor);
|
|
252
|
+
const m = /^\s*(sun|mon|tue|wed|thu|fri|sat)\s+(\d{1,2}):(\d{2})(?:\s+([+-])(\d{2}):(\d{2}))?\s*$/i.exec(anchor);
|
|
239
253
|
if (!m) return null;
|
|
240
254
|
const weekday = WEEKDAY_TO_DAY[m[1]!.toLowerCase()];
|
|
241
255
|
const hour = Number(m[2]);
|
|
242
256
|
const minute = Number(m[3]);
|
|
243
257
|
if (weekday === undefined || !Number.isInteger(hour) || !Number.isInteger(minute)) return null;
|
|
244
258
|
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) return null;
|
|
259
|
+
if (m[4] !== undefined) {
|
|
260
|
+
const offH = Number(m[5]);
|
|
261
|
+
const offM = Number(m[6]);
|
|
262
|
+
if (!Number.isInteger(offH) || !Number.isInteger(offM) || offH > 14 || offM > 59) return null;
|
|
263
|
+
const sign = m[4] === '-' ? -1 : 1;
|
|
264
|
+
return { weekday, hour, minute, offsetMinutes: sign * (offH * 60 + offM) };
|
|
265
|
+
}
|
|
245
266
|
return { weekday, hour, minute };
|
|
246
267
|
}
|
|
247
268
|
|
|
@@ -250,6 +271,25 @@ export function weeklyWindowFor(nowMs: number, anchor: string): UsageWindow | nu
|
|
|
250
271
|
const parsed = parseWeeklyResetAnchor(anchor);
|
|
251
272
|
if (!parsed) return null;
|
|
252
273
|
|
|
274
|
+
if (parsed.offsetMinutes !== undefined) {
|
|
275
|
+
// ABSOLUTE-instant math (idea c8513be9): shift into the anchor's fixed offset, do the weekday
|
|
276
|
+
// arithmetic with UTC getters, shift back. No local-Date call ⇒ the boundary cannot move with
|
|
277
|
+
// the server's timezone — the property the legacy branch below demonstrably lacks.
|
|
278
|
+
const offMs = parsed.offsetMinutes * 60_000;
|
|
279
|
+
const shifted = new Date(nowMs + offMs);
|
|
280
|
+
const boundaryShifted = Date.UTC(
|
|
281
|
+
shifted.getUTCFullYear(),
|
|
282
|
+
shifted.getUTCMonth(),
|
|
283
|
+
shifted.getUTCDate() + (parsed.weekday - shifted.getUTCDay()),
|
|
284
|
+
parsed.hour,
|
|
285
|
+
parsed.minute,
|
|
286
|
+
0,
|
|
287
|
+
0,
|
|
288
|
+
);
|
|
289
|
+
let startedAtMs = boundaryShifted - offMs;
|
|
290
|
+
if (startedAtMs > nowMs) startedAtMs -= 7 * 24 * 60 * 60_000;
|
|
291
|
+
return { startedAtMs, resetsAtMs: startedAtMs + 7 * 24 * 60 * 60_000 };
|
|
292
|
+
}
|
|
253
293
|
const now = new Date(nowMs);
|
|
254
294
|
const candidate = new Date(
|
|
255
295
|
now.getFullYear(),
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 dzhechko
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|