@aipper/aiws 0.0.29 → 0.0.31

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