@aipper/aiws 0.0.28 → 0.0.30

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 (267) hide show
  1. package/README.md +18 -2
  2. package/bin/aiws.js +2 -2
  3. package/dist/aiws-package.d.ts +4 -0
  4. package/dist/aiws-package.js +11 -0
  5. package/dist/aiws-package.js.map +1 -0
  6. package/dist/aiws-paths.d.ts +48 -0
  7. package/dist/aiws-paths.js +129 -0
  8. package/dist/aiws-paths.js.map +1 -0
  9. package/dist/backup.d.ts +27 -0
  10. package/dist/backup.js +125 -0
  11. package/dist/backup.js.map +1 -0
  12. package/dist/cli.d.ts +1 -0
  13. package/dist/cli.js +773 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/codex-prompts.d.ts +17 -0
  16. package/dist/codex-prompts.js +49 -0
  17. package/dist/codex-prompts.js.map +1 -0
  18. package/dist/codex-skills.d.ts +17 -0
  19. package/dist/codex-skills.js +75 -0
  20. package/dist/codex-skills.js.map +1 -0
  21. package/dist/commands/change-advice.d.ts +25 -0
  22. package/dist/commands/change-advice.js +197 -0
  23. package/dist/commands/change-advice.js.map +1 -0
  24. package/dist/commands/change-evidence-command.d.ts +29 -0
  25. package/dist/commands/change-evidence-command.js +213 -0
  26. package/dist/commands/change-evidence-command.js.map +1 -0
  27. package/dist/commands/change-evidence-entry.d.ts +16 -0
  28. package/dist/commands/change-evidence-entry.js +35 -0
  29. package/dist/commands/change-evidence-entry.js.map +1 -0
  30. package/dist/commands/change-evidence.d.ts +108 -0
  31. package/dist/commands/change-evidence.js +341 -0
  32. package/dist/commands/change-evidence.js.map +1 -0
  33. package/dist/commands/change-finish.d.ts +71 -0
  34. package/dist/commands/change-finish.js +387 -0
  35. package/dist/commands/change-finish.js.map +1 -0
  36. package/dist/commands/change-git-status.d.ts +22 -0
  37. package/dist/commands/change-git-status.js +50 -0
  38. package/dist/commands/change-git-status.js.map +1 -0
  39. package/dist/commands/change-lifecycle-entry.d.ts +29 -0
  40. package/{src → dist}/commands/change-lifecycle-entry.js +21 -28
  41. package/dist/commands/change-lifecycle-entry.js.map +1 -0
  42. package/dist/commands/change-lifecycle.d.ts +56 -0
  43. package/dist/commands/change-lifecycle.js +211 -0
  44. package/dist/commands/change-lifecycle.js.map +1 -0
  45. package/dist/commands/change-metrics-command.d.ts +12 -0
  46. package/dist/commands/change-metrics-command.js +110 -0
  47. package/dist/commands/change-metrics-command.js.map +1 -0
  48. package/dist/commands/change-next-command.d.ts +18 -0
  49. package/dist/commands/change-next-command.js +138 -0
  50. package/dist/commands/change-next-command.js.map +1 -0
  51. package/dist/commands/change-review-gates.d.ts +107 -0
  52. package/dist/commands/change-review-gates.js +329 -0
  53. package/dist/commands/change-review-gates.js.map +1 -0
  54. package/dist/commands/change-scope-gate.d.ts +21 -0
  55. package/dist/commands/change-scope-gate.js +32 -0
  56. package/dist/commands/change-scope-gate.js.map +1 -0
  57. package/dist/commands/change-start.d.ts +30 -0
  58. package/dist/commands/change-start.js +91 -0
  59. package/dist/commands/change-start.js.map +1 -0
  60. package/dist/commands/change-state-command.d.ts +3 -0
  61. package/dist/commands/change-state-command.js +32 -0
  62. package/dist/commands/change-state-command.js.map +1 -0
  63. package/dist/commands/change-status-command.d.ts +13 -0
  64. package/dist/commands/change-status-command.js +126 -0
  65. package/dist/commands/change-status-command.js.map +1 -0
  66. package/dist/commands/change-status-context.d.ts +58 -0
  67. package/dist/commands/change-status-context.js +166 -0
  68. package/dist/commands/change-status-context.js.map +1 -0
  69. package/dist/commands/change-task-stats.d.ts +24 -0
  70. package/dist/commands/change-task-stats.js +66 -0
  71. package/dist/commands/change-task-stats.js.map +1 -0
  72. package/dist/commands/change-validate-entry.d.ts +17 -0
  73. package/dist/commands/change-validate-entry.js +44 -0
  74. package/dist/commands/change-validate-entry.js.map +1 -0
  75. package/dist/commands/change-validate.d.ts +32 -0
  76. package/dist/commands/change-validate.js +128 -0
  77. package/dist/commands/change-validate.js.map +1 -0
  78. package/dist/commands/change.d.ts +322 -0
  79. package/dist/commands/change.js +1731 -0
  80. package/dist/commands/change.js.map +1 -0
  81. package/dist/commands/codex-install-prompts.d.ts +4 -0
  82. package/dist/commands/codex-install-prompts.js +68 -0
  83. package/dist/commands/codex-install-prompts.js.map +1 -0
  84. package/dist/commands/codex-install-skills.d.ts +4 -0
  85. package/dist/commands/codex-install-skills.js +74 -0
  86. package/dist/commands/codex-install-skills.js.map +1 -0
  87. package/dist/commands/codex-status-prompts.d.ts +4 -0
  88. package/dist/commands/codex-status-prompts.js +44 -0
  89. package/dist/commands/codex-status-prompts.js.map +1 -0
  90. package/dist/commands/codex-status-skills.d.ts +4 -0
  91. package/dist/commands/codex-status-skills.js +54 -0
  92. package/dist/commands/codex-status-skills.js.map +1 -0
  93. package/dist/commands/codex-uninstall-prompts.d.ts +4 -0
  94. package/dist/commands/codex-uninstall-prompts.js +51 -0
  95. package/dist/commands/codex-uninstall-prompts.js.map +1 -0
  96. package/dist/commands/codex-uninstall-skills.d.ts +4 -0
  97. package/dist/commands/codex-uninstall-skills.js +59 -0
  98. package/dist/commands/codex-uninstall-skills.js.map +1 -0
  99. package/dist/commands/dashboard.d.ts +222 -0
  100. package/dist/commands/dashboard.js +193 -0
  101. package/dist/commands/dashboard.js.map +1 -0
  102. package/dist/commands/hooks-install.d.ts +4 -0
  103. package/dist/commands/hooks-install.js +90 -0
  104. package/dist/commands/hooks-install.js.map +1 -0
  105. package/dist/commands/hooks-status.d.ts +4 -0
  106. package/dist/commands/hooks-status.js +89 -0
  107. package/dist/commands/hooks-status.js.map +1 -0
  108. package/dist/commands/init.d.ts +4 -0
  109. package/dist/commands/init.js +100 -0
  110. package/dist/commands/init.js.map +1 -0
  111. package/dist/commands/opencode-auto.d.ts +11 -0
  112. package/dist/commands/opencode-auto.js +158 -0
  113. package/dist/commands/opencode-auto.js.map +1 -0
  114. package/dist/commands/opencode-status.d.ts +4 -0
  115. package/dist/commands/opencode-status.js +75 -0
  116. package/dist/commands/opencode-status.js.map +1 -0
  117. package/dist/commands/opencode-supervise.d.ts +24 -0
  118. package/dist/commands/opencode-supervise.js +188 -0
  119. package/dist/commands/opencode-supervise.js.map +1 -0
  120. package/dist/commands/rollback.d.ts +4 -0
  121. package/dist/commands/rollback.js +12 -0
  122. package/dist/commands/rollback.js.map +1 -0
  123. package/dist/commands/update.d.ts +4 -0
  124. package/dist/commands/update.js +212 -0
  125. package/dist/commands/update.js.map +1 -0
  126. package/dist/commands/validate.d.ts +4 -0
  127. package/dist/commands/validate.js +222 -0
  128. package/dist/commands/validate.js.map +1 -0
  129. package/dist/commands/ws-commit.d.ts +5 -0
  130. package/dist/commands/ws-commit.js +39 -0
  131. package/dist/commands/ws-commit.js.map +1 -0
  132. package/dist/commands/ws-deliver.d.ts +5 -0
  133. package/dist/commands/ws-deliver.js +59 -0
  134. package/dist/commands/ws-deliver.js.map +1 -0
  135. package/dist/commands/ws-finish.d.ts +5 -0
  136. package/dist/commands/ws-finish.js +142 -0
  137. package/dist/commands/ws-finish.js.map +1 -0
  138. package/dist/commands/ws-handoff.d.ts +5 -0
  139. package/dist/commands/ws-handoff.js +35 -0
  140. package/dist/commands/ws-handoff.js.map +1 -0
  141. package/dist/commands/ws-migrate.d.ts +5 -0
  142. package/dist/commands/ws-migrate.js +41 -0
  143. package/dist/commands/ws-migrate.js.map +1 -0
  144. package/dist/commands/ws-plan-verify.d.ts +5 -0
  145. package/dist/commands/ws-plan-verify.js +38 -0
  146. package/dist/commands/ws-plan-verify.js.map +1 -0
  147. package/dist/commands/ws-pull.d.ts +5 -0
  148. package/dist/commands/ws-pull.js +26 -0
  149. package/dist/commands/ws-pull.js.map +1 -0
  150. package/dist/commands/ws-push.d.ts +5 -0
  151. package/dist/commands/ws-push.js +68 -0
  152. package/dist/commands/ws-push.js.map +1 -0
  153. package/dist/commands/ws-submodule-setup.d.ts +5 -0
  154. package/dist/commands/ws-submodule-setup.js +55 -0
  155. package/dist/commands/ws-submodule-setup.js.map +1 -0
  156. package/dist/commands/ws-verify-before-complete.d.ts +5 -0
  157. package/dist/commands/ws-verify-before-complete.js +35 -0
  158. package/dist/commands/ws-verify-before-complete.js.map +1 -0
  159. package/dist/dashboard/app.d.ts +1 -0
  160. package/dist/dashboard/app.js +370 -0
  161. package/dist/dashboard/app.js.map +1 -0
  162. package/dist/delegation/cli.d.ts +6 -0
  163. package/dist/delegation/cli.js +14 -0
  164. package/dist/delegation/cli.js.map +1 -0
  165. package/dist/delegation/index.d.ts +35 -0
  166. package/dist/delegation/index.js +118 -0
  167. package/dist/delegation/index.js.map +1 -0
  168. package/dist/errors.d.ts +8 -0
  169. package/dist/errors.js +11 -0
  170. package/dist/errors.js.map +1 -0
  171. package/dist/exec.d.ts +9 -0
  172. package/dist/exec.js +22 -0
  173. package/dist/exec.js.map +1 -0
  174. package/dist/fs.d.ts +9 -0
  175. package/dist/fs.js +62 -0
  176. package/dist/fs.js.map +1 -0
  177. package/dist/governance.d.ts +10 -0
  178. package/dist/governance.js +135 -0
  179. package/dist/governance.js.map +1 -0
  180. package/dist/hash.d.ts +3 -0
  181. package/dist/hash.js +13 -0
  182. package/dist/hash.js.map +1 -0
  183. package/dist/hooks/deploy-claude.d.ts +13 -0
  184. package/dist/hooks/deploy-claude.js +67 -0
  185. package/dist/hooks/deploy-claude.js.map +1 -0
  186. package/dist/journal.d.ts +22 -0
  187. package/dist/journal.js +112 -0
  188. package/dist/journal.js.map +1 -0
  189. package/dist/json-schema-lite.d.ts +22 -0
  190. package/dist/json-schema-lite.js +148 -0
  191. package/dist/json-schema-lite.js.map +1 -0
  192. package/dist/managed-blocks.d.ts +24 -0
  193. package/dist/managed-blocks.js +84 -0
  194. package/dist/managed-blocks.js.map +1 -0
  195. package/dist/manifest.d.ts +24 -0
  196. package/dist/manifest.js +145 -0
  197. package/dist/manifest.js.map +1 -0
  198. package/dist/opencode-env.d.ts +62 -0
  199. package/dist/opencode-env.js +178 -0
  200. package/dist/opencode-env.js.map +1 -0
  201. package/dist/path-utils.d.ts +2 -0
  202. package/dist/path-utils.js +8 -0
  203. package/dist/path-utils.js.map +1 -0
  204. package/dist/spec.d.ts +17 -0
  205. package/dist/spec.js +174 -0
  206. package/dist/spec.js.map +1 -0
  207. package/dist/template.d.ts +20 -0
  208. package/dist/template.js +123 -0
  209. package/dist/template.js.map +1 -0
  210. package/dist/workspace.d.ts +4 -0
  211. package/dist/workspace.js +19 -0
  212. package/dist/workspace.js.map +1 -0
  213. package/package.json +11 -3
  214. package/src/aiws-package.js +0 -15
  215. package/src/backup.js +0 -149
  216. package/src/cli.js +0 -647
  217. package/src/codex-prompts.js +0 -74
  218. package/src/codex-skills.js +0 -111
  219. package/src/commands/change-advice.js +0 -200
  220. package/src/commands/change-evidence-command.js +0 -242
  221. package/src/commands/change-evidence-entry.js +0 -40
  222. package/src/commands/change-evidence.js +0 -340
  223. package/src/commands/change-finish.js +0 -484
  224. package/src/commands/change-git-status.js +0 -53
  225. package/src/commands/change-lifecycle.js +0 -236
  226. package/src/commands/change-metrics-command.js +0 -110
  227. package/src/commands/change-next-command.js +0 -129
  228. package/src/commands/change-review-gates.js +0 -315
  229. package/src/commands/change-scope-gate.js +0 -34
  230. package/src/commands/change-start.js +0 -120
  231. package/src/commands/change-state-command.js +0 -40
  232. package/src/commands/change-status-command.js +0 -134
  233. package/src/commands/change-status-context.js +0 -202
  234. package/src/commands/change-task-stats.js +0 -64
  235. package/src/commands/change-validate-entry.js +0 -45
  236. package/src/commands/change-validate.js +0 -127
  237. package/src/commands/change.js +0 -2087
  238. package/src/commands/codex-install-prompts.js +0 -68
  239. package/src/commands/codex-install-skills.js +0 -74
  240. package/src/commands/codex-status-prompts.js +0 -55
  241. package/src/commands/codex-status-skills.js +0 -63
  242. package/src/commands/codex-uninstall-prompts.js +0 -55
  243. package/src/commands/codex-uninstall-skills.js +0 -62
  244. package/src/commands/dashboard.js +0 -205
  245. package/src/commands/hooks-install.js +0 -92
  246. package/src/commands/hooks-status.js +0 -95
  247. package/src/commands/init.js +0 -93
  248. package/src/commands/opencode-status.js +0 -61
  249. package/src/commands/rollback.js +0 -13
  250. package/src/commands/update.js +0 -133
  251. package/src/commands/validate.js +0 -222
  252. package/src/dashboard/app.js +0 -371
  253. package/src/errors.js +0 -15
  254. package/src/exec.js +0 -34
  255. package/src/fs.js +0 -91
  256. package/src/governance.js +0 -159
  257. package/src/hash.js +0 -25
  258. package/src/json-schema-lite.js +0 -164
  259. package/src/managed-blocks.js +0 -131
  260. package/src/manifest.js +0 -153
  261. package/src/opencode-env.js +0 -76
  262. package/src/path-utils.js +0 -20
  263. package/src/spec.js +0 -195
  264. package/src/template.js +0 -187
  265. package/src/workspace.js +0 -23
  266. /package/{src → dist}/dashboard/index.html +0 -0
  267. /package/{src → dist}/dashboard/style.css +0 -0
package/src/cli.js DELETED
@@ -1,647 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { UserError } from "./errors.js";
5
- import { initCommand } from "./commands/init.js";
6
- import { updateCommand } from "./commands/update.js";
7
- import { validateCommand } from "./commands/validate.js";
8
- import { rollbackCommand } from "./commands/rollback.js";
9
- import { codexInstallPromptsCommand } from "./commands/codex-install-prompts.js";
10
- import { codexStatusPromptsCommand } from "./commands/codex-status-prompts.js";
11
- import { codexUninstallPromptsCommand } from "./commands/codex-uninstall-prompts.js";
12
- import { codexInstallSkillsCommand } from "./commands/codex-install-skills.js";
13
- import { codexStatusSkillsCommand } from "./commands/codex-status-skills.js";
14
- import { codexUninstallSkillsCommand } from "./commands/codex-uninstall-skills.js";
15
- import { hooksInstallCommand } from "./commands/hooks-install.js";
16
- import { hooksStatusCommand } from "./commands/hooks-status.js";
17
- import { opencodeStatusCommand } from "./commands/opencode-status.js";
18
- import { dashboardServeCommand } from "./commands/dashboard.js";
19
- import {
20
- changeArchiveCommand,
21
- changeEvidenceCommand,
22
- changeFinishCommand,
23
- changeListCommand,
24
- changeNewCommand,
25
- changeNextCommand,
26
- changeStateCommand,
27
- changeStartCommand,
28
- changeStatusCommand,
29
- changeSyncCommand,
30
- changeTemplatesInitCommand,
31
- changeTemplatesWhichCommand,
32
- changeValidateCommand,
33
- metricsSummaryCommand,
34
- } from "./commands/change.js";
35
-
36
- /**
37
- * @param {string[]} argv
38
- * @returns {Promise<number>} exit code
39
- */
40
- export async function cliMain(argv) {
41
- const args = argv.slice();
42
- if (args[0] === "codex" && (args.includes("-h") || args.includes("--help"))) {
43
- printCodexHelp();
44
- return 0;
45
- }
46
- if (args[0] === "hooks" && (args.includes("-h") || args.includes("--help"))) {
47
- printHooksHelp();
48
- return 0;
49
- }
50
- if (args[0] === "opencode" && (args.includes("-h") || args.includes("--help"))) {
51
- printOpenCodeHelp();
52
- return 0;
53
- }
54
- if (args[0] === "dashboard" && (args.includes("-h") || args.includes("--help"))) {
55
- printDashboardHelp();
56
- return 0;
57
- }
58
- if (args[0] === "change" && (args.includes("-h") || args.includes("--help"))) {
59
- printChangeHelp();
60
- return 0;
61
- }
62
- if (args[0] === "metrics" && (args.includes("-h") || args.includes("--help"))) {
63
- printMetricsHelp();
64
- return 0;
65
- }
66
- if (args.length === 0 || args.includes("-h") || args.includes("--help") || args[0] === "help") {
67
- printHelp();
68
- return 0;
69
- }
70
- if (args[0] === "--version" || args[0] === "-v") {
71
- console.log(getAiwsVersion());
72
- return 0;
73
- }
74
-
75
- const cmd = args.shift();
76
- if (!cmd) {
77
- printHelp();
78
- return 0;
79
- }
80
-
81
- switch (cmd) {
82
- case "init": {
83
- const { positionals, options } = parseArgs(args, {
84
- template: { type: "string" },
85
- });
86
- const targetPath = positionals[0] ?? ".";
87
- const templateId = options.template ?? "workspace";
88
- await initCommand({ targetPath, templateId });
89
- return 0;
90
- }
91
- case "update": {
92
- const { positionals } = parseArgs(args, {});
93
- const targetPath = positionals[0] ?? ".";
94
- await updateCommand({ targetPath });
95
- return 0;
96
- }
97
- case "validate": {
98
- const { positionals, options } = parseArgs(args, {
99
- stamp: { type: "boolean" },
100
- });
101
- const targetPath = positionals[0] ?? ".";
102
- await validateCommand({ targetPath, stamp: options.stamp === true });
103
- return 0;
104
- }
105
- case "rollback": {
106
- const { positionals } = parseArgs(args, {});
107
- if (positionals.length === 0) {
108
- throw new UserError("rollback requires <timestamp|latest>", { details: "Usage: aiws rollback [path] <timestamp|latest>" });
109
- }
110
- let targetPath = ".";
111
- let stamp = "";
112
- if (positionals.length === 1) {
113
- stamp = positionals[0] ?? "";
114
- } else {
115
- targetPath = positionals[0] ?? ".";
116
- stamp = positionals[1] ?? "";
117
- }
118
- await rollbackCommand({ targetPath, stamp });
119
- return 0;
120
- }
121
- case "codex": {
122
- const sub = args.shift();
123
- if (!sub || sub === "help" || sub === "--help" || sub === "-h") {
124
- printCodexHelp();
125
- return 0;
126
- }
127
- switch (sub) {
128
- case "install-skills": {
129
- const { options } = parseArgs(args, {
130
- template: { type: "string" },
131
- dir: { type: "string" },
132
- force: { type: "boolean" },
133
- "dry-run": { type: "boolean" },
134
- });
135
- await codexInstallSkillsCommand({
136
- templateId: options.template ?? "workspace",
137
- skillsDir: options.dir,
138
- force: options.force === true,
139
- dryRun: options["dry-run"] === true,
140
- });
141
- return 0;
142
- }
143
- case "status-skills": {
144
- const { options } = parseArgs(args, {
145
- template: { type: "string" },
146
- dir: { type: "string" },
147
- });
148
- await codexStatusSkillsCommand({
149
- templateId: options.template ?? "workspace",
150
- skillsDir: options.dir,
151
- });
152
- return 0;
153
- }
154
- case "uninstall-skills": {
155
- const { options } = parseArgs(args, {
156
- template: { type: "string" },
157
- dir: { type: "string" },
158
- });
159
- await codexUninstallSkillsCommand({
160
- templateId: options.template ?? "workspace",
161
- skillsDir: options.dir,
162
- });
163
- return 0;
164
- }
165
- case "install-prompts": {
166
- const { options } = parseArgs(args, {
167
- template: { type: "string" },
168
- dir: { type: "string" },
169
- force: { type: "boolean" },
170
- "dry-run": { type: "boolean" },
171
- });
172
- await codexInstallPromptsCommand({
173
- templateId: options.template ?? "workspace",
174
- promptsDir: options.dir,
175
- force: options.force === true,
176
- dryRun: options["dry-run"] === true,
177
- });
178
- return 0;
179
- }
180
- case "status": {
181
- const { options } = parseArgs(args, {
182
- template: { type: "string" },
183
- dir: { type: "string" },
184
- });
185
- await codexStatusPromptsCommand({
186
- templateId: options.template ?? "workspace",
187
- promptsDir: options.dir,
188
- });
189
- return 0;
190
- }
191
- case "uninstall-prompts": {
192
- const { options } = parseArgs(args, {
193
- template: { type: "string" },
194
- dir: { type: "string" },
195
- });
196
- await codexUninstallPromptsCommand({
197
- templateId: options.template ?? "workspace",
198
- promptsDir: options.dir,
199
- });
200
- return 0;
201
- }
202
- default:
203
- throw new UserError(`Unknown codex subcommand: ${sub}`, { details: "Use `aiws codex --help` to see available subcommands." });
204
- }
205
- }
206
- case "hooks": {
207
- const sub = args.shift();
208
- if (!sub || sub === "help" || sub === "--help" || sub === "-h") {
209
- printHooksHelp();
210
- return 0;
211
- }
212
- switch (sub) {
213
- case "install": {
214
- const { positionals } = parseArgs(args, {});
215
- const targetPath = positionals[0] ?? ".";
216
- await hooksInstallCommand({ targetPath });
217
- return 0;
218
- }
219
- case "status": {
220
- const { positionals } = parseArgs(args, {});
221
- const targetPath = positionals[0] ?? ".";
222
- await hooksStatusCommand({ targetPath });
223
- return 0;
224
- }
225
- default:
226
- throw new UserError(`Unknown hooks subcommand: ${sub}`, { details: "Use `aiws hooks --help` to see available subcommands." });
227
- }
228
- }
229
- case "dashboard": {
230
- const sub = args.shift();
231
- if (!sub || sub === "help" || sub === "--help" || sub === "-h") {
232
- printDashboardHelp();
233
- return 0;
234
- }
235
- switch (sub) {
236
- case "serve": {
237
- const { options } = parseArgs(args, {
238
- host: { type: "string" },
239
- port: { type: "string" },
240
- });
241
- const host = options.host ?? "127.0.0.1";
242
- const port = options.port ? Number.parseInt(String(options.port), 10) : 3456;
243
- await dashboardServeCommand({ host, port });
244
- return 0;
245
- }
246
- default:
247
- throw new UserError(`Unknown dashboard subcommand: ${sub}`, { details: "Use `aiws dashboard --help` to see available subcommands." });
248
- }
249
- }
250
- case "opencode": {
251
- const sub = args.shift();
252
- if (!sub || sub === "help" || sub === "--help" || sub === "-h") {
253
- printOpenCodeHelp();
254
- return 0;
255
- }
256
- switch (sub) {
257
- case "status": {
258
- const { positionals } = parseArgs(args, {});
259
- const targetPath = positionals[0] ?? ".";
260
- await opencodeStatusCommand({ targetPath });
261
- return 0;
262
- }
263
- default:
264
- throw new UserError(`Unknown opencode subcommand: ${sub}`, { details: "Use `aiws opencode --help` to see available subcommands." });
265
- }
266
- }
267
- case "change": {
268
- const sub = args.shift();
269
- if (!sub || sub === "help" || sub === "--help" || sub === "-h") {
270
- printChangeHelp();
271
- return 0;
272
- }
273
- switch (sub) {
274
- case "list": {
275
- await changeListCommand();
276
- return 0;
277
- }
278
- case "start": {
279
- const { positionals, options } = parseArgs(args, {
280
- title: { type: "string" },
281
- "no-design": { type: "boolean" },
282
- hooks: { type: "boolean" },
283
- "no-switch": { type: "boolean" },
284
- switch: { type: "boolean" },
285
- "allow-dirty": { type: "boolean" },
286
- worktree: { type: "boolean" },
287
- "worktree-dir": { type: "string" },
288
- submodules: { type: "boolean" },
289
- });
290
- const changeId = positionals[0] ?? "";
291
- if (!changeId)
292
- throw new UserError("change start requires <change-id>", {
293
- details:
294
- "Usage: aiws change start <change-id> [--title <title>] [--no-design] [--hooks] [--no-switch] [--switch] [--allow-dirty] [--worktree] [--worktree-dir <path>] [--submodules]",
295
- });
296
- await changeStartCommand({
297
- changeId,
298
- title: options.title,
299
- noDesign: options["no-design"] === true,
300
- enableHooks: options.hooks === true,
301
- noSwitch: options["no-switch"] === true,
302
- forceSwitch: options.switch === true,
303
- allowDirty: options["allow-dirty"] === true,
304
- worktree: options.worktree === true,
305
- worktreeDir: options["worktree-dir"],
306
- submodules: options.submodules === true,
307
- });
308
- return 0;
309
- }
310
- case "new": {
311
- const { positionals, options } = parseArgs(args, {
312
- title: { type: "string" },
313
- "no-design": { type: "boolean" },
314
- });
315
- const changeId = positionals[0] ?? "";
316
- if (!changeId) throw new UserError("change new requires <change-id>", { details: "Usage: aiws change new <change-id> [--title <title>] [--no-design]" });
317
- await changeNewCommand({
318
- changeId,
319
- title: options.title,
320
- noDesign: options["no-design"] === true,
321
- });
322
- return 0;
323
- }
324
- case "status": {
325
- const { positionals } = parseArgs(args, {});
326
- const changeId = positionals[0];
327
- await changeStatusCommand({ changeId });
328
- return 0;
329
- }
330
- case "next": {
331
- const { positionals } = parseArgs(args, {});
332
- const changeId = positionals[0];
333
- await changeNextCommand({ changeId });
334
- return 0;
335
- }
336
- case "validate": {
337
- const { positionals, options } = parseArgs(args, {
338
- strict: { type: "boolean" },
339
- "allow-truth-drift": { type: "boolean" },
340
- "check-evidence": { type: "boolean" },
341
- "check-scope": { type: "boolean" },
342
- });
343
- const changeId = positionals[0];
344
- await changeValidateCommand({
345
- changeId,
346
- strict: options.strict === true,
347
- allowTruthDrift: options["allow-truth-drift"] === true,
348
- checkEvidence: options["check-evidence"] === true,
349
- checkScope: options["check-scope"] === true,
350
- });
351
- return 0;
352
- }
353
- case "evidence": {
354
- const { positionals, options } = parseArgs(args, {
355
- "no-validate": { type: "boolean" },
356
- "allow-fail": { type: "boolean" },
357
- });
358
- const changeId = positionals[0];
359
- await changeEvidenceCommand({
360
- changeId,
361
- noValidate: options["no-validate"] === true,
362
- allowFail: options["allow-fail"] === true,
363
- });
364
- return 0;
365
- }
366
- case "state": {
367
- const { positionals, options } = parseArgs(args, { write: { type: "boolean" } });
368
- const changeId = positionals[0];
369
- await changeStateCommand({ changeId, write: options.write === true });
370
- return 0;
371
- }
372
- case "sync": {
373
- const { positionals } = parseArgs(args, {});
374
- const changeId = positionals[0];
375
- await changeSyncCommand({ changeId });
376
- return 0;
377
- }
378
- case "archive": {
379
- const { positionals, options } = parseArgs(args, {
380
- date: { type: "string" },
381
- force: { type: "boolean" },
382
- });
383
- const changeId = positionals[0];
384
- await changeArchiveCommand({
385
- changeId,
386
- datePrefix: options.date,
387
- force: options.force === true,
388
- });
389
- return 0;
390
- }
391
- case "finish": {
392
- const { positionals, options } = parseArgs(args, {
393
- into: { type: "string" },
394
- base: { type: "string" },
395
- push: { type: "boolean" },
396
- remote: { type: "string" },
397
- });
398
- const changeId = positionals[0];
399
- await changeFinishCommand({
400
- changeId,
401
- into: options.into,
402
- base: options.base,
403
- push: options.push === true,
404
- remote: options.remote,
405
- });
406
- return 0;
407
- }
408
- case "templates": {
409
- const templatesSub = args.shift();
410
- if (!templatesSub) throw new UserError("change templates requires <which|init>", { details: "Usage: aiws change templates which|init" });
411
- if (templatesSub === "which") {
412
- const { positionals } = parseArgs(args, {});
413
- if (positionals.length > 0) throw new UserError("change templates which takes no args");
414
- await changeTemplatesWhichCommand();
415
- return 0;
416
- }
417
- if (templatesSub === "init") {
418
- const { positionals } = parseArgs(args, {});
419
- if (positionals.length > 0) throw new UserError("change templates init takes no args");
420
- await changeTemplatesInitCommand();
421
- return 0;
422
- }
423
- throw new UserError(`Unknown change templates subcommand: ${templatesSub}`, { details: "Use `aiws change --help` to see available commands." });
424
- }
425
- default:
426
- throw new UserError(`Unknown change subcommand: ${sub}`, { details: "Use `aiws change --help` to see available subcommands." });
427
- }
428
- }
429
- case "metrics": {
430
- const sub = args.shift();
431
- if (!sub || sub === "help" || sub === "--help" || sub === "-h") {
432
- printMetricsHelp();
433
- return 0;
434
- }
435
- if (sub === "summary") {
436
- const { options } = parseArgs(args, { since: { type: "string" } });
437
- await metricsSummaryCommand({ since: options.since });
438
- return 0;
439
- }
440
- throw new UserError(`Unknown metrics subcommand: ${sub}`, { details: "Use `aiws metrics --help` to see available subcommands." });
441
- }
442
- default:
443
- throw new UserError(`Unknown command: ${cmd}`, { details: "Use --help to see available commands." });
444
- }
445
- }
446
-
447
- function printHelp() {
448
- console.log(`aiws (WORK IN PROGRESS)
449
-
450
- Usage:
451
- aiws init [path] [--template <id>]
452
- aiws update [path]
453
- aiws validate [path] [--stamp]
454
- aiws rollback [path] <timestamp|latest>
455
- aiws change <subcommand>
456
- aiws metrics <subcommand>
457
- aiws dashboard <subcommand>
458
- aiws opencode <subcommand>
459
- aiws codex <subcommand>
460
- aiws hooks <subcommand>
461
-
462
- Options:
463
- --template <id> Template id (default: workspace)
464
- --stamp Write evidence stamp (validate)
465
- -h, --help Show help
466
- -v, --version Show version
467
- `);
468
- }
469
-
470
- function printCodexHelp() {
471
- console.log(`aiws codex
472
-
473
- Usage:
474
- aiws codex install-skills [--template <id>] [--dir <path>] [--force] [--dry-run]
475
- aiws codex status-skills [--template <id>] [--dir <path>]
476
- aiws codex uninstall-skills [--template <id>] [--dir <path>]
477
- aiws codex install-prompts [--template <id>] [--dir <path>] [--force] [--dry-run]
478
- aiws codex status [--template <id>] [--dir <path>]
479
- aiws codex uninstall-prompts [--template <id>] [--dir <path>]
480
-
481
- Notes:
482
- - Prefer repo skills: .agents/skills (no install needed)
483
- - Prefer global skills over legacy prompts
484
- - Default skills dir: ~/.agents/skills
485
- - Compatibility/test override: $CODEX_HOME/.agents/skills or --dir <path>
486
- - install-prompts is legacy (prompts are deprecated)
487
- - Default target dir: ~/.codex/prompts
488
- - If CODEX_HOME is set: $CODEX_HOME/prompts
489
- `);
490
- }
491
-
492
- function printHooksHelp() {
493
- console.log(`aiws hooks
494
-
495
- Usage:
496
- aiws hooks install [path]
497
- aiws hooks status [path]
498
-
499
- Notes:
500
- - install will set: git config core.hooksPath .githooks
501
- - hooks can be bypassed with: WS_CHANGE_HOOK_BYPASS=1
502
- `);
503
- }
504
-
505
- function printOpenCodeHelp() {
506
- console.log(`aiws opencode
507
-
508
- Usage:
509
- aiws opencode status [path]
510
-
511
- Notes:
512
- - Detects project-local .opencode/ and oh-my-opencode (oMo) config.
513
- - Helps verify whether AIWS OpenCode skills should prefer oMo agents or fallback to standard-opencode.
514
- `);
515
- }
516
-
517
- function printDashboardHelp() {
518
- console.log(`aiws dashboard
519
-
520
- Usage:
521
- aiws dashboard serve [--host 127.0.0.1] [--port 3456]
522
-
523
- Notes:
524
- - Local-only dashboard, no external dependencies.
525
- - Dashboard also exposes workflow governance data sourced from @aipper/aiws-spec:
526
- /api/changes, /api/workflow-stages, /api/change/<id>/validate?strict=1
527
- - Recommended: run change quality gate first (AI tools: $ws-plan-verify):
528
- aiws change validate <change-id> --strict
529
- `);
530
- }
531
-
532
- function printChangeHelp() {
533
- console.log(`aiws change
534
-
535
- Usage:
536
- aiws change list
537
- aiws change start <change-id> [--title <title>] [--no-design] [--hooks] [--no-switch] [--switch] [--allow-dirty] [--worktree] [--worktree-dir <path>]
538
- aiws change finish [change-id] [--into <branch> | --base <branch>] [--push] [--remote <name>]
539
- aiws change new <change-id> [--title <title>] [--no-design]
540
- aiws change status [change-id]
541
- aiws change next [change-id]
542
- aiws change validate [change-id] [--strict] [--allow-truth-drift] [--check-evidence] [--check-scope]
543
- aiws change evidence [change-id] [--no-validate] [--allow-fail]
544
- aiws change state [change-id] [--write]
545
- aiws change sync [change-id]
546
- aiws change archive [change-id] [--date YYYY-MM-DD] [--force]
547
- aiws change templates which
548
- aiws change templates init
549
-
550
- Notes:
551
- - change-id must be kebab-case: ^[a-z0-9]+(-[a-z0-9]+)*$
552
- - If your git branch matches change/<change-id> (or changes/ws/ws-change prefixes),
553
- you can omit <change-id> for status/next/validate/sync/archive/finish.
554
- - Execution quality gate first: aiws change validate [change-id] --strict
555
- (equivalent to running $ws-plan-verify in AI tools).
556
- - status/next now prioritize quality-gate guidance before coding ($ws-dev-lite / $ws-dev).
557
- - start refuses to switch/create worktree with a dirty working tree (unless --allow-dirty).
558
- - finish --push is submodule-aware: when .gitmodules exists it pushes submodules first, then the target branch, then safely cleans the separate change worktree if possible.
559
- - If .gitmodules exists and you didn't specify --switch/--no-switch/--worktree,
560
- start will prefer --worktree (fallback: --no-switch) to avoid switching the superproject branch.
561
- - archive runs strict validation and (by default) requires all tasks checked.
562
- - archive --force also bypasses truth drift gating (not recommended).
563
- `);
564
- }
565
-
566
- function printMetricsHelp() {
567
- console.log(`aiws metrics
568
-
569
- Usage:
570
- aiws metrics summary [--since YYYY-MM-DD]
571
-
572
- Notes:
573
- - Reads changes/*/metrics.json (and changes/archive/*/metrics.json) and prints a best-effort summary.
574
- `);
575
- }
576
-
577
- /**
578
- * Minimal argv parser:
579
- * - supports: --k=v, --k v
580
- * - collects unknown flags as error
581
- *
582
- * @param {string[]} argv
583
- * @param {Record<string, { type: "string" | "boolean" }>} schema
584
- * @returns {{ positionals: string[], options: Record<string, any> }}
585
- */
586
- function parseArgs(argv, schema) {
587
- /** @type {string[]} */
588
- const positionals = [];
589
- /** @type {Record<string, any>} */
590
- const options = {};
591
-
592
- for (let i = 0; i < argv.length; i++) {
593
- const a = argv[i] ?? "";
594
- if (!a.startsWith("-")) {
595
- positionals.push(a);
596
- continue;
597
- }
598
- if (a === "--") {
599
- positionals.push(...argv.slice(i + 1));
600
- break;
601
- }
602
- if (!a.startsWith("--")) {
603
- throw new UserError(`Unknown option: ${a}`);
604
- }
605
- const eq = a.indexOf("=");
606
- const key = (eq === -1 ? a.slice(2) : a.slice(2, eq)).trim();
607
- if (!schema[key]) {
608
- throw new UserError(`Unknown option: --${key}`);
609
- }
610
- const type = schema[key]?.type;
611
- if (type === "boolean") {
612
- if (eq !== -1) {
613
- const raw = a.slice(eq + 1).trim().toLowerCase();
614
- options[key] = raw === "1" || raw === "true" || raw === "yes" || raw === "y" || raw === "on";
615
- } else {
616
- options[key] = true;
617
- }
618
- continue;
619
- }
620
-
621
- let value = "";
622
- if (eq !== -1) {
623
- value = a.slice(eq + 1);
624
- } else {
625
- const next = argv[i + 1];
626
- if (!next || next.startsWith("-")) {
627
- throw new UserError(`Missing value for --${key}`);
628
- }
629
- value = next;
630
- i++;
631
- }
632
- options[key] = value;
633
- }
634
-
635
- return { positionals, options };
636
- }
637
-
638
- function getAiwsVersion() {
639
- const here = path.dirname(fileURLToPath(import.meta.url));
640
- const pkgPath = path.resolve(here, "../package.json");
641
- try {
642
- const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
643
- return String(pkg.version || "").trim() || "0.0.0";
644
- } catch {
645
- return "0.0.0";
646
- }
647
- }