autonomous-sdlc-harness 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 (171) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +7 -0
  3. package/README.md +24 -0
  4. package/dist/cli.js +194 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/config.js +561 -0
  7. package/dist/commands/config.js.map +1 -0
  8. package/dist/commands/daemon.js +791 -0
  9. package/dist/commands/daemon.js.map +1 -0
  10. package/dist/commands/doctor.js +336 -0
  11. package/dist/commands/doctor.js.map +1 -0
  12. package/dist/commands/init.js +2023 -0
  13. package/dist/commands/init.js.map +1 -0
  14. package/dist/commands/registry.js +42 -0
  15. package/dist/commands/registry.js.map +1 -0
  16. package/dist/config/check.js +505 -0
  17. package/dist/config/check.js.map +1 -0
  18. package/dist/config/io.js +177 -0
  19. package/dist/config/io.js.map +1 -0
  20. package/dist/config/model.js +406 -0
  21. package/dist/config/model.js.map +1 -0
  22. package/dist/core/errors.js +71 -0
  23. package/dist/core/errors.js.map +1 -0
  24. package/dist/core/git.js +537 -0
  25. package/dist/core/git.js.map +1 -0
  26. package/dist/core/json.js +125 -0
  27. package/dist/core/json.js.map +1 -0
  28. package/dist/core/layerCoverage.js +141 -0
  29. package/dist/core/layerCoverage.js.map +1 -0
  30. package/dist/core/layerGapRemedy.js +62 -0
  31. package/dist/core/layerGapRemedy.js.map +1 -0
  32. package/dist/core/nameList.js +23 -0
  33. package/dist/core/nameList.js.map +1 -0
  34. package/dist/core/paths.js +153 -0
  35. package/dist/core/paths.js.map +1 -0
  36. package/dist/core/prompt.js +206 -0
  37. package/dist/core/prompt.js.map +1 -0
  38. package/dist/core/repoPaths.js +55 -0
  39. package/dist/core/repoPaths.js.map +1 -0
  40. package/dist/core/report.js +150 -0
  41. package/dist/core/report.js.map +1 -0
  42. package/dist/core/templating.js +88 -0
  43. package/dist/core/templating.js.map +1 -0
  44. package/dist/core/writer.js +479 -0
  45. package/dist/core/writer.js.map +1 -0
  46. package/dist/daemon/backend.js +180 -0
  47. package/dist/daemon/backend.js.map +1 -0
  48. package/dist/daemon/units.js +380 -0
  49. package/dist/daemon/units.js.map +1 -0
  50. package/dist/detect/nestedApplication.js +79 -0
  51. package/dist/detect/nestedApplication.js.map +1 -0
  52. package/dist/detect/presets.js +2033 -0
  53. package/dist/detect/presets.js.map +1 -0
  54. package/dist/detect/signals.js +1368 -0
  55. package/dist/detect/signals.js.map +1 -0
  56. package/dist/doctor/checks.js +3530 -0
  57. package/dist/doctor/checks.js.map +1 -0
  58. package/dist/generators/claudeContext.js +588 -0
  59. package/dist/generators/claudeContext.js.map +1 -0
  60. package/dist/generators/githooks.js +446 -0
  61. package/dist/generators/githooks.js.map +1 -0
  62. package/dist/generators/harnessConfig.js +632 -0
  63. package/dist/generators/harnessConfig.js.map +1 -0
  64. package/dist/generators/notifications.js +191 -0
  65. package/dist/generators/notifications.js.map +1 -0
  66. package/dist/generators/outerLoopScripts.js +165 -0
  67. package/dist/generators/outerLoopScripts.js.map +1 -0
  68. package/dist/generators/permissionProfile.js +1172 -0
  69. package/dist/generators/permissionProfile.js.map +1 -0
  70. package/dist/generators/projectSettings.js +322 -0
  71. package/dist/generators/projectSettings.js.map +1 -0
  72. package/dist/generators/repoRoot.js +417 -0
  73. package/dist/generators/repoRoot.js.map +1 -0
  74. package/dist/generators/scripts.js +557 -0
  75. package/dist/generators/scripts.js.map +1 -0
  76. package/dist/generators/stateDir.js +221 -0
  77. package/dist/generators/stateDir.js.map +1 -0
  78. package/dist/machine/paths.js +111 -0
  79. package/dist/machine/paths.js.map +1 -0
  80. package/dist/machine/plugins.js +224 -0
  81. package/dist/machine/plugins.js.map +1 -0
  82. package/dist/machine/registry.js +330 -0
  83. package/dist/machine/registry.js.map +1 -0
  84. package/package.json +23 -0
  85. package/scripts/README.md +13 -0
  86. package/scripts/daemon/launchd.plist.template +59 -0
  87. package/scripts/daemon/systemd.service.template +58 -0
  88. package/templates/README.md +15 -0
  89. package/templates/claude/CLAUDE.md +54 -0
  90. package/templates/claude/README.md +5 -0
  91. package/templates/claude/context/api.md +29 -0
  92. package/templates/claude/context/conventions.md +23 -0
  93. package/templates/claude/context/data-layer.md +28 -0
  94. package/templates/claude/context/data-storage.md +29 -0
  95. package/templates/claude/context/docs-catalog.md +29 -0
  96. package/templates/claude/context/domain.md +28 -0
  97. package/templates/claude/context/layer.md +20 -0
  98. package/templates/claude/context/module.md +30 -0
  99. package/templates/claude/context/package.md +29 -0
  100. package/templates/claude/context/presentation.md +32 -0
  101. package/templates/claude/context/state-slices.md +28 -0
  102. package/templates/claude/context/tests.md +28 -0
  103. package/templates/claude/harness-task-offer.md +58 -0
  104. package/templates/claude/push-notify.env.example +21 -0
  105. package/templates/claude/qa-accounts.env.example +38 -0
  106. package/templates/claude/qa_test_scenarios.md +110 -0
  107. package/templates/claude/settings.autonomous.json +93 -0
  108. package/templates/claude/settings.autonomous.qa.json +36 -0
  109. package/templates/githooks/README.md +3 -0
  110. package/templates/githooks/pre-push +72 -0
  111. package/templates/repo/README.md +3 -0
  112. package/templates/repo/gitattributes +16 -0
  113. package/templates/repo/gitignore +61 -0
  114. package/templates/repo/gitignore.qa +25 -0
  115. package/templates/repo/mcp.json +17 -0
  116. package/templates/scripts/README.md +5 -0
  117. package/templates/scripts/autonomous-format-stream.sh +95 -0
  118. package/templates/scripts/autonomous-notify.sh +337 -0
  119. package/templates/scripts/autonomous-watcher.sh +3087 -0
  120. package/templates/scripts/cleanup-merged-worktrees.sh +327 -0
  121. package/templates/scripts/commit-on-branch.sh +288 -0
  122. package/templates/scripts/create-worktree.sh +360 -0
  123. package/templates/scripts/deploy.sh +47 -0
  124. package/templates/scripts/lib/harness-run-lib.sh +1481 -0
  125. package/templates/scripts/push-branch.sh +140 -0
  126. package/templates/scripts/refresh-branch.sh +244 -0
  127. package/templates/scripts/restart-watcher.sh +401 -0
  128. package/templates/scripts/scratch-run.sh +302 -0
  129. package/templates/scripts/setup-worktree.sh +262 -0
  130. package/templates/scripts/start-dev-server.sh +99 -0
  131. package/templates/scripts/test.sh +50 -0
  132. package/templates/scripts/typecheck.sh +50 -0
  133. package/templates/state-dir/README-root.md +13 -0
  134. package/templates/state-dir/README.md +9 -0
  135. package/templates/state-dir/architecture_branch_review_point_reviews/README.md +9 -0
  136. package/templates/state-dir/architecture_branch_reviews/README.md +9 -0
  137. package/templates/state-dir/architecture_reviews/README.md +9 -0
  138. package/templates/state-dir/architecture_user_review_reviews/README.md +9 -0
  139. package/templates/state-dir/autonomous_inbox/README.md +9 -0
  140. package/templates/state-dir/autonomous_logs/README.md +9 -0
  141. package/templates/state-dir/branch_statistics/README.md +9 -0
  142. package/templates/state-dir/business_parity_branch_review_point_reviews/README.md +9 -0
  143. package/templates/state-dir/business_parity_branch_reviews/README.md +9 -0
  144. package/templates/state-dir/business_parity_reviews/README.md +9 -0
  145. package/templates/state-dir/business_parity_user_review_reviews/README.md +9 -0
  146. package/templates/state-dir/clarification_digests/README.md +9 -0
  147. package/templates/state-dir/clarifications/README.md +9 -0
  148. package/templates/state-dir/code_reviews/README.md +9 -0
  149. package/templates/state-dir/dispatch_additions/README.md +19 -0
  150. package/templates/state-dir/docs_catalog/README.md +9 -0
  151. package/templates/state-dir/flow_progress/README.md +9 -0
  152. package/templates/state-dir/improvement_observations/README.md +19 -0
  153. package/templates/state-dir/improvement_suggestions.md +29 -0
  154. package/templates/state-dir/lessons.md +23 -0
  155. package/templates/state-dir/qa_review_point_reviews/README.md +9 -0
  156. package/templates/state-dir/qa_reviews/README.md +9 -0
  157. package/templates/state-dir/review_plan_point_reviews/README.md +9 -0
  158. package/templates/state-dir/review_plan_reviews/README.md +9 -0
  159. package/templates/state-dir/scratch/README.md +11 -0
  160. package/templates/state-dir/skeptic_review_plan_reviews/README.md +9 -0
  161. package/templates/state-dir/skeptic_review_point_reviews/README.md +9 -0
  162. package/templates/state-dir/skeptic_reviews/README.md +9 -0
  163. package/templates/state-dir/story_plans/README.md +9 -0
  164. package/templates/state-dir/task_plan_point_reviews/README.md +9 -0
  165. package/templates/state-dir/task_plan_reviews/README.md +9 -0
  166. package/templates/state-dir/task_plans/README.md +9 -0
  167. package/templates/state-dir/task_prompts/README.md +9 -0
  168. package/templates/state-dir/ui_test_plan_reviews/README.md +9 -0
  169. package/templates/state-dir/ui_test_plans/README.md +9 -0
  170. package/templates/state-dir/user_review_fix_plan_point_reviews/README.md +9 -0
  171. package/templates/state-dir/user_reviews/README.md +9 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ autonomous-sdlc-harness
2
+ Copyright 2026 Firu Daniel
3
+
4
+ Licensed under the Apache License, Version 2.0. See LICENSE for the full terms.
5
+ The appendix in LICENSE is upstream's template for adopters and is deliberately
6
+ left unfilled; this file carries the copyright assertion, which section 4(d)
7
+ then requires any derivative work to reproduce.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # autonomous-sdlc-harness (cli)
2
+
3
+ ```bash
4
+ npx autonomous-sdlc-harness init # wire a repository, in one deterministic pass
5
+ npx autonomous-sdlc-harness doctor # re-check a wired one; the exit status is the contract
6
+ npx autonomous-sdlc-harness config list | get <key> | set <key> <value>
7
+ npx autonomous-sdlc-harness daemon <install|start|stop|list>
8
+ ```
9
+
10
+ Node `>=20.11.0`. Licence Apache-2.0 — `LICENSE` and `NOTICE` ship beside this file. Every command takes `-h`, `-v`, `--dry-run`, `--force`, `--quiet` (progress narration only — results, warnings and failures still print), `--non-interactive` and `--cwd <path>`, and exits `0` (did what it was asked), `1` (a refusal or a failed check, `doctor` FAIL included) or `2` (an internal fault). What each command writes, the `init` re-run contract, the stack-detection table, the enumerated `doctor` checks and the failure modes the generated permission profile encodes are in [`docs/cli.md`](https://github.com/firu-daniel/autonomous-sdlc-harness/blob/main/docs/cli.md) — which the published tarball does not carry, so every repository link on this page is an absolute URL.
11
+
12
+ The npm package that carries the harness's **outer loop** — `init`, `doctor`, `config` and `daemon`. The process assets those runs execute — agents, slash commands, hooks, instructions and samples — are not here; they ship as the sibling `plugin/` Claude Code plugin. This package exists at all because a plugin cannot write a repository's `settings.json`, and getting that permission profile right is the highest-friction part of adoption. Installing that plugin is a step of its own, separate from installing this package — see the harness root [`README.md`](https://github.com/firu-daniel/autonomous-sdlc-harness/blob/main/README.md) `## Quick start` for the lettered sequence an adopter runs.
13
+
14
+ **What the four subcommands do.** `init` wires an adopting repository in one deterministic pass: it detects the stack, then writes the configuration, the wrapper scripts, the run-artifact tree, the conventions stubs, the permission profile, the committable project settings, the repository-root files and the pre-push hook — creating what is absent and keeping what the adopter has edited. `doctor` re-checks a wired repository — git and worktrees, that the configured default branch still resolves, the daemon backend, the configuration, the state directory, the ignore rules, which notification settings file the notifier resolves, whether this checkout is in the machine-local registry of installed daemons, the plugin wiring and the permission profile — and reports every finding, with the exit status as the contract; [`docs/cli.md`](https://github.com/firu-daniel/autonomous-sdlc-harness/blob/main/docs/cli.md) §7 is the enumerated list and the severity each check carries. `config` reads and updates one dotted key of `harness.config.json` at a time, refusing a key the file may not carry and backing the file up before each write. `daemon` installs, starts and stops this repository's run daemon on whichever service manager the host has, and lists the repositories on this machine one has been installed for.
15
+
16
+ Five decisions are recorded here so they are not re-litigated later:
17
+
18
+ - **No lockfile of its own.** `cli/` is a workspace member and the single `package-lock.json` lives at the harness root — npm workspaces resolve and hoist from the root lockfile by design, so a second lockfile inside a member is ignored by the root install and silently drifts. The package stays independently publishable with `npm publish --workspace cli`.
19
+ - **Node floor `>=20.11.0`.** Node 18 is past end-of-life and 20.11 is the first Node 20 LTS carrying `import.meta.dirname` / `import.meta.filename`, which a template-copying ESM CLI wants; Node 22 and 24 satisfy the same floor, and raising it to 22 would exclude LTS users for no capability this CLI needs.
20
+ - **`files` carries `LICENSE`, and `cli/LICENSE` is a byte-copy of the root one.** npm auto-includes a licence only from the package root, so a tarball built from this directory would otherwise declare `"license": "Apache-2.0"` and contain no licence text — which Apache-2.0 §4(a) does not allow, since every recipient of the Work must receive a copy. The duplication is the cost of publishing a workspace member as its own package; nothing enforces the two copies' identity, so a change to the root `LICENSE` is a `diff ../LICENSE LICENSE` against this one.
21
+ - **Never shell out to `rm -rf`.** A user-level `permissions.deny` rule on it is realistic, deny is evaluated before any allow and cannot be overridden, so a teardown implemented as a shelled-out `rm -rf` is silently blocked with no useful error. Use Node's in-process `fs.rm` for every removal.
22
+ - **The run watcher's path is derived from `scriptsDir`, not a config key of its own.** `init` writes the watcher into the configured scripts directory with the rest of the outer-loop set, so `daemon` resolves it as `<repoRoot>/<scriptsDir>/autonomous-watcher.sh`: `scriptsDir` is the one key that moves it, and a second key naming the same location could only ever disagree with it. That also keeps the unit's `ExecStart` inside the repository its `WorkingDirectory` names — a CLI run through `npx` lives in a cache directory that can be evicted under a long-running service. `--watcher` overrides the resolution for developing against a watcher that is not the written one. (This decision replaces an earlier package-relative one; `scripts/README.md` records why.)
23
+
24
+ TypeScript in `src/` compiles with `tsc` to `dist/`, which is what `bin` points at; `templates/` holds generator templates and is deliberately outside the compiler's `include`. Two families live there: the **wrapper** scripts `init` renders from a detected command line, and the **outer-loop** shell assets — the run watcher, its restart wrapper, the notifier and its stream formatter, the commit / push / branch-refresh / worktree / cleanup wrappers and the library they share — which `init` copies verbatim into the same `scriptsDir` because each reads `harness.config.json` at run time. `scripts/` keeps only the daemon unit templates the `daemon` subcommand renders into the account's home directory; it is likewise uncompiled and carried into the published tarball by `files` alongside `templates/` (`scripts/README.md` records why the outer-loop set is not there). A watcher that is missing — deleted, or left behind when `scriptsDir` moved — is a `doctor` warning and a `daemon install` refusal, repaired by re-running `init`.
package/dist/cli.js ADDED
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * autonomous-sdlc-harness — CLI entry point.
4
+ *
5
+ * Scope of this file: argv handling and dispatch, and nothing else. It parses the global
6
+ * flags into a `CommandContext`, resolves the command against `commands/registry.ts`, and
7
+ * hands off. Command behaviour lives behind `Subcommand.run`; this file detects no stack,
8
+ * reads no config and touches no filesystem — it only resolves `--cwd` to an absolute path.
9
+ *
10
+ * **This is the only place an error becomes an exit code.** A `HarnessError` thrown
11
+ * anywhere below prints `autonomous-sdlc-harness: <message>` on stderr and yields its own
12
+ * `exitCode`; any other thrown value prints with an `(unexpected)` suffix and yields
13
+ * `EXIT.INTERNAL`. No other module inspects or assigns exit codes, and nothing in the CLI
14
+ * calls `process.exit()` — the contract lives in `core/errors.ts`.
15
+ *
16
+ * One constraint every command inherits: **never shell out to `rm -rf`.** A user-level
17
+ * `permissions.deny` rule on it is realistic, deny is evaluated before any allow and cannot
18
+ * be overridden, so a teardown implemented as a shelled-out `rm -rf` is silently blocked
19
+ * with no useful error. Use Node's in-process `fs.rm` instead.
20
+ */
21
+ import { createRequire } from 'node:module';
22
+ import { resolve } from 'node:path';
23
+ import { commandListLines, commandSynopsis, findSubcommand, } from './commands/registry.js';
24
+ import { EXIT, HarnessError } from './core/errors.js';
25
+ import { Reporter } from './core/report.js';
26
+ // Read the version from the manifest so `--version` cannot drift from package.json.
27
+ // From dist/cli.js this resolves to cli/package.json. Deliberately not a static JSON
28
+ // import: `resolveJsonModule` under `rootDir: "src"` would drag the manifest into dist/.
29
+ const require = createRequire(import.meta.url);
30
+ const { version } = require('../package.json');
31
+ /**
32
+ * The global flag table: the single source for both the parser below and the `Options:`
33
+ * block of the usage text, so the two cannot disagree. `value` present means the option
34
+ * consumes the next argument (or an inline `--name=value`).
35
+ *
36
+ * Deliberately hand-rolled: the CLI package declares no runtime dependencies and a flag
37
+ * parser is not worth the first one.
38
+ */
39
+ const GLOBAL_OPTIONS = [
40
+ { key: 'help', aliases: ['-h', '--help'], summary: 'Print usage — for the harness, or for <command> — and exit 0' },
41
+ { key: 'version', aliases: ['-v', '--version'], summary: 'Print the version and exit 0' },
42
+ { key: 'dryRun', aliases: ['--dry-run'], summary: 'Print what would be written and write nothing' },
43
+ {
44
+ key: 'force',
45
+ aliases: ['--force'],
46
+ summary: 'Overwrite an existing generated file, after a .bak; never harness.config.json, which init reads (--reset-config rebuilds it)',
47
+ },
48
+ {
49
+ key: 'quiet',
50
+ aliases: ['--quiet'],
51
+ summary: 'Suppress progress narration; results, warnings and failures still print',
52
+ },
53
+ {
54
+ key: 'nonInteractive',
55
+ aliases: ['--non-interactive'],
56
+ summary: "Never prompt: take each prompt's documented default",
57
+ },
58
+ { key: 'cwd', aliases: ['--cwd'], value: '<path>', summary: 'Act on this directory instead of the current one' },
59
+ ];
60
+ /**
61
+ * Consume the recognised global flags wherever they appear and leave everything else —
62
+ * unknown flags included — for the subcommand. `--` stops parsing: every argument after it
63
+ * is passed through untouched.
64
+ */
65
+ function parseArgv(argv) {
66
+ const flags = {
67
+ help: false,
68
+ version: false,
69
+ dryRun: false,
70
+ force: false,
71
+ quiet: false,
72
+ nonInteractive: false,
73
+ };
74
+ let cwdOption;
75
+ let command;
76
+ const rest = [];
77
+ let passthrough = false;
78
+ for (let index = 0; index < argv.length; index += 1) {
79
+ const token = argv[index];
80
+ if (passthrough) {
81
+ rest.push(token);
82
+ continue;
83
+ }
84
+ if (token === '--') {
85
+ passthrough = true;
86
+ continue;
87
+ }
88
+ const separator = token.startsWith('--') ? token.indexOf('=') : -1;
89
+ const name = separator > 0 ? token.slice(0, separator) : token;
90
+ const inlineValue = separator > 0 ? token.slice(separator + 1) : undefined;
91
+ const option = GLOBAL_OPTIONS.find((candidate) => candidate.aliases.includes(name));
92
+ if (option === undefined) {
93
+ if (command === undefined && !token.startsWith('-'))
94
+ command = token;
95
+ else
96
+ rest.push(token);
97
+ continue;
98
+ }
99
+ if (option.value === undefined) {
100
+ if (inlineValue !== undefined)
101
+ throw new HarnessError(`${name} does not take a value`);
102
+ flags[option.key] = true;
103
+ continue;
104
+ }
105
+ let value = inlineValue;
106
+ if (value === undefined) {
107
+ index += 1;
108
+ value = argv[index];
109
+ }
110
+ if (value === undefined || value === '')
111
+ throw new HarnessError(`${name} requires ${option.value}`);
112
+ cwdOption = value;
113
+ }
114
+ return { command, argv: rest, flags, cwd: resolve(cwdOption ?? '.') };
115
+ }
116
+ /** The `Options:` rows, invocation-aligned, derived from {@link GLOBAL_OPTIONS}. */
117
+ function optionLines() {
118
+ const invocations = GLOBAL_OPTIONS.map((option) => `${option.aliases.join(', ')}${option.value === undefined ? '' : ` ${option.value}`}`);
119
+ const width = Math.max(...invocations.map((invocation) => invocation.length));
120
+ return GLOBAL_OPTIONS.map((option, index) => ` ${invocations[index].padEnd(width)} ${option.summary}`);
121
+ }
122
+ function usage() {
123
+ return [
124
+ `autonomous-sdlc-harness ${version}`,
125
+ '',
126
+ 'Usage: npx autonomous-sdlc-harness <command> [options]',
127
+ '',
128
+ 'Commands:',
129
+ ...commandListLines(),
130
+ '',
131
+ 'Options:',
132
+ ...optionLines(),
133
+ '',
134
+ "Run `npx autonomous-sdlc-harness <command> --help` for a command's own usage.",
135
+ ].join('\n');
136
+ }
137
+ function commandUsage(command) {
138
+ return [...commandSynopsis(command), '', 'Options:', ...optionLines()].join('\n');
139
+ }
140
+ /** Parse, resolve and dispatch. Returns the exit code; throws for every failure path. */
141
+ async function dispatch(rawArgv) {
142
+ const parsed = parseArgv(rawArgv);
143
+ if (parsed.command === undefined) {
144
+ if (parsed.flags.version) {
145
+ // Bare semver, no prefix, so a script can consume it directly.
146
+ console.log(version);
147
+ return EXIT.OK;
148
+ }
149
+ // No command at all is the same request as `--help`.
150
+ console.log(usage());
151
+ return EXIT.OK;
152
+ }
153
+ const command = findSubcommand(parsed.command);
154
+ if (command === undefined) {
155
+ console.error(`autonomous-sdlc-harness: unknown command '${parsed.command}'`);
156
+ console.error(usage());
157
+ return EXIT.FAILURE;
158
+ }
159
+ // `<command> --help` and `<command> --version` answer for themselves and exit 0 — they
160
+ // never reach `run`, so they stay safe to invoke against a command that writes files.
161
+ if (parsed.flags.help) {
162
+ console.log(commandUsage(command));
163
+ return EXIT.OK;
164
+ }
165
+ if (parsed.flags.version) {
166
+ console.log(version);
167
+ return EXIT.OK;
168
+ }
169
+ const context = {
170
+ argv: parsed.argv,
171
+ flags: parsed.flags,
172
+ cwd: parsed.cwd,
173
+ report: new Reporter({ quiet: parsed.flags.quiet }),
174
+ };
175
+ return command.run(context);
176
+ }
177
+ async function main(rawArgv) {
178
+ try {
179
+ return await dispatch(rawArgv);
180
+ }
181
+ catch (error) {
182
+ if (error instanceof HarnessError) {
183
+ console.error(`autonomous-sdlc-harness: ${error.message}`);
184
+ return error.exitCode;
185
+ }
186
+ const message = error instanceof Error ? error.message : String(error);
187
+ console.error(`autonomous-sdlc-harness: ${message} (unexpected)`);
188
+ return EXIT.INTERNAL;
189
+ }
190
+ }
191
+ // Set `exitCode` rather than calling `process.exit()`: on POSIX, stdout to a pipe is
192
+ // asynchronous, and exiting outright can truncate the usage block mid-write.
193
+ process.exitCode = await main(process.argv.slice(2));
194
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,GAIf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,oFAAoF;AACpF,qFAAqF;AACrF,yFAAyF;AACzF,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAwB,CAAC;AAItE;;;;;;;GAOG;AACH,MAAM,cAA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