@mjasnikovs/pi-task 0.13.31 → 0.13.32

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.
@@ -21,8 +21,12 @@ export interface AutoDeps {
21
21
  * CLAUDE.md guidelines (and auto-fix violations) BEFORE it is committed.
22
22
  * Optional: when absent (tests, or the feature disabled), the loop treats it
23
23
  * as a pass. ok === false blocks the commit and fails the task.
24
+ *
25
+ * Takes the loop's CURRENT ctx (not the one captured at defaultDeps time):
26
+ * each task runs in a fresh session, so the captured ctx is stale by the time
27
+ * enforcement runs and using it for the loader widget throws "stale ctx".
24
28
  */
25
- enforce?: (cwd: string, taskTitle: string) => Promise<EnforceOutcome>;
29
+ enforce?: (ctx: ExtensionCommandContext, cwd: string, taskTitle: string) => Promise<EnforceOutcome>;
26
30
  }
27
31
  /**
28
32
  * Expand any @file references in the feature text by appending each referenced
@@ -306,7 +306,7 @@ function defaultDeps(ctx, cwd, signal, title) {
306
306
  commit: (cwd2, message) => getConfig().autoCommit ?
307
307
  gitCommitAll(cwd2, message, signal)
308
308
  : Promise.resolve({ committed: false, reason: 'auto-commit disabled' }),
309
- enforce: (cwd2, taskTitle) => {
309
+ enforce: (enforceCtx, cwd2, taskTitle) => {
310
310
  if (!getConfig().enforceGuidelines) {
311
311
  return Promise.resolve({ ok: true, reason: 'disabled' });
312
312
  }
@@ -328,7 +328,7 @@ function defaultDeps(ctx, cwd, signal, title) {
328
328
  lastLine = undefined;
329
329
  contextUsage = undefined;
330
330
  const startedAt = Date.now();
331
- const stopLoader = startAutoLoader(ctx, () => ({
331
+ const stopLoader = startAutoLoader(enforceCtx, () => ({
332
332
  title: taskTitle,
333
333
  kind: 'enforce',
334
334
  step: 'guidelines',
@@ -470,7 +470,7 @@ export async function runAutoLoop(ctx, cwd, id, deps) {
470
470
  // dep.) Fixes it makes are folded into this task's snapshot below.
471
471
  if (deps.enforce) {
472
472
  active.ui.notify(`${id}: enforcing AGENTS.md/CLAUDE.md on "${next.title}"…`, 'info');
473
- const verdict = await deps.enforce(cwd, next.title);
473
+ const verdict = await deps.enforce(active, cwd, next.title);
474
474
  if (!verdict.ok) {
475
475
  await updateTaskFrontMatter(cwd, id, { state: 'failed' });
476
476
  announceDone(active, `${id} stopped at "${next.title}" — ${verdict.reason ?? 'guideline check failed'} — fix and run /task-auto-resume.`, 'error');
@@ -159,6 +159,11 @@ export async function runGuidelineEnforcement(deps) {
159
159
  text = await deps.runChild(ENFORCE_TOOLS, buildEnforcePrompt(doc.text, diff), deps.signal);
160
160
  }
161
161
  catch (err) {
162
+ // A user cancellation is not an enforcement failure — re-throw it so the
163
+ // /task-auto loop's USER_CANCELLED handler reports a clean "cancelled —
164
+ // resume" instead of wrapping it as "enforcement pass could not run".
165
+ if (err instanceof Error && err.message === USER_CANCELLED)
166
+ throw err;
162
167
  const msg = err instanceof Error ? err.message : String(err);
163
168
  return { ok: false, reason: `enforcement pass could not run: ${msg}` };
164
169
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjasnikovs/pi-task",
3
- "version": "0.13.31",
3
+ "version": "0.13.32",
4
4
  "description": "Deterministic spec-orchestration for local models, with a bundled real-time remote web view and web/docs/fetch/worker subagent tools.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",