@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.
Files changed (170) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +527 -0
  3. package/SECURITY.md +91 -0
  4. package/config.yml +104 -0
  5. package/dist/neal/activity-footer.js +177 -0
  6. package/dist/neal/activity-reporting.js +1 -0
  7. package/dist/neal/adjudicator/artifacts.js +58 -0
  8. package/dist/neal/adjudicator/blocked-adjudicator.js +223 -0
  9. package/dist/neal/adjudicator/contracts.js +139 -0
  10. package/dist/neal/adjudicator/execute.js +611 -0
  11. package/dist/neal/adjudicator/final-completion.js +104 -0
  12. package/dist/neal/adjudicator/planning.js +145 -0
  13. package/dist/neal/adjudicator/specs.js +453 -0
  14. package/dist/neal/agents/prompts.js +120 -0
  15. package/dist/neal/agents/rounds.js +706 -0
  16. package/dist/neal/agents/schemas.js +832 -0
  17. package/dist/neal/agents/structured-coder.js +82 -0
  18. package/dist/neal/agents/structured-json.js +528 -0
  19. package/dist/neal/agents.js +4 -0
  20. package/dist/neal/atomic-write.js +18 -0
  21. package/dist/neal/blocked-guidance.js +406 -0
  22. package/dist/neal/cli.js +471 -0
  23. package/dist/neal/commands/check.js +401 -0
  24. package/dist/neal/commands/compat.js +807 -0
  25. package/dist/neal/commands/interactive-activity.js +57 -0
  26. package/dist/neal/commands/new-run.js +79 -0
  27. package/dist/neal/commands/plan-and-execute.js +44 -0
  28. package/dist/neal/commands/recovery-guidance.js +217 -0
  29. package/dist/neal/commands/resume-run.js +395 -0
  30. package/dist/neal/commands/review.js +21 -0
  31. package/dist/neal/commands/runtime.js +557 -0
  32. package/dist/neal/commands/setup.js +596 -0
  33. package/dist/neal/commands/squash.js +113 -0
  34. package/dist/neal/commands/status.js +33 -0
  35. package/dist/neal/commands/writer-exit-codes.js +42 -0
  36. package/dist/neal/commit-message.js +17 -0
  37. package/dist/neal/config.js +432 -0
  38. package/dist/neal/context/artifacts.js +140 -0
  39. package/dist/neal/context/context.js +324 -0
  40. package/dist/neal/context/inline-review-context.js +131 -0
  41. package/dist/neal/context/reviewer-context.js +166 -0
  42. package/dist/neal/context/shared.js +117 -0
  43. package/dist/neal/context/types.js +1 -0
  44. package/dist/neal/diagnostic.js +208 -0
  45. package/dist/neal/execute-finalization.js +5 -0
  46. package/dist/neal/final-completion-review.js +188 -0
  47. package/dist/neal/final-completion.js +229 -0
  48. package/dist/neal/git.js +339 -0
  49. package/dist/neal/index.js +135 -0
  50. package/dist/neal/interactive-controls.js +85 -0
  51. package/dist/neal/logger.js +102 -0
  52. package/dist/neal/manual-gates.js +121 -0
  53. package/dist/neal/orchestrator/artifacts.js +70 -0
  54. package/dist/neal/orchestrator/completion.js +531 -0
  55. package/dist/neal/orchestrator/failures.js +31 -0
  56. package/dist/neal/orchestrator/notifications.js +175 -0
  57. package/dist/neal/orchestrator/phases/coder.js +516 -0
  58. package/dist/neal/orchestrator/phases/planning.js +540 -0
  59. package/dist/neal/orchestrator/phases/recovery.js +798 -0
  60. package/dist/neal/orchestrator/phases/review.js +136 -0
  61. package/dist/neal/orchestrator/phases/shared.js +279 -0
  62. package/dist/neal/orchestrator/run-loop.js +113 -0
  63. package/dist/neal/orchestrator/split-plan.js +235 -0
  64. package/dist/neal/orchestrator/transitions.js +309 -0
  65. package/dist/neal/orchestrator.js +215 -0
  66. package/dist/neal/phase-display.js +27 -0
  67. package/dist/neal/plan-doc.js +154 -0
  68. package/dist/neal/plan-queue.js +1092 -0
  69. package/dist/neal/plan-refinement.js +39 -0
  70. package/dist/neal/plan-validation.js +525 -0
  71. package/dist/neal/progress.js +237 -0
  72. package/dist/neal/prompts/assert-builder.js +13 -0
  73. package/dist/neal/prompts/execute.js +290 -0
  74. package/dist/neal/prompts/guidance.js +70 -0
  75. package/dist/neal/prompts/planning.js +313 -0
  76. package/dist/neal/prompts/review-doctrine.js +142 -0
  77. package/dist/neal/prompts/shared.js +101 -0
  78. package/dist/neal/prompts/specialized.js +212 -0
  79. package/dist/neal/prompts/specs.js +572 -0
  80. package/dist/neal/providers/anthropic-claude.js +1599 -0
  81. package/dist/neal/providers/detection.js +139 -0
  82. package/dist/neal/providers/generic-agentic-tools.js +586 -0
  83. package/dist/neal/providers/generic-agentic.js +1238 -0
  84. package/dist/neal/providers/liveness.js +151 -0
  85. package/dist/neal/providers/openai-codex.js +1014 -0
  86. package/dist/neal/providers/openai-compatible.js +654 -0
  87. package/dist/neal/providers/registry.js +389 -0
  88. package/dist/neal/providers/telemetry.js +208 -0
  89. package/dist/neal/providers/types.js +21 -0
  90. package/dist/neal/recovery-artifacts.js +50 -0
  91. package/dist/neal/resume-decision.js +220 -0
  92. package/dist/neal/resume-planner.js +265 -0
  93. package/dist/neal/retrospective.js +391 -0
  94. package/dist/neal/review-debt.js +18 -0
  95. package/dist/neal/review-findings/artifacts.js +173 -0
  96. package/dist/neal/review-findings/prompts.js +172 -0
  97. package/dist/neal/review-findings/provider.js +330 -0
  98. package/dist/neal/review-findings/run.js +373 -0
  99. package/dist/neal/review-findings/types.js +1 -0
  100. package/dist/neal/review-mode.js +67 -0
  101. package/dist/neal/review.js +137 -0
  102. package/dist/neal/run-lock.js +334 -0
  103. package/dist/neal/run-metrics.js +355 -0
  104. package/dist/neal/run-narrative-types.js +1 -0
  105. package/dist/neal/run-narrative.js +1374 -0
  106. package/dist/neal/run-registry.js +218 -0
  107. package/dist/neal/run-status.js +25 -0
  108. package/dist/neal/scopes.js +451 -0
  109. package/dist/neal/sensitive-text.js +8 -0
  110. package/dist/neal/squash-message.js +379 -0
  111. package/dist/neal/squash.js +591 -0
  112. package/dist/neal/state-invariants.js +496 -0
  113. package/dist/neal/state-views.js +344 -0
  114. package/dist/neal/state.js +887 -0
  115. package/dist/neal/status-footer.js +258 -0
  116. package/dist/neal/status.js +1260 -0
  117. package/dist/neal/storage-paths.js +57 -0
  118. package/dist/neal/support.js +58 -0
  119. package/dist/neal/terminal-narrator.js +435 -0
  120. package/dist/neal/types.js +1 -0
  121. package/dist/neal/verification-events.js +81 -0
  122. package/dist/neal/version.js +37 -0
  123. package/dist/neal/worktree-status.js +137 -0
  124. package/dist/notifier.js +44 -0
  125. package/docs/ADJUDICATOR_INVENTORY.md +310 -0
  126. package/docs/PROMPT_SPECS.md +266 -0
  127. package/docs/README.md +22 -0
  128. package/docs/architecture.md +113 -0
  129. package/docs/assets/neal-execution-flow.png +0 -0
  130. package/docs/automation.md +65 -0
  131. package/docs/comparison.md +105 -0
  132. package/docs/compat.md +269 -0
  133. package/docs/compatible-models.md +135 -0
  134. package/docs/demo.md +55 -0
  135. package/docs/maintenance.md +64 -0
  136. package/docs/plan-format.md +213 -0
  137. package/docs/providers.md +751 -0
  138. package/docs/release.md +147 -0
  139. package/docs/state-machine.md +266 -0
  140. package/docs/storage.md +207 -0
  141. package/docs/troubleshooting.md +152 -0
  142. package/examples/compat/add-edit-verify/PLAN.md +29 -0
  143. package/examples/compat/add-edit-verify/broken.diff +8 -0
  144. package/examples/compat/add-edit-verify/good.diff +8 -0
  145. package/examples/compat/add-edit-verify/package.json +5 -0
  146. package/examples/compat/add-edit-verify/src/add.js +2 -0
  147. package/examples/compat/add-edit-verify/test/add.test.js +9 -0
  148. package/examples/compat/is-even-add-test/PLAN.md +30 -0
  149. package/examples/compat/is-even-add-test/broken.diff +11 -0
  150. package/examples/compat/is-even-add-test/good.diff +11 -0
  151. package/examples/compat/is-even-add-test/package.json +5 -0
  152. package/examples/compat/is-even-add-test/src/is-even.js +3 -0
  153. package/examples/compat/is-even-add-test/test/is-even.test.js +9 -0
  154. package/examples/compat/manifest.json +60 -0
  155. package/examples/compat/plan-greeting/ISSUE.md +25 -0
  156. package/examples/compat/plan-greeting/package.json +5 -0
  157. package/examples/compat/plan-greeting/src/greet.js +2 -0
  158. package/examples/compat/plan-greeting/test/greet.test.js +8 -0
  159. package/examples/compat/reverse-grep-edit/PLAN.md +32 -0
  160. package/examples/compat/reverse-grep-edit/broken.diff +12 -0
  161. package/examples/compat/reverse-grep-edit/good.diff +12 -0
  162. package/examples/compat/reverse-grep-edit/package.json +5 -0
  163. package/examples/compat/reverse-grep-edit/src/strings.js +10 -0
  164. package/examples/compat/reverse-grep-edit/test/strings.test.js +15 -0
  165. package/examples/issue-triage-js/PLAN.md +83 -0
  166. package/examples/issue-triage-js/README.md +76 -0
  167. package/examples/issue-triage-js/package.json +9 -0
  168. package/examples/issue-triage-js/src/issue-triage.js +87 -0
  169. package/examples/issue-triage-js/test/issue-triage.test.js +107 -0
  170. package/package.json +70 -0
@@ -0,0 +1,213 @@
1
+ # Neal Plan Format
2
+
3
+ This is the canonical public reference for executable Neal plan documents.
4
+ The validator lives in `src/neal/plan-validation.ts` as `validatePlanDocument`.
5
+ The selected-plan Git contract lives in `src/neal/plan-doc.ts` as
6
+ `inspectPlanDocDisposition` and `toPlanDocMetadata`. Scope counting and status
7
+ labels come from `getExecutionPlanScopeCount` and
8
+ `getCurrentExecutionScopeDescriptor` in `src/neal/scopes.ts`.
9
+
10
+ Executable plans are instructions for Neal's planner/coder/reviewer loop, not
11
+ project requirements documents. They should be specific enough that one scope
12
+ can be implemented, reviewed, and verified without relying on hidden operator
13
+ intent.
14
+
15
+ ## Execution Shape
16
+
17
+ Every executable plan must choose exactly one execution shape. The plan must
18
+ include a literal `## Execution Shape` section, and that section must contain
19
+ exactly one non-empty line:
20
+
21
+ - `executionShape: one_shot`
22
+ - `executionShape: multi_scope`
23
+ - `executionShape: multi_scope_unknown`
24
+
25
+ Use `one_shot` when the whole task fits in one bounded implementation scope.
26
+ Use `multi_scope` when the task has a finite ordered queue of known scopes.
27
+ Use `multi_scope_unknown` when Neal should repeat one bounded scope template
28
+ until a concrete completion rule is satisfied, but the number of iterations is
29
+ not knowable when the plan is written.
30
+
31
+ ## One-Shot Format
32
+
33
+ `executionShape: one_shot` must not include a literal `## Execution Queue`
34
+ section, a literal `## Execution Loop` section, or a standalone
35
+ `## Completion Condition` section.
36
+
37
+ Minimal valid example:
38
+
39
+ ```md
40
+ # One Shot
41
+
42
+ ## Execution Shape
43
+
44
+ executionShape: one_shot
45
+
46
+ ## Objective
47
+
48
+ Complete one bounded change and verify it.
49
+ ```
50
+
51
+ For status display, Neal treats a one-shot plan as one known scope. If the
52
+ document has a level-one Markdown title, that title can be used as the scope
53
+ display title; otherwise Neal falls back to a generic one-scope label.
54
+
55
+ ### `one_shot` Is Defended Through Plan Refinement, Not Clamped
56
+
57
+ An author-declared `executionShape: one_shot` is captured once from the seed
58
+ plan document and defended through refinement by both roles' prompts: the
59
+ planner is instructed to keep the plan one scope and make the smallest complete
60
+ change, and the plan reviewer is instructed to raise a blocking finding if the
61
+ refined document declares any other execution shape or adds orchestration
62
+ sections. That finding routes through the normal revision loop like any other.
63
+
64
+ There is deliberately no hard mechanical clamp: if the review loop converges on
65
+ a different shape (the reviewer accepts an expansion), Neal adopts the refined
66
+ document's shape. An earlier version clamped the saved shape back to `one_shot`
67
+ unconditionally, which caused non-convergence on complex plans — the planner
68
+ could not produce an accurate single-scope plan, so review correctly rejected
69
+ it until the round cap failed the run.
70
+
71
+ This defense applies only to the top-level authored plan. A derived plan
72
+ declares and owns its own execution shape. Plans authored `multi_scope` or
73
+ `multi_scope_unknown` are unaffected — refinement may adjust their scope
74
+ content as usual.
75
+
76
+ ## Multi-Scope Format
77
+
78
+ `executionShape: multi_scope` must include a literal `## Execution Queue`
79
+ section. It must not include a literal `## Execution Loop` section or a
80
+ standalone `## Completion Condition` section.
81
+
82
+ Inside `## Execution Queue`, use literal scope headings with contiguous numbers
83
+ starting at 1:
84
+
85
+ ```md
86
+ # Multi Scope
87
+
88
+ ## Execution Shape
89
+
90
+ executionShape: multi_scope
91
+
92
+ ## Execution Queue
93
+
94
+ ### Scope 1: First bounded change
95
+ - Goal: Implement one bounded slice.
96
+ - Verification: `pnpm typecheck`
97
+ - Success Condition: The first slice is complete and verified.
98
+
99
+ ### Scope 2: Regression coverage
100
+ - Goal: Add focused coverage for the changed behavior.
101
+ - Verification: `pnpm test`
102
+ - Success Condition: The tests cover the new behavior and still pass.
103
+ ```
104
+
105
+ Each scope entry must include these labeled bullets:
106
+
107
+ - `- Goal:`
108
+ - `- Verification:`
109
+ - `- Success Condition:`
110
+
111
+ The queue cannot skip or repeat numbers. Neal uses the queue headings to count
112
+ known scopes and to show progress labels such as the current scope number and
113
+ scope title.
114
+
115
+ For a concrete in-repo multi-scope plan, see
116
+ [../examples/issue-triage-js/PLAN.md](../examples/issue-triage-js/PLAN.md).
117
+
118
+ ## Multi-Scope-Unknown Format
119
+
120
+ `executionShape: multi_scope_unknown` must include a literal
121
+ `## Execution Loop` section with exactly one literal `### Recurring Scope`
122
+ entry. It must also include a standalone, non-empty
123
+ `## Completion Condition` section. It must not include a literal
124
+ `## Execution Queue` section.
125
+
126
+ Minimal valid example:
127
+
128
+ ```md
129
+ # Recurring Scope
130
+
131
+ ## Execution Shape
132
+
133
+ executionShape: multi_scope_unknown
134
+
135
+ ## Execution Loop
136
+
137
+ ### Recurring Scope
138
+ - Goal: Implement one bounded recurring slice.
139
+ - Verification: `pnpm typecheck`
140
+ - Success Condition: The recurring slice is complete and reviewable.
141
+
142
+ ## Completion Condition
143
+
144
+ Stop when the explicit completion rule is satisfied.
145
+ ```
146
+
147
+ The recurring scope uses the same required bullets as a fixed queue. Neal treats
148
+ the total scope count as unknown by contract, and status displays the recurring
149
+ scope title rather than a finite total.
150
+
151
+ ## Verification And Acceptance
152
+
153
+ A scope should name verification commands that are deterministic and
154
+ noninteractive when possible. Examples include typecheck, test, lint, build,
155
+ package verification, or a focused smoke command. If a command needs external
156
+ state, credentials, network access, or manual setup, call that out in the plan
157
+ so Neal can distinguish expected manual gates from unexpected blockers.
158
+
159
+ The success condition should state what must be true after the scope is
160
+ complete. It is not a prose summary of the goal; it is the reviewable exit
161
+ criterion. Good success conditions mention the changed surface, the expected
162
+ behavior or docs state, and the verification evidence required for acceptance.
163
+
164
+ ## Planning Normalization
165
+
166
+ `neal plan` revises the selected plan file in place. It should preserve the
167
+ user's product objective while making the document executable by Neal.
168
+
169
+ During validation, Neal may normalize known legacy plan wording before checking
170
+ the final shape. Current normalization can convert legacy queue section
171
+ headings to `## Execution Queue`, normalize compatible scope labels to literal
172
+ `### Scope N:` headings, and normalize known aliases for the verification and
173
+ success-condition bullet labels. Normalization is still bounded by the same
174
+ shape rules above; it is not a license to omit the execution shape or required
175
+ scope fields.
176
+
177
+ For `neal plan`, the original selected plan backup is stored under the run
178
+ directory at `.neal/runs/<run-id>/PLAN_ORIGINAL.md`. Neal does not use a sibling
179
+ repository backup directory for that copy.
180
+
181
+ ## Selected Plan Documents And Git
182
+
183
+ Neal records selected-plan metadata with `inspectPlanDocDisposition` and
184
+ `toPlanDocMetadata` from `src/neal/plan-doc.ts`.
185
+
186
+ A selected plan document is eligible for ordinary Git inclusion only when it is
187
+ repo-local, exists, is a regular file, and is not ignored. If that eligible
188
+ plan document changes during a run, Neal may include it in the final tree using
189
+ normal Git staging.
190
+
191
+ The selected plan document can be the only allowed dirty path at writer-run
192
+ start when it is the explicit plan under execution. Dirty work outside that
193
+ selected plan still blocks writer-run start and queue continuation.
194
+
195
+ ## Ignored Or External Plan Documents
196
+
197
+ Ignored plan files, plan files outside the repository, missing paths, and
198
+ non-file paths are metadata-only. Neal records where they came from, but it does
199
+ not force-add them to the repository and does not treat them as package or
200
+ source artifacts.
201
+
202
+ This distinction is useful for ignored local plans under `tmp/` or for plans
203
+ stored outside the target repository. Those plans can drive a run, but they
204
+ remain operator-local unless the operator intentionally copies their contents
205
+ into a tracked document.
206
+
207
+ ## Protocol Boundary
208
+
209
+ Neal's terminal control protocol is not Markdown artifact content. Plan files,
210
+ derived plans, review notes, recovery guidance, and JSON artifacts should use
211
+ their normal schema or prose fields instead of embedding terminal control marker
212
+ words. This keeps executable plans portable and prevents transport signals from
213
+ being misread as user instructions or repository documentation.