@ordewell/core 0.7.0 → 0.7.1
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/dist/{IFileSystem-DgpX0BU7.d.mts → IFileSystem-BnLh-_SK.d.mts} +1 -1
- package/dist/{IFileSystem-D4ADfTrX.d.ts → IFileSystem-DofiRcCo.d.ts} +1 -1
- package/dist/{ModeResolver-Cv01ZDd9.d.mts → ModeResolver-DZzJSdIU.d.mts} +1 -1
- package/dist/{ModeResolver-BEcRAz1c.d.ts → ModeResolver-DkMYf4uS.d.ts} +1 -1
- package/dist/{Task-CoKhvBa1.d.mts → Task-BnLxkVQF.d.mts} +140 -21
- package/dist/{Task-CoKhvBa1.d.ts → Task-BnLxkVQF.d.ts} +140 -21
- package/dist/{chunk-YU4UKKKI.mjs → chunk-LGQNXPBX.mjs} +10 -2
- package/dist/chunk-LGQNXPBX.mjs.map +1 -0
- package/dist/{chunk-N66ZHFGN.mjs → chunk-OYUSADFM.mjs} +11 -1
- package/dist/chunk-OYUSADFM.mjs.map +1 -0
- package/dist/{chunk-HPNUFBIT.mjs → chunk-V3JHS7AX.mjs} +9 -1
- package/dist/chunk-V3JHS7AX.mjs.map +1 -0
- package/dist/{chunk-LSGY7AIZ.mjs → chunk-Y36NIASW.mjs} +183 -11
- package/dist/chunk-Y36NIASW.mjs.map +1 -0
- package/dist/{chunk-J3YSTPCE.mjs → chunk-ZV5LDNCO.mjs} +5 -4
- package/dist/chunk-ZV5LDNCO.mjs.map +1 -0
- package/dist/index.d.mts +287 -223
- package/dist/index.d.ts +287 -223
- package/dist/index.js +2111 -1086
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1973 -1117
- package/dist/index.mjs.map +1 -1
- package/dist/order-labels.d.mts +15 -2
- package/dist/order-labels.d.ts +15 -2
- package/dist/order-labels.js +12 -2
- package/dist/order-labels.js.map +1 -1
- package/dist/order-labels.mjs +7 -3
- package/dist/{parsing-B4OCHH1_.d.mts → parsing-B6ctfF80.d.mts} +2 -2
- package/dist/{parsing-DMdOq-BV.d.ts → parsing-ddZXZFP4.d.ts} +2 -2
- package/dist/parsing.d.mts +3 -3
- package/dist/parsing.d.ts +3 -3
- package/dist/parsing.js +6 -3
- package/dist/parsing.js.map +1 -1
- package/dist/parsing.mjs +3 -3
- package/dist/{plan-utils-BdYPRBno.d.ts → plan-utils--kQRzSE-.d.ts} +226 -7
- package/dist/{plan-utils-CD1Xu65s.d.mts → plan-utils-CKgNtDwQ.d.mts} +226 -7
- package/dist/plan-utils.d.mts +4 -3
- package/dist/plan-utils.d.ts +4 -3
- package/dist/plan-utils.js +202 -3
- package/dist/plan-utils.js.map +1 -1
- package/dist/plan-utils.mjs +40 -3
- package/dist/testing.d.mts +17 -5
- package/dist/testing.d.ts +17 -5
- package/dist/testing.js +45 -2
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +45 -4
- package/dist/testing.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-HPNUFBIT.mjs.map +0 -1
- package/dist/chunk-J3YSTPCE.mjs.map +0 -1
- package/dist/chunk-LSGY7AIZ.mjs.map +0 -1
- package/dist/chunk-N66ZHFGN.mjs.map +0 -1
- package/dist/chunk-YU4UKKKI.mjs.map +0 -1
|
@@ -150,9 +150,15 @@ function createTask(overrides = {}) {
|
|
|
150
150
|
autonomy: overrides.autonomy,
|
|
151
151
|
sliceType: overrides.sliceType,
|
|
152
152
|
userStoriesCovered: overrides.userStoriesCovered,
|
|
153
|
-
...overrides.ops
|
|
153
|
+
...opsFlag(overrides.ops, overrides.type) ? { ops: true } : {}
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
+
function opsFlag(value, type = "ai") {
|
|
157
|
+
return value === true && type === "ai" ? true : void 0;
|
|
158
|
+
}
|
|
159
|
+
function inheritedOps(from, chosen) {
|
|
160
|
+
return chosen ?? from.every((t) => opsFlag(t.ops) === true);
|
|
161
|
+
}
|
|
156
162
|
function createEmptyPlan() {
|
|
157
163
|
return {
|
|
158
164
|
tasks: [],
|
|
@@ -493,6 +499,8 @@ export {
|
|
|
493
499
|
migratePlanState,
|
|
494
500
|
migrateLegacyPlan,
|
|
495
501
|
createTask,
|
|
502
|
+
opsFlag,
|
|
503
|
+
inheritedOps,
|
|
496
504
|
createEmptyPlan,
|
|
497
505
|
flattenTasks,
|
|
498
506
|
flattenTasksWithParents,
|
|
@@ -516,4 +524,4 @@ export {
|
|
|
516
524
|
stripTrailingCommas,
|
|
517
525
|
escapeControlCharsInStrings
|
|
518
526
|
};
|
|
519
|
-
//# sourceMappingURL=chunk-
|
|
527
|
+
//# sourceMappingURL=chunk-LGQNXPBX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/models/Task.ts","../src/services/JsonExtractor.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport type { PlanIsolation } from '../interfaces/IWorktreeIsolation';\nimport type { RunnerTransport } from '../interfaces/ITerminalRunner';\nimport type { PlannerUsage, UsageRecord, UsageTotals } from './Usage';\n\nexport interface UserStep {\n order: number;\n instruction: string;\n completed: boolean;\n}\n\n/** One deterministic signal gathered while verifying a completed task. */\nexport interface VerificationCheck {\n name: 'exit_code' | 'completion_marker' | 'task_complete' | 'manual';\n passed: boolean;\n /** A check that did not apply. Skipped checks don't affect the verdict. */\n skipped: boolean;\n detail: string;\n}\n\n/** Evidence-based verdict for a completed task. Single end-to-end outcome produced by verification. */\nexport interface Verdict {\n outcome: 'pass' | 'fail';\n reason: string;\n checks: VerificationCheck[];\n decidedAt: string;\n}\n\nexport interface TaskOutputSummary {\n reviewReason: string;\n logTail: string;\n capturedAt: string;\n}\n\nexport type TaskType = 'ai' | 'user';\nexport type TaskStatus = 'pending' | 'approved' | 'in_progress' | 'completed' | 'failed' | 'blocked' | 'awaiting_user';\nexport type TaskMode = string;\n\n/**\n * Why an `awaiting_user` task waits (ADR-0018, W1): a structured turn that\n * ended without the done marker, a checkpoint question, work that did not\n * land, or an ops task that changed tracked files (ADR-0020). Saved, so no\n * surface has to guess it from whether an attempt is live.\n */\nexport type AwaitingReason = 'input' | 'checkpoint' | 'conflict' | 'files-changed';\n\nexport function isAwaitingReason(value: unknown): value is AwaitingReason {\n return value === 'input' || value === 'checkpoint' || value === 'conflict' || value === 'files-changed';\n}\n\nexport interface TaskModelAssignment {\n modelId: string;\n modelLabel: string;\n thinkingEffort?: string;\n /**\n * All variant ids the model offered when this assignment was made. Carried\n * on the assignment because runners need it at spawn time (opencode's TUI\n * only honors an assigned variant when the others are config-disabled) and\n * the discovery catalog isn't available there.\n */\n availableVariants?: string[];\n}\n\nexport type RunnerId = string;\n\n/**\n * How a task's latest attempt was driven (ADR-0018). Recorded only when its\n * plan asked for the structured transport, so a terminal plan's tasks carry\n * nothing new.\n */\nexport interface TaskTransport {\n kind: RunnerTransport;\n /** Why a plan that asked for structured ran this task on the terminal — never a silent downgrade (S3). */\n fallback?: string;\n /** The runner's own session id of a structured attempt, once it ends: what a continue resumes (K1). */\n nativeSessionId?: string;\n}\n\nexport interface Task {\n id: string;\n order: number;\n title: string;\n description: string;\n type: TaskType;\n status: TaskStatus;\n dependencies: string[];\n prompt?: string;\n userSteps?: UserStep[];\n subtasks: Task[];\n verdict?: Verdict;\n outputSummary?: TaskOutputSummary;\n assignedModel?: TaskModelAssignment;\n assignedRunner: RunnerId;\n thinkingEffort?: string;\n taskMode?: TaskMode;\n completionMarker: string;\n autonomy?: 'AFK' | 'HITL';\n sliceType?: 'HITL' | 'AFK';\n userStoriesCovered?: string[];\n transport?: TaskTransport;\n /** Set only while `status` is `awaiting_user`, and not always then — a usage-limit pause has none. */\n awaitingReason?: AwaitingReason;\n /**\n * An ops task (ADR-0020): it changes no repository files, runs at the\n * workspace root rather than in a worktree, and waits for the change tasks\n * it depends on to be merged into the user's branch. Top-level AI tasks\n * only; absent means a change task.\n */\n ops?: boolean;\n /**\n * The dependencies, by title, whose work was not merged into the user's\n * branch when the user force-started this task past its merge gate\n * (ADR-0020). Cleared when the task is retried.\n */\n forcedPastGate?: string[];\n}\n\nexport interface DiscoveredMode {\n id: string;\n label: string;\n description: string;\n}\n\nexport type ResearchToolType =\n | 'read_file' | 'read_files' | 'glob' | 'grep' | 'find_symbol' | 'list_dir'\n | 'bash' | 'fetch' | 'web_search' | 'spawn_research_agent'\n /**\n * A tool belonging to a harness planner's own toolbox (ADR-0009) that has no\n * Ordewell equivalent — Edit, WebFetch, TodoWrite, whatever a coding agent\n * ships next. The real name travels in `toolLabel` rather than being\n * relabelled as a tool it is not; the union stays closed so the\n * exhaustiveness checks in every surface's icon/label switch survive.\n */\n | 'agent_tool';\n\n/**\n * What happened when a research tool call ran, for honest per-surface\n * rendering. The broadcast seam carries this on every `research_step_done` so\n * surfaces do not have to pattern-match refusal text to tell a refused `rm`\n * from a successful `rm` — the old render path flipped a `✓` for both.\n */\nexport type ResearchStepOutcome = 'success' | 'failure' | 'refused' | 'denied' | 'not_executed';\n\nexport interface ResearchStep {\n id: string;\n tool: ResearchToolType;\n /** The tool's own name when it came from a harness planner — always set for `agent_tool`. */\n toolLabel?: string;\n args: string;\n result: string;\n success: boolean;\n outcome: ResearchStepOutcome;\n /** The model's tool_call id, so a surface can match `tool_result` to the\n * pending `tool_call` it announced — robust under parallel same-tool rounds. */\n toolCallId?: string;\n /** The research subagent that ran the call, so a reload regroups it under that subagent. */\n subagentId?: string;\n timestamp: string;\n thinkingText?: string;\n}\n\nexport interface UserPromptEntry {\n id: string;\n type: 'user_prompt' | 'system';\n content: string;\n timestamp: string;\n}\n\nexport type SubagentOutcome = 'done' | 'failed' | 'stopped';\n\n/**\n * One subagent's whole run, logged when it finishes: what it was asked, how it\n * ended and what it reported. Its steps stay separate entries carrying the same\n * `subagentId`, so an older reader that knows only steps still shows them.\n */\nexport interface SubagentLogEntry {\n id: string;\n type: 'subagent';\n subagentId: string;\n brief: string;\n model?: string;\n outcome: SubagentOutcome;\n digest: string;\n usage?: UsageTotals;\n timestamp: string;\n}\n\nexport type ResearchLogEntry = ResearchStep | UserPromptEntry | SubagentLogEntry;\n\nexport interface ResearchProgress {\n // 'liveness' carries no content: a raw-line signal from the harness process\n // (ADR-0009) that reaches a surface even when a turn is producing nothing\n // visible — a subagent's filtered chatter, most often — so an idle watchdog\n // downstream doesn't mistake \"nothing to show\" for \"nothing happening\".\n //\n // The turn-scoped kinds below carry one planner turn's stream (#47); see the\n // matching SessionMessage variants for the invariants each one keeps.\n // 'text_delta' is reply text as the model streams it (`text`, `segmentId`),\n // an envelope included: the turn's owner routes each segment to prose or to\n // the plan display, so no backend has to tell them apart. 'text_retracted'\n // takes back an attempt's text: `segmentId`'s, or when absent everything the\n // backend call that sends it has streamed.\n // 'usage' reports one model call (`record`). 'subagent_started' carries\n // `brief` and `model`; 'subagent_finished' carries `outcome`, `digest` and\n // `usage`.\n type:\n | 'thinking' | 'tool_call' | 'tool_result' | 'plan_token' | 'interrupted' | 'liveness'\n | 'text_delta' | 'text_retracted' | 'usage' | 'subagent_started' | 'subagent_finished';\n /** Minted by whoever runs the turn and passed through untouched; absent outside a turn. */\n turnId?: string;\n /** One continuous run of model text — text before a tool call is its own segment. */\n segmentId?: string;\n text?: string;\n tool?: string;\n /** Harness planners (ADR-0009): the agent's own name for a tool Ordewell has no member for. */\n toolLabel?: string;\n toolArgs?: string;\n toolResult?: string;\n planToken?: string;\n step?: ResearchStep;\n /** The model's tool_call id, threaded on tool_call and tool_result so a\n * surface can match the result to its pending call — robust under parallel\n * same-tool rounds where LIFO-by-name matching mislabels summaries. */\n toolCallId?: string;\n /** Present when this event originates from (or reports on) one spawned research subagent (issue #34). */\n subagentId?: string;\n record?: UsageRecord;\n brief?: string;\n model?: string;\n outcome?: SubagentOutcome;\n digest?: string;\n usage?: UsageTotals;\n}\n\nexport interface ThinkingBlock {\n id: string;\n text: string;\n}\n\nexport interface StreamThinkingEvent {\n type: 'thinking';\n block: ThinkingBlock;\n}\n\nexport interface StreamStepEvent {\n type: 'step';\n step: ResearchStep;\n}\n\nexport type StreamEvent = StreamThinkingEvent | StreamStepEvent;\n\nexport interface DiscoveredModel {\n modelId: string;\n modelLabel: string;\n runnerProvider?: string;\n /**\n * Human-facing provider name as the runner itself reports it (e.g.\n * \"OpenCode Zen\" for `runnerProvider: 'opencode'`). Populated from the\n * runner's own provider catalog when available; when absent the UI derives a\n * label from `runnerProvider` by title-casing.\n */\n runnerProviderLabel?: string;\n /**\n * The runner whose catalog listed this model. Stamped once, at the single\n * `ModelDiscovery.discover` choke point, so a flat cross-runner list can\n * still say where each entry came from — `runnerProvider` alone cannot:\n * OpenCode reports most of its catalog as `openrouter`, which names the\n * serving backend, not the agent Ordewell would spawn.\n */\n runnerId?: string;\n /** The runner's display name (`OpenCode`), from its manifest. */\n runnerLabel?: string;\n variants: { id: string; label: string }[];\n /**\n * The model's context window when the runner or catalog reports it (#49).\n * Read by the planner-model lookup so context fill can be shown; absent when\n * unknown rather than defaulted to zero.\n */\n contextWindow?: number;\n}\n\nexport type PlanStatus = 'draft' | 'approved' | 'rejected' | 'running' | 'completed';\n\n/**\n * One entry of the planner's persisted dialogue (ADR-0002). The single source\n * of truth for both UI redisplay and conversational context. Tool-call results\n * are NOT stored here — they live in the AI service's tool-use history;\n * `researchLog` remains the persisted tool trace for the UI.\n */\nexport interface ConversationMessage {\n role: 'user' | 'assistant';\n content: string;\n timestamp: string;\n /**\n * Timeline marker: 'plan_generated' records the point in the dialogue where\n * the plan was committed (the UI anchors the plan card there on restore);\n * 'system' is a host-injected notice; 'compaction' is the summary a\n * user-triggered compaction left in place of the earlier messages — always\n * the transcript's first entry. Absent for ordinary chat turns, so\n * sessions saved before markers existed degrade gracefully.\n */\n kind?: 'plan_generated' | 'system' | 'compaction';\n}\n\nexport interface QueuedMessage {\n id: string;\n text: string;\n timestamp: string;\n}\n\nexport interface PlanModificationWarnings {\n deletedCompleted: string[];\n changedCompleted: string[];\n deletedInProgress: string[];\n modifiedInProgress: string[];\n brokenDependencies: string[];\n}\n\nexport function emptyWarnings(): PlanModificationWarnings {\n return { deletedCompleted: [], changedCompleted: [], deletedInProgress: [], modifiedInProgress: [], brokenDependencies: [] };\n}\n\nexport interface LegacyPlanState {\n tasks: Task[];\n generatedAt: string;\n status: PlanStatus;\n runners: RunnerId[];\n lastUpdated: string;\n researchLog?: ResearchLogEntry[];\n /** The planner dialogue — user messages and assistant messages, in order (ADR-0002). */\n conversationHistory?: ConversationMessage[];\n /** Full markdown PRD once written by the planner (PRD mode), also saved to .scratch/<slug>/PRD.md. */\n prdMarkdown?: string;\n /** Follow-ups queued while tasks execute — applied as plan modifications between batches. */\n queuedMessages?: QueuedMessage[];\n /**\n * The plan's isolation run (ADR-0013), written from the orchestrator at\n * persist time and read back only when a saved plan is adopted. It names\n * branches and worktrees that belong to this plan alone: a fork of the plan\n * must leave it behind rather than share it.\n */\n isolation?: PlanIsolation;\n /**\n * The `runnerTransport` setting as the plan's latest run copied it when it\n * started (ADR-0018, S1): the plan, not the live setting, says what runs.\n */\n runnerTransport?: RunnerTransport;\n /** Kept so a reopened session shows the same token line (#49). */\n plannerUsage?: PlannerUsage;\n}\n\nexport interface Message {\n id: string;\n role: 'user' | 'planner' | 'system';\n content: string;\n timestamp: number;\n}\n\nexport interface TaskSnapshot extends Task {\n completedAt: number;\n verdict?: Verdict;\n retryCount: number;\n finalized: boolean;\n}\n\nexport type PlanState =\n | {\n phase: 'planning';\n history: Message[];\n message: string;\n pendingTasks: Task[];\n }\n | {\n phase: 'executing';\n history: Message[];\n message: string;\n executionLog: TaskSnapshot[];\n pendingTasks: Task[];\n goal: string;\n runners: string[];\n status: PlanStatus;\n };\n\nfunction hasPhase(raw: unknown): raw is PlanState {\n return typeof raw === 'object' && raw !== null && 'phase' in raw;\n}\n\nfunction hasTasks(raw: unknown): raw is LegacyPlanState {\n return typeof raw === 'object' && raw !== null && 'tasks' in raw && Array.isArray((raw as Record<string, unknown>).tasks);\n}\n\nfunction logEntryToMessage(entry: ResearchLogEntry): Message {\n const timestamp = new Date(entry.timestamp).getTime();\n if (!('type' in entry)) {\n return { id: entry.id, role: 'system', content: JSON.stringify({ tool: entry.tool, args: entry.args, result: entry.result }), timestamp };\n }\n if (entry.type === 'subagent') {\n const { subagentId, brief, outcome, digest } = entry;\n return { id: entry.id, role: 'system', content: JSON.stringify({ subagentId, brief, outcome, digest }), timestamp };\n }\n return { id: entry.id, role: entry.type === 'user_prompt' ? 'user' : 'system', content: entry.content, timestamp };\n}\n\nfunction migrateHistory(raw: LegacyPlanState): Message[] {\n const messages: Message[] = [];\n\n if (raw.researchLog) {\n messages.push(...raw.researchLog.map(logEntryToMessage));\n }\n\n if (raw.queuedMessages) {\n for (const qm of raw.queuedMessages) {\n messages.push({\n id: qm.id,\n role: 'system',\n content: qm.text,\n timestamp: new Date(qm.timestamp).getTime(),\n });\n }\n }\n\n return messages;\n}\n\nexport function migratePlanState(raw: unknown): PlanState {\n if (hasPhase(raw)) return raw;\n\n if (!hasTasks(raw)) {\n return {\n phase: 'planning',\n history: [],\n message: '',\n pendingTasks: [],\n };\n }\n\n const hasExecution = raw.tasks.some(\n (t) => t.status === 'completed' || t.status === 'failed',\n );\n\n const messages = migrateHistory(raw);\n\n if (hasExecution) {\n const executionLog: TaskSnapshot[] = raw.tasks\n .filter((t) => t.status === 'completed' || t.status === 'failed')\n .map((t) => ({\n ...t,\n completedAt: new Date(raw.lastUpdated).getTime(),\n verdict: t.verdict,\n retryCount: 0,\n finalized: true,\n }));\n\n const pendingTasks = raw.tasks.filter(\n (t) => t.status !== 'completed' && t.status !== 'failed' && t.status !== 'blocked',\n );\n\n return {\n phase: 'executing',\n history: messages,\n message: '',\n executionLog,\n pendingTasks,\n goal: '',\n runners: raw.runners,\n status: raw.status,\n };\n }\n\n return {\n phase: 'planning',\n history: messages,\n message: '',\n pendingTasks: raw.tasks,\n };\n}\n\nexport function migrateLegacyPlan(legacy: LegacyPlanState): PlanState {\n const messages: Message[] = [];\n\n if (legacy.researchLog) {\n messages.push(...legacy.researchLog.map(logEntryToMessage));\n }\n\n if (legacy.queuedMessages) {\n for (const qm of legacy.queuedMessages) {\n messages.push({\n id: qm.id,\n role: 'system',\n content: qm.text,\n timestamp: new Date(qm.timestamp).getTime(),\n });\n }\n }\n\n const isPlanning = legacy.status === 'draft' || legacy.status === 'approved' || legacy.status === 'rejected';\n\n if (isPlanning) {\n return {\n phase: 'planning',\n history: messages,\n message: 'Plan generation',\n pendingTasks: legacy.tasks.filter((t) => t.status === 'pending' || t.status === ('draft' as never)),\n };\n }\n\n const nonCompletedTasks = legacy.tasks.filter(\n (t) => t.status !== 'completed' && t.status !== 'failed' && t.status !== 'blocked'\n );\n\n const completedSnapshot: TaskSnapshot[] = legacy.tasks\n .filter((t) => t.status === 'completed' || t.status === 'failed')\n .map((t) => ({\n ...t,\n completedAt: new Date(legacy.lastUpdated).getTime(),\n verdict: t.verdict,\n retryCount: 0,\n finalized: true,\n }));\n\n return {\n phase: 'executing',\n history: messages,\n message: 'Plan migration',\n executionLog: completedSnapshot,\n pendingTasks: nonCompletedTasks,\n goal: 'Plan migration',\n runners: legacy.runners,\n status: legacy.status,\n };\n}\n\nexport { taskOrderLabel, taskRef, titledTaskRef, resolveOrderLabel } from '../order-labels';\n\nexport function createTask(overrides: Partial<Task> = {}): Task {\n return {\n id: overrides.id ?? uuidv4(),\n order: overrides.order ?? 0,\n title: overrides.title ?? '',\n description: overrides.description ?? '',\n type: overrides.type ?? 'ai',\n status: overrides.status ?? 'pending',\n dependencies: overrides.dependencies ?? [],\n prompt: overrides.prompt,\n userSteps: overrides.userSteps,\n subtasks: overrides.subtasks ?? [],\n verdict: overrides.verdict,\n outputSummary: overrides.outputSummary,\n assignedModel: overrides.assignedModel,\n assignedRunner: overrides.assignedRunner ?? 'claude-code',\n thinkingEffort: overrides.thinkingEffort,\n taskMode: overrides.taskMode ?? 'build',\n completionMarker: overrides.completionMarker ?? uuidv4(),\n autonomy: overrides.autonomy,\n sliceType: overrides.sliceType,\n userStoriesCovered: overrides.userStoriesCovered,\n ...(opsFlag(overrides.ops, overrides.type) ? { ops: true } : {}),\n };\n}\n\n/**\n * The `ops` flag as a task stores it (ADR-0020), however it arrived. Only a\n * literal `true` on an AI task marks an ops task: the planner's JSON is\n * untyped, and a quoted \"true\" read as ops would move a task out of its\n * worktree. Anything else is a change task, stored absent so saved plans need\n * no migration. Whether the task may be ops at all — a subtask may not — is\n * for whoever knows where it sits: parsing drops the flag, an edit refuses it.\n */\nexport function opsFlag(value: unknown, type: Task['type'] = 'ai'): true | undefined {\n return value === true && type === 'ai' ? true : undefined;\n}\n\n/**\n * The flag of a task a merge or a split makes from others: what the edit\n * chose, else ops only when every task it came from was. A merge that takes\n * in a change edits files, so it is a change; a split part runs where its\n * task did.\n */\nexport function inheritedOps(from: readonly Pick<Task, 'ops'>[], chosen?: boolean): boolean {\n return chosen ?? from.every((t) => opsFlag(t.ops) === true);\n}\n\nexport function createEmptyPlan(): LegacyPlanState {\n return {\n tasks: [],\n generatedAt: new Date().toISOString(),\n status: 'draft',\n runners: ['claude-code'],\n lastUpdated: new Date().toISOString(),\n };\n}\n\nexport function flattenTasks(tasks: readonly Task[]): Task[] {\n return tasks.flatMap((t) => [t, ...flattenTasks(t.subtasks ?? [])]);\n}\n\n/** A flattened task with the parent it hangs under, null for a top-level task. */\nexport interface TaskWithParent {\n task: Task;\n parent: Task | null;\n}\n\nexport function flattenTasksWithParents(tasks: readonly Task[]): TaskWithParent[] {\n const rows: TaskWithParent[] = [];\n const walk = (t: Task, parent: Task | null) => {\n rows.push({ task: t, parent });\n for (const sub of t.subtasks ?? []) walk(sub, t);\n };\n for (const t of tasks) walk(t, null);\n return rows;\n}\n\nexport function migrateTask(task: Record<string, unknown>): Task {\n if (!task.assignedModel) {\n task.assignedModel = undefined;\n }\n if (!task.assignedRunner) {\n task.assignedRunner = 'claude-code';\n }\n if (!task.thinkingEffort) {\n task.thinkingEffort = undefined;\n }\n if (!task.completionMarker) {\n task.completionMarker = uuidv4();\n }\n if (task.verdict && task.verification) {\n delete task.verification;\n }\n if (!task.autonomy) {\n task.autonomy = undefined;\n }\n if (!task.sliceType) {\n task.sliceType = undefined;\n }\n if (!task.userStoriesCovered) {\n task.userStoriesCovered = undefined;\n }\n return task as unknown as Task;\n}\n\nexport function addTaskToPlan(tasks: readonly Task[], partial: Partial<Task>): Task[] {\n const maxOrder = tasks.reduce((max, t) => Math.max(max, t.order), 0);\n const newTask = createTask({\n ...partial,\n order: partial.order ?? maxOrder + 1,\n status: 'pending',\n });\n return renumberTasks([...tasks, newTask]);\n}\n\nexport function removeTaskFromPlan(tasks: readonly Task[], taskId: string): Task[] {\n const result = tasks\n .filter((t) => t.id !== taskId)\n .map((t) => ({\n ...t,\n dependencies: t.dependencies.filter((depId) => depId !== taskId),\n subtasks: removeTaskFromPlan(t.subtasks, taskId),\n }));\n return renumberTasks(result);\n}\n\nexport function updateTaskInPlan(tasks: readonly Task[], taskId: string, changes: Partial<Task>): Task[] {\n return renumberTasks(\n tasks.map((t) => {\n if (t.id === taskId) return { ...t, ...changes, id: t.id };\n return { ...t, subtasks: updateTaskInPlan(t.subtasks, taskId, changes) };\n })\n );\n}\n\nexport function renumberTasks(tasks: readonly Task[]): Task[] {\n return tasks.map((t, i) => ({\n ...t,\n order: i + 1,\n subtasks: renumberTasks(t.subtasks),\n }));\n}\n\n/** Done, running, or held for the user: execution state only a runner or the user can change. */\nconst SETTLED_STATUSES: ReadonlySet<TaskStatus> = new Set<TaskStatus>(['completed', 'in_progress', 'awaiting_user']);\n\nfunction holdsSettledWork(task: Task): boolean {\n return SETTLED_STATUSES.has(task.status) || (task.subtasks ?? []).some(holdsSettledWork);\n}\n\n/**\n * Lay a planner-written task list over the plan it rewrites without letting it\n * change execution state. A planner restates tasks; it never witnessed one run,\n * so the status it writes is not evidence. A settled task is kept exactly as\n * it stands wherever the rewrite names it, and put back beside its old\n * neighbour where the rewrite leaves it out. Every other task keeps the status\n * it had; a task the rewrite adds starts pending.\n */\nexport function keepExecutionState(current: readonly Task[], rewrite: Task[]): Task[] {\n const existing = new Map(flattenTasks(current).map((t) => [t.id, t]));\n const named = new Set(flattenTasks(rewrite).map((t) => t.id));\n\n const overlay = (tasks: Task[], was: readonly Task[]): Task[] => {\n const result = tasks.map((t): Task => {\n const prior = existing.get(t.id);\n if (prior && SETTLED_STATUSES.has(prior.status)) return { ...prior };\n return {\n ...t,\n status: prior?.status ?? 'pending',\n verdict: prior?.verdict,\n outputSummary: prior?.outputSummary,\n transport: prior?.transport,\n // Where a task that has run ran is fixed, like its transport (ADR-0020).\n ...(prior?.status === 'failed' ? { ops: prior.ops } : {}),\n forcedPastGate: prior?.forcedPastGate,\n subtasks: overlay(t.subtasks ?? [], prior?.subtasks ?? []),\n };\n });\n was.forEach((left, i) => {\n if (named.has(left.id) || !holdsSettledWork(left)) return;\n const neighbour = was.slice(0, i).reverse().find((t) => result.some((r) => r.id === t.id));\n const at = neighbour ? result.findIndex((r) => r.id === neighbour.id) + 1 : 0;\n result.splice(at, 0, { ...left });\n });\n return result;\n };\n\n return renumberTasks(overlay(rewrite, current));\n}\n\nexport function validateModifiedPlan(original: Task[], modified: Task[]): PlanModificationWarnings {\n const allOriginal = flattenTasks(original);\n const allModified = flattenTasks(modified);\n const warnings = emptyWarnings();\n const originalMap = new Map(allOriginal.map((t) => [t.id, t]));\n const modifiedIds = new Set(allModified.map((t) => t.id));\n\n for (const ot of originalMap.values()) {\n if (ot.status === 'completed' && !modifiedIds.has(ot.id)) {\n warnings.deletedCompleted.push(ot.title);\n } else if (ot.status === 'in_progress' && !modifiedIds.has(ot.id)) {\n warnings.deletedInProgress.push(ot.title);\n }\n }\n\n for (const mt of allModified) {\n const orig = originalMap.get(mt.id);\n if (orig) {\n if (orig.status === 'completed' && mt.status !== 'completed') {\n warnings.changedCompleted.push(orig.title);\n }\n if (orig.status === 'in_progress' && (mt.status !== 'in_progress' || mt.prompt !== orig.prompt)) {\n warnings.modifiedInProgress.push(orig.title);\n }\n if (orig.status === 'failed' && mt.status === 'pending') {\n for (const dt of allModified) {\n if (dt.dependencies.includes(mt.id) && dt.status === 'blocked') {\n dt.status = 'pending';\n }\n }\n }\n }\n }\n\n for (const t of allModified) {\n for (const depId of t.dependencies) {\n if (!modifiedIds.has(depId)) {\n warnings.brokenDependencies.push(`${t.title} → ${depId}`);\n }\n }\n }\n\n return warnings;\n}\n\nexport interface ActiveTaskSession {\n id: string;\n taskId: string;\n}\n\nexport interface ValidationResult {\n valid: boolean;\n errors: string[];\n}\n\nexport interface ValidationContext {\n executionLog: TaskSnapshot[];\n oldPending: Task[];\n newPending: Task[];\n activeSessions: Map<string, ActiveTaskSession>;\n}\n\nexport type ValidationCheck = (ctx: ValidationContext) => ValidationResult;\n\nexport function warningsText(w: PlanModificationWarnings): string | null {\n const lines: string[] = [];\n if (w.deletedCompleted.length) lines.push(`Completed tasks deleted: ${w.deletedCompleted.join(', ')}`);\n if (w.changedCompleted.length) lines.push(`Completed tasks modified: ${w.changedCompleted.join(', ')}`);\n if (w.deletedInProgress.length) lines.push(`In-progress tasks deleted: ${w.deletedInProgress.join(', ')}`);\n if (w.modifiedInProgress.length) lines.push(`In-progress tasks modified: ${w.modifiedInProgress.join(', ')}`);\n if (w.brokenDependencies.length) lines.push(`Broken dependencies: ${w.brokenDependencies.join(', ')}`);\n return lines.length > 0 ? lines.join('\\n') : null;\n}\n","/** The envelope key a full plan reply is keyed by: `{\"tasks\":[...]}`. */\nexport const PLAN_ENVELOPE_KEY = 'tasks';\n/** The envelope key a targeted-edits reply is keyed by: `{\"taskOps\":[...]}`. */\nexport const TASK_OPS_ENVELOPE_KEY = 'taskOps';\n/** The envelope key a read-only detail request is keyed by: `{\"taskQuery\":{...}}`. */\nexport const TASK_QUERY_ENVELOPE_KEY = 'taskQuery';\n\n/** Thrown when an LLM plan response cannot be parsed into a valid plan. Carries the raw text so callers can log it or retry. */\nexport class PlanParseError extends Error {\n readonly raw: string;\n /**\n * True when the reply was cut off mid-object (output-token limit) rather\n * than malformed — the two need different repairs: a truncated emission will\n * be cut at the same point again unless the retry frees context or asks for\n * terser output.\n */\n readonly truncated: boolean;\n /**\n * True when the JSON parsed fine and a *shape* rule rejected it. The generic\n * \"could not be parsed as JSON\" corrective is a lie for these, so the model\n * re-sends the same object; a semantic rejection must be repaired by naming\n * the rule it broke.\n */\n readonly semantic: boolean;\n constructor(message: string, raw: string, opts?: { truncated?: boolean; semantic?: boolean }) {\n super(message);\n this.name = 'PlanParseError';\n this.raw = raw;\n this.truncated = opts?.truncated ?? false;\n this.semantic = opts?.semantic ?? false;\n }\n}\n/**\n * Strip the noise reasoning models wrap around their answer: markdown code\n * fences and `<think>…</think>` chain-of-thought blocks (which routinely contain\n * stray braces that would otherwise derail brace-balancing). Reasoning captured\n * out-of-band by the service never reaches here, but a model that inlines its\n * thinking in the content channel still must not corrupt parsing.\n */\nexport function stripModelNoise(raw: string): string {\n return raw\n .replace(/<think>[\\s\\S]*?<\\/think>/gi, '')\n .replace(/```json\\s*/gi, '')\n .replace(/```\\s*/g, '')\n .trim();\n}\n\nconst THINK_OPEN = '<think>';\nconst THINK_CLOSE = '</think>';\nconst FENCE = '```';\nconst FENCE_JSON_TAG = 'json';\n\n/**\n * Whether a reply that begins with `prefix` opens with a JSON object once the\n * noise {@link stripModelNoise} removes is skipped — the streaming counterpart\n * of it, answering from the start of a reply that has not finished arriving.\n * Undefined while the prefix cannot tell yet: blank, inside an unclosed think\n * block, or partway through a fence or a tag.\n */\nexport function opensWithJsonObject(prefix: string): boolean | undefined {\n let rest = prefix;\n for (;;) {\n rest = rest.trimStart();\n if (!rest) return undefined;\n const head = rest.slice(0, THINK_OPEN.length).toLowerCase();\n if (head === THINK_OPEN) {\n const close = rest.toLowerCase().indexOf(THINK_CLOSE);\n if (close < 0) return undefined;\n rest = rest.slice(close + THINK_CLOSE.length);\n continue;\n }\n if (rest.startsWith(FENCE)) {\n rest = rest.slice(FENCE.length);\n const tag = rest.slice(0, FENCE_JSON_TAG.length).toLowerCase();\n if (tag === FENCE_JSON_TAG) rest = rest.slice(FENCE_JSON_TAG.length);\n else if (tag === rest.toLowerCase() && FENCE_JSON_TAG.startsWith(tag)) return undefined;\n continue;\n }\n if (THINK_OPEN.startsWith(head) || FENCE.startsWith(rest)) return undefined;\n return rest.startsWith('{');\n }\n}\n\n/**\n * Scan from `start` (which must point at a `{`) for the matching balanced close,\n * ignoring braces inside strings. Returns the object substring and whether it was\n * balanced; an unbalanced result means the input was truncated mid-object.\n */\nfunction balancedObjectAt(text: string, start: number): { json: string; balanced: boolean } {\n let depth = 0;\n let inString = false;\n let escaped = false;\n for (let i = start; i < text.length; i++) {\n const ch = text[i];\n if (inString) {\n if (escaped) escaped = false;\n else if (ch === '\\\\') escaped = true;\n else if (ch === '\"') inString = false;\n continue;\n }\n if (ch === '\"') inString = true;\n else if (ch === '{') depth++;\n else if (ch === '}') {\n depth--;\n if (depth === 0) return { json: text.slice(start, i + 1), balanced: true };\n }\n }\n return { json: text.slice(start), balanced: false };\n}\n\n/**\n * Scan an LLM response for every balanced `{…}` object carrying a `\"<key>\":`\n * entry. Strips fences and `<think>` blocks first. A matching object is\n * skipped over wholesale, so its nested braces don't produce fragment\n * candidates; non-matching objects are descended into, so a match wrapped in\n * an unrelated outer object is still found. `fallback` preserves the legacy\n * behavior for callers with no keyed match: the first balanced object, else\n * the stripped text so a JSON.parse error still surfaces.\n */\nexport function extractObjectsWithKey(raw: string, key: string): {\n matches: string[];\n fallback: { json: string; balanced: boolean };\n sawBrace: boolean;\n /** An object ran to EOF unclosed — the classic signature of truncated output. */\n sawUnbalanced: boolean;\n} {\n const stripped = stripModelNoise(raw);\n const keyRe = new RegExp(`\"${key}\"\\\\s*:`);\n\n const matches: string[] = [];\n let firstObject: string | null = null;\n let sawBrace = false;\n let sawUnbalanced = false;\n let inString = false;\n let escaped = false;\n for (let i = 0; i < stripped.length; i++) {\n const ch = stripped[i];\n if (inString) {\n if (escaped) escaped = false;\n else if (ch === '\\\\') escaped = true;\n else if (ch === '\"') inString = false;\n continue;\n }\n if (ch === '\"') { inString = true; continue; }\n if (ch !== '{') continue;\n\n sawBrace = true;\n const obj = balancedObjectAt(stripped, i);\n // A stray brace in a reasoning preamble produces an unbalanced candidate,\n // which we skip so it can't swallow the real object that follows.\n if (obj.balanced && keyRe.test(obj.json)) {\n matches.push(obj.json);\n i += obj.json.length - 1;\n continue;\n }\n if (!obj.balanced) sawUnbalanced = true;\n if (!firstObject && obj.balanced) firstObject = obj.json;\n }\n\n return {\n matches,\n fallback: firstObject !== null ? { json: firstObject, balanced: true } : { json: stripped, balanced: false },\n sawBrace,\n sawUnbalanced,\n };\n}\n\n/**\n * Pull the JSON object out of an LLM response and report whether it was balanced.\n * Strips fences and `<think>` blocks, then walks every top-level `{…}` and\n * returns the FIRST one that contains a `\"tasks\"` key — so a brace appearing\n * earlier in reasoning (or an unrelated preamble object) can't make us parse the\n * wrong thing. Falls back to the first balanced object and, failing that, the\n * first `{` onwards so a genuine `JSON.parse` error still surfaces.\n */\nexport function extractObjectWithBalance(raw: string): { json: string; balanced: boolean; sawBrace: boolean } {\n const { matches, fallback, sawBrace } = extractObjectsWithKey(raw, PLAN_ENVELOPE_KEY);\n if (matches.length > 0) return { json: matches[0], balanced: true, sawBrace };\n return { ...fallback, sawBrace };\n}\n\n/**\n * Pull the JSON object out of an LLM response. Strips markdown code fences and\n * `<think>` blocks, prefers the object containing a `tasks` key, and tolerates a\n * prose preamble and trailing prose. Returns the fence-stripped text unchanged\n * if no `{` is present so the caller's JSON.parse produces a clear failure.\n */\nexport function extractJsonObject(raw: string): string {\n return extractObjectWithBalance(raw).json;\n}\n\n/** Drop trailing commas before a closing `}` or `]` — a common model quirk. */\nexport function stripTrailingCommas(json: string): string {\n return json.replace(/,(\\s*[}\\]])/g, '$1');\n}\n\n/**\n * Escape raw control characters that appear INSIDE string literals — budget\n * models routinely emit multi-line `prompt` strings with literal newlines,\n * which strict JSON.parse rejects (\"bad control character\"). Characters\n * outside strings (formatting whitespace) are left untouched.\n */\nexport function escapeControlCharsInStrings(json: string): string {\n let out = '';\n let inString = false;\n let escaped = false;\n for (const ch of json) {\n if (inString) {\n if (escaped) { out += ch; escaped = false; continue; }\n if (ch === '\\\\') { out += ch; escaped = true; continue; }\n if (ch === '\"') { out += ch; inString = false; continue; }\n if (ch === '\\n') { out += '\\\\n'; continue; }\n if (ch === '\\r') { out += '\\\\r'; continue; }\n if (ch === '\\t') { out += '\\\\t'; continue; }\n out += ch;\n continue;\n }\n if (ch === '\"') inString = true;\n out += ch;\n }\n return out;\n}\n"],"mappings":";AAAA,SAAS,MAAM,cAAc;AA8CtB,SAAS,iBAAiB,OAAyC;AACxE,SAAO,UAAU,WAAW,UAAU,gBAAgB,UAAU,cAAc,UAAU;AAC1F;AA8QO,SAAS,gBAA0C;AACxD,SAAO,EAAE,kBAAkB,CAAC,GAAG,kBAAkB,CAAC,GAAG,mBAAmB,CAAC,GAAG,oBAAoB,CAAC,GAAG,oBAAoB,CAAC,EAAE;AAC7H;AA+DA,SAAS,SAAS,KAAgC;AAChD,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,WAAW;AAC/D;AAEA,SAAS,SAAS,KAAsC;AACtD,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,WAAW,OAAO,MAAM,QAAS,IAAgC,KAAK;AAC1H;AAEA,SAAS,kBAAkB,OAAkC;AAC3D,QAAM,YAAY,IAAI,KAAK,MAAM,SAAS,EAAE,QAAQ;AACpD,MAAI,EAAE,UAAU,QAAQ;AACtB,WAAO,EAAE,IAAI,MAAM,IAAI,MAAM,UAAU,SAAS,KAAK,UAAU,EAAE,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,QAAQ,MAAM,OAAO,CAAC,GAAG,UAAU;AAAA,EAC1I;AACA,MAAI,MAAM,SAAS,YAAY;AAC7B,UAAM,EAAE,YAAY,OAAO,SAAS,OAAO,IAAI;AAC/C,WAAO,EAAE,IAAI,MAAM,IAAI,MAAM,UAAU,SAAS,KAAK,UAAU,EAAE,YAAY,OAAO,SAAS,OAAO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AsB;AACxD,SAAO,KAAK,QAAQ,gBAAgB,IAAI;AAC1C;AAQO,SAAS,4BAA4B,MAAsB;AAChE,MAAI,MAAM;AACV,MAAI,WAAW;AACf,MAAI,UAAU;AACd,aAAW,MAAM,MAAM;AACrB,QAAI,UAAU;AACZ,UAAI,SAAS;AAAE,eAAO;AAAI,kBAAU;AAAO;AAAA,MAAU;AACrD,UAAI,OAAO,MAAM;AAAE,eAAO;AAAI,kBAAU;AAAM;AAAA,MAAU;AACxD,UAAI,OAAO,KAAK;AAAE,eAAO;AAAI,mBAAW;AAAO;AAAA,MAAU;AACzD,UAAI,OAAO,MAAM;AAAE,eAAO;AAAO;AAAA,MAAU;AAC3C,UAAI,OAAO,MAAM;AAAE,eAAO;AAAO;AAAA,MAAU;AAC3C,UAAI,OAAO,KAAM;AAAE,eAAO;AAAO;AAAA,MAAU;AAC3C,aAAO;AACP;AAAA,IACF;AACA,QAAI,OAAO,IAAK,YAAW;AAC3B,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":[]}
|
|
@@ -7,6 +7,14 @@ function integrationBranchFor(runId) {
|
|
|
7
7
|
function repoRootOf(workspaceRoot, repoPath) {
|
|
8
8
|
return path.join(workspaceRoot, repoPath);
|
|
9
9
|
}
|
|
10
|
+
function noRemoval() {
|
|
11
|
+
return { preserved: [], refused: [] };
|
|
12
|
+
}
|
|
13
|
+
function absorbRemoval(into, from) {
|
|
14
|
+
into.preserved.push(...from.preserved);
|
|
15
|
+
into.refused.push(...from.refused);
|
|
16
|
+
return into;
|
|
17
|
+
}
|
|
10
18
|
function layoutOf(run) {
|
|
11
19
|
return { repos: run.repos.map((r) => r.path), shared: [...run.shared] };
|
|
12
20
|
}
|
|
@@ -92,6 +100,8 @@ export {
|
|
|
92
100
|
SELF_REPO,
|
|
93
101
|
integrationBranchFor,
|
|
94
102
|
repoRootOf,
|
|
103
|
+
noRemoval,
|
|
104
|
+
absorbRemoval,
|
|
95
105
|
layoutOf,
|
|
96
106
|
integrationBranchNameOf,
|
|
97
107
|
changedReposOf,
|
|
@@ -100,4 +110,4 @@ export {
|
|
|
100
110
|
migratePlanIsolation,
|
|
101
111
|
migratePlanStateIsolation
|
|
102
112
|
};
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
113
|
+
//# sourceMappingURL=chunk-OYUSADFM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/isolationRecord.ts"],"sourcesContent":["import * as path from 'path';\nimport type {\n IsolationHandoff,\n IsolationLandedTask,\n IsolationRemoval,\n IsolationRepo,\n IsolationRun,\n IsolationTaskRecord,\n IsolationTaskStatus,\n PlanIsolation,\n RepoGroupLayout,\n TaskIsolation,\n} from '../interfaces/IWorktreeIsolation';\n\n/** The path of the repo in a workspace that is itself the repository. */\nexport const SELF_REPO = '.';\n\nexport function integrationBranchFor(runId: string): string {\n return `ordewell/${runId}/integration`;\n}\n\nexport function repoRootOf(workspaceRoot: string, repoPath: string): string {\n return path.join(workspaceRoot, repoPath);\n}\n\n/** A removal that kept nothing back. */\nexport function noRemoval(): IsolationRemoval {\n return { preserved: [], refused: [] };\n}\n\n/** Add what `from` kept back to `into`. */\nexport function absorbRemoval(into: IsolationRemoval, from: IsolationRemoval): IsolationRemoval {\n into.preserved.push(...from.preserved);\n into.refused.push(...from.refused);\n return into;\n}\n\n/** The group a run isolates, as the planner is told it. */\nexport function layoutOf(run: IsolationRun): RepoGroupLayout {\n return { repos: run.repos.map((r) => r.path), shared: [...run.shared] };\n}\n\n/** The run's integration branch for a one-line notice: every repo's has the same name. */\nexport function integrationBranchNameOf(run: IsolationRun): string {\n return [...new Set(run.repos.map((r) => r.integrationBranch))].join(', ');\n}\n\nconst ISOLATION_STATE: Record<IsolationTaskStatus, Exclude<TaskIsolation['state'], 'none'>> = {\n active: 'active',\n merged: 'integrated',\n conflict: 'conflict',\n repairing: 'repairing',\n kept: 'kept',\n failed: 'kept',\n};\n\n/** Paths of the repos a task brought commits to. */\nexport function changedReposOf(record: IsolationTaskRecord): string[] {\n return Object.entries(record.repos).filter(([, r]) => r.changed).map(([repoPath]) => repoPath);\n}\n\n/** `repairLimit` is `conflictRepairAttempts` as it stands now, which is what the next repair will be held to. */\nexport function taskIsolationOf(record: IsolationTaskRecord, repairLimit: number): TaskIsolation {\n return {\n state: ISOLATION_STATE[record.status],\n branch: record.branch,\n worktree: record.workspace,\n repos: changedReposOf(record),\n ...(record.conflictRepo ? { conflictRepo: record.conflictRepo } : {}),\n ...(record.conflictFiles?.length ? { conflictFiles: record.conflictFiles } : {}),\n ...(record.repairs ? { repair: { attempt: record.repairs, limit: repairLimit } } : {}),\n ...(record.repairedFiles?.length ? { repairedFiles: record.repairedFiles } : {}),\n };\n}\n\n/**\n * What a run hands over: each repo's integration branch and base, and what\n * landed, in plan order. Work the user has merged already, at a merge gate\n * (ADR-0020), is not handed over again.\n */\nexport function handoffOf(run: IsolationRun): IsolationHandoff {\n const merged = Object.values(run.tasks)\n .filter((r) => r.status === 'merged' && !r.inHead)\n .sort((a, b) => a.order - b.order);\n const entry = (r: IsolationTaskRecord): IsolationLandedTask => ({\n taskId: r.taskId, order: r.order, title: r.title,\n ...(r.repairedFiles?.length ? { repairedFiles: r.repairedFiles } : {}),\n });\n return {\n repos: run.repos.map((repo) => ({\n path: repo.path,\n integrationBranch: repo.integrationBranch,\n baseRef: repo.baseRef,\n landed: merged.filter((r) => r.repos[repo.path]?.changed).map(entry),\n })),\n landed: merged.map(entry),\n };\n}\n\n/** A task record as ADR-0013 persisted it, for one repository. */\nexport interface Adr0013TaskRecord {\n taskId: string;\n order: number;\n title: string;\n branch: string;\n worktree: string;\n status: IsolationTaskStatus;\n linked: string[];\n}\n\n/** A run as ADR-0013 persisted it (0.4.23): one repository, its refs on the run itself. */\nexport interface Adr0013IsolationRun {\n id: string;\n workspaceRoot: string;\n baseRef: string;\n baseBranch?: string;\n integrationBranch: string;\n tasks: Record<string, Adr0013TaskRecord>;\n}\n\nexport interface Adr0013PlanIsolation {\n run: Adr0013IsolationRun;\n resolvers: Record<string, string>;\n}\n\nfunction isAdr0013(run: IsolationRun | Adr0013IsolationRun): run is Adr0013IsolationRun {\n return 'integrationBranch' in run && typeof run.integrationBranch === 'string';\n}\n\nfunction fromAdr0013Task(r: Adr0013TaskRecord): IsolationTaskRecord {\n return {\n taskId: r.taskId,\n order: r.order,\n title: r.title,\n branch: r.branch,\n workspace: r.worktree,\n status: r.status,\n // A merged task's branch was merged into the one repo there was; what it\n // changed was never recorded, and landing is what `changed` stands for.\n repos: { [SELF_REPO]: { worktree: r.worktree, linked: r.linked ?? [], ...(r.status === 'merged' ? { changed: true } : {}) } },\n ...(r.status === 'conflict' ? { conflictRepo: SELF_REPO } : {}),\n };\n}\n\n/**\n * A persisted plan isolation in today's shape. A run saved in the ADR-0013\n * format — recognised by its own `integrationBranch` — becomes a group of one\n * at `.`, keeping its branches, so a session saved by 0.4.23 resumes and hands\n * off exactly as it would have.\n */\nexport function migratePlanIsolation(state: PlanIsolation | Adr0013PlanIsolation): PlanIsolation {\n const { run, resolvers } = state;\n if (!isAdr0013(run)) return { run, resolvers: resolvers ?? {} };\n const repo: IsolationRepo = {\n path: SELF_REPO,\n root: repoRootOf(run.workspaceRoot, SELF_REPO),\n baseRef: run.baseRef,\n ...(run.baseBranch ? { baseBranch: run.baseBranch } : {}),\n integrationBranch: run.integrationBranch,\n };\n const tasks = Object.fromEntries(Object.entries(run.tasks ?? {}).map(([id, r]) => [id, fromAdr0013Task(r)]));\n return { run: { id: run.id, workspaceRoot: run.workspaceRoot, repos: [repo], shared: [], sharedRepos: [], tasks }, resolvers: resolvers ?? {} };\n}\n\n/** Bring a loaded plan's isolation record, if any, to today's shape in place. */\nexport function migratePlanStateIsolation(plan: { isolation?: PlanIsolation | Adr0013PlanIsolation }): void {\n if (plan.isolation?.run) plan.isolation = migratePlanIsolation(plan.isolation);\n}\n"],"mappings":";AAAA,YAAY,UAAU;AAef,IAAM,YAAY;AAElB,SAAS,qBAAqB,OAAuB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AW,WAAW,EAAE,SAAS,KAAK,IAAI,CAAC,EAAG,EAAE;AAAA,IAC5H,GAAI,EAAE,WAAW,aAAa,EAAE,cAAc,UAAU,IAAI,CAAC;AAAA,EAC/D;AACF;AAQO,SAAS,qBAAqB,OAA4D;AAC/F,QAAM,EAAE,KAAK,UAAU,IAAI;AAC3B,MAAI,CAAC,UAAU,GAAG,EAAG,QAAO,EAAE,KAAK,WAAW,aAAa,CAAC,EAAE;AAC9D,QAAM,OAAsB;AAAA,IAC1B,MAAM;AAAA,IACN,MAAM,WAAW,IAAI,eAAe,SAAS;AAAA,IAC7C,SAAS,IAAI;AAAA,IACb,GAAI,IAAI,aAAa,EAAE,YAAY,IAAI,WAAW,IAAI,CAAC;AAAA,IACvD,mBAAmB,IAAI;AAAA,EACzB;AACA,QAAM,QAAQ,OAAO,YAAY,OAAO,QAAQ,IAAI,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAC3G,SAAO,EAAE,KAAK,EAAE,IAAI,IAAI,IAAI,eAAe,IAAI,eAAe,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,aAAa,CAAC,GAAG,MAAM,GAAG,WAAW,aAAa,CAAC,EAAE;AAChJ;AAGO,SAAS,0BAA0B,MAAkE;AAC1G,MAAI,KAAK,WAAW,IAAK,MAAK,YAAY,qBAAqB,KAAK,SAAS;AAC/E;","names":[]}
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
function taskOrderLabel(task, parent) {
|
|
3
3
|
return parent ? `${parent.order}.${task.order}` : String(task.order);
|
|
4
4
|
}
|
|
5
|
+
function taskRef(task, parent) {
|
|
6
|
+
return `#${taskOrderLabel(task, parent)}`;
|
|
7
|
+
}
|
|
8
|
+
function titledTaskRef(task, parent) {
|
|
9
|
+
return `${taskRef(task, parent)} ${task.title}`;
|
|
10
|
+
}
|
|
5
11
|
function resolveOrderLabel(tasks, label) {
|
|
6
12
|
const parts = label.split(".");
|
|
7
13
|
if (parts.length > 2 || parts.some((p) => !/^\d+$/.test(p))) return void 0;
|
|
@@ -14,6 +20,8 @@ function resolveOrderLabel(tasks, label) {
|
|
|
14
20
|
|
|
15
21
|
export {
|
|
16
22
|
taskOrderLabel,
|
|
23
|
+
taskRef,
|
|
24
|
+
titledTaskRef,
|
|
17
25
|
resolveOrderLabel
|
|
18
26
|
};
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
27
|
+
//# sourceMappingURL=chunk-V3JHS7AX.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/order-labels.ts"],"sourcesContent":["import type { Task } from './models/Task';\n\n/**\n * Parent-scoped dotted order label for a task, e.g. \"2.1\" for the first subtask\n * of task 2. Kept in its own module (no Node imports) so a browser-bundled\n * surface — the VS Code webview — can import it via `@ordewell/core/order-labels`\n * without dragging the rest of core in.\n */\nexport function taskOrderLabel(task: { order: number }, parent?: { order: number }): string {\n return parent ? `${parent.order}.${task.order}` : String(task.order);\n}\n\n/** How a surface refers to a task in prose: \"#2\", or \"#2.1\" for a subtask. */\nexport function taskRef(task: { order: number }, parent?: { order: number }): string {\n return `#${taskOrderLabel(task, parent)}`;\n}\n\n/** A task named in full, as a confirmation or a picker title does: \"#2 Deploy\". */\nexport function titledTaskRef(task: { order: number; title: string }, parent?: { order: number }): string {\n return `${taskRef(task, parent)} ${task.title}`;\n}\n\n/** Resolve a dotted label to a task in a plan's top-level task list. */\nexport function resolveOrderLabel(tasks: Task[], label: string): Task | undefined {\n const parts = label.split('.');\n if (parts.length > 2 || parts.some((p) => !/^\\d+$/.test(p))) return undefined;\n const [topOrder, childOrder] = parts.map(Number);\n const top = tasks.find((t) => t.order === topOrder);\n if (!top) return undefined;\n if (childOrder === undefined) return top;\n return top.subtasks.find((s) => s.order === childOrder);\n}"],"mappings":";AAQO,SAAS,eAAe,MAAyB,QAAoC;AAC1F,SAAO,SAAS,GAAG,OAAO,KAAK,IAAI,KAAK,KAAK,KAAK,OAAO,KAAK,KAAK;AACrE;AAGO,SAAS,QAAQ,MAAyB,QAAoC;AACnF,SAAO,IAAI,eAAe,MAAM,MAAM,CAAC;AACzC;AAGO,SAAS,cAAc,MAAwC,QAAoC;AACxG,SAAO,GAAG,QAAQ,MAAM,MAAM,CAAC,IAAI,KAAK,KAAK;AAC/C;AAGO,SAAS,kBAAkB,OAAe,OAAiC;AAChF,QAAM,QAAQ,MAAM,MAAM,GAAG;AAC7B,MAAI,MAAM,SAAS,KAAK,MAAM,KAAK,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,EAAG,QAAO;AACpE,QAAM,CAAC,UAAU,UAAU,IAAI,MAAM,IAAI,MAAM;AAC/C,QAAM,MAAM,MAAM,KAAK,CAAC,MAAM,EAAE,UAAU,QAAQ;AAClD,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI,eAAe,OAAW,QAAO;AACrC,SAAO,IAAI,SAAS,KAAK,CAAC,MAAM,EAAE,UAAU,UAAU;AACxD;","names":[]}
|
|
@@ -6,11 +6,18 @@ import {
|
|
|
6
6
|
escapeControlCharsInStrings,
|
|
7
7
|
extractObjectsWithKey,
|
|
8
8
|
flattenTasks,
|
|
9
|
+
inheritedOps,
|
|
10
|
+
opsFlag,
|
|
9
11
|
removeTaskFromPlan,
|
|
10
12
|
renumberTasks,
|
|
11
13
|
stripTrailingCommas,
|
|
12
14
|
updateTaskInPlan
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-LGQNXPBX.mjs";
|
|
16
|
+
import {
|
|
17
|
+
taskOrderLabel,
|
|
18
|
+
taskRef,
|
|
19
|
+
titledTaskRef
|
|
20
|
+
} from "./chunk-V3JHS7AX.mjs";
|
|
14
21
|
|
|
15
22
|
// src/models/Usage.ts
|
|
16
23
|
function partedPromptUsage(parts) {
|
|
@@ -731,9 +738,25 @@ function endTurn(view, { reason }) {
|
|
|
731
738
|
const closed = closeOpenBlocks({ ...view, working: false, lastTurnEnd: reason, streams: {} }, CUT[reason]);
|
|
732
739
|
return reason === "interrupted" ? append(closed, (id) => settledMessage(id, "system", "Interrupted.")) : closed;
|
|
733
740
|
}
|
|
734
|
-
function queueMessage(view, { messageId, text: text2 }) {
|
|
735
|
-
|
|
736
|
-
|
|
741
|
+
function queueMessage(view, { messageId, text: text2, forced }) {
|
|
742
|
+
const listed = view.queued.find((m) => m.id === messageId);
|
|
743
|
+
if (forced) {
|
|
744
|
+
const rest = view.queued.filter((m) => m !== listed);
|
|
745
|
+
const at = rest.findIndex((m) => !m.forced);
|
|
746
|
+
const placed = at < 0 ? rest.length : at;
|
|
747
|
+
return { ...view, queued: [...rest.slice(0, placed), { id: messageId, text: text2, forced: true }, ...rest.slice(placed)] };
|
|
748
|
+
}
|
|
749
|
+
if (!listed) return { ...view, queued: [...view.queued, { id: messageId, text: text2 }] };
|
|
750
|
+
if (!listed.handedOver) return view;
|
|
751
|
+
return { ...view, queued: view.queued.map((m) => m === listed ? { id: m.id, text: m.text } : m) };
|
|
752
|
+
}
|
|
753
|
+
function handOver(view, { messageId }) {
|
|
754
|
+
const listed = view.queued.find((m) => m.id === messageId);
|
|
755
|
+
if (!listed || listed.handedOver) return view;
|
|
756
|
+
return { ...view, queued: view.queued.map((m) => m === listed ? { ...m, handedOver: true } : m) };
|
|
757
|
+
}
|
|
758
|
+
function deliverMidTurn(view, event) {
|
|
759
|
+
return appendOutput(unqueueMessage(view, event), null, (id) => settledMessage(id, "user", event.text));
|
|
737
760
|
}
|
|
738
761
|
function unqueueMessage(view, { messageId }) {
|
|
739
762
|
const queued = view.queued.filter((m) => m.id !== messageId);
|
|
@@ -767,6 +790,12 @@ function reduceTaskLog(view, event) {
|
|
|
767
790
|
return queueMessage(view, event);
|
|
768
791
|
case "message_removed":
|
|
769
792
|
return unqueueMessage(view, event);
|
|
793
|
+
case "message_handed_over":
|
|
794
|
+
return handOver(view, event);
|
|
795
|
+
case "message_delivered":
|
|
796
|
+
return deliverMidTurn(view, event);
|
|
797
|
+
case "message_undelivered":
|
|
798
|
+
return append(unqueueMessage(view, event), (id) => settledMessage(id, "system", `${event.text} \xB7 not delivered`));
|
|
770
799
|
case "error":
|
|
771
800
|
return appendOutput(view, null, (id) => settledMessage(id, "error", event.message));
|
|
772
801
|
case "approval_requested":
|
|
@@ -893,6 +922,37 @@ function coerceAssignments(tasks, perRunnerAllowlist, allowedRunners, modelsByRu
|
|
|
893
922
|
});
|
|
894
923
|
}
|
|
895
924
|
|
|
925
|
+
// src/taskRow/status.ts
|
|
926
|
+
var isTaskRunning = (task) => task.status === "in_progress" || task.status === "running";
|
|
927
|
+
var NOT_STARTED = /* @__PURE__ */ new Set(["pending", "approved", "blocked"]);
|
|
928
|
+
function taskStatusKind(task) {
|
|
929
|
+
switch (task.status) {
|
|
930
|
+
case "completed":
|
|
931
|
+
return "done";
|
|
932
|
+
case "failed":
|
|
933
|
+
return "failed";
|
|
934
|
+
case "blocked":
|
|
935
|
+
return "blocked";
|
|
936
|
+
case "awaiting_user":
|
|
937
|
+
return "awaiting";
|
|
938
|
+
}
|
|
939
|
+
if (!isTaskRunning(task)) return "todo";
|
|
940
|
+
return task.status === "in_progress" && task.idleSince ? "quiet" : "running";
|
|
941
|
+
}
|
|
942
|
+
var AWAITING_LABELS = {
|
|
943
|
+
input: "Waiting for your input",
|
|
944
|
+
checkpoint: "Checkpoint",
|
|
945
|
+
conflict: "Merge conflict",
|
|
946
|
+
"files-changed": "Changed tracked files"
|
|
947
|
+
};
|
|
948
|
+
function awaitingLabel(task) {
|
|
949
|
+
return task.status === "awaiting_user" && task.awaitingReason ? AWAITING_LABELS[task.awaitingReason] : null;
|
|
950
|
+
}
|
|
951
|
+
function approvalLabel(count) {
|
|
952
|
+
if (!count) return null;
|
|
953
|
+
return count > 1 ? `Waiting for approval (${count})` : "Waiting for approval";
|
|
954
|
+
}
|
|
955
|
+
|
|
896
956
|
// src/services/TaskOps.ts
|
|
897
957
|
import { v4 as uuidv4 } from "uuid";
|
|
898
958
|
|
|
@@ -934,7 +994,6 @@ function typeCoherenceCheck(target, changes) {
|
|
|
934
994
|
}
|
|
935
995
|
return { ok: true, clear: target.userSteps && target.userSteps.length > 0 ? ["userSteps"] : [] };
|
|
936
996
|
}
|
|
937
|
-
var NOT_STARTED = /* @__PURE__ */ new Set(["pending", "approved", "blocked"]);
|
|
938
997
|
function opsCheck(tasks, target, changes) {
|
|
939
998
|
if (!("ops" in changes) || !!changes.ops === !!target.ops) return null;
|
|
940
999
|
if (!NOT_STARTED.has(target.status)) {
|
|
@@ -1099,7 +1158,7 @@ function updatableChanges(raw) {
|
|
|
1099
1158
|
for (const key of UPDATABLE_FIELDS) {
|
|
1100
1159
|
if (raw && key in raw) changes[key] = raw[key];
|
|
1101
1160
|
}
|
|
1102
|
-
if ("ops" in changes) changes.ops = changes.ops
|
|
1161
|
+
if ("ops" in changes) changes.ops = opsFlag(changes.ops);
|
|
1103
1162
|
return changes;
|
|
1104
1163
|
}
|
|
1105
1164
|
function findInTasks(tasks, id) {
|
|
@@ -1435,7 +1494,7 @@ function applyTaskOps(currentTasks, ops, runners, catalog) {
|
|
|
1435
1494
|
taskMode: spec.taskMode ?? toMerge[0].taskMode,
|
|
1436
1495
|
autonomy: spec.autonomy ?? toMerge.find((t) => t.autonomy)?.autonomy,
|
|
1437
1496
|
sliceType: spec.sliceType ?? toMerge.find((t) => t.sliceType)?.sliceType,
|
|
1438
|
-
ops:
|
|
1497
|
+
ops: inheritedOps(toMerge, spec.ops),
|
|
1439
1498
|
userStoriesCovered: spec.userStoriesCovered ?? (toMerge.flatMap((t) => t.userStoriesCovered ?? []).length ? [...new Set(toMerge.flatMap((t) => t.userStoriesCovered ?? []))] : void 0)
|
|
1440
1499
|
});
|
|
1441
1500
|
const mergedId = mergedTask.id;
|
|
@@ -1516,7 +1575,7 @@ function applyTaskOps(currentTasks, ops, runners, catalog) {
|
|
|
1516
1575
|
taskMode: spec.taskMode ?? target.taskMode,
|
|
1517
1576
|
autonomy: spec.autonomy ?? target.autonomy,
|
|
1518
1577
|
sliceType: spec.sliceType ?? target.sliceType,
|
|
1519
|
-
ops: spec.ops
|
|
1578
|
+
ops: inheritedOps([target], spec.ops),
|
|
1520
1579
|
userStoriesCovered: spec.userStoriesCovered ?? target.userStoriesCovered
|
|
1521
1580
|
});
|
|
1522
1581
|
newTasks.push(nt);
|
|
@@ -1720,7 +1779,7 @@ function serializeTask(t) {
|
|
|
1720
1779
|
...t.ops ? { ops: true } : {}
|
|
1721
1780
|
};
|
|
1722
1781
|
}
|
|
1723
|
-
function serializeTaskStatus(t, idleSince = null, isolation = null, queued = [], awaitingApproval = 0, mergeGate = []) {
|
|
1782
|
+
function serializeTaskStatus(t, idleSince = null, isolation = null, queued = [], awaitingApproval = 0, mergeGate = [], checkpoint = "") {
|
|
1724
1783
|
return {
|
|
1725
1784
|
id: t.id,
|
|
1726
1785
|
status: t.status,
|
|
@@ -1729,6 +1788,7 @@ function serializeTaskStatus(t, idleSince = null, isolation = null, queued = [],
|
|
|
1729
1788
|
...isolation ? { isolation } : {},
|
|
1730
1789
|
...t.transport ? { transport: t.transport.fallback ? { kind: t.transport.kind, fallback: t.transport.fallback } : { kind: t.transport.kind } } : {},
|
|
1731
1790
|
...t.status === "awaiting_user" && t.awaitingReason ? { awaitingReason: t.awaitingReason } : {},
|
|
1791
|
+
...t.status === "awaiting_user" && t.awaitingReason === "checkpoint" && checkpoint ? { checkpoint } : {},
|
|
1732
1792
|
...queued.length > 0 ? { queued: queued.map((m) => ({ ...m })) } : {},
|
|
1733
1793
|
...canContinue(t) ? { continuable: true } : {},
|
|
1734
1794
|
...awaitingApproval > 0 ? { awaitingApproval } : {},
|
|
@@ -2123,6 +2183,103 @@ function taskStartedNotice(title, runner) {
|
|
|
2123
2183
|
return runner ? `Started "${title}" \xB7 ${runner}` : `Started "${title}"`;
|
|
2124
2184
|
}
|
|
2125
2185
|
|
|
2186
|
+
// src/taskRow/actions.ts
|
|
2187
|
+
var UNSTARTED_AI = (t) => t.type === "ai" && NOT_STARTED.has(t.status);
|
|
2188
|
+
var QUEUED = (t) => t.status === "pending" || t.status === "approved";
|
|
2189
|
+
var TASK_RULES = [
|
|
2190
|
+
["cancel", (t) => t.status === "in_progress"],
|
|
2191
|
+
["skip", (t) => t.status === "blocked"],
|
|
2192
|
+
["force-start", UNSTARTED_AI],
|
|
2193
|
+
// A manual task has no runner to report it done, so it can always be marked.
|
|
2194
|
+
["complete", (t) => t.status === "awaiting_user" || t.type === "user"],
|
|
2195
|
+
["uncomplete", (t) => t.status === "completed"]
|
|
2196
|
+
];
|
|
2197
|
+
var SUBTASK_RULES = [
|
|
2198
|
+
["cancel", (t) => t.status === "in_progress"],
|
|
2199
|
+
["complete", (t) => t.status === "in_progress" && t.type === "ai"],
|
|
2200
|
+
["force-start", (t) => t.type === "ai" && QUEUED(t)],
|
|
2201
|
+
["skip", QUEUED],
|
|
2202
|
+
["complete", (t) => t.status === "awaiting_user"],
|
|
2203
|
+
["uncomplete", (t) => t.status === "completed"]
|
|
2204
|
+
];
|
|
2205
|
+
function taskRowActions(task, placement = "task") {
|
|
2206
|
+
const rules = placement === "subtask" ? SUBTASK_RULES : TASK_RULES;
|
|
2207
|
+
return rules.filter(([, applies]) => applies(task)).map(([action]) => action);
|
|
2208
|
+
}
|
|
2209
|
+
function markAction(task) {
|
|
2210
|
+
return task.status === "completed" ? "uncomplete" : "complete";
|
|
2211
|
+
}
|
|
2212
|
+
function markRequestFor(action) {
|
|
2213
|
+
if (action === "complete" || action === "skip") return "complete";
|
|
2214
|
+
if (action === "uncomplete") return "uncomplete";
|
|
2215
|
+
return null;
|
|
2216
|
+
}
|
|
2217
|
+
function opsEditable(task) {
|
|
2218
|
+
return UNSTARTED_AI(task);
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
// src/taskRow/view.ts
|
|
2222
|
+
var refsOf = (ids, orderOf) => ids.map((id) => {
|
|
2223
|
+
const order = orderOf?.get(id);
|
|
2224
|
+
return order === void 0 ? id : taskRef({ order });
|
|
2225
|
+
});
|
|
2226
|
+
var namedRepo = (repo) => repo && repo !== "." ? repo : null;
|
|
2227
|
+
var namedRepos = (repos) => (repos ?? []).filter((r) => r !== ".");
|
|
2228
|
+
var filesOf = (files) => files?.length ? capConflictFiles(files) : null;
|
|
2229
|
+
function taskRowView(task, context = {}) {
|
|
2230
|
+
const parent = context.parent ?? void 0;
|
|
2231
|
+
const isolation = task.isolation && task.isolation.state !== "none" ? task.isolation : null;
|
|
2232
|
+
return {
|
|
2233
|
+
orderLabel: taskOrderLabel(task, parent),
|
|
2234
|
+
kind: task.type === "user" ? "user" : task.ops ? "ops" : "ai",
|
|
2235
|
+
status: taskStatusKind(task),
|
|
2236
|
+
running: isTaskRunning(task),
|
|
2237
|
+
awaiting: awaitingLabel(task),
|
|
2238
|
+
approvals: approvalLabel(task.awaitingApproval),
|
|
2239
|
+
autonomous: task.type === "ai" && context.modes?.find((m) => m.id === task.taskMode)?.autonomous === true,
|
|
2240
|
+
repos: namedRepos(isolation?.repos),
|
|
2241
|
+
conflict: isolation?.state === "conflict" ? { repo: namedRepo(isolation.conflictRepo), files: filesOf(isolation.conflictFiles) } : null,
|
|
2242
|
+
repairing: isolation?.state === "repairing" ? { files: filesOf(isolation.conflictFiles), attempt: isolation.repair ?? null } : null,
|
|
2243
|
+
repaired: isolation?.repairedFiles?.length ? { files: capConflictFiles(isolation.repairedFiles), landed: isolation.state === "integrated" } : null,
|
|
2244
|
+
mergeGate: task.mergeGate?.length ? refsOf(task.mergeGate, context.orderOf) : null,
|
|
2245
|
+
opsChangedFiles: task.status === "awaiting_user" && task.awaitingReason === "files-changed",
|
|
2246
|
+
forcedPastGate: task.forcedPastGate?.length ? task.forcedPastGate : null,
|
|
2247
|
+
dependencies: refsOf(task.dependencies, context.orderOf),
|
|
2248
|
+
actions: taskRowActions(task, context.placement ?? (parent ? "subtask" : "task")),
|
|
2249
|
+
mark: markAction(task),
|
|
2250
|
+
opsEditable: opsEditable(task)
|
|
2251
|
+
};
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
// src/taskRow/texts.ts
|
|
2255
|
+
function findNamed(tasks, id) {
|
|
2256
|
+
for (const task of tasks) {
|
|
2257
|
+
if (task.id === id) return task;
|
|
2258
|
+
const nested = findNamed(task.subtasks ?? [], id);
|
|
2259
|
+
if (nested) return nested;
|
|
2260
|
+
}
|
|
2261
|
+
return void 0;
|
|
2262
|
+
}
|
|
2263
|
+
function titledRefs(ids, tasks) {
|
|
2264
|
+
return ids.map((id) => {
|
|
2265
|
+
const task = findNamed(tasks, id);
|
|
2266
|
+
return task ? titledTaskRef(task) : id;
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
function dependentsNotice(dependents) {
|
|
2270
|
+
if (dependents.length === 0) return null;
|
|
2271
|
+
const subject = dependents.length === 1 ? "1 task depends" : `${dependents.length} tasks depend`;
|
|
2272
|
+
return `${subject} on it and will lose that dependency: ${dependents.map((t) => titledTaskRef(t)).join(", ")}.`;
|
|
2273
|
+
}
|
|
2274
|
+
function pastGateConfirmation(unmerged, subject = "This task") {
|
|
2275
|
+
return `${subject} waits for Merge all: the work of ${unmerged.join(", ")} is not merged into your branch yet, so it would act without it. Starting it now is kept on the task.`;
|
|
2276
|
+
}
|
|
2277
|
+
function newTaskFields(title, prompt) {
|
|
2278
|
+
const name = title.trim();
|
|
2279
|
+
if (!name) return null;
|
|
2280
|
+
return { title: name, description: name, prompt: prompt?.trim() ? prompt : name, type: "ai" };
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2126
2283
|
export {
|
|
2127
2284
|
partedPromptUsage,
|
|
2128
2285
|
addUsage,
|
|
@@ -2150,6 +2307,11 @@ export {
|
|
|
2150
2307
|
filterModelsForPrompt,
|
|
2151
2308
|
clampThinkingEffort,
|
|
2152
2309
|
coerceAssignments,
|
|
2310
|
+
isTaskRunning,
|
|
2311
|
+
NOT_STARTED,
|
|
2312
|
+
taskStatusKind,
|
|
2313
|
+
awaitingLabel,
|
|
2314
|
+
approvalLabel,
|
|
2153
2315
|
validateTaskEdit,
|
|
2154
2316
|
taskOpsProtocol,
|
|
2155
2317
|
textHasTaskOps,
|
|
@@ -2185,6 +2347,16 @@ export {
|
|
|
2185
2347
|
followTurn,
|
|
2186
2348
|
stopTurn,
|
|
2187
2349
|
hasHiddenDetail,
|
|
2188
|
-
taskStartedNotice
|
|
2350
|
+
taskStartedNotice,
|
|
2351
|
+
taskRowActions,
|
|
2352
|
+
markAction,
|
|
2353
|
+
markRequestFor,
|
|
2354
|
+
opsEditable,
|
|
2355
|
+
namedRepos,
|
|
2356
|
+
taskRowView,
|
|
2357
|
+
titledRefs,
|
|
2358
|
+
dependentsNotice,
|
|
2359
|
+
pastGateConfirmation,
|
|
2360
|
+
newTaskFields
|
|
2189
2361
|
};
|
|
2190
|
-
//# sourceMappingURL=chunk-
|
|
2362
|
+
//# sourceMappingURL=chunk-Y36NIASW.mjs.map
|