@navels/neal 0.1.0
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/LICENSE +21 -0
- package/README.md +527 -0
- package/SECURITY.md +91 -0
- package/config.yml +104 -0
- package/dist/neal/activity-footer.js +177 -0
- package/dist/neal/activity-reporting.js +1 -0
- package/dist/neal/adjudicator/artifacts.js +58 -0
- package/dist/neal/adjudicator/blocked-adjudicator.js +223 -0
- package/dist/neal/adjudicator/contracts.js +139 -0
- package/dist/neal/adjudicator/execute.js +611 -0
- package/dist/neal/adjudicator/final-completion.js +104 -0
- package/dist/neal/adjudicator/planning.js +145 -0
- package/dist/neal/adjudicator/specs.js +453 -0
- package/dist/neal/agents/prompts.js +120 -0
- package/dist/neal/agents/rounds.js +706 -0
- package/dist/neal/agents/schemas.js +832 -0
- package/dist/neal/agents/structured-coder.js +82 -0
- package/dist/neal/agents/structured-json.js +528 -0
- package/dist/neal/agents.js +4 -0
- package/dist/neal/atomic-write.js +18 -0
- package/dist/neal/blocked-guidance.js +406 -0
- package/dist/neal/cli.js +471 -0
- package/dist/neal/commands/check.js +401 -0
- package/dist/neal/commands/compat.js +807 -0
- package/dist/neal/commands/interactive-activity.js +57 -0
- package/dist/neal/commands/new-run.js +79 -0
- package/dist/neal/commands/plan-and-execute.js +44 -0
- package/dist/neal/commands/recovery-guidance.js +217 -0
- package/dist/neal/commands/resume-run.js +395 -0
- package/dist/neal/commands/review.js +21 -0
- package/dist/neal/commands/runtime.js +557 -0
- package/dist/neal/commands/setup.js +596 -0
- package/dist/neal/commands/squash.js +113 -0
- package/dist/neal/commands/status.js +33 -0
- package/dist/neal/commands/writer-exit-codes.js +42 -0
- package/dist/neal/commit-message.js +17 -0
- package/dist/neal/config.js +432 -0
- package/dist/neal/context/artifacts.js +140 -0
- package/dist/neal/context/context.js +324 -0
- package/dist/neal/context/inline-review-context.js +131 -0
- package/dist/neal/context/reviewer-context.js +166 -0
- package/dist/neal/context/shared.js +117 -0
- package/dist/neal/context/types.js +1 -0
- package/dist/neal/diagnostic.js +208 -0
- package/dist/neal/execute-finalization.js +5 -0
- package/dist/neal/final-completion-review.js +188 -0
- package/dist/neal/final-completion.js +229 -0
- package/dist/neal/git.js +339 -0
- package/dist/neal/index.js +135 -0
- package/dist/neal/interactive-controls.js +85 -0
- package/dist/neal/logger.js +102 -0
- package/dist/neal/manual-gates.js +121 -0
- package/dist/neal/orchestrator/artifacts.js +70 -0
- package/dist/neal/orchestrator/completion.js +531 -0
- package/dist/neal/orchestrator/failures.js +31 -0
- package/dist/neal/orchestrator/notifications.js +175 -0
- package/dist/neal/orchestrator/phases/coder.js +516 -0
- package/dist/neal/orchestrator/phases/planning.js +540 -0
- package/dist/neal/orchestrator/phases/recovery.js +798 -0
- package/dist/neal/orchestrator/phases/review.js +136 -0
- package/dist/neal/orchestrator/phases/shared.js +279 -0
- package/dist/neal/orchestrator/run-loop.js +113 -0
- package/dist/neal/orchestrator/split-plan.js +235 -0
- package/dist/neal/orchestrator/transitions.js +309 -0
- package/dist/neal/orchestrator.js +215 -0
- package/dist/neal/phase-display.js +27 -0
- package/dist/neal/plan-doc.js +154 -0
- package/dist/neal/plan-queue.js +1092 -0
- package/dist/neal/plan-refinement.js +39 -0
- package/dist/neal/plan-validation.js +525 -0
- package/dist/neal/progress.js +237 -0
- package/dist/neal/prompts/assert-builder.js +13 -0
- package/dist/neal/prompts/execute.js +290 -0
- package/dist/neal/prompts/guidance.js +70 -0
- package/dist/neal/prompts/planning.js +313 -0
- package/dist/neal/prompts/review-doctrine.js +142 -0
- package/dist/neal/prompts/shared.js +101 -0
- package/dist/neal/prompts/specialized.js +212 -0
- package/dist/neal/prompts/specs.js +572 -0
- package/dist/neal/providers/anthropic-claude.js +1599 -0
- package/dist/neal/providers/detection.js +139 -0
- package/dist/neal/providers/generic-agentic-tools.js +586 -0
- package/dist/neal/providers/generic-agentic.js +1238 -0
- package/dist/neal/providers/liveness.js +151 -0
- package/dist/neal/providers/openai-codex.js +1014 -0
- package/dist/neal/providers/openai-compatible.js +654 -0
- package/dist/neal/providers/registry.js +389 -0
- package/dist/neal/providers/telemetry.js +208 -0
- package/dist/neal/providers/types.js +21 -0
- package/dist/neal/recovery-artifacts.js +50 -0
- package/dist/neal/resume-decision.js +220 -0
- package/dist/neal/resume-planner.js +265 -0
- package/dist/neal/retrospective.js +391 -0
- package/dist/neal/review-debt.js +18 -0
- package/dist/neal/review-findings/artifacts.js +173 -0
- package/dist/neal/review-findings/prompts.js +172 -0
- package/dist/neal/review-findings/provider.js +330 -0
- package/dist/neal/review-findings/run.js +373 -0
- package/dist/neal/review-findings/types.js +1 -0
- package/dist/neal/review-mode.js +67 -0
- package/dist/neal/review.js +137 -0
- package/dist/neal/run-lock.js +334 -0
- package/dist/neal/run-metrics.js +355 -0
- package/dist/neal/run-narrative-types.js +1 -0
- package/dist/neal/run-narrative.js +1374 -0
- package/dist/neal/run-registry.js +218 -0
- package/dist/neal/run-status.js +25 -0
- package/dist/neal/scopes.js +451 -0
- package/dist/neal/sensitive-text.js +8 -0
- package/dist/neal/squash-message.js +379 -0
- package/dist/neal/squash.js +591 -0
- package/dist/neal/state-invariants.js +496 -0
- package/dist/neal/state-views.js +344 -0
- package/dist/neal/state.js +887 -0
- package/dist/neal/status-footer.js +258 -0
- package/dist/neal/status.js +1260 -0
- package/dist/neal/storage-paths.js +57 -0
- package/dist/neal/support.js +58 -0
- package/dist/neal/terminal-narrator.js +435 -0
- package/dist/neal/types.js +1 -0
- package/dist/neal/verification-events.js +81 -0
- package/dist/neal/version.js +37 -0
- package/dist/neal/worktree-status.js +137 -0
- package/dist/notifier.js +44 -0
- package/docs/ADJUDICATOR_INVENTORY.md +310 -0
- package/docs/PROMPT_SPECS.md +266 -0
- package/docs/README.md +22 -0
- package/docs/architecture.md +113 -0
- package/docs/assets/neal-execution-flow.png +0 -0
- package/docs/automation.md +65 -0
- package/docs/comparison.md +105 -0
- package/docs/compat.md +269 -0
- package/docs/compatible-models.md +135 -0
- package/docs/demo.md +55 -0
- package/docs/maintenance.md +64 -0
- package/docs/plan-format.md +213 -0
- package/docs/providers.md +751 -0
- package/docs/release.md +147 -0
- package/docs/state-machine.md +266 -0
- package/docs/storage.md +207 -0
- package/docs/troubleshooting.md +152 -0
- package/examples/compat/add-edit-verify/PLAN.md +29 -0
- package/examples/compat/add-edit-verify/broken.diff +8 -0
- package/examples/compat/add-edit-verify/good.diff +8 -0
- package/examples/compat/add-edit-verify/package.json +5 -0
- package/examples/compat/add-edit-verify/src/add.js +2 -0
- package/examples/compat/add-edit-verify/test/add.test.js +9 -0
- package/examples/compat/is-even-add-test/PLAN.md +30 -0
- package/examples/compat/is-even-add-test/broken.diff +11 -0
- package/examples/compat/is-even-add-test/good.diff +11 -0
- package/examples/compat/is-even-add-test/package.json +5 -0
- package/examples/compat/is-even-add-test/src/is-even.js +3 -0
- package/examples/compat/is-even-add-test/test/is-even.test.js +9 -0
- package/examples/compat/manifest.json +60 -0
- package/examples/compat/plan-greeting/ISSUE.md +25 -0
- package/examples/compat/plan-greeting/package.json +5 -0
- package/examples/compat/plan-greeting/src/greet.js +2 -0
- package/examples/compat/plan-greeting/test/greet.test.js +8 -0
- package/examples/compat/reverse-grep-edit/PLAN.md +32 -0
- package/examples/compat/reverse-grep-edit/broken.diff +12 -0
- package/examples/compat/reverse-grep-edit/good.diff +12 -0
- package/examples/compat/reverse-grep-edit/package.json +5 -0
- package/examples/compat/reverse-grep-edit/src/strings.js +10 -0
- package/examples/compat/reverse-grep-edit/test/strings.test.js +15 -0
- package/examples/issue-triage-js/PLAN.md +83 -0
- package/examples/issue-triage-js/README.md +76 -0
- package/examples/issue-triage-js/package.json +9 -0
- package/examples/issue-triage-js/src/issue-triage.js +87 -0
- package/examples/issue-triage-js/test/issue-triage.test.js +107 -0
- package/package.json +70 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
2
|
+
import { EXECUTE_FINALIZATION_PHASE } from './execute-finalization.js';
|
|
3
|
+
import { formatPublicPhase } from './phase-display.js';
|
|
4
|
+
import { formatPublicRunStatus, getRunDisplayStatus } from './run-status.js';
|
|
5
|
+
import { getExecutionPlanPath, getExecutionPlanScopeCount, renderScopeProgressSegments } from './scopes.js';
|
|
6
|
+
import { getDerivedPlanView, getFinalCompletionView } from './state-views.js';
|
|
7
|
+
const DEFAULT_REFRESH_INTERVAL_MS = 1_000;
|
|
8
|
+
const DEFAULT_MIN_REDRAW_INTERVAL_MS = 100;
|
|
9
|
+
const DEFAULT_MIN_COLUMNS = 60;
|
|
10
|
+
const FOOTER_ACTIVITY_LABELS = {
|
|
11
|
+
coder_plan: 'planner planning',
|
|
12
|
+
reviewer_plan: 'reviewer reviewing plan',
|
|
13
|
+
coder_plan_response: 'planner revising plan',
|
|
14
|
+
coder_plan_optional_response: 'planner optional plan follow-up',
|
|
15
|
+
awaiting_derived_plan_execution: 'preparing derived plan',
|
|
16
|
+
coder_scope: 'coder working',
|
|
17
|
+
manual_gate: 'waiting for manual gate',
|
|
18
|
+
reviewer_scope: 'reviewer reviewing',
|
|
19
|
+
coder_response: 'coder revising',
|
|
20
|
+
coder_optional_response: 'coder optional follow-up',
|
|
21
|
+
interactive_blocked_recovery: 'waiting for guidance',
|
|
22
|
+
[EXECUTE_FINALIZATION_PHASE]: 'finalizing scope',
|
|
23
|
+
final_completion_review: 'reviewer final check',
|
|
24
|
+
done: 'done',
|
|
25
|
+
blocked: 'blocked',
|
|
26
|
+
};
|
|
27
|
+
function formatElapsed(elapsedMs) {
|
|
28
|
+
const totalSeconds = Math.max(0, Math.round(elapsedMs / 1_000));
|
|
29
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
30
|
+
const seconds = totalSeconds % 60;
|
|
31
|
+
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
|
32
|
+
}
|
|
33
|
+
function truncateForColumns(text, columns) {
|
|
34
|
+
if (columns <= 0 || text.length <= columns) {
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
37
|
+
if (columns <= 3) {
|
|
38
|
+
return text.slice(0, columns);
|
|
39
|
+
}
|
|
40
|
+
return `${text.slice(0, columns - 3)}...`;
|
|
41
|
+
}
|
|
42
|
+
export function renderStatusFooterLine(args) {
|
|
43
|
+
const now = args.now ?? Date.now();
|
|
44
|
+
const state = args.state;
|
|
45
|
+
const displayStatus = getRunDisplayStatus(state);
|
|
46
|
+
const segments = [`[neal] ${basename(state.planDoc)}`];
|
|
47
|
+
if (state.topLevelMode !== 'plan') {
|
|
48
|
+
const { scopeSegment, derivedSegment } = renderScopeProgressSegments(state, args.totalScopeCount);
|
|
49
|
+
segments.push(scopeSegment);
|
|
50
|
+
if (derivedSegment) {
|
|
51
|
+
segments.push(derivedSegment);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
segments.push(`activity: ${formatFooterActivity(state)}`);
|
|
55
|
+
segments.push(`elapsed: ${formatElapsed(now - args.phaseStartedAt)}`);
|
|
56
|
+
segments.push(`status: ${formatPublicRunStatus(displayStatus)}`);
|
|
57
|
+
if (displayStatus.effectiveStatus === 'waiting_for_manual_gate') {
|
|
58
|
+
segments.push(`manual gate: ${state.manualGate?.id ?? 'unknown'}`);
|
|
59
|
+
segments.push(`next: neal resume --run ${basename(state.runDir)}`);
|
|
60
|
+
}
|
|
61
|
+
else if (displayStatus.pendingOperatorGuidance) {
|
|
62
|
+
segments.push('operator guidance: pending');
|
|
63
|
+
segments.push(`next: neal resume --run ${basename(state.runDir)}`);
|
|
64
|
+
}
|
|
65
|
+
else if (displayStatus.waitingForOperatorGuidance) {
|
|
66
|
+
segments.push('operator guidance: waiting');
|
|
67
|
+
segments.push(`next: neal resume --run ${basename(state.runDir)} --message "..."`);
|
|
68
|
+
}
|
|
69
|
+
if (state.phase === 'reviewer_scope' || state.phase === 'reviewer_plan') {
|
|
70
|
+
segments.push(`review round: ${state.rounds.length + 1}`);
|
|
71
|
+
}
|
|
72
|
+
const finalCompletion = getFinalCompletionView(state);
|
|
73
|
+
if (finalCompletion?.activeReview) {
|
|
74
|
+
segments.push('completion review');
|
|
75
|
+
}
|
|
76
|
+
const derivedPlan = getDerivedPlanView(state);
|
|
77
|
+
if (derivedPlan && !derivedPlan.executing) {
|
|
78
|
+
segments.push(`derived plan: ${derivedPlan.status ?? 'pending_review'}`);
|
|
79
|
+
}
|
|
80
|
+
return segments.join(' | ');
|
|
81
|
+
}
|
|
82
|
+
function formatFooterActivity(state) {
|
|
83
|
+
if (state.status === 'paused') {
|
|
84
|
+
return 'paused after scope';
|
|
85
|
+
}
|
|
86
|
+
return FOOTER_ACTIVITY_LABELS[state.phase] ?? formatPublicPhase(state.phase);
|
|
87
|
+
}
|
|
88
|
+
export class StatusFooter {
|
|
89
|
+
stream;
|
|
90
|
+
now;
|
|
91
|
+
refreshIntervalMs;
|
|
92
|
+
minRedrawIntervalMs;
|
|
93
|
+
minColumns;
|
|
94
|
+
scopeCountCache = new Map();
|
|
95
|
+
redrawTimer = null;
|
|
96
|
+
refreshTimer = null;
|
|
97
|
+
resizeListener = null;
|
|
98
|
+
currentLine = '';
|
|
99
|
+
footerVisible = false;
|
|
100
|
+
lastRedrawAt = 0;
|
|
101
|
+
state = null;
|
|
102
|
+
phaseStartedAt = 0;
|
|
103
|
+
disposed = false;
|
|
104
|
+
constructor(options = {}) {
|
|
105
|
+
this.stream = options.stream ?? process.stderr;
|
|
106
|
+
this.now = options.now ?? (() => Date.now());
|
|
107
|
+
this.refreshIntervalMs = options.refreshIntervalMs ?? DEFAULT_REFRESH_INTERVAL_MS;
|
|
108
|
+
this.minRedrawIntervalMs = options.minRedrawIntervalMs ?? DEFAULT_MIN_REDRAW_INTERVAL_MS;
|
|
109
|
+
this.minColumns = options.minColumns ?? DEFAULT_MIN_COLUMNS;
|
|
110
|
+
if (this.isEnabled() && this.stream === process.stderr) {
|
|
111
|
+
this.resizeListener = () => {
|
|
112
|
+
this.handleResize();
|
|
113
|
+
};
|
|
114
|
+
process.on('SIGWINCH', this.resizeListener);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
isEnabled() {
|
|
118
|
+
return this.stream.isTTY === true;
|
|
119
|
+
}
|
|
120
|
+
async setState(state, phaseStartedAt) {
|
|
121
|
+
if (this.disposed) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.state = state;
|
|
125
|
+
this.phaseStartedAt = phaseStartedAt;
|
|
126
|
+
this.currentLine = await this.buildFooterLine();
|
|
127
|
+
this.ensureRefreshTimer();
|
|
128
|
+
this.renderFooter(true);
|
|
129
|
+
}
|
|
130
|
+
write(message) {
|
|
131
|
+
if (!this.isEnabled() || this.disposed) {
|
|
132
|
+
this.stream.write(message);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
this.clearFooter();
|
|
136
|
+
this.stream.write(message);
|
|
137
|
+
if (message.endsWith('\n') || message.endsWith('\r\n')) {
|
|
138
|
+
this.renderFooter(true);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
replaceView(message) {
|
|
142
|
+
if (!this.isEnabled() || this.disposed) {
|
|
143
|
+
this.stream.write(message);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.clearFooter();
|
|
147
|
+
this.stream.write('\x1b[H\x1b[2J');
|
|
148
|
+
if (message !== '') {
|
|
149
|
+
this.stream.write(message);
|
|
150
|
+
}
|
|
151
|
+
this.renderFooter(true);
|
|
152
|
+
}
|
|
153
|
+
dispose() {
|
|
154
|
+
if (this.disposed) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
this.disposed = true;
|
|
158
|
+
if (this.refreshTimer) {
|
|
159
|
+
clearInterval(this.refreshTimer);
|
|
160
|
+
this.refreshTimer = null;
|
|
161
|
+
}
|
|
162
|
+
if (this.redrawTimer) {
|
|
163
|
+
clearTimeout(this.redrawTimer);
|
|
164
|
+
this.redrawTimer = null;
|
|
165
|
+
}
|
|
166
|
+
if (this.resizeListener) {
|
|
167
|
+
process.off('SIGWINCH', this.resizeListener);
|
|
168
|
+
this.resizeListener = null;
|
|
169
|
+
}
|
|
170
|
+
this.clearFooter();
|
|
171
|
+
}
|
|
172
|
+
handleResize() {
|
|
173
|
+
if (this.disposed) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!this.canRender()) {
|
|
177
|
+
this.clearFooter();
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
void this.refresh(true);
|
|
181
|
+
}
|
|
182
|
+
async buildFooterLine() {
|
|
183
|
+
if (!this.state) {
|
|
184
|
+
return '';
|
|
185
|
+
}
|
|
186
|
+
let totalScopeCount = { kind: 'unavailable' };
|
|
187
|
+
if (this.state.topLevelMode !== 'plan') {
|
|
188
|
+
const executionPlanPath = getExecutionPlanPath(this.state);
|
|
189
|
+
const cachedScopeCount = this.scopeCountCache.get(executionPlanPath);
|
|
190
|
+
if (cachedScopeCount === undefined) {
|
|
191
|
+
totalScopeCount = await getExecutionPlanScopeCount(executionPlanPath);
|
|
192
|
+
this.scopeCountCache.set(executionPlanPath, totalScopeCount);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
totalScopeCount = cachedScopeCount;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const line = renderStatusFooterLine({
|
|
199
|
+
state: this.state,
|
|
200
|
+
phaseStartedAt: this.phaseStartedAt,
|
|
201
|
+
totalScopeCount,
|
|
202
|
+
now: this.now(),
|
|
203
|
+
});
|
|
204
|
+
return truncateForColumns(line, this.stream.columns ?? 0);
|
|
205
|
+
}
|
|
206
|
+
canRender() {
|
|
207
|
+
return this.isEnabled() && (this.stream.columns ?? 0) >= this.minColumns;
|
|
208
|
+
}
|
|
209
|
+
ensureRefreshTimer() {
|
|
210
|
+
if (this.refreshTimer || this.refreshIntervalMs <= 0 || !this.isEnabled()) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
this.refreshTimer = setInterval(() => {
|
|
214
|
+
void this.refresh();
|
|
215
|
+
}, this.refreshIntervalMs);
|
|
216
|
+
}
|
|
217
|
+
async refresh(force = false) {
|
|
218
|
+
if (!this.state || !this.canRender()) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
this.currentLine = await this.buildFooterLine();
|
|
222
|
+
this.renderFooter(force);
|
|
223
|
+
}
|
|
224
|
+
scheduleRedraw(delayMs) {
|
|
225
|
+
if (this.redrawTimer) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
this.redrawTimer = setTimeout(() => {
|
|
229
|
+
this.redrawTimer = null;
|
|
230
|
+
this.renderFooter(true);
|
|
231
|
+
}, delayMs);
|
|
232
|
+
}
|
|
233
|
+
renderFooter(force = false) {
|
|
234
|
+
if (!this.currentLine || !this.canRender()) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (force && this.redrawTimer) {
|
|
238
|
+
clearTimeout(this.redrawTimer);
|
|
239
|
+
this.redrawTimer = null;
|
|
240
|
+
}
|
|
241
|
+
const now = this.now();
|
|
242
|
+
const elapsedSinceRedraw = now - this.lastRedrawAt;
|
|
243
|
+
if (!force && elapsedSinceRedraw < this.minRedrawIntervalMs) {
|
|
244
|
+
this.scheduleRedraw(this.minRedrawIntervalMs - elapsedSinceRedraw);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
this.stream.write(`\r\x1b[2K${this.currentLine}`);
|
|
248
|
+
this.footerVisible = true;
|
|
249
|
+
this.lastRedrawAt = now;
|
|
250
|
+
}
|
|
251
|
+
clearFooter() {
|
|
252
|
+
if (!this.footerVisible || !this.isEnabled()) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
this.stream.write('\r\x1b[2K');
|
|
256
|
+
this.footerVisible = false;
|
|
257
|
+
}
|
|
258
|
+
}
|