@mjasnikovs/pi-task 0.17.5 → 0.17.6

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.
@@ -17,6 +17,7 @@ import { allocateAutoId, buildAutoBody, parseDecomposeList, parseTaskList, check
17
17
  import { writeTaskFile, readTaskFile, updateTaskFrontMatter, taskFilePath, tasksDir } from './task-io.js';
18
18
  import { findPhantomImports, rewritePhantomSpecifiers } from '../workers/phantom-imports.js';
19
19
  import { runPhaseChild, prependHint, USER_CANCELLED } from './child-runner.js';
20
+ import { refineExistingFilesBlock } from './phases.js';
20
21
  import { SessionUI, registerBridgeCommand, publishLifecycleNotice } from '../remote/bridge.js';
21
22
  import { pushNotify } from '../remote/push.js';
22
23
  import { startAutoLoader } from './widget.js';
@@ -80,9 +81,19 @@ function logPlanDebug(cwd, msg) {
80
81
  * throw or an untagged reply falls back to surfacing the question (the prior
81
82
  * behavior), never dropping it silently.
82
83
  */
83
- async function triageClarifyQuestion(deps, cwd, featureForModel, question) {
84
+ async function triageClarifyQuestion(deps, cwd, featureForModel, existingFilesBlock, question) {
84
85
  try {
85
- const basePrompt = GRILL_AUTO_ANSWER_PROMPT(featureForModel, '(none clarify runs before decomposition; each task researches itself later)', question);
86
+ // Prepend the existing-files block (refine's REFINE_PRESERVE_DIRECTIVE +
87
+ // manifest/config content) so a "scaffold/create/from scratch" question is
88
+ // auto-resolved as an in-place UPDATE that PRESERVES what is on disk —
89
+ // instead of "greenfield, from scratch", which the spec-only triage emitted
90
+ // 13/15 of the time and would mint a destructive decompose decision that can
91
+ // outrank refine's preserve directive (A/B live: 2/15 → 14/15 preserve).
92
+ // Empty (greenfield repo / orientation off) → byte-identical to before.
93
+ const source = existingFilesBlock.length > 0 ?
94
+ `${existingFilesBlock}\n\n${featureForModel}`
95
+ : featureForModel;
96
+ const basePrompt = GRILL_AUTO_ANSWER_PROMPT(source, '(none — clarify runs before decomposition; each task researches itself later)', question);
86
97
  let text = await deps.runChild('clarify-triage', 'read', basePrompt);
87
98
  if (!autoAnswerHasTag(text)) {
88
99
  // No ANSWER/UNKNOWN/ALT tag — the model wrote prose. Reprompt once for
@@ -261,6 +272,15 @@ export async function planAuto(ctx, cwd, feature, deps) {
261
272
  if (planPhantoms.length > 0) {
262
273
  logPlanDebug(cwd, `phantom specifiers rewritten in plan spec: ${planPhantoms.map(x => x.spec).join(', ')}`);
263
274
  }
275
+ // Existing manifest/config on disk (REFINE_PRESERVE_DIRECTIVE + tier 0–1
276
+ // content), computed ONCE and fed to every triage call so a "scaffold X"
277
+ // question resolves to an in-place update instead of "greenfield". '' for a
278
+ // greenfield/non-git repo or orientation off → triage stays spec-only.
279
+ const existingFilesBlock = await refineExistingFilesBlock({
280
+ cwd,
281
+ taskId: '',
282
+ signal: new AbortController().signal
283
+ }).catch(() => '');
264
284
  const answers = [];
265
285
  // Plain text of every question already shown, for the duplicate backstop.
266
286
  const askedQuestions = [];
@@ -299,7 +319,7 @@ export async function planAuto(ctx, cwd, feature, deps) {
299
319
  // this question, auto-resolve it and never show it. The resolved value is
300
320
  // recorded so decompose sees the decision and the next gen call's priorQA
301
321
  // won't re-ask it.
302
- const autoResolved = await triageClarifyQuestion(deps, cwd, featureForModel, plainQ);
322
+ const autoResolved = await triageClarifyQuestion(deps, cwd, featureForModel, existingFilesBlock, plainQ);
303
323
  if (autoResolved !== null) {
304
324
  answers.push(`Q${answers.length + 1}: ${plainQ}\n`
305
325
  + `A${answers.length + 1}: ${autoResolved} (auto-resolved — already settled by the spec)`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjasnikovs/pi-task",
3
- "version": "0.17.5",
3
+ "version": "0.17.6",
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",