@mjasnikovs/pi-task 0.13.31 → 0.13.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.
|
@@ -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
|
|
@@ -13,7 +13,7 @@ import { renderInlineMarkdown, stripInlineMarkdown } from './inline-markdown.js'
|
|
|
13
13
|
import { AUTO_CLARIFY_PROMPT, AUTO_DECOMPOSE_PROMPT } from './auto-prompts.js';
|
|
14
14
|
import { isDuplicateQuestion, MAX_DUP_STRIKES, DUP_REPROMPT_HINT } from './question-dedup.js';
|
|
15
15
|
import { allocateAutoId, buildAutoBody, parseDecomposeList, parseTaskList, checkOffTask, stampTaskInProgress, findResumableAuto } from './auto-io.js';
|
|
16
|
-
import { writeTaskFile, readTaskFile, updateTaskFrontMatter, taskFilePath } from './task-io.js';
|
|
16
|
+
import { writeTaskFile, readTaskFile, updateTaskFrontMatter, taskFilePath, tasksDir } from './task-io.js';
|
|
17
17
|
import { gitCommitAll } from './auto-commit.js';
|
|
18
18
|
import { runGuidelineEnforcement, classifyEnforceChildFailure, ENFORCE_TIMEOUT_MS } from './enforce-guidelines.js';
|
|
19
19
|
import { runWorker } from '../workers/pi-worker-core.js';
|
|
@@ -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,21 @@ function defaultDeps(ctx, cwd, signal, title) {
|
|
|
328
328
|
lastLine = undefined;
|
|
329
329
|
contextUsage = undefined;
|
|
330
330
|
const startedAt = Date.now();
|
|
331
|
-
|
|
331
|
+
// Per-pass debug log. The enforce child is otherwise
|
|
332
|
+
// unobservable (it has no per-task file like the impl runner),
|
|
333
|
+
// so a loop/timeout in the verifier was undiagnosable. One
|
|
334
|
+
// rolling file under .pi-tasks/; each pass brackets its
|
|
335
|
+
// tool/text lines with start/end markers naming the task and
|
|
336
|
+
// the terminal outcome, so a kill shows the exact repeated
|
|
337
|
+
// calls that tripped the loop detector. Fire-and-forget.
|
|
338
|
+
const enforceLogPath = path.join(tasksDir(cwd2), 'enforce-debug.log');
|
|
339
|
+
const logEnforce = (msg) => {
|
|
340
|
+
void fsp
|
|
341
|
+
.appendFile(enforceLogPath, `${new Date().toISOString()} ${msg}\n`)
|
|
342
|
+
.catch(() => { });
|
|
343
|
+
};
|
|
344
|
+
logEnforce(`=== enforce start: ${taskTitle} ===`);
|
|
345
|
+
const stopLoader = startAutoLoader(enforceCtx, () => ({
|
|
332
346
|
title: taskTitle,
|
|
333
347
|
kind: 'enforce',
|
|
334
348
|
step: 'guidelines',
|
|
@@ -347,10 +361,13 @@ function defaultDeps(ctx, cwd, signal, title) {
|
|
|
347
361
|
timeoutMs: ENFORCE_TIMEOUT_MS,
|
|
348
362
|
onLine: line => {
|
|
349
363
|
lastLine = line;
|
|
350
|
-
|
|
364
|
+
logEnforce(line);
|
|
351
365
|
}
|
|
352
366
|
});
|
|
353
367
|
const failure = classifyEnforceChildFailure(r);
|
|
368
|
+
logEnforce(failure ?
|
|
369
|
+
`=== enforce end: FAIL — ${failure} ===`
|
|
370
|
+
: '=== enforce end: verdict captured ===');
|
|
354
371
|
if (failure)
|
|
355
372
|
throw new Error(failure);
|
|
356
373
|
return r.text;
|
|
@@ -470,7 +487,7 @@ export async function runAutoLoop(ctx, cwd, id, deps) {
|
|
|
470
487
|
// dep.) Fixes it makes are folded into this task's snapshot below.
|
|
471
488
|
if (deps.enforce) {
|
|
472
489
|
active.ui.notify(`${id}: enforcing AGENTS.md/CLAUDE.md on "${next.title}"…`, 'info');
|
|
473
|
-
const verdict = await deps.enforce(cwd, next.title);
|
|
490
|
+
const verdict = await deps.enforce(active, cwd, next.title);
|
|
474
491
|
if (!verdict.ok) {
|
|
475
492
|
await updateTaskFrontMatter(cwd, id, { state: 'failed' });
|
|
476
493
|
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.
|
|
3
|
+
"version": "0.13.33",
|
|
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",
|