@ngockhoale/ukit 3.5.15 → 3.5.18
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 +25 -0
- package/manifests/platform.full.yaml +48 -0
- package/package.json +2 -1
- package/scripts/release/heavy-first.mjs +12 -0
- package/scripts/release/release-steps.mjs +7 -4
- package/scripts/release/run-core-batch.mjs +50 -0
- package/src/cli/commands/mission.js +102 -0
- package/src/cli/commands/rescue.js +83 -0
- package/src/cli/index.js +14 -0
- package/src/core/compact/contextBudget.js +62 -41
- package/src/core/compact/threshold.js +14 -32
- package/src/core/observability/schema/registry.js +91 -0
- package/src/core/runtimeConfig.js +53 -2
- package/src/diagnostics/routeOutcomes.js +5 -1
- package/src/diagnostics/skillAccuracy.js +5 -2
- package/src/render/buildVariables.js +2 -5
- package/template_project/.claude/commands/ukit/handoff-implement.md +3 -3
- package/template_project/.claude/commands/ukit/handoff-review.md +3 -3
- package/template_project/.claude/hooks/context-hardcap-gate.sh +47 -20
- package/template_project/.claude/hooks/context-window-guard.sh +82 -27
- package/template_project/.claude/hooks/delegation-gate.mjs +1 -1
- package/template_project/.claude/hooks/handoff-resume.sh +11 -2
- package/template_project/.claude/hooks/mission-capture.mjs +37 -0
- package/template_project/.claude/hooks/post-compact-observe.mjs +34 -0
- package/template_project/.claude/hooks/shell-watch.mjs +34 -0
- package/template_project/.claude/hooks/skill-router.sh +13 -0
- package/template_project/.claude/hooks/stop-failure-rescue.mjs +109 -0
- package/template_project/.claude/settings.json +36 -4
- package/template_project/.claude/skills/backend-api/SKILL.md +1 -1
- package/template_project/.claude/skills/delivery/SKILL.md +1 -1
- package/template_project/.claude/skills/docs-manager/SKILL.md +1 -1
- package/template_project/.claude/skills/duraone/SKILL.md +2 -1
- package/template_project/.claude/skills/file-organizer/SKILL.md +1 -1
- package/template_project/.claude/skills/frontend/SKILL.md +1 -1
- package/template_project/.claude/skills/frontend-vue/SKILL.md +1 -1
- package/template_project/.claude/skills/pdf-processing/SKILL.md +1 -1
- package/template_project/.claude/skills/postgres/SKILL.md +1 -1
- package/template_project/.claude/skills/testing-quality/SKILL.md +2 -0
- package/template_project/.claude/skills/webapp-testing/SKILL.md +1 -1
- package/template_project/.claude/ukit/index/route-task.mjs +3 -1
- package/template_project/.claude/ukit/index/tier-lane.mjs +1 -1
- package/template_project/.claude/ukit/runtime/compact-threshold.mjs +15 -29
- package/template_project/.claude/ukit/runtime/context-capacity.mjs +64 -1
- package/template_project/.claude/ukit/runtime/execution-ledger.mjs +107 -4
- package/template_project/.claude/ukit/runtime/hook-chain-runner.mjs +20 -1
- package/template_project/.claude/ukit/runtime/mission/checkpoint.mjs +85 -0
- package/template_project/.claude/ukit/runtime/mission/classify.mjs +182 -0
- package/template_project/.claude/ukit/runtime/mission/drift.mjs +58 -0
- package/template_project/.claude/ukit/runtime/mission/graph.mjs +381 -0
- package/template_project/.claude/ukit/runtime/mission/hooks.mjs +199 -0
- package/template_project/.claude/ukit/runtime/mission/journal.mjs +68 -0
- package/template_project/.claude/ukit/runtime/mission/metrics.mjs +64 -0
- package/template_project/.claude/ukit/runtime/mission/recall.mjs +132 -0
- package/template_project/.claude/ukit/runtime/mission/redact.mjs +25 -0
- package/template_project/.claude/ukit/runtime/mission/restore.mjs +107 -0
- package/template_project/.claude/ukit/runtime/mission/store.mjs +231 -0
- package/template_project/.claude/ukit/runtime/mission/working.mjs +88 -0
- package/template_project/.claude/ukit/runtime/prompt-injection-cap.mjs +33 -0
- package/template_project/.claude/ukit/runtime/reinject-context.mjs +87 -6
- package/template_project/.claude/ukit/runtime/rescue/bundle.mjs +122 -0
- package/template_project/.claude/ukit/runtime/rescue/classify-failure.mjs +136 -0
- package/template_project/.claude/ukit/runtime/rescue/lease.mjs +65 -0
- package/template_project/.claude/ukit/runtime/rescue/reconstruct.mjs +273 -0
- package/template_project/.claude/ukit/runtime/rescue/recovery-state.mjs +120 -0
- package/template_project/.claude/ukit/runtime/rescue/rollover.mjs +151 -0
- package/template_project/.claude/ukit/runtime/sensitive-value-scanner.mjs +1 -1
- package/template_project/.claude/ukit/runtime/shell-watch.mjs +278 -0
- package/template_project/.claude/ukit/runtime/stop-coordinator.mjs +154 -0
- package/template_project/.omp/RULES.md +1 -1
- package/template_project/.omp/config.yml +2 -2
- package/template_project/.omp/hooks/pre/ukit-bridge.js +69 -2
- package/template_project/AGENTS.md +5 -1
- package/template_project/CLAUDE.md +5 -1
- package/template_project/docs/AI_HANDOFF/RULES.md +4 -4
- package/template_project/instructions/core.md +5 -1
- package/template_project/instructions/overlays/omp-rules.md +1 -1
- package/template_project/ukit/storage/config.json +32 -10
|
@@ -127,12 +127,18 @@ try {
|
|
|
127
127
|
} catch { /* fall through to the defaults */ }
|
|
128
128
|
if (!runtimeConfig || typeof runtimeConfig !== 'object') runtimeConfig = {};
|
|
129
129
|
|
|
130
|
-
//
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
// UKit-owned context tiers (compact.bestTokens/okTokens/mandatoryTokens/stopTokens =
|
|
131
|
+
// 100k/150k/200k/250k; legacy hardCapTokens -> stopTokens, tokenThreshold -> bestTokens).
|
|
132
|
+
// Resolved by context-capacity.mjs; the inline fallback keeps the shipped numbers when the
|
|
133
|
+
// runtime helper is missing (pre-install tree).
|
|
134
|
+
function inlineTiers() {
|
|
135
|
+
const c = runtimeConfig?.compact ?? {};
|
|
136
|
+
const pos = (v) => (typeof v === 'number' && Number.isInteger(v) && v > 0 ? v : null);
|
|
137
|
+
const stop = pos(c.hardCapTokens) ?? pos(c.stopTokens) ?? 250_000;
|
|
138
|
+
const mandatory = Math.min(pos(c.mandatoryTokens) ?? 200_000, stop);
|
|
139
|
+
const ok = Math.min(pos(c.okTokens) ?? 150_000, mandatory);
|
|
140
|
+
const best = Math.min(pos(c.tokenThreshold) ?? pos(c.bestTokens) ?? 100_000, ok);
|
|
141
|
+
return { bestTokens: best, okTokens: ok, mandatoryTokens: mandatory, stopTokens: stop };
|
|
136
142
|
}
|
|
137
143
|
|
|
138
144
|
// H04: bounded async tail scan instead of a whole-transcript sync stat/read/split. The
|
|
@@ -184,6 +190,8 @@ for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
|
184
190
|
const estimatePartial = Boolean(tail?.truncated) && boundaryTs === null;
|
|
185
191
|
|
|
186
192
|
let contentChars = 0;
|
|
193
|
+
let usageTokens = 0;
|
|
194
|
+
let charsAfterUsage = 0;
|
|
187
195
|
let sidechainEntries = 0;
|
|
188
196
|
const modelSequence = [];
|
|
189
197
|
for (let i = start; i < entries.length; i += 1) {
|
|
@@ -200,12 +208,30 @@ for (let i = start; i < entries.length; i += 1) {
|
|
|
200
208
|
if (typeof model === 'string' && model.trim()) modelSequence.push(model.trim());
|
|
201
209
|
}
|
|
202
210
|
if (entry?.type !== 'user' && entry?.type !== 'assistant' && entry?.type !== 'attachment') continue;
|
|
211
|
+
// Hook bookkeeping attachments (hook_success carries the hook's full command line + stdout)
|
|
212
|
+
// are transcript-only: Claude Code never sends them to the model. Counting them inflated the
|
|
213
|
+
// estimate ~3x (400k reported vs ~134k real), so the alerts were noise and the real window
|
|
214
|
+
// was never tracked.
|
|
215
|
+
if (entry?.type === 'attachment' && /^hook_/.test(String(entry?.attachment?.type ?? ''))
|
|
216
|
+
&& entry.attachment.type !== 'hook_additional_context') continue;
|
|
217
|
+
// Real usage reported by the API for the newest main-chain assistant turn is the ground
|
|
218
|
+
// truth for everything sent before it; only entries after it are estimated from chars.
|
|
219
|
+
const usage = entry?.type === 'assistant' ? entry?.message?.usage : null;
|
|
220
|
+
if (usage && typeof usage === 'object') {
|
|
221
|
+
const real = (Number(usage.input_tokens) || 0) + (Number(usage.cache_read_input_tokens) || 0)
|
|
222
|
+
+ (Number(usage.cache_creation_input_tokens) || 0) + (Number(usage.output_tokens) || 0);
|
|
223
|
+
if (real > 0) { usageTokens = real; charsAfterUsage = 0; continue; }
|
|
224
|
+
}
|
|
203
225
|
try {
|
|
204
|
-
|
|
226
|
+
const chars = JSON.stringify(entry.message ?? entry.attachment ?? '').length;
|
|
227
|
+
contentChars += chars;
|
|
228
|
+
charsAfterUsage += chars;
|
|
205
229
|
} catch { /* unserialisable entry */ }
|
|
206
230
|
}
|
|
207
231
|
|
|
208
|
-
const estimatedTokens =
|
|
232
|
+
const estimatedTokens = usageTokens > 0
|
|
233
|
+
? usageTokens + Math.round(charsAfterUsage / CHARS_PER_TOKEN)
|
|
234
|
+
: Math.round(contentChars / CHARS_PER_TOKEN);
|
|
209
235
|
|
|
210
236
|
// Latest assistant model in the live window — this is the model that must fit the NEXT
|
|
211
237
|
// request, so capacity negotiation follows it. A mid-session gateway swap to a smaller
|
|
@@ -235,22 +261,29 @@ async function loadCapacityResolver() {
|
|
|
235
261
|
}
|
|
236
262
|
}
|
|
237
263
|
|
|
238
|
-
let
|
|
264
|
+
let tiers = inlineTiers();
|
|
265
|
+
let capacityModuleRef = null;
|
|
239
266
|
let capacitySource = 'default';
|
|
240
267
|
let negotiatedCapacity = null;
|
|
241
268
|
try {
|
|
242
269
|
const capacityModule = await loadCapacityResolver();
|
|
270
|
+
capacityModuleRef = capacityModule;
|
|
271
|
+
if (capacityModule && typeof capacityModule.resolveContextTiers === 'function') {
|
|
272
|
+
tiers = capacityModule.resolveContextTiers(runtimeConfig);
|
|
273
|
+
}
|
|
243
274
|
if (capacityModule && typeof capacityModule.resolveContextCapTokens === 'function') {
|
|
244
275
|
const resolved = capacityModule.resolveContextCapTokens({
|
|
245
276
|
env: process.env,
|
|
246
277
|
config: runtimeConfig,
|
|
247
278
|
modelMetadata: { model: currentModel },
|
|
248
279
|
});
|
|
249
|
-
hardCap = resolved.capTokens;
|
|
250
280
|
capacitySource = resolved.capacity?.source ?? 'default';
|
|
251
281
|
negotiatedCapacity = resolved.capacity ?? null;
|
|
252
282
|
}
|
|
253
283
|
} catch { /* negotiation is advisory — the operator ceiling already applies */ }
|
|
284
|
+
// The tiers are UKit policy and are never lowered by the negotiated model window;
|
|
285
|
+
// negotiation only feeds the published capacity record and diagnostics.
|
|
286
|
+
const hardCap = tiers.stopTokens;
|
|
254
287
|
const ratio = estimatedTokens / hardCap;
|
|
255
288
|
|
|
256
289
|
// Publish what this hook negotiated so the compact-threshold/hard-cap-gate path stops
|
|
@@ -350,8 +383,8 @@ if (swapDetected && persistedState.lastSwapModel !== currentModel) {
|
|
|
350
383
|
// prompts right after a fresh compact already measure >= 60% of the cap, the summary did
|
|
351
384
|
// not shrink the session enough — and re-compacting the same session recovers very little.
|
|
352
385
|
// The honest recovery moves are: stop re-inflating it with rereads, delegate broad work to
|
|
353
|
-
// subagents (separate windows), or
|
|
354
|
-
// the goal across). Fires once per compact boundary.
|
|
386
|
+
// subagents (separate windows), or keep going on disk state (UKit resume state carries
|
|
387
|
+
// the goal across the next auto-compaction). Fires once per compact boundary.
|
|
355
388
|
const POST_COMPACT_RATIO = 0.6;
|
|
356
389
|
const POST_COMPACT_WINDOW_MS = 10 * 60 * 1000;
|
|
357
390
|
const boundaryAgeMs = boundaryTs !== null ? Date.now() - boundaryTs : null;
|
|
@@ -365,27 +398,48 @@ if (justCompacted && ratio >= POST_COMPACT_RATIO && persistedState.lastPostCompa
|
|
|
365
398
|
'The compact did not shrink this session enough. Recover context now, in this order:',
|
|
366
399
|
'1) STOP re-reading old files, logs and tool outputs — durable state is in the PROJECT CONTEXT block or on disk. Rereads are what re-inflate a just-compacted session.',
|
|
367
400
|
'2) DELEGATE remaining broad work (searches, big reads, multi-file edits) to subagents: their tool output lives in their own windows; keep this context for decisions and short summaries only.',
|
|
368
|
-
'3) If substantial work still remains: land the current step, persist docs/STATUS.md, then
|
|
401
|
+
'3) If substantial work still remains: land the current step, persist docs/STATUS.md, then keep working in this session: the host auto-compacts and UKit resume state (PROJECT CONTEXT block + docs/STATUS.md) carries the goal forward. Never stop to ask the user for /compact or a new session.',
|
|
369
402
|
].join('\n') + '\n',
|
|
370
403
|
);
|
|
371
404
|
}
|
|
372
405
|
|
|
373
|
-
|
|
406
|
+
const tierOf = (tokens) => {
|
|
407
|
+
if (tokens >= tiers.stopTokens) return 'stop';
|
|
408
|
+
if (tokens >= tiers.mandatoryTokens) return 'red';
|
|
409
|
+
if (tokens >= tiers.okTokens) return 'orange';
|
|
410
|
+
if (tokens >= tiers.bestTokens) return 'yellow';
|
|
411
|
+
return 'green';
|
|
412
|
+
};
|
|
413
|
+
const fmt = (n) => Math.round(n).toLocaleString('en-US');
|
|
414
|
+
const tierMessage = (tier) => {
|
|
415
|
+
if (capacityModuleRef && typeof capacityModuleRef.contextTierMessage === 'function') {
|
|
416
|
+
return capacityModuleRef.contextTierMessage(tier, estimatedTokens, tiers);
|
|
417
|
+
}
|
|
418
|
+
return `UKit context ~${fmt(estimatedTokens)} tokens (tier ${tier}): land the current item, persist to docs/STATUS.md, delegate broad work; compaction is automatic - do not ask the user to /compact.`;
|
|
419
|
+
};
|
|
420
|
+
const tier = tierOf(estimatedTokens);
|
|
421
|
+
if (tier === 'green') process.exit(0);
|
|
374
422
|
|
|
375
423
|
const pct = Math.round(ratio * 100);
|
|
376
|
-
const phase =
|
|
424
|
+
const phase = tier;
|
|
377
425
|
|
|
378
|
-
// Debounce the directive
|
|
379
|
-
//
|
|
380
|
-
//
|
|
381
|
-
|
|
382
|
-
// the live transcript back under 0.8, since this whole branch exits early above.
|
|
383
|
-
const COOLDOWN_MS = phase === 'hard' ? 3 * 60 * 1000 : 8 * 60 * 1000;
|
|
426
|
+
// Debounce so the directive does not re-print in full every prompt while the tier is
|
|
427
|
+
// unchanged. Re-arms on tier change or after the cooldown, and resets naturally once real
|
|
428
|
+
// compaction drops the live transcript back under the best tier.
|
|
429
|
+
const COOLDOWN_MS = (tier === 'stop' || tier === 'red') ? 3 * 60 * 1000 : 8 * 60 * 1000;
|
|
384
430
|
|
|
385
431
|
const now = Date.now();
|
|
386
432
|
const withinCooldown = guardState.lastPhase === phase
|
|
387
433
|
&& (now - Number(guardState.lastActionAt || 0)) < COOLDOWN_MS;
|
|
388
434
|
|
|
435
|
+
if (tier === 'yellow') {
|
|
436
|
+
if (!withinCooldown) {
|
|
437
|
+
await writeGuardState({ ...persistedState, lastPhase: phase, lastActionAt: now });
|
|
438
|
+
process.stdout.write(`${tierMessage(tier)}\n`);
|
|
439
|
+
}
|
|
440
|
+
process.exit(0);
|
|
441
|
+
}
|
|
442
|
+
|
|
389
443
|
// A one-shot pipeline (handoff-fullstack) is mid-flight when RUN.md exists with a phase
|
|
390
444
|
// other than `done`. Telling the agent to stop and ask for /compact there is actively
|
|
391
445
|
// harmful: the human is deliberately away, the pipeline has a disk cursor that makes it
|
|
@@ -409,11 +463,12 @@ async function readRunCursor() {
|
|
|
409
463
|
const run = await readRunCursor();
|
|
410
464
|
|
|
411
465
|
const lines_out = [];
|
|
412
|
-
if (
|
|
413
|
-
lines_out.push(`UKIT CONTEXT
|
|
414
|
-
|
|
466
|
+
if (tier === 'stop') {
|
|
467
|
+
lines_out.push(`UKIT CONTEXT STOP - ${tierMessage(tier)} (capacitySource=${capacitySource}).`);
|
|
468
|
+
} else if (tier === 'red') {
|
|
469
|
+
lines_out.push(`UKIT CONTEXT ALERT - ${tierMessage(tier)} (${pct}% of the ${fmt(hardCap)} stop line, capacitySource=${capacitySource}).`);
|
|
415
470
|
} else {
|
|
416
|
-
lines_out.push(`UKIT CONTEXT WARNING
|
|
471
|
+
lines_out.push(`UKIT CONTEXT WARNING - ${tierMessage(tier)} (capacitySource=${capacitySource}).`);
|
|
417
472
|
}
|
|
418
473
|
|
|
419
474
|
if (estimatePartial) {
|
|
@@ -428,7 +483,7 @@ if (withinCooldown) {
|
|
|
428
483
|
lines_out.push('1) Finish the step in flight, then update docs/AI_HANDOFF/RUN.md so the cursor is current.');
|
|
429
484
|
lines_out.push('2) At the next wave boundary, collapse the finished wave to one line per task and stop re-reading task files, executor reports, and earlier diffs — that detail is already on disk.');
|
|
430
485
|
lines_out.push('3) Make sure spawned agents are returning their short summary form (<=10 lines), not pasted RED/verification logs. Pasted subagent logs are the usual cause of this warning.');
|
|
431
|
-
lines_out.push('4) Continue to the next wave/phase.
|
|
486
|
+
lines_out.push('4) Continue to the next wave/phase. Never stop to ask for /compact; the host auto-compacts and RUN.md carries the run across it.');
|
|
432
487
|
if (sidechainEntries > 0) {
|
|
433
488
|
lines_out.push(`Note: ${sidechainEntries} subagent entries in this stretch. Keep concurrency at or below handoff.maxParallelAgents and keep returns short; do not widen the batch while this warning stands.`);
|
|
434
489
|
}
|
|
@@ -438,7 +493,7 @@ if (withinCooldown) {
|
|
|
438
493
|
lines_out.push('1) LAND ONE THING: pick the smallest in-flight item you can finish end-to-end in ≤3 tool calls (edit + verify), complete exactly that one, and report it done. Do not open anything new.');
|
|
439
494
|
lines_out.push('2) DEFER THE REST: write each remaining step as one line into docs/STATUS.md (update-status skill), or split what remains into bounded docs/AI_HANDOFF tasks — a fresh context then continues from disk without re-reading this thread.');
|
|
440
495
|
lines_out.push('3) DELEGATE anything broad that must still run (searches, big reads, multi-file edits) to subagents instead of doing it inline — their tool output stays in their own windows, not this one.');
|
|
441
|
-
lines_out.push(
|
|
496
|
+
lines_out.push(`4) Do NOT keep stacking new work: host auto-compaction is automatic and fires inside the ${fmt(tiers.okTokens)}-${fmt(tiers.mandatoryTokens)} band; the tool gate blocks new work at ${fmt(tiers.stopTokens)}. Land the one item and defer the rest to disk; keep working. Never ask the user to /compact.`);
|
|
442
497
|
if (sidechainEntries > 0) {
|
|
443
498
|
lines_out.push(`Note: ${sidechainEntries} subagent entries in this stretch — each teammate carries its own context window, and every finished report is injected back here, so running many at once is the fastest way to overflow this session. Avoid spawning more until context drops back under the cap.`);
|
|
444
499
|
}
|
|
@@ -270,7 +270,7 @@ function mainMessage(attempt, limit, taskId, mutation, projectRoot) {
|
|
|
270
270
|
if (attempt >= limit) {
|
|
271
271
|
return `UKit delegation gate — BLOCKED: this task's feature-implementation Playbook requires the coding to be delegated to the Tier 2 worker, but the orchestrator tried ${attempt} times to write ${describeTarget(mutation, projectRoot)} itself. This run is now recorded as BLOCKED (delegation-required-not-performed). Do not retry the write; report the blocker to the user.`;
|
|
272
272
|
}
|
|
273
|
-
return `UKit delegation gate (attempt ${attempt} of ${limit}): this task's feature-implementation Playbook requires Tier 2 coding delegation, and you are the Tier 3 orchestrator — writing ${describeTarget(mutation, projectRoot)} yourself is refused. Dispatch a native worker now with the Agent tool (subagent_type "feature-implementer", the Tier 2 coding model) and start its prompt with "[ukit-task ${taskId}]", naming the files and behaviour to implement; the worker must edit with Edit/Write. When it returns, verify the integrated result yourself with the bare test runner (for example \`npm test\`) — no pipe, tail, grep or compound command — so the runner's own exit status is the evidence. Repeating this write will end the run as BLOCKED.`;
|
|
273
|
+
return `UKit delegation gate (attempt ${attempt} of ${limit}): this task's feature-implementation Playbook requires Tier 2 coding delegation, and you are the Tier 3 orchestrator — writing ${describeTarget(mutation, projectRoot)} yourself is refused. Dispatch a native worker now with the Agent tool (subagent_type "feature-implementer", the Tier 2 coding model) and start its prompt with "[ukit-task ${taskId}]", naming the files and behaviour to implement; the worker must edit with Edit/Write. When it returns, verify the integrated result yourself with the bare test runner (for example \`npm test\`) — no pipe, tail, grep or compound command — so the runner's own exit status is the evidence; a full-suite run uses \`node .claude/ukit/index/test-batches.mjs run\` (its exit status is the evidence). Repeating this write will end the run as BLOCKED.`;
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
function workerMessage(mutation, projectRoot) {
|
|
@@ -135,7 +135,7 @@ async function emitOrdinaryResume(payload, source) {
|
|
|
135
135
|
if (!runtimeExists) return false;
|
|
136
136
|
try {
|
|
137
137
|
const runtime = await import(pathToFileURL(runtimePath).href);
|
|
138
|
-
const intent = await runtime.readResumeIntent(projectRoot, payload, { consume: true });
|
|
138
|
+
const intent = await runtime.readResumeIntent(projectRoot, payload, { consume: true, compact: source === 'compact' });
|
|
139
139
|
if (!intent) return false;
|
|
140
140
|
const out = [
|
|
141
141
|
'UKIT ROUTED TASK RESUME — an unfinished ordinary routed task was preserved before context compaction.',
|
|
@@ -146,7 +146,16 @@ async function emitOrdinaryResume(payload, source) {
|
|
|
146
146
|
];
|
|
147
147
|
if (source === 'compact') {
|
|
148
148
|
out.push('');
|
|
149
|
-
out.push('
|
|
149
|
+
out.push('=== POST-COMPACTION RESUME ===');
|
|
150
|
+
// Snapshot fields come from the PreCompact checkpoint; absent on legacy intents.
|
|
151
|
+
if (intent.goal) out.push(`Goal: ${intent.goal.replace(/\s+/g, ' ').slice(0, 1200)}`);
|
|
152
|
+
if (intent.contract) out.push(`Contract: ${intent.contract}`);
|
|
153
|
+
if (intent.observedEvidence?.length) out.push(`Evidence observed: ${intent.observedEvidence.join(', ')}`);
|
|
154
|
+
if (intent.unmetEvidence?.length) out.push(`Unmet evidence: ${intent.unmetEvidence.join(', ')}`);
|
|
155
|
+
if (intent.nextStep) out.push(`Next step: ${intent.nextStep}`);
|
|
156
|
+
if (intent.git?.head) out.push(`Git at compaction: HEAD ${String(intent.git.head).slice(0, 12)}, ${intent.git.dirtyFiles || 0} dirty file(s) — re-check git status before mutating.`);
|
|
157
|
+
out.push('Compaction is not completion — continue the work now; the window is clean. Do not report status and wait, and do not ask the user to /compact or start a new session.');
|
|
158
|
+
out.push('=== END ===');
|
|
150
159
|
}
|
|
151
160
|
process.stdout.write(`${out.join('\n')}\n`);
|
|
152
161
|
return true;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// mission-capture.mjs - UserPromptSubmit + PostToolUse(TodoWrite|TaskCreate|TaskUpdate) chain step (WP4).
|
|
2
|
+
// Records the (redacted) prompt into the mission journal, classifies it into the requirement graph, and mirrors
|
|
3
|
+
// todo/task tool calls into graph task status. Emits nothing to the model except one short drift line when the
|
|
4
|
+
// drift signature changes. Advisory: always code 0, fail-open, deadline-bounded. Logic: ukit/runtime/mission/hooks.mjs.
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
export const hookFailClosed = false;
|
|
9
|
+
const NONE = { code: 0, stdout: '', stderr: '' };
|
|
10
|
+
const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
|
|
12
|
+
export async function runHook(ctx = {}) {
|
|
13
|
+
let timer;
|
|
14
|
+
try {
|
|
15
|
+
const projectRoot = ctx.projectRoot || process.cwd();
|
|
16
|
+
const payload = ctx.payload && typeof ctx.payload === 'object' ? ctx.payload : {};
|
|
17
|
+
const deadlineMs = Number(ctx.deadlineMs || process.env.HOOK_DEADLINE_MS) || 2000;
|
|
18
|
+
const timeout = new Promise((resolve) => { timer = setTimeout(() => resolve(''), Math.max(100, deadlineMs - 150)); timer.unref?.(); });
|
|
19
|
+
const work = (async () => {
|
|
20
|
+
const mod = await import(pathToFileURL(path.join(MODULE_DIR, '..', 'ukit', 'runtime', 'mission', 'hooks.mjs')).href);
|
|
21
|
+
if (payload.hook_event_name === 'PostToolUse') { await mod.todoMirrorStep({ projectRoot, payload }); return ''; }
|
|
22
|
+
if (payload.tool_name) return '';
|
|
23
|
+
return mod.captureStep({ projectRoot, payload });
|
|
24
|
+
})();
|
|
25
|
+
const text = await Promise.race([work, timeout]);
|
|
26
|
+
if (!text) return NONE;
|
|
27
|
+
const env = ctx.env || process.env;
|
|
28
|
+
const omp = payload.ukit_harness === 'omp' || env.UKIT_HARNESS === 'omp';
|
|
29
|
+
const stdout = omp ? `${text}\n`
|
|
30
|
+
: `${JSON.stringify({ hookSpecificOutput: { hookEventName: 'UserPromptSubmit', additionalContext: text } })}\n`;
|
|
31
|
+
return { code: 0, stdout, stderr: '' };
|
|
32
|
+
} catch {
|
|
33
|
+
return NONE;
|
|
34
|
+
} finally {
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// post-compact-observe.mjs - PostCompact chain step (observe-only, always code 0, fail-open).
|
|
2
|
+
// Records COMPACT_SUCCEEDED; an empty/unusable summary (<200 chars) is flagged as failure class 11.
|
|
3
|
+
// Only the summary LENGTH is stored, never its text.
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
export const hookFailClosed = false;
|
|
8
|
+
const NONE = { code: 0, stdout: '', stderr: '' };
|
|
9
|
+
const HOOKS_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
export const MIN_SUMMARY_CHARS = 200;
|
|
11
|
+
|
|
12
|
+
async function handle(ctx) {
|
|
13
|
+
const root = ctx.projectRoot || process.cwd();
|
|
14
|
+
const p = ctx.payload || {};
|
|
15
|
+
const sw = await import(pathToFileURL(path.join(HOOKS_DIR, 'stop-failure-rescue.mjs')).href);
|
|
16
|
+
const len = typeof p.compact_summary === 'string' ? p.compact_summary.trim().length : 0;
|
|
17
|
+
const empty = len < MIN_SUMMARY_CHARS;
|
|
18
|
+
await sw.appendEvent(root, {
|
|
19
|
+
ts: new Date().toISOString(), type: 'COMPACT_SUCCEEDED', trigger: String(p.trigger || '').slice(0, 20),
|
|
20
|
+
summaryChars: len, ...(empty ? { cls: 11, name: 'empty-compaction-summary', flag: 'empty-summary' } : {}),
|
|
21
|
+
});
|
|
22
|
+
return NONE;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function runHook(ctx = {}) {
|
|
26
|
+
try {
|
|
27
|
+
const deadlineMs = Number(ctx.deadlineMs || process.env.HOOK_DEADLINE_MS) || 2000;
|
|
28
|
+
let timer;
|
|
29
|
+
const timeout = new Promise((resolve) => { timer = setTimeout(() => resolve(NONE), Math.max(100, deadlineMs - 100)); timer.unref?.(); });
|
|
30
|
+
return await Promise.race([handle(ctx), timeout]).finally(() => clearTimeout(timer));
|
|
31
|
+
} catch {
|
|
32
|
+
return NONE;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// shell-watch.mjs - UserPromptSubmit chain step (advisory, always code 0, fail-open).
|
|
2
|
+
// Emits an ACTION directive when hung shells / stalled background tasks exist.
|
|
3
|
+
// Claude Code: JSON hookSpecificOutput.additionalContext; omp: plain text (bridge appends it).
|
|
4
|
+
// Logic lives in ukit/runtime/shell-watch.mjs.
|
|
5
|
+
import fsp from 'node:fs/promises';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
export const hookFailClosed = false;
|
|
10
|
+
const NONE = { code: 0, stdout: '', stderr: '' };
|
|
11
|
+
const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
|
|
13
|
+
export async function runHook(ctx = {}) {
|
|
14
|
+
try {
|
|
15
|
+
const projectRoot = ctx.projectRoot || process.cwd();
|
|
16
|
+
let config = null;
|
|
17
|
+
try { config = JSON.parse(await fsp.readFile(path.join(projectRoot, '.ukit', 'storage', 'config.json'), 'utf8')); } catch { /* defaults */ }
|
|
18
|
+
const mod = await import(pathToFileURL(path.join(MODULE_DIR, '..', 'ukit', 'runtime', 'shell-watch.mjs')).href);
|
|
19
|
+
// Deadline contract: never outlive the chain slot (ctx.deadlineMs or HOOK_DEADLINE_MS).
|
|
20
|
+
const deadlineMs = Number(ctx.deadlineMs || process.env.HOOK_DEADLINE_MS) || 2000;
|
|
21
|
+
let timer;
|
|
22
|
+
const timeout = new Promise((resolve) => { timer = setTimeout(() => resolve(''), Math.max(100, deadlineMs - 100)); timer.unref?.(); });
|
|
23
|
+
const text = await Promise.race([mod.runShellWatch({ projectRoot, config }), timeout]).finally(() => clearTimeout(timer));
|
|
24
|
+
if (!text) return NONE;
|
|
25
|
+
const env = ctx.env || process.env;
|
|
26
|
+
const omp = ctx.payload?.ukit_harness === 'omp' || env.UKIT_HARNESS === 'omp';
|
|
27
|
+
const stdout = omp
|
|
28
|
+
? `${text}\n`
|
|
29
|
+
: `${JSON.stringify({ hookSpecificOutput: { hookEventName: 'UserPromptSubmit', additionalContext: text } })}\n`;
|
|
30
|
+
return { code: 0, stdout, stderr: '' };
|
|
31
|
+
} catch {
|
|
32
|
+
return NONE;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -4478,9 +4478,19 @@ function applyTaskSemantics(contract, semantic) {
|
|
|
4478
4478
|
return { entries: merged.slice(0, 40), evicted: merged.slice(40) };
|
|
4479
4479
|
}
|
|
4480
4480
|
|
|
4481
|
+
// Field #8: size-capped rotation (one `.1` generation), parity with
|
|
4482
|
+
// rotateAppendLogSync in runtime/execution-ledger.mjs.
|
|
4483
|
+
const SEGMENTS_MAX_BYTES = 4 * 1024 * 1024;
|
|
4484
|
+
async function rotateSegments() {
|
|
4485
|
+
try {
|
|
4486
|
+
if ((await fsp.stat(segmentsPath)).size >= SEGMENTS_MAX_BYTES) await fsp.rename(segmentsPath, `${segmentsPath}.1`);
|
|
4487
|
+
} catch {}
|
|
4488
|
+
}
|
|
4489
|
+
|
|
4481
4490
|
async function spillEvictedEntries(evicted) {
|
|
4482
4491
|
if (!evicted?.length) return;
|
|
4483
4492
|
try {
|
|
4493
|
+
await rotateSegments();
|
|
4484
4494
|
await fsp.appendFile(
|
|
4485
4495
|
segmentsPath,
|
|
4486
4496
|
evicted.map((item) => JSON.stringify(item)).join('\n') + '\n',
|
|
@@ -4504,6 +4514,9 @@ function applyTaskSemantics(contract, semantic) {
|
|
|
4504
4514
|
function spillEvictedEntriesSync(evicted) {
|
|
4505
4515
|
if (!evicted?.length) return;
|
|
4506
4516
|
try {
|
|
4517
|
+
try {
|
|
4518
|
+
if (fsSync.statSync(segmentsPath).size >= SEGMENTS_MAX_BYTES) fsSync.renameSync(segmentsPath, `${segmentsPath}.1`);
|
|
4519
|
+
} catch {}
|
|
4507
4520
|
fsSync.appendFileSync(
|
|
4508
4521
|
segmentsPath,
|
|
4509
4522
|
evicted.map((item) => JSON.stringify(item)).join('\n') + '\n',
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// stop-failure-rescue.mjs - StopFailure chain step (detect + record only, always code 0, fail-open).
|
|
2
|
+
// Classifies the failure, appends a redacted event to .ukit/storage/rescue/events.jsonl (rotates at
|
|
3
|
+
// 1 MiB) and advances the recovery state machine. Never writes prompt text or touches transcripts.
|
|
4
|
+
import fsp from 'node:fs/promises';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import crypto from 'node:crypto';
|
|
7
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
export const hookFailClosed = false;
|
|
10
|
+
const NONE = { code: 0, stdout: '', stderr: '' };
|
|
11
|
+
const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const RESCUE_DIR = path.join(MODULE_DIR, '..', 'ukit', 'runtime', 'rescue');
|
|
13
|
+
export const EVENTS_MAX_BYTES = 1024 * 1024;
|
|
14
|
+
|
|
15
|
+
const load = (name) => import(pathToFileURL(path.join(RESCUE_DIR, name)).href);
|
|
16
|
+
|
|
17
|
+
export async function appendEvent(root, event) {
|
|
18
|
+
const dir = path.join(root, '.ukit', 'storage', 'rescue');
|
|
19
|
+
const file = path.join(dir, 'events.jsonl');
|
|
20
|
+
await fsp.mkdir(dir, { recursive: true });
|
|
21
|
+
try {
|
|
22
|
+
const st = await fsp.stat(file);
|
|
23
|
+
if (st.size >= EVENTS_MAX_BYTES) await fsp.rename(file, `${file}.1`);
|
|
24
|
+
} catch { /* no file yet */ }
|
|
25
|
+
await fsp.appendFile(file, `${JSON.stringify(event)}\n`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function handle(ctx) {
|
|
29
|
+
const root = ctx.projectRoot || process.cwd();
|
|
30
|
+
const p = ctx.payload || {};
|
|
31
|
+
const cf = await load('classify-failure.mjs');
|
|
32
|
+
const rs = await load('recovery-state.mjs');
|
|
33
|
+
const input = { error: p.error, error_details: p.error_details, message: p.last_assistant_message ?? p.message, usage: p.usage };
|
|
34
|
+
const c = cf.classifyFailure(input);
|
|
35
|
+
const fp = cf.fingerprint(input);
|
|
36
|
+
// eventId: stable for an identical payload within the same session+minute -> duplicate hook events dedupe.
|
|
37
|
+
const sid = String(p.session_id || ctx.sessionId || '').slice(0, 64);
|
|
38
|
+
const eventId = crypto.createHash('sha1').update(`${sid}|${fp}|${p.turn_id ?? ''}|${Math.floor(Date.now() / 60000)}`).digest('hex').slice(0, 24);
|
|
39
|
+
const missionId = p.mission_id || undefined;
|
|
40
|
+
|
|
41
|
+
const cur = await rs.readState({ root, missionId });
|
|
42
|
+
let outcome;
|
|
43
|
+
if (c.action === 'block') {
|
|
44
|
+
outcome = await rs.transition({ root, missionId, from: cur.state, to: 'BLOCKED', eventId, reason: c.name, fingerprint: fp, failure: true });
|
|
45
|
+
} else if (c.action === 'none') {
|
|
46
|
+
outcome = { ok: true, applied: false };
|
|
47
|
+
} else if (cur.state === 'COMPACT_FAILED') {
|
|
48
|
+
outcome = await rs.recordFailure({ root, missionId, fingerprint: fp, eventId });
|
|
49
|
+
if (outcome.ok && outcome.applied && !outcome.open && c.action !== 'wait') {
|
|
50
|
+
outcome = await rs.transition({ root, missionId, from: 'COMPACT_FAILED', to: 'RECOVERING', eventId: `${eventId}:r`, reason: c.name, fingerprint: fp });
|
|
51
|
+
}
|
|
52
|
+
} else if (cur.state === 'HEALTHY' || cur.state === 'PRESSURE' || cur.state === 'CHECKPOINTED' || cur.state === 'COMPACTING' || cur.state === 'RECOVERING' || cur.state === 'ROLLOVER_PENDING') {
|
|
53
|
+
outcome = await rs.transition({ root, missionId, from: cur.state, to: 'COMPACT_FAILED', eventId, reason: c.name, fingerprint: fp, failure: true });
|
|
54
|
+
} else {
|
|
55
|
+
outcome = { ok: true, applied: false };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const redacted = cf.redact(`${typeof p.error_details === 'string' ? p.error_details : ''}`).slice(0, 200);
|
|
59
|
+
await appendEvent(root, {
|
|
60
|
+
ts: new Date().toISOString(), type: 'STOP_FAILURE', eventId, error: String(p.error || '').slice(0, 40),
|
|
61
|
+
cls: c.cls, name: c.name, action: c.action, retryable: c.retryable, flags: c.flags, fingerprint: fp,
|
|
62
|
+
byteRatio: Number(c.byteRatio.toFixed(3)), detail: redacted, transition: outcome?.ok ? (outcome.state || null) : outcome?.code || null,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
const ev = outcome?.ok && outcome.applied ? { COMPACT_FAILED: 'COMPACT_FAILED', RECOVERING: 'RECOVERY_STARTED' }[outcome.state] : null;
|
|
67
|
+
if (ev) await (await load('rollover.mjs')).emitRescueEvent(root, ev, { eventId, cls: c.cls, name: c.name });
|
|
68
|
+
} catch { /* event is best-effort */ }
|
|
69
|
+
|
|
70
|
+
// WP-R3: rollover/reconstruct-class failures also persist an offline restoration bundle (fail-open).
|
|
71
|
+
let rolloverNotice = '';
|
|
72
|
+
if (c.action === 'rollover' || c.action === 'reconstruct') {
|
|
73
|
+
try {
|
|
74
|
+
const rc = await load('reconstruct.mjs');
|
|
75
|
+
const bd = await load('bundle.mjs');
|
|
76
|
+
const recon = await rc.reconstructMission({ projectRoot: root, transcriptPath: p.transcript_path, sessionId: sid || undefined });
|
|
77
|
+
const bundle = bd.buildBundle(recon, { maxChars: 6000 });
|
|
78
|
+
const w = await bd.writeBundle(root, bundle);
|
|
79
|
+
await appendEvent(root, { ts: new Date().toISOString(), type: 'RESCUE_BUNDLE_WRITTEN', eventId, sha256: bundle.sha256.slice(0, 16), chars: bundle.text.length, reconcile: bundle.reconcile, file: path.basename(w.bundlePath) });
|
|
80
|
+
let ro = null;
|
|
81
|
+
try { ro = await load('rollover.mjs'); await ro.emitRescueEvent(root, 'OFFLINE_CONTEXT_REBUILT', { eventId, sha256: bundle.sha256.slice(0, 16), chars: bundle.text.length, reconcile: bundle.reconcile }); } catch { /* event is best-effort */ }
|
|
82
|
+
if (ro && c.action === 'rollover') {
|
|
83
|
+
let config = {};
|
|
84
|
+
try { config = JSON.parse(await fsp.readFile(path.join(root, '.ukit', 'storage', 'config.json'), 'utf8')); } catch { /* defaults */ }
|
|
85
|
+
const lease = await (await load('lease.mjs')).readLease(root).catch(() => null);
|
|
86
|
+
const state = await rs.readState({ root, missionId });
|
|
87
|
+
const r = await ro.maybeRollover({ projectRoot: root, config, state, lease, autonomy: config?.autonomy?.level, failure: c, fingerprint: fp, ownerStop: recon.ownerStop === true });
|
|
88
|
+
rolloverNotice = typeof r?.notice === 'string' ? r.notice.split('\n')[0] : '';
|
|
89
|
+
}
|
|
90
|
+
} catch { /* bundle is best-effort */ }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const rollover = c.action === 'rollover';
|
|
94
|
+
const stderr = rollover
|
|
95
|
+
? `UKit rescue: context overflow detected (class ${c.cls}: ${c.name}). Your work is preserved; run \`ukit rescue\` or start a fresh session and UKit will reconstruct state on start.\n${rolloverNotice ? `${rolloverNotice}\n` : ''}`
|
|
96
|
+
: '';
|
|
97
|
+
return { code: 0, stdout: '', stderr };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export async function runHook(ctx = {}) {
|
|
101
|
+
try {
|
|
102
|
+
const deadlineMs = Number(ctx.deadlineMs || process.env.HOOK_DEADLINE_MS) || 2000;
|
|
103
|
+
let timer;
|
|
104
|
+
const timeout = new Promise((resolve) => { timer = setTimeout(() => resolve(NONE), Math.max(100, deadlineMs - 100)); timer.unref?.(); });
|
|
105
|
+
return await Promise.race([handle(ctx), timeout]).finally(() => clearTimeout(timer));
|
|
106
|
+
} catch {
|
|
107
|
+
return NONE;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -162,6 +162,16 @@
|
|
|
162
162
|
}
|
|
163
163
|
]
|
|
164
164
|
},
|
|
165
|
+
{
|
|
166
|
+
"matcher": "TodoWrite|TaskCreate|TaskUpdate",
|
|
167
|
+
"hooks": [
|
|
168
|
+
{
|
|
169
|
+
"type": "command",
|
|
170
|
+
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/ukit/runtime/hook-chain-runner.mjs\" --emit-verdict - \"$CLAUDE_PROJECT_DIR/.claude/hooks/mission-capture.mjs\":8",
|
|
171
|
+
"timeout": 18
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
},
|
|
165
175
|
{
|
|
166
176
|
"matcher": "Bash",
|
|
167
177
|
"hooks": [
|
|
@@ -202,8 +212,8 @@
|
|
|
202
212
|
"hooks": [
|
|
203
213
|
{
|
|
204
214
|
"type": "command",
|
|
205
|
-
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/ukit/runtime/hook-chain-runner.mjs\" --emit-verdict - \"$CLAUDE_PROJECT_DIR/.claude/hooks/sensitive-data-guard.mjs\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/record-execution.mjs\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-router.sh\":20 \"$CLAUDE_PROJECT_DIR/.claude/hooks/vision-router.sh\":12 \"$CLAUDE_PROJECT_DIR/.claude/hooks/context-window-guard.sh\":10",
|
|
206
|
-
"timeout":
|
|
215
|
+
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/ukit/runtime/hook-chain-runner.mjs\" --emit-verdict - \"$CLAUDE_PROJECT_DIR/.claude/hooks/sensitive-data-guard.mjs\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/record-execution.mjs\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/skill-router.sh\":20 \"$CLAUDE_PROJECT_DIR/.claude/hooks/vision-router.sh\":12 \"$CLAUDE_PROJECT_DIR/.claude/hooks/context-window-guard.sh\":10 \"$CLAUDE_PROJECT_DIR/.claude/hooks/mission-capture.mjs\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/shell-watch.mjs\":8",
|
|
216
|
+
"timeout": 84
|
|
207
217
|
}
|
|
208
218
|
]
|
|
209
219
|
}
|
|
@@ -219,6 +229,28 @@
|
|
|
219
229
|
]
|
|
220
230
|
}
|
|
221
231
|
],
|
|
232
|
+
"StopFailure": [
|
|
233
|
+
{
|
|
234
|
+
"hooks": [
|
|
235
|
+
{
|
|
236
|
+
"type": "command",
|
|
237
|
+
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/ukit/runtime/hook-chain-runner.mjs\" --emit-verdict - \"$CLAUDE_PROJECT_DIR/.claude/hooks/stop-failure-rescue.mjs\":8",
|
|
238
|
+
"timeout": 18
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
],
|
|
243
|
+
"PostCompact": [
|
|
244
|
+
{
|
|
245
|
+
"hooks": [
|
|
246
|
+
{
|
|
247
|
+
"type": "command",
|
|
248
|
+
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/ukit/runtime/hook-chain-runner.mjs\" --emit-verdict - \"$CLAUDE_PROJECT_DIR/.claude/hooks/post-compact-observe.mjs\":8",
|
|
249
|
+
"timeout": 18
|
|
250
|
+
}
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
],
|
|
222
254
|
"PreCompact": [
|
|
223
255
|
{
|
|
224
256
|
"hooks": [
|
|
@@ -235,8 +267,8 @@
|
|
|
235
267
|
"hooks": [
|
|
236
268
|
{
|
|
237
269
|
"type": "command",
|
|
238
|
-
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/ukit/runtime/hook-chain-runner.mjs\" --emit-verdict - \"$CLAUDE_PROJECT_DIR/.claude/hooks/project-important.sh\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/auto-prune-bash.sh\":12 \"$CLAUDE_PROJECT_DIR/.claude/hooks/reset-compact-pressure.sh\":12 \"$CLAUDE_PROJECT_DIR/.claude/hooks/handoff-resume.sh\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/observability-emit.mjs\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/session-episode-start.mjs\":8",
|
|
239
|
-
"timeout":
|
|
270
|
+
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/ukit/runtime/hook-chain-runner.mjs\" --emit-verdict - \"$CLAUDE_PROJECT_DIR/.claude/hooks/project-important.sh\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/auto-prune-bash.sh\":12 \"$CLAUDE_PROJECT_DIR/.claude/hooks/reset-compact-pressure.sh\":12 \"$CLAUDE_PROJECT_DIR/.claude/hooks/handoff-resume.sh\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/reinject-context.sh\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/observability-emit.mjs\":8 \"$CLAUDE_PROJECT_DIR/.claude/hooks/session-episode-start.mjs\":8",
|
|
271
|
+
"timeout": 74
|
|
240
272
|
}
|
|
241
273
|
]
|
|
242
274
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: backend-api
|
|
3
|
-
description: Backend API standards for endpoints, contracts, auth, and service logic.
|
|
3
|
+
description: Backend API standards for endpoints, contracts, auth, and service logic. Use when adding or changing an HTTP/RPC endpoint, request/response contract, auth check, or service-layer logic.
|
|
4
4
|
enabledByDefault: false
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: delivery
|
|
3
|
-
description: Project delivery workflow and quality gates for UKit templates.
|
|
3
|
+
description: Project delivery workflow and quality gates for UKit templates. Use when preparing a change to ship — version bump, changelog, release checklist, or final quality gate before handoff.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Delivery Skill
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: docs-manager
|
|
3
|
-
description: Standardized documentation workflow for template-based projects.
|
|
3
|
+
description: Standardized documentation workflow for template-based projects. Use when creating, restructuring, or syncing project docs (README, docs/*.md, CHANGELOG) with the code.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Documentation Manager Skill
|
|
@@ -8,7 +8,8 @@ description: >
|
|
|
8
8
|
load dropdown data, xử lý datetime, validate form, thiết kế luồng tính năng, hay bất kỳ task code
|
|
9
9
|
nào liên quan đến FE_DuraOne, BE_DuraOne, hoặc dự án cùng stack (Nuxt 3 + Sanic + PostgreSQL).
|
|
10
10
|
Skill này là nguồn sự thật duy nhất — không đoán mò, không dùng raw input, không dùng new Date().
|
|
11
|
-
Đọc reference phù hợp TRƯỚC KHI code bất kỳ thứ gì.
|
|
11
|
+
Đọc reference phù hợp TRƯỚC KHI code bất kỳ thứ gì. Use when working on any DuraOne-stack
|
|
12
|
+
project (FE_DuraOne, BE_DuraOne, Nuxt 3 + Sanic + PostgreSQL).
|
|
12
13
|
---
|
|
13
14
|
|
|
14
15
|
# DuraOne Skill — Phong Cách Code Cá Nhân
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: file-organizer
|
|
3
|
-
description: Intelligently organizes your files and folders across your computer by understanding context, finding duplicates, suggesting better structures, and automating cleanup tasks.
|
|
3
|
+
description: Intelligently organizes your files and folders across your computer by understanding context, finding duplicates, suggesting better structures, and automating cleanup tasks. Use when asked to tidy, deduplicate, or restructure files or folders.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# File Organizer
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: frontend
|
|
3
|
-
description: Generic frontend implementation standards for UI and UX work.
|
|
3
|
+
description: Generic frontend implementation standards for UI and UX work. Use when building or changing UI components, pages, styling, forms, or client-side state in a non-Vue stack.
|
|
4
4
|
enabledByDefault: false
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: frontend-vue
|
|
3
|
-
description: Vue 2 / Nuxt frontend skill pack for UKit projects. Options API, Bootstrap 5 + Ant Design Vue, predefined components (Control*, Grid*, Popup*), composables (request, session, translation, utils).
|
|
3
|
+
description: Vue 2 / Nuxt frontend skill pack for UKit projects. Options API, Bootstrap 5 + Ant Design Vue, predefined components (Control*, Grid*, Popup*), composables (request, session, translation, utils). Use when creating or editing a Vue/Nuxt page, component, form, or grid; always reuse existing components before creating new ones.
|
|
4
4
|
triggers:
|
|
5
5
|
- vue
|
|
6
6
|
- nuxt
|