@planu/cli 8.2.16 → 8.2.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +15 -3
  3. package/dist/sdd-engine/cli.js +0 -0
  4. package/dist/sdd-engine/completion-guard.d.ts +28 -0
  5. package/dist/sdd-engine/completion-guard.js +320 -0
  6. package/dist/sdd-engine/completion-snapshot.d.ts +11 -0
  7. package/dist/sdd-engine/completion-snapshot.js +155 -0
  8. package/dist/sdd-engine/feature-authority.d.ts +20 -0
  9. package/dist/sdd-engine/feature-authority.js +199 -0
  10. package/dist/sdd-engine/feature-manifest.d.ts +6 -0
  11. package/dist/sdd-engine/feature-manifest.js +116 -0
  12. package/dist/sdd-engine/host-rule-pack.d.ts +1 -0
  13. package/dist/sdd-engine/host-rule-pack.js +63 -7
  14. package/dist/sdd-engine/lock-integrity.d.ts +3 -18
  15. package/dist/sdd-engine/lock-integrity.js +192 -217
  16. package/dist/sdd-engine/patch-sandbox.js +6 -14
  17. package/dist/sdd-engine/server.js +4 -6
  18. package/dist/sdd-engine/task-content.d.ts +8 -0
  19. package/dist/sdd-engine/task-content.js +132 -0
  20. package/dist/sdd-engine/task-failures.d.ts +12 -0
  21. package/dist/sdd-engine/task-failures.js +125 -0
  22. package/dist/sdd-engine/task-window.d.ts +10 -4
  23. package/dist/sdd-engine/task-window.js +177 -246
  24. package/dist/sdd-engine/tools/execution-tools.js +29 -26
  25. package/dist/sdd-engine/tools/feature-store.d.ts +11 -0
  26. package/dist/sdd-engine/tools/feature-store.js +224 -0
  27. package/dist/sdd-engine/tools/workspace-tools.js +70 -127
  28. package/dist/sdd-engine/workspace-init.d.ts +3 -0
  29. package/dist/sdd-engine/workspace-init.js +197 -0
  30. package/dist/sdd-engine/workspace-root.d.ts +3 -1
  31. package/dist/sdd-engine/workspace-root.js +69 -3
  32. package/dist/types/completion.d.ts +77 -0
  33. package/dist/types/completion.js +2 -0
  34. package/package.json +32 -35
  35. package/templates/AGENTS.md +4 -0
  36. package/templates/host/planu-sdd.md +4 -0
  37. package/templates/skills/reconciler.md +8 -0
  38. package/templates/skills/spec-architect.md +22 -5
  39. package/templates/skills/spec-executor.md +11 -0
  40. package/templates/skills/verification-auditor.md +20 -0
@@ -0,0 +1,132 @@
1
+ const UNLOCKED_CARD = { locked: false, trinity: 'unlocked', manifest: [] };
2
+ export function activeTaskFromContent(content, extractCommand) {
3
+ return buildActiveTaskResult(parseTasks(content.split('\n')), extractCommand);
4
+ }
5
+ function buildActiveTaskResult(acc, extractCommand) {
6
+ if (acc.totalTasks === 0) {
7
+ return {
8
+ success: true,
9
+ data: { activeTask: null, allCompleted: false, status: 'NO_TASKS', ...UNLOCKED_CARD },
10
+ };
11
+ }
12
+ if (acc.activeTaskIndex === -1 || acc.completedTasks === acc.totalTasks) {
13
+ return {
14
+ success: true,
15
+ data: { activeTask: null, allCompleted: true, status: 'ALL_COMPLETED', ...UNLOCKED_CARD },
16
+ };
17
+ }
18
+ return {
19
+ success: true,
20
+ data: {
21
+ activeTask: {
22
+ taskId: acc.activeTaskId,
23
+ taskTitle: acc.activeTaskTitle,
24
+ fullTaskMarkdown: acc.activeTaskLines.join('\n').trim(),
25
+ verificationCommand: extractCommand(acc.activeTaskLines.join('\n')),
26
+ taskIndex: acc.activeTaskIndex,
27
+ totalTasks: acc.totalTasks,
28
+ completedTasks: acc.completedTasks,
29
+ },
30
+ allCompleted: false,
31
+ status: 'IN_PROGRESS',
32
+ ...UNLOCKED_CARD,
33
+ },
34
+ };
35
+ }
36
+ function parseTasks(lines) {
37
+ const acc = {
38
+ totalTasks: 0,
39
+ completedTasks: 0,
40
+ activeTaskIndex: -1,
41
+ activeTaskId: '',
42
+ activeTaskTitle: '',
43
+ activeTaskLines: [],
44
+ isCapturingActive: false,
45
+ };
46
+ const taskRegex = /^[-*]\s*\[([\s/xX])\]\s*(.*)$/;
47
+ for (const line of lines) {
48
+ const match = taskRegex.exec(line.trim());
49
+ if (match?.[1] && match[2]) {
50
+ acc.totalTasks++;
51
+ const statusChar = match[1].trim().toLowerCase();
52
+ if (statusChar === 'x') {
53
+ acc.completedTasks++;
54
+ if (acc.isCapturingActive) {
55
+ acc.isCapturingActive = false;
56
+ }
57
+ }
58
+ else if (!acc.isCapturingActive && acc.activeTaskIndex === -1) {
59
+ acc.isCapturingActive = true;
60
+ acc.activeTaskIndex = acc.totalTasks;
61
+ const parsed = extractTaskId(match[2].trim(), acc.activeTaskIndex);
62
+ acc.activeTaskId = parsed.id;
63
+ acc.activeTaskTitle = parsed.title;
64
+ acc.activeTaskLines.push(line);
65
+ }
66
+ else if (acc.isCapturingActive) {
67
+ acc.isCapturingActive = false;
68
+ }
69
+ }
70
+ else if (acc.isCapturingActive) {
71
+ acc.activeTaskLines.push(line);
72
+ }
73
+ }
74
+ return acc;
75
+ }
76
+ function extractTaskId(rawTitle, index) {
77
+ const idMatch = /^(TASK-[A-Z0-9_-]+|[A-Z0-9_-]+):\s*(.*)$/i.exec(rawTitle);
78
+ if (idMatch?.[1] && idMatch[2]) {
79
+ return { id: idMatch[1].toUpperCase(), title: idMatch[2].trim() };
80
+ }
81
+ return { id: `TASK-${index}`, title: rawTitle };
82
+ }
83
+ export function markTaskVerified(lines, taskId, cleanOutput) {
84
+ const regexExact = new RegExp(`^(\\s*[-*]\\s*\\[)[\\s/](\\]\\s*(?:${taskId}\\b|.*\\b${taskId}\\b.*))`, 'i');
85
+ const next = [...lines];
86
+ for (let i = 0; i < next.length; i++) {
87
+ const line = next[i];
88
+ if (line !== undefined && regexExact.test(line)) {
89
+ next[i] = line.replace(regexExact, (_, open, rest) => `${open}x${rest} — [Verified: ${cleanOutput}]`);
90
+ return next;
91
+ }
92
+ }
93
+ return null;
94
+ }
95
+ export function remainingTaskCount(checkRes) {
96
+ if (!checkRes.success || !checkRes.data.activeTask) {
97
+ return 0;
98
+ }
99
+ return checkRes.data.activeTask.totalTasks - checkRes.data.activeTask.completedTasks;
100
+ }
101
+ const EVIDENCE_LIMIT = 500;
102
+ export function summarizeEvidence(output) {
103
+ const collapsed = output.trim().replace(/\s+/g, ' ');
104
+ if (collapsed.length <= EVIDENCE_LIMIT) {
105
+ return collapsed;
106
+ }
107
+ const head = Array.from(collapsed).slice(0, EVIDENCE_LIMIT).join('');
108
+ const lastSpace = head.lastIndexOf(' ');
109
+ return `${(lastSpace > 0 ? head.slice(0, lastSpace) : head).trimEnd()}…`;
110
+ }
111
+ export function wasTaskCompleted(tasksContent, taskId) {
112
+ return tasksContent.split('\n').some((line) => {
113
+ const completedId = /^[-*]\s*\[[xX]\]\s*(TASK-[A-Z0-9_-]+|[A-Z0-9_-]+)\b/iu.exec(line.trim())?.[1];
114
+ return completedId?.toUpperCase() === taskId.toUpperCase();
115
+ });
116
+ }
117
+ export function catalogueFromContent(id, locked, tasksContent, extractCommand) {
118
+ const parsed = activeTaskFromContent(tasksContent, extractCommand);
119
+ if (!parsed.success) {
120
+ return parsed;
121
+ }
122
+ return {
123
+ success: true,
124
+ data: {
125
+ id,
126
+ status: !locked ? 'planning' : parsed.data.allCompleted ? 'done' : 'executing',
127
+ locked: locked,
128
+ activeTaskId: parsed.data.activeTask?.taskId ?? null,
129
+ },
130
+ };
131
+ }
132
+ //# sourceMappingURL=task-content.js.map
@@ -0,0 +1,12 @@
1
+ import type { CompleteTaskResult, SddResult } from '../types/sdd-engine.js';
2
+ import type { ScopedVerificationRun } from '../types/verification.js';
3
+ export declare function completionFailure(reason: string, code?: 'ERR_VERIFICATION_FAILED' | 'ERR_SPEC_DRIFT', trigger?: string): SddResult<never>;
4
+ export declare function completionError(error: unknown, trigger?: string): SddResult<never>;
5
+ export declare function taskOutOfSequence(taskId: string, activeTaskId: string | null, alreadyCompleted?: boolean): SddResult<CompleteTaskResult>;
6
+ export declare function verificationMissing(): SddResult<CompleteTaskResult>;
7
+ export declare function verificationFailed(run: ScopedVerificationRun): SddResult<CompleteTaskResult>;
8
+ export declare function unsupportedVerificationPlatform(): SddResult<CompleteTaskResult>;
9
+ export declare function scopedPathMismatch(): SddResult<never>;
10
+ export declare function taskFileMissing(tasksFilePath: string): SddResult<never>;
11
+ export declare function catalogueReadFailure(error: unknown, id: string): SddResult<never>;
12
+ //# sourceMappingURL=task-failures.d.ts.map
@@ -0,0 +1,125 @@
1
+ import { CompletionGuardError } from './feature-authority.js';
2
+ export function completionFailure(reason, code = reason === 'contract_drift'
3
+ ? 'ERR_SPEC_DRIFT'
4
+ : 'ERR_VERIFICATION_FAILED', trigger = 'sdd_complete_task') {
5
+ return {
6
+ success: false,
7
+ error: {
8
+ code,
9
+ message: reason === 'persistence_uncertain'
10
+ ? 'Completion state requires explicit reviewed recovery with sdd_lock_spec.'
11
+ : 'Completion was denied; inspect the bounded reason before retrying.',
12
+ trigger,
13
+ details: { reason },
14
+ },
15
+ };
16
+ }
17
+ export function completionError(error, trigger = 'sdd_complete_task') {
18
+ if (error instanceof CompletionGuardError) {
19
+ return {
20
+ success: false,
21
+ error: {
22
+ code: error.code,
23
+ message: error.message,
24
+ trigger,
25
+ details: { reason: error.reason },
26
+ },
27
+ };
28
+ }
29
+ return completionFailure('failed', undefined, trigger);
30
+ }
31
+ export function taskOutOfSequence(taskId, activeTaskId, alreadyCompleted = false) {
32
+ return {
33
+ success: false,
34
+ error: {
35
+ code: 'ERR_TASK_OUT_OF_SEQUENCE',
36
+ message: `Task '${taskId}' is not active or was already completed.`,
37
+ trigger: 'sdd_complete_task',
38
+ details: {
39
+ requestedTaskId: taskId,
40
+ activeTaskId,
41
+ ...(alreadyCompleted ? { reason: 'already_completed' } : {}),
42
+ },
43
+ },
44
+ };
45
+ }
46
+ export function verificationMissing() {
47
+ return {
48
+ success: false,
49
+ error: {
50
+ code: 'ERR_VERIFICATION_MISSING',
51
+ message: 'The active task needs one Verification line whose command does not contain < or >.',
52
+ trigger: 'sdd_complete_task',
53
+ },
54
+ };
55
+ }
56
+ export function verificationFailed(run) {
57
+ const exitCode = run.exitCode ?? 1;
58
+ return {
59
+ success: false,
60
+ error: {
61
+ code: 'ERR_VERIFICATION_FAILED',
62
+ message: `Verification command exited ${String(exitCode)}.`,
63
+ trigger: 'sdd_complete_task',
64
+ details: {
65
+ reason: run.cancelled ? 'cancelled' : run.timedOut ? 'timeout' : 'failed',
66
+ exitCode,
67
+ outputTail: run.output.slice(-2000),
68
+ cleanupComplete: run.cleanupComplete,
69
+ },
70
+ },
71
+ };
72
+ }
73
+ export function unsupportedVerificationPlatform() {
74
+ return {
75
+ success: false,
76
+ error: {
77
+ code: 'ERR_VERIFICATION_FAILED',
78
+ message: 'Automatic task verification currently requires local macOS or Linux for owned process-tree cleanup. Planning and read-only tools remain available.',
79
+ trigger: 'sdd_complete_task',
80
+ details: {
81
+ reason: 'failed',
82
+ platform: process.platform,
83
+ verificationSupported: false,
84
+ },
85
+ },
86
+ };
87
+ }
88
+ export function scopedPathMismatch() {
89
+ return {
90
+ success: false,
91
+ error: {
92
+ code: 'ERR_WORKSPACE_UNRESOLVED',
93
+ message: 'Scoped verification path does not match its trusted policy.',
94
+ trigger: 'sdd_complete_task',
95
+ details: { reason: 'verification_policy_workspace_mismatch' },
96
+ },
97
+ };
98
+ }
99
+ export function taskFileMissing(tasksFilePath) {
100
+ return {
101
+ success: false,
102
+ error: {
103
+ code: 'ERR_TASK_NOT_FOUND',
104
+ message: `File tasks.md not found at: '${tasksFilePath}'.`,
105
+ trigger: 'sdd_get_active_task',
106
+ },
107
+ };
108
+ }
109
+ export function catalogueReadFailure(error, id) {
110
+ return {
111
+ success: false,
112
+ error: {
113
+ code: error instanceof CompletionGuardError ? error.code : 'ERR_INVALID_ARTIFACT',
114
+ message: error instanceof CompletionGuardError
115
+ ? error.message
116
+ : 'Could not read the complete feature catalogue.',
117
+ trigger: 'sdd_list_features',
118
+ details: {
119
+ entry: id,
120
+ ...(error instanceof CompletionGuardError ? { reason: error.reason } : {}),
121
+ },
122
+ },
123
+ };
124
+ }
125
+ //# sourceMappingURL=task-failures.js.map
@@ -1,18 +1,24 @@
1
- import type { ActiveTaskResult, CompleteTaskResult, SddResult } from '../types/sdd-engine.js';
1
+ import type { ActiveTaskResult, CompleteTaskResult, FeatureSummary, SddResult } from '../types/sdd-engine.js';
2
2
  import type { VerificationPolicy } from '../types/verification.js';
3
3
  export declare class TaskWindowManager {
4
4
  private readonly scopedPolicy;
5
5
  private readonly scoped;
6
+ private readonly shutdownController;
7
+ private readonly pending;
6
8
  constructor(policy?: VerificationPolicy);
7
9
  shutdown(): Promise<void>;
8
10
  private activeTaskFromContent;
9
11
  private selectScopedTask;
10
12
  private commitScopedTask;
11
13
  getActiveTask(tasksFilePath: string): Promise<SddResult<ActiveTaskResult>>;
12
- private buildActiveTaskResult;
13
- private parseTasks;
14
- private extractTaskId;
14
+ getCatalogueEntry(featDir: string): Promise<SddResult<FeatureSummary>>;
15
15
  completeTask(tasksFilePath: string, taskId: string, workspaceRoot: string, _verificationOutput: string, signal?: AbortSignal): Promise<SddResult<CompleteTaskResult>>;
16
+ private completeOwned;
17
+ private checkScopedPaths;
18
+ private attemptScopedCompletion;
19
+ private commitOwnedScopedTask;
20
+ private completeOrdinary;
21
+ private commitOrdinary;
16
22
  }
17
23
  export declare function verificationCommand(taskMarkdown: string): string | null;
18
24
  //# sourceMappingURL=task-window.d.ts.map