agentera 0.0.0 → 3.0.0-dev.1

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 (256) hide show
  1. package/README.md +6 -45
  2. package/bundle/.agentera-npx-bundle.json +4 -0
  3. package/bundle/references/adapters/cursor.md +213 -0
  4. package/bundle/references/adapters/opencode.md +530 -0
  5. package/bundle/references/adapters/package-manifest-interface-model.yaml +337 -0
  6. package/bundle/references/adapters/package-registry.yaml +247 -0
  7. package/bundle/references/adapters/package-surface-characterization.md +48 -0
  8. package/bundle/references/adapters/runtime-adapter-characterization.md +79 -0
  9. package/bundle/references/adapters/runtime-adapter-interface-model.yaml +200 -0
  10. package/bundle/references/adapters/runtime-adapter-registry.yaml +548 -0
  11. package/bundle/references/adapters/runtime-feature-parity.md +189 -0
  12. package/bundle/references/analysis/benchmark.md +267 -0
  13. package/bundle/references/analysis/startup-measurement-contract.yaml +424 -0
  14. package/bundle/references/artifacts/artifact-registry-interface-model.yaml +288 -0
  15. package/bundle/references/cli/agent-ready-state-contract.yaml +950 -0
  16. package/bundle/references/cli/app-lifecycle-vocabulary.yaml +241 -0
  17. package/bundle/references/cli/audience-namespace-cli-migration.yaml +355 -0
  18. package/bundle/references/cli/bundle-skill-vocabulary.yaml +278 -0
  19. package/bundle/references/cli/capability-instruction-contract.yaml +123 -0
  20. package/bundle/references/cli/capability-tool-classification.yaml +53 -0
  21. package/bundle/references/cli/routing-execution-vocabulary.yaml +281 -0
  22. package/bundle/references/cli/update-channels.yaml +147 -0
  23. package/bundle/references/cli/vocabulary-index.yaml +160 -0
  24. package/bundle/references/cli/vocabulary.md +566 -0
  25. package/bundle/references/meta/documentation-inventory.md +43 -0
  26. package/bundle/references/v1-section-mapping.md +47 -0
  27. package/bundle/registry.json +39 -0
  28. package/bundle/skills/agentera/.claude-plugin/plugin.json +27 -0
  29. package/bundle/skills/agentera/SKILL.md +470 -0
  30. package/bundle/skills/agentera/agents/dokumentera.toml +6 -0
  31. package/bundle/skills/agentera/agents/hej.toml +6 -0
  32. package/bundle/skills/agentera/agents/inspektera.toml +6 -0
  33. package/bundle/skills/agentera/agents/inspirera.toml +6 -0
  34. package/bundle/skills/agentera/agents/optimera.toml +6 -0
  35. package/bundle/skills/agentera/agents/orkestrera.toml +6 -0
  36. package/bundle/skills/agentera/agents/planera.toml +6 -0
  37. package/bundle/skills/agentera/agents/profilera.toml +6 -0
  38. package/bundle/skills/agentera/agents/realisera.toml +6 -0
  39. package/bundle/skills/agentera/agents/resonera.toml +6 -0
  40. package/bundle/skills/agentera/agents/visionera.toml +6 -0
  41. package/bundle/skills/agentera/agents/visualisera.toml +6 -0
  42. package/bundle/skills/agentera/capabilities/dokumentera/instructions.md +428 -0
  43. package/bundle/skills/agentera/capabilities/dokumentera/schemas/artifacts.yaml +73 -0
  44. package/bundle/skills/agentera/capabilities/dokumentera/schemas/exit.yaml +35 -0
  45. package/bundle/skills/agentera/capabilities/dokumentera/schemas/triggers.yaml +35 -0
  46. package/bundle/skills/agentera/capabilities/dokumentera/schemas/validation.yaml +139 -0
  47. package/bundle/skills/agentera/capabilities/hej/instructions.md +331 -0
  48. package/bundle/skills/agentera/capabilities/hej/schemas/artifacts.yaml +69 -0
  49. package/bundle/skills/agentera/capabilities/hej/schemas/exit.yaml +32 -0
  50. package/bundle/skills/agentera/capabilities/hej/schemas/triggers.yaml +58 -0
  51. package/bundle/skills/agentera/capabilities/hej/schemas/validation.yaml +55 -0
  52. package/bundle/skills/agentera/capabilities/inspektera/instructions.md +514 -0
  53. package/bundle/skills/agentera/capabilities/inspektera/schemas/artifacts.yaml +76 -0
  54. package/bundle/skills/agentera/capabilities/inspektera/schemas/exit.yaml +36 -0
  55. package/bundle/skills/agentera/capabilities/inspektera/schemas/triggers.yaml +38 -0
  56. package/bundle/skills/agentera/capabilities/inspektera/schemas/validation.yaml +113 -0
  57. package/bundle/skills/agentera/capabilities/inspirera/instructions.md +280 -0
  58. package/bundle/skills/agentera/capabilities/inspirera/schemas/artifacts.yaml +24 -0
  59. package/bundle/skills/agentera/capabilities/inspirera/schemas/exit.yaml +33 -0
  60. package/bundle/skills/agentera/capabilities/inspirera/schemas/triggers.yaml +34 -0
  61. package/bundle/skills/agentera/capabilities/inspirera/schemas/validation.yaml +58 -0
  62. package/bundle/skills/agentera/capabilities/optimera/instructions.md +437 -0
  63. package/bundle/skills/agentera/capabilities/optimera/schemas/artifacts.yaml +69 -0
  64. package/bundle/skills/agentera/capabilities/optimera/schemas/exit.yaml +35 -0
  65. package/bundle/skills/agentera/capabilities/optimera/schemas/triggers.yaml +39 -0
  66. package/bundle/skills/agentera/capabilities/optimera/schemas/validation.yaml +91 -0
  67. package/bundle/skills/agentera/capabilities/orkestrera/instructions.md +433 -0
  68. package/bundle/skills/agentera/capabilities/orkestrera/schemas/artifacts.yaml +64 -0
  69. package/bundle/skills/agentera/capabilities/orkestrera/schemas/exit.yaml +34 -0
  70. package/bundle/skills/agentera/capabilities/orkestrera/schemas/triggers.yaml +42 -0
  71. package/bundle/skills/agentera/capabilities/orkestrera/schemas/validation.yaml +107 -0
  72. package/bundle/skills/agentera/capabilities/planera/instructions.md +368 -0
  73. package/bundle/skills/agentera/capabilities/planera/schemas/artifacts.yaml +62 -0
  74. package/bundle/skills/agentera/capabilities/planera/schemas/exit.yaml +33 -0
  75. package/bundle/skills/agentera/capabilities/planera/schemas/triggers.yaml +34 -0
  76. package/bundle/skills/agentera/capabilities/planera/schemas/validation.yaml +61 -0
  77. package/bundle/skills/agentera/capabilities/profilera/instructions.md +419 -0
  78. package/bundle/skills/agentera/capabilities/profilera/schemas/artifacts.yaml +18 -0
  79. package/bundle/skills/agentera/capabilities/profilera/schemas/exit.yaml +34 -0
  80. package/bundle/skills/agentera/capabilities/profilera/schemas/triggers.yaml +45 -0
  81. package/bundle/skills/agentera/capabilities/profilera/schemas/validation.yaml +57 -0
  82. package/bundle/skills/agentera/capabilities/realisera/instructions.md +403 -0
  83. package/bundle/skills/agentera/capabilities/realisera/schemas/artifacts.yaml +80 -0
  84. package/bundle/skills/agentera/capabilities/realisera/schemas/exit.yaml +35 -0
  85. package/bundle/skills/agentera/capabilities/realisera/schemas/triggers.yaml +39 -0
  86. package/bundle/skills/agentera/capabilities/realisera/schemas/validation.yaml +110 -0
  87. package/bundle/skills/agentera/capabilities/resonera/instructions.md +329 -0
  88. package/bundle/skills/agentera/capabilities/resonera/schemas/artifacts.yaml +47 -0
  89. package/bundle/skills/agentera/capabilities/resonera/schemas/exit.yaml +35 -0
  90. package/bundle/skills/agentera/capabilities/resonera/schemas/triggers.yaml +46 -0
  91. package/bundle/skills/agentera/capabilities/resonera/schemas/validation.yaml +77 -0
  92. package/bundle/skills/agentera/capabilities/visionera/instructions.md +309 -0
  93. package/bundle/skills/agentera/capabilities/visionera/schemas/artifacts.yaml +57 -0
  94. package/bundle/skills/agentera/capabilities/visionera/schemas/exit.yaml +35 -0
  95. package/bundle/skills/agentera/capabilities/visionera/schemas/triggers.yaml +41 -0
  96. package/bundle/skills/agentera/capabilities/visionera/schemas/validation.yaml +74 -0
  97. package/bundle/skills/agentera/capabilities/visualisera/instructions.md +400 -0
  98. package/bundle/skills/agentera/capabilities/visualisera/schemas/artifacts.yaml +44 -0
  99. package/bundle/skills/agentera/capabilities/visualisera/schemas/exit.yaml +34 -0
  100. package/bundle/skills/agentera/capabilities/visualisera/schemas/triggers.yaml +33 -0
  101. package/bundle/skills/agentera/capabilities/visualisera/schemas/validation.yaml +80 -0
  102. package/bundle/skills/agentera/capability_schema_contract.yaml +385 -0
  103. package/bundle/skills/agentera/protocol.yaml +463 -0
  104. package/bundle/skills/agentera/references/contract.md +1039 -0
  105. package/bundle/skills/agentera/schemas/artifacts/changelog.yaml +60 -0
  106. package/bundle/skills/agentera/schemas/artifacts/decisions.yaml +461 -0
  107. package/bundle/skills/agentera/schemas/artifacts/design.yaml +55 -0
  108. package/bundle/skills/agentera/schemas/artifacts/docs.yaml +402 -0
  109. package/bundle/skills/agentera/schemas/artifacts/experiments.yaml +373 -0
  110. package/bundle/skills/agentera/schemas/artifacts/health.yaml +484 -0
  111. package/bundle/skills/agentera/schemas/artifacts/objective.yaml +399 -0
  112. package/bundle/skills/agentera/schemas/artifacts/plan.yaml +342 -0
  113. package/bundle/skills/agentera/schemas/artifacts/progress.yaml +325 -0
  114. package/bundle/skills/agentera/schemas/artifacts/todo.yaml +110 -0
  115. package/bundle/skills/agentera/schemas/artifacts/vision.yaml +262 -0
  116. package/bundle/skills/hej/.claude-plugin/plugin.json +6 -0
  117. package/bundle/skills/hej/SKILL.md +69 -0
  118. package/bundle/skills/hej/agents/hej.toml +11 -0
  119. package/bundle/skills/hej/agents/openai.yaml +8 -0
  120. package/dist/analytics/extractCorpus.js +1791 -0
  121. package/dist/analytics/extractCorpus.js.map +1 -0
  122. package/dist/analytics/usageStats.js +487 -0
  123. package/dist/analytics/usageStats.js.map +1 -0
  124. package/dist/bin/agentera.js +4 -0
  125. package/dist/bin/agentera.js.map +1 -0
  126. package/dist/cli/appContext.js +226 -0
  127. package/dist/cli/appContext.js.map +1 -0
  128. package/dist/cli/argvalidate.js +41 -0
  129. package/dist/cli/argvalidate.js.map +1 -0
  130. package/dist/cli/capabilityContext.js +2421 -0
  131. package/dist/cli/capabilityContext.js.map +1 -0
  132. package/dist/cli/commands/backfill.js +84 -0
  133. package/dist/cli/commands/backfill.js.map +1 -0
  134. package/dist/cli/commands/capability.js +44 -0
  135. package/dist/cli/commands/capability.js.map +1 -0
  136. package/dist/cli/commands/compact.js +148 -0
  137. package/dist/cli/commands/compact.js.map +1 -0
  138. package/dist/cli/commands/doctor.js +180 -0
  139. package/dist/cli/commands/doctor.js.map +1 -0
  140. package/dist/cli/commands/lint.js +179 -0
  141. package/dist/cli/commands/lint.js.map +1 -0
  142. package/dist/cli/commands/prime.js +544 -0
  143. package/dist/cli/commands/prime.js.map +1 -0
  144. package/dist/cli/commands/query.js +346 -0
  145. package/dist/cli/commands/query.js.map +1 -0
  146. package/dist/cli/commands/report.js +210 -0
  147. package/dist/cli/commands/report.js.map +1 -0
  148. package/dist/cli/commands/schema.js +306 -0
  149. package/dist/cli/commands/schema.js.map +1 -0
  150. package/dist/cli/commands/state.js +1012 -0
  151. package/dist/cli/commands/state.js.map +1 -0
  152. package/dist/cli/commands/upgrade.js +48 -0
  153. package/dist/cli/commands/upgrade.js.map +1 -0
  154. package/dist/cli/commands/validate.js +519 -0
  155. package/dist/cli/commands/validate.js.map +1 -0
  156. package/dist/cli/commands/verify.js +204 -0
  157. package/dist/cli/commands/verify.js.map +1 -0
  158. package/dist/cli/dispatch.js +958 -0
  159. package/dist/cli/dispatch.js.map +1 -0
  160. package/dist/cli/orientation.js +595 -0
  161. package/dist/cli/orientation.js.map +1 -0
  162. package/dist/cli/prime-blob.js +3 -0
  163. package/dist/cli/prime-blob.js.map +1 -0
  164. package/dist/cli/stateQuery.js +292 -0
  165. package/dist/cli/stateQuery.js.map +1 -0
  166. package/dist/cli/structured.js +18 -0
  167. package/dist/cli/structured.js.map +1 -0
  168. package/dist/core/difflib.js +274 -0
  169. package/dist/core/difflib.js.map +1 -0
  170. package/dist/core/git.js +43 -0
  171. package/dist/core/git.js.map +1 -0
  172. package/dist/core/paths.js +50 -0
  173. package/dist/core/paths.js.map +1 -0
  174. package/dist/core/pyjson.js +101 -0
  175. package/dist/core/pyjson.js.map +1 -0
  176. package/dist/core/sourceRoot.js +72 -0
  177. package/dist/core/sourceRoot.js.map +1 -0
  178. package/dist/core/toml.js +11 -0
  179. package/dist/core/toml.js.map +1 -0
  180. package/dist/core/yaml.js +25 -0
  181. package/dist/core/yaml.js.map +1 -0
  182. package/dist/eval/evalSkills.js +258 -0
  183. package/dist/eval/evalSkills.js.map +1 -0
  184. package/dist/eval/semanticEval.js +148 -0
  185. package/dist/eval/semanticEval.js.map +1 -0
  186. package/dist/eval/semanticFixtures.js +227 -0
  187. package/dist/eval/semanticFixtures.js.map +1 -0
  188. package/dist/hooks/common.js +160 -0
  189. package/dist/hooks/common.js.map +1 -0
  190. package/dist/hooks/compaction.js +935 -0
  191. package/dist/hooks/compaction.js.map +1 -0
  192. package/dist/hooks/cursorPreToolUse.js +19 -0
  193. package/dist/hooks/cursorPreToolUse.js.map +1 -0
  194. package/dist/hooks/cursorSessionStart.js +71 -0
  195. package/dist/hooks/cursorSessionStart.js.map +1 -0
  196. package/dist/hooks/sessionStart.js +209 -0
  197. package/dist/hooks/sessionStart.js.map +1 -0
  198. package/dist/hooks/sessionStop.js +212 -0
  199. package/dist/hooks/sessionStop.js.map +1 -0
  200. package/dist/hooks/validateArtifact.js +933 -0
  201. package/dist/hooks/validateArtifact.js.map +1 -0
  202. package/dist/registries/artifactRegistry.js +206 -0
  203. package/dist/registries/artifactRegistry.js.map +1 -0
  204. package/dist/registries/capabilityContract.js +310 -0
  205. package/dist/registries/capabilityContract.js.map +1 -0
  206. package/dist/registries/packageRegistry.js +641 -0
  207. package/dist/registries/packageRegistry.js.map +1 -0
  208. package/dist/registries/runtimeAdapterRegistry.js +315 -0
  209. package/dist/registries/runtimeAdapterRegistry.js.map +1 -0
  210. package/dist/setup/codex.js +1056 -0
  211. package/dist/setup/codex.js.map +1 -0
  212. package/dist/setup/copilot.js +227 -0
  213. package/dist/setup/copilot.js.map +1 -0
  214. package/dist/setup/cursor.js +127 -0
  215. package/dist/setup/cursor.js.map +1 -0
  216. package/dist/setup/doctor.js +1276 -0
  217. package/dist/setup/doctor.js.map +1 -0
  218. package/dist/state/installRoot.js +279 -0
  219. package/dist/state/installRoot.js.map +1 -0
  220. package/dist/state/progressCommit.js +289 -0
  221. package/dist/state/progressCommit.js.map +1 -0
  222. package/dist/state/startupAnalysis.js +1953 -0
  223. package/dist/state/startupAnalysis.js.map +1 -0
  224. package/dist/upgrade/appModel.js +189 -0
  225. package/dist/upgrade/appModel.js.map +1 -0
  226. package/dist/upgrade/channels.js +208 -0
  227. package/dist/upgrade/channels.js.map +1 -0
  228. package/dist/upgrade/compatibility.js +201 -0
  229. package/dist/upgrade/compatibility.js.map +1 -0
  230. package/dist/upgrade/doctor.js +373 -0
  231. package/dist/upgrade/doctor.js.map +1 -0
  232. package/dist/upgrade/migrateArtifactsV2ToV3.js +332 -0
  233. package/dist/upgrade/migrateArtifactsV2ToV3.js.map +1 -0
  234. package/dist/upgrade/runtimeMigration.js +484 -0
  235. package/dist/upgrade/runtimeMigration.js.map +1 -0
  236. package/dist/upgrade/upgradeCommands.js +36 -0
  237. package/dist/upgrade/upgradeCommands.js.map +1 -0
  238. package/dist/upgrade/upgradeOrchestrator.js +299 -0
  239. package/dist/upgrade/upgradeOrchestrator.js.map +1 -0
  240. package/dist/upgrade/versionResolution.js +179 -0
  241. package/dist/upgrade/versionResolution.js.map +1 -0
  242. package/dist/validate/appHomeContract.js +150 -0
  243. package/dist/validate/appHomeContract.js.map +1 -0
  244. package/dist/validate/capability.js +412 -0
  245. package/dist/validate/capability.js.map +1 -0
  246. package/dist/validate/crossCapability.js +145 -0
  247. package/dist/validate/crossCapability.js.map +1 -0
  248. package/dist/validate/lifecycleAdapters.js +772 -0
  249. package/dist/validate/lifecycleAdapters.js.map +1 -0
  250. package/dist/validate/selfAudit.js +107 -0
  251. package/dist/validate/selfAudit.js.map +1 -0
  252. package/package.json +28 -8
  253. package/LICENSE +0 -201
  254. package/bin/agentera.mjs +0 -50
  255. package/lib/exec.mjs +0 -116
  256. package/lib/resolve.mjs +0 -129
@@ -0,0 +1,958 @@
1
+ import { cmdPrime } from "./commands/prime.js";
2
+ import { cmdLint } from "./commands/lint.js";
3
+ import { cmdBackfill } from "./commands/backfill.js";
4
+ import { cmdState, isPortedStateCommand } from "./commands/state.js";
5
+ import { COMMAND_FILTERS } from "./stateQuery.js";
6
+ import { cmdQuery } from "./commands/query.js";
7
+ import { cmdCompact, cmdGate } from "./commands/compact.js";
8
+ import { cmdSchema } from "./commands/schema.js";
9
+ import { cmdDoctor } from "./commands/doctor.js";
10
+ import { cmdUpgrade } from "./commands/upgrade.js";
11
+ import { cmdVerify } from "./commands/verify.js";
12
+ import { cmdReport } from "./commands/report.js";
13
+ import { runSessionStart } from "../hooks/sessionStart.js";
14
+ import { runSessionStop } from "../hooks/sessionStop.js";
15
+ import { runCursorSessionStart } from "../hooks/cursorSessionStart.js";
16
+ import { runCursorPreToolUse } from "../hooks/cursorPreToolUse.js";
17
+ import { HookCliAdapter } from "../hooks/validateArtifact.js";
18
+ import fsForHooks from "node:fs";
19
+ import { usageMain } from "../analytics/usageStats.js";
20
+ import { validatePathValue } from "./argvalidate.js";
21
+ import { cmdCapability, CAPABILITY_ROUTING_NAMES } from "./commands/capability.js";
22
+ import { cmdValidate, cmdValidateCapability, cmdValidateCapabilityContract, cmdValidateArtifact, cmdValidateDescriptors, isDelegatedValidateFamily, } from "./commands/validate.js";
23
+ function emitDeprecationAlias(legacy, canonical, err) {
24
+ err(`Deprecation: agentera ${legacy} is deprecated; use agentera ${canonical}\n`);
25
+ }
26
+ /** Minimal flag parser for the `lint` command surface. */
27
+ function parseLintArgs(argv) {
28
+ const args = { artifact: "", file: null, text: null, strict: false, format: "text" };
29
+ let sawArtifact = false;
30
+ for (let i = 0; i < argv.length; i++) {
31
+ const a = argv[i];
32
+ const value = (name) => {
33
+ if (a === name)
34
+ return argv[++i];
35
+ if (a.startsWith(name + "="))
36
+ return a.slice(name.length + 1);
37
+ return null;
38
+ };
39
+ let v;
40
+ if ((v = value("--artifact")) !== null) {
41
+ args.artifact = v;
42
+ sawArtifact = true;
43
+ }
44
+ else if ((v = value("--file")) !== null) {
45
+ args.file = v;
46
+ }
47
+ else if ((v = value("--text")) !== null) {
48
+ args.text = v;
49
+ }
50
+ else if (a === "--strict") {
51
+ args.strict = true;
52
+ }
53
+ else if ((v = value("--format")) !== null) {
54
+ if (v !== "text" && v !== "json") {
55
+ return { error: `argument --format: invalid choice: '${v}' (choose from 'text', 'json')` };
56
+ }
57
+ args.format = v;
58
+ }
59
+ else {
60
+ return { error: `unrecognized arguments: ${a}` };
61
+ }
62
+ }
63
+ if (!sawArtifact)
64
+ return { error: "the following arguments are required: --artifact" };
65
+ if (args.file !== null && args.text !== null) {
66
+ return { error: "argument --text: not allowed with argument --file" };
67
+ }
68
+ return args;
69
+ }
70
+ function runLint(argv, io, prog = "agentera lint") {
71
+ const err = io.err ?? ((t) => process.stderr.write(t));
72
+ const parsed = parseLintArgs(argv);
73
+ if ("error" in parsed) {
74
+ err(`${prog}: error: ${parsed.error}\n`);
75
+ return 2;
76
+ }
77
+ try {
78
+ return cmdLint(parsed, io);
79
+ }
80
+ catch (exc) {
81
+ err(`Error: ${exc.message}\n`);
82
+ return 2;
83
+ }
84
+ }
85
+ function parseBackfillArgs(argv) {
86
+ const args = { project: null, mode: "check", commit: null, cycle: null, format: "text" };
87
+ for (let i = 0; i < argv.length; i++) {
88
+ const a = argv[i];
89
+ const value = (name) => {
90
+ if (a === name)
91
+ return argv[++i];
92
+ if (a.startsWith(name + "="))
93
+ return a.slice(name.length + 1);
94
+ return null;
95
+ };
96
+ let v;
97
+ if ((v = value("--project")) !== null)
98
+ args.project = v;
99
+ else if ((v = value("--mode")) !== null) {
100
+ if (v !== "check" && v !== "fix") {
101
+ return { error: `argument --mode: invalid choice: '${v}' (choose from 'check', 'fix')` };
102
+ }
103
+ args.mode = v;
104
+ }
105
+ else if ((v = value("--commit")) !== null)
106
+ args.commit = v;
107
+ else if ((v = value("--cycle")) !== null) {
108
+ const n = Number(v);
109
+ if (!Number.isInteger(n))
110
+ return { error: `argument --cycle: invalid int value: '${v}'` };
111
+ args.cycle = n;
112
+ }
113
+ else if ((v = value("--format")) !== null) {
114
+ if (v !== "text" && v !== "json") {
115
+ return { error: `argument --format: invalid choice: '${v}' (choose from 'text', 'json')` };
116
+ }
117
+ args.format = v;
118
+ }
119
+ else {
120
+ return { error: `unrecognized arguments: ${a}` };
121
+ }
122
+ }
123
+ return args;
124
+ }
125
+ function runBackfill(argv, io, prog = "agentera backfill") {
126
+ const err = io.err ?? ((t) => process.stderr.write(t));
127
+ const parsed = parseBackfillArgs(argv);
128
+ if ("error" in parsed) {
129
+ err(`${prog}: error: ${parsed.error}\n`);
130
+ return 2;
131
+ }
132
+ try {
133
+ return cmdBackfill(parsed, io);
134
+ }
135
+ catch (exc) {
136
+ err(`Error: ${exc.message}\n`);
137
+ return 2;
138
+ }
139
+ }
140
+ function parseStateArgs(command, argv) {
141
+ const args = {
142
+ command,
143
+ topic: null,
144
+ status: null,
145
+ dimension: null,
146
+ severity: null,
147
+ limit: 5,
148
+ format: "text",
149
+ fields: null,
150
+ };
151
+ const allowed = new Set([...(COMMAND_FILTERS[command] ?? []), "format", "fields"]);
152
+ for (let i = 0; i < argv.length; i++) {
153
+ const a = argv[i];
154
+ const value = (name) => {
155
+ if (a === name)
156
+ return argv[++i];
157
+ if (a.startsWith(name + "="))
158
+ return a.slice(name.length + 1);
159
+ return null;
160
+ };
161
+ const named = (flag, key) => allowed.has(key) && (a === flag || a.startsWith(flag + "="));
162
+ let v;
163
+ if (named("--topic", "topic"))
164
+ args.topic = value("--topic");
165
+ else if (named("--status", "status"))
166
+ args.status = value("--status");
167
+ else if (named("--dimension", "dimension"))
168
+ args.dimension = value("--dimension");
169
+ else if (named("--severity", "severity"))
170
+ args.severity = value("--severity");
171
+ else if (named("--limit", "limit")) {
172
+ v = value("--limit");
173
+ const n = Number(v);
174
+ if (!Number.isInteger(n))
175
+ return { error: `argument --limit: invalid int value: '${v}'` };
176
+ args.limit = n;
177
+ }
178
+ else if (a === "--format" || a.startsWith("--format=")) {
179
+ v = value("--format");
180
+ if (v !== "text" && v !== "json" && v !== "yaml") {
181
+ return { error: `argument --format: invalid choice: '${v}' (choose from 'text', 'json', 'yaml')` };
182
+ }
183
+ args.format = v;
184
+ }
185
+ else if (a === "--fields" || a.startsWith("--fields="))
186
+ args.fields = value("--fields");
187
+ else
188
+ return { error: `unrecognized arguments: ${a}` };
189
+ }
190
+ return args;
191
+ }
192
+ function runState(command, argv, io, prog) {
193
+ const err = io.err ?? ((t) => process.stderr.write(t));
194
+ const parsed = parseStateArgs(command, argv);
195
+ if ("error" in parsed) {
196
+ err(`${prog}: error: ${parsed.error}\n`);
197
+ return 2;
198
+ }
199
+ return cmdState(parsed, io);
200
+ }
201
+ function parseQueryArgs(argv) {
202
+ const args = {
203
+ query: null,
204
+ list_artifacts: false,
205
+ topic: null,
206
+ severity: null,
207
+ dimension: null,
208
+ status: null,
209
+ limit: null,
210
+ format: "text",
211
+ fields: null,
212
+ };
213
+ for (let i = 0; i < argv.length; i++) {
214
+ const a = argv[i];
215
+ const value = (name) => {
216
+ if (a === name)
217
+ return argv[++i];
218
+ if (a.startsWith(name + "="))
219
+ return a.slice(name.length + 1);
220
+ return null;
221
+ };
222
+ let v;
223
+ if (a === "--list-artifacts")
224
+ args.list_artifacts = true;
225
+ else if ((v = value("--topic")) !== null)
226
+ args.topic = v;
227
+ else if ((v = value("--severity")) !== null)
228
+ args.severity = v;
229
+ else if ((v = value("--dimension")) !== null)
230
+ args.dimension = v;
231
+ else if ((v = value("--status")) !== null)
232
+ args.status = v;
233
+ else if ((v = value("--limit")) !== null) {
234
+ const n = Number(v);
235
+ if (!Number.isInteger(n))
236
+ return { error: `argument --limit: invalid int value: '${v}'` };
237
+ args.limit = n;
238
+ }
239
+ else if ((v = value("--format")) !== null) {
240
+ if (v !== "text" && v !== "json" && v !== "yaml") {
241
+ return { error: `argument --format: invalid choice: '${v}' (choose from 'text', 'json', 'yaml')` };
242
+ }
243
+ args.format = v;
244
+ }
245
+ else if ((v = value("--fields")) !== null)
246
+ args.fields = v;
247
+ else if (a.startsWith("--"))
248
+ return { error: `unrecognized arguments: ${a}` };
249
+ else if (args.query === null)
250
+ args.query = a;
251
+ else
252
+ return { error: `unrecognized arguments: ${a}` };
253
+ }
254
+ return args;
255
+ }
256
+ function runQuery(argv, io, prog) {
257
+ const err = io.err ?? ((t) => process.stderr.write(t));
258
+ const parsed = parseQueryArgs(argv);
259
+ if ("error" in parsed) {
260
+ err(`${prog}: error: ${parsed.error}\n`);
261
+ return 2;
262
+ }
263
+ try {
264
+ return cmdQuery(parsed, io);
265
+ }
266
+ catch (exc) {
267
+ err(`Error: ${exc.message}\n`);
268
+ return 2;
269
+ }
270
+ }
271
+ function compactModeOf(argv) {
272
+ for (let i = 0; i < argv.length; i++) {
273
+ if (argv[i] === "--mode")
274
+ return argv[i + 1] ?? "check";
275
+ if (argv[i].startsWith("--mode="))
276
+ return argv[i].slice("--mode=".length);
277
+ }
278
+ return "check";
279
+ }
280
+ function parseCompactArgs(argv) {
281
+ const args = { project: null, mode: "check", format: "text" };
282
+ for (let i = 0; i < argv.length; i++) {
283
+ const a = argv[i];
284
+ const value = (name) => {
285
+ if (a === name)
286
+ return argv[++i];
287
+ if (a.startsWith(name + "="))
288
+ return a.slice(name.length + 1);
289
+ return null;
290
+ };
291
+ let v;
292
+ if ((v = value("--project")) !== null)
293
+ args.project = v;
294
+ else if ((v = value("--mode")) !== null) {
295
+ if (v !== "check" && v !== "fix") {
296
+ return { error: `argument --mode: invalid choice: '${v}' (choose from 'check', 'fix')` };
297
+ }
298
+ args.mode = v;
299
+ }
300
+ else if ((v = value("--format")) !== null) {
301
+ if (v !== "text" && v !== "json") {
302
+ return { error: `argument --format: invalid choice: '${v}' (choose from 'text', 'json')` };
303
+ }
304
+ args.format = v;
305
+ }
306
+ else
307
+ return { error: `unrecognized arguments: ${a}` };
308
+ }
309
+ return args;
310
+ }
311
+ function runCompact(argv, io, prog) {
312
+ const err = io.err ?? ((t) => process.stderr.write(t));
313
+ const parsed = parseCompactArgs(argv);
314
+ if ("error" in parsed) {
315
+ err(`${prog}: error: ${parsed.error}\n`);
316
+ return 2;
317
+ }
318
+ try {
319
+ return cmdCompact(parsed, io);
320
+ }
321
+ catch (exc) {
322
+ err(`Error: ${exc.message}\n`);
323
+ return 2;
324
+ }
325
+ }
326
+ function runValidate(argv, io, prog) {
327
+ const err = io.err ?? ((t) => process.stderr.write(t));
328
+ let family = null;
329
+ let capabilityTarget = null;
330
+ let artifactFlag = null;
331
+ let fileFlag = null;
332
+ let cwdFlag = null;
333
+ let format = "text";
334
+ for (let i = 0; i < argv.length; i++) {
335
+ const a = argv[i];
336
+ if (a === "--format") {
337
+ const v = argv[++i];
338
+ if (v !== "text" && v !== "json") {
339
+ err(`${prog}: error: argument --format: invalid choice: '${v}' (choose from 'text', 'json')\n`);
340
+ return 2;
341
+ }
342
+ format = v;
343
+ }
344
+ else if (a.startsWith("--format=")) {
345
+ const v = a.slice("--format=".length);
346
+ if (v !== "text" && v !== "json") {
347
+ err(`${prog}: error: argument --format: invalid choice: '${v}' (choose from 'text', 'json')\n`);
348
+ return 2;
349
+ }
350
+ format = v;
351
+ }
352
+ else if (a === "--artifact" || a.startsWith("--artifact=")) {
353
+ artifactFlag = a === "--artifact" ? argv[++i] : a.slice("--artifact=".length);
354
+ }
355
+ else if (a === "--file" || a.startsWith("--file=")) {
356
+ fileFlag = a === "--file" ? argv[++i] : a.slice("--file=".length);
357
+ }
358
+ else if (a === "--cwd" || a.startsWith("--cwd=")) {
359
+ cwdFlag = a === "--cwd" ? argv[++i] : a.slice("--cwd=".length);
360
+ }
361
+ else if (a.startsWith("--")) {
362
+ err(`${prog}: error: unrecognized arguments: ${a}\n`);
363
+ return 2;
364
+ }
365
+ else if (family === null) {
366
+ family = a;
367
+ }
368
+ else if (capabilityTarget === null) {
369
+ capabilityTarget = a;
370
+ }
371
+ else {
372
+ err(`${prog}: error: unrecognized arguments: ${a}\n`);
373
+ return 2;
374
+ }
375
+ }
376
+ if (family === null) {
377
+ err(`${prog}: error: the following arguments are required: validate_family\n`);
378
+ return 2;
379
+ }
380
+ try {
381
+ if (family === "capability") {
382
+ if (capabilityTarget === null) {
383
+ err(`${prog} capability: error: the following arguments are required: target\n`);
384
+ return 2;
385
+ }
386
+ return cmdValidateCapability(capabilityTarget, { format }, io);
387
+ }
388
+ if (family === "capability-contract") {
389
+ return cmdValidateCapabilityContract({ format }, io);
390
+ }
391
+ if (family === "descriptors") {
392
+ return cmdValidateDescriptors({ format }, io);
393
+ }
394
+ if (family === "artifact") {
395
+ if (artifactFlag === null) {
396
+ err(`${prog} artifact: error: the following arguments are required: --artifact\n`);
397
+ return 2;
398
+ }
399
+ return cmdValidateArtifact({ artifact: artifactFlag, file: fileFlag, cwd: cwdFlag, format }, io);
400
+ }
401
+ if (isDelegatedValidateFamily(family)) {
402
+ return cmdValidate(family, { format }, io);
403
+ }
404
+ err(`agentera: validate family not yet ported: ${family}\n`);
405
+ return 1;
406
+ }
407
+ catch (exc) {
408
+ err(`Error: ${exc.message}\n`);
409
+ return 2;
410
+ }
411
+ }
412
+ function runSchema(argv, io, prog) {
413
+ const err = io.err ?? ((t) => process.stderr.write(t));
414
+ let format = "json";
415
+ for (let i = 0; i < argv.length; i++) {
416
+ const a = argv[i];
417
+ let v = null;
418
+ if (a === "--format")
419
+ v = argv[++i];
420
+ else if (a.startsWith("--format="))
421
+ v = a.slice("--format=".length);
422
+ else {
423
+ err(`${prog}: error: unrecognized arguments: ${a}\n`);
424
+ return 2;
425
+ }
426
+ if (v !== "json" && v !== "yaml") {
427
+ err(`${prog}: error: argument --format: invalid choice: '${v}' (choose from 'json', 'yaml')\n`);
428
+ return 2;
429
+ }
430
+ format = v;
431
+ }
432
+ try {
433
+ return cmdSchema({ format }, io);
434
+ }
435
+ catch (exc) {
436
+ err(`Error: ${exc.message}\n`);
437
+ return 2;
438
+ }
439
+ }
440
+ function runCapability(command, argv, io, prog) {
441
+ const err = io.err ?? ((t) => process.stderr.write(t));
442
+ let format = "text";
443
+ for (let i = 0; i < argv.length; i++) {
444
+ const a = argv[i];
445
+ let v = null;
446
+ if (a === "--format")
447
+ v = argv[++i];
448
+ else if (a.startsWith("--format="))
449
+ v = a.slice("--format=".length);
450
+ else if (a === "--fields" || a.startsWith("--fields=")) {
451
+ // accepted by the parser but unused by capability routing
452
+ if (a === "--fields")
453
+ i++;
454
+ continue;
455
+ }
456
+ else {
457
+ err(`${prog}: error: unrecognized arguments: ${a}\n`);
458
+ return 2;
459
+ }
460
+ if (v !== "text" && v !== "json" && v !== "yaml") {
461
+ err(`${prog}: error: argument --format: invalid choice: '${v}' (choose from 'text', 'json', 'yaml')\n`);
462
+ return 2;
463
+ }
464
+ format = v;
465
+ }
466
+ return cmdCapability(command, { format }, io);
467
+ }
468
+ function runPrime(command, argv, io, prog) {
469
+ const err = io.err ?? ((t) => process.stderr.write(t));
470
+ const args = { command, guidance: false, context: null, dashboard: false, orientation: false, format: "text" };
471
+ for (let i = 0; i < argv.length; i++) {
472
+ const a = argv[i];
473
+ let v = null;
474
+ if (a === "--guidance")
475
+ args.guidance = true;
476
+ else if (a === "--dashboard")
477
+ args.dashboard = true;
478
+ else if (a === "--orientation")
479
+ args.orientation = true;
480
+ else if (a === "--context")
481
+ args.context = argv[++i];
482
+ else if (a.startsWith("--context="))
483
+ args.context = a.slice("--context=".length);
484
+ else if (a === "--format" || a.startsWith("--format=")) {
485
+ v = a === "--format" ? argv[++i] : a.slice("--format=".length);
486
+ if (v !== "text" && v !== "json" && v !== "yaml") {
487
+ err(`${prog}: error: argument --format: invalid choice: '${v}' (choose from 'text', 'json', 'yaml')\n`);
488
+ return 2;
489
+ }
490
+ args.format = v;
491
+ }
492
+ else if (a === "--fields") {
493
+ args.fields = argv[++i];
494
+ }
495
+ else if (a.startsWith("--fields=")) {
496
+ args.fields = a.slice("--fields=".length);
497
+ }
498
+ else {
499
+ err(`${prog}: error: unrecognized arguments: ${a}\n`);
500
+ return 2;
501
+ }
502
+ }
503
+ return cmdPrime(args, io);
504
+ }
505
+ function runGate(argv, io, prog) {
506
+ const err = io.err ?? ((t) => process.stderr.write(t));
507
+ const parsed = parseCompactArgs(argv);
508
+ if ("error" in parsed) {
509
+ err(`${prog}: error: ${parsed.error}\n`);
510
+ return 2;
511
+ }
512
+ try {
513
+ return cmdGate(parsed, io);
514
+ }
515
+ catch (exc) {
516
+ err(`Error: ${exc.message}\n`);
517
+ return 2;
518
+ }
519
+ }
520
+ function runDoctor(argv, io, prog) {
521
+ const err = io.err ?? ((t) => process.stderr.write(t));
522
+ const args = { installRoot: null, home: null, project: null, expectedVersion: null, expectCommand: [], format: "text" };
523
+ let jsonFlag = false;
524
+ for (let i = 0; i < argv.length; i++) {
525
+ const a = argv[i];
526
+ const value = (name) => {
527
+ if (a === name)
528
+ return argv[++i];
529
+ if (a.startsWith(name + "="))
530
+ return a.slice(name.length + 1);
531
+ return null;
532
+ };
533
+ let v;
534
+ if ((v = value("--install-root")) !== null)
535
+ args.installRoot = v;
536
+ else if ((v = value("--home")) !== null)
537
+ args.home = v;
538
+ else if ((v = value("--project")) !== null)
539
+ args.project = v;
540
+ else if ((v = value("--expected-version")) !== null)
541
+ args.expectedVersion = v;
542
+ else if ((v = value("--expect-command")) !== null)
543
+ args.expectCommand.push(v);
544
+ else if ((v = value("--format")) !== null) {
545
+ if (v !== "text" && v !== "json") {
546
+ err(`${prog}: error: argument --format: invalid choice: '${v}' (choose from 'text', 'json')\n`);
547
+ return 2;
548
+ }
549
+ args.format = v;
550
+ }
551
+ else if (a === "--json")
552
+ jsonFlag = true;
553
+ else {
554
+ err(`${prog}: error: unrecognized arguments: ${a}\n`);
555
+ return 2;
556
+ }
557
+ }
558
+ if (jsonFlag) {
559
+ emitDeprecationAlias("doctor --json", "doctor --format json", err);
560
+ args.format = "json";
561
+ }
562
+ return cmdDoctor(args, io);
563
+ }
564
+ function readStdin() {
565
+ try {
566
+ return fsForHooks.readFileSync(0, "utf8");
567
+ }
568
+ catch {
569
+ return "";
570
+ }
571
+ }
572
+ function runHook(name, argv, io) {
573
+ const err = io.err ?? ((t) => process.stderr.write(t));
574
+ const raw = io.stdin ? io.stdin() : readStdin();
575
+ // Each hook owns its own stdout newline convention; do not wrap stdout here.
576
+ switch (name) {
577
+ case "session-start":
578
+ return runSessionStart(raw);
579
+ case "session-stop":
580
+ return runSessionStop(raw);
581
+ case "cursor-session-start":
582
+ return runCursorSessionStart(raw);
583
+ case "cursor-pre-tool-use":
584
+ return runCursorPreToolUse(raw);
585
+ case "validate-artifact": {
586
+ const [rc, violations] = new HookCliAdapter().run(raw, null);
587
+ for (const v of violations)
588
+ err(`${v}\n`);
589
+ return rc;
590
+ }
591
+ default:
592
+ err(`agentera hook: unknown hook '${name}'\n`);
593
+ return 2;
594
+ }
595
+ }
596
+ function runUsage(argv, io, prog) {
597
+ const realOut = io.out ?? ((t) => process.stdout.write(t));
598
+ const realErr = io.err ?? ((t) => process.stderr.write(t));
599
+ let format = "text";
600
+ let corpus = null;
601
+ let project = null;
602
+ for (let i = 0; i < argv.length; i++) {
603
+ const a = argv[i];
604
+ const value = (name) => {
605
+ if (a === name)
606
+ return argv[++i] ?? null;
607
+ if (a.startsWith(name + "="))
608
+ return a.slice(name.length + 1);
609
+ return null;
610
+ };
611
+ let v;
612
+ if ((v = value("--format")) !== null)
613
+ format = v;
614
+ else if ((v = value("--corpus")) !== null)
615
+ corpus = v;
616
+ else if ((v = value("--project")) !== null)
617
+ project = v;
618
+ else {
619
+ realErr(`${prog}: error: unrecognized arguments: ${a}\n`);
620
+ return 2;
621
+ }
622
+ }
623
+ if (corpus !== null) {
624
+ try {
625
+ validatePathValue(corpus, "path");
626
+ }
627
+ catch (e) {
628
+ realErr(`${prog}: error: argument --corpus: ${e.message}\n`);
629
+ return 2;
630
+ }
631
+ }
632
+ if (format !== "text" && format !== "json") {
633
+ const syntax = "agentera usage [--format text|json] [--corpus PATH] [--project VALUE]";
634
+ const example = "agentera usage --format json --project agentera";
635
+ realErr(`Error: unsupported usage format '${format}'; valid formats: text, json. ` +
636
+ `Syntax: ${syntax}. Example: ${example}\n`);
637
+ return 2;
638
+ }
639
+ const engineArgv = [];
640
+ if (corpus !== null)
641
+ engineArgv.push("--corpus", corpus);
642
+ if (project !== null)
643
+ engineArgv.push("--project", project);
644
+ if (format === "json")
645
+ engineArgv.push("--json");
646
+ return usageMain(engineArgv, {
647
+ out: (t) => realOut(t + "\n"),
648
+ err: (t) => realErr(t + "\n"),
649
+ });
650
+ }
651
+ function runUpgrade(argv, io, prog) {
652
+ const err = io.err ?? ((t) => process.stderr.write(t));
653
+ const args = {
654
+ installRoot: null,
655
+ home: null,
656
+ project: null,
657
+ expectedVersion: null,
658
+ channel: null,
659
+ yes: false,
660
+ dryRun: false,
661
+ only: [],
662
+ force: false,
663
+ format: "text",
664
+ };
665
+ let jsonFlag = false;
666
+ for (let i = 0; i < argv.length; i++) {
667
+ const a = argv[i];
668
+ const value = (name) => {
669
+ if (a === name)
670
+ return argv[++i] ?? null;
671
+ if (a.startsWith(name + "="))
672
+ return a.slice(name.length + 1);
673
+ return null;
674
+ };
675
+ let v;
676
+ if ((v = value("--install-root")) !== null)
677
+ args.installRoot = v;
678
+ else if ((v = value("--home")) !== null)
679
+ args.home = v;
680
+ else if ((v = value("--project")) !== null)
681
+ args.project = v;
682
+ else if ((v = value("--expected-version")) !== null)
683
+ args.expectedVersion = v;
684
+ else if ((v = value("--channel")) !== null)
685
+ args.channel = v;
686
+ else if ((v = value("--target-major")) !== null) {
687
+ void v;
688
+ err(`${prog}: error: --target-major was removed; use --channel with dry-run preview then --yes\n`);
689
+ return 2;
690
+ }
691
+ else if ((v = value("--runtime")) !== null)
692
+ void v; // accepted; orchestrator uses fixture runtimes
693
+ else if ((v = value("--only")) !== null) {
694
+ if (v !== "artifacts" && v !== "runtime" && v !== "cleanup") {
695
+ err(`${prog}: error: argument --only: invalid choice: '${v}' (choose from 'artifacts', 'runtime', 'cleanup')\n`);
696
+ return 2;
697
+ }
698
+ args.only.push(v);
699
+ }
700
+ else if ((v = value("--opencode-config-dir")) !== null)
701
+ void v; // accepted; ignored
702
+ else if (a === "--yes")
703
+ args.yes = true;
704
+ else if (a === "--dry-run")
705
+ args.dryRun = true;
706
+ else if (a === "--force")
707
+ args.force = true;
708
+ else if (a === "--update-packages")
709
+ void 0; // deferred for 3.x channel model
710
+ else if (a === "--json")
711
+ jsonFlag = true;
712
+ else if ((v = value("--format")) !== null) {
713
+ if (v !== "text" && v !== "json") {
714
+ err(`${prog}: error: argument --format: invalid choice: '${v}' (choose from 'text', 'json')\n`);
715
+ return 2;
716
+ }
717
+ args.format = v;
718
+ }
719
+ else {
720
+ err(`${prog}: error: unrecognized arguments: ${a}\n`);
721
+ return 2;
722
+ }
723
+ }
724
+ if (jsonFlag)
725
+ args.format = "json";
726
+ return cmdUpgrade(args, io);
727
+ }
728
+ function runVerify(argv, io, prog) {
729
+ const err = io.err ?? ((t) => process.stderr.write(t));
730
+ const args = {
731
+ family: null,
732
+ target: null,
733
+ format: "text",
734
+ run: false,
735
+ dryRun: false,
736
+ skill: null,
737
+ timeout: 120,
738
+ parallel: 1,
739
+ runtime: "auto",
740
+ fixtures: [],
741
+ };
742
+ const positionals = [];
743
+ for (let i = 0; i < argv.length; i++) {
744
+ const a = argv[i];
745
+ const value = (name) => {
746
+ if (a === name)
747
+ return argv[++i] ?? null;
748
+ if (a.startsWith(name + "="))
749
+ return a.slice(name.length + 1);
750
+ return null;
751
+ };
752
+ let v;
753
+ if ((v = value("--format")) !== null) {
754
+ if (v !== "text" && v !== "json") {
755
+ err(`${prog}: error: argument --format: invalid choice: '${v}' (choose from 'text', 'json')\n`);
756
+ return 2;
757
+ }
758
+ args.format = v;
759
+ }
760
+ else if ((v = value("--skill")) !== null)
761
+ args.skill = v;
762
+ else if ((v = value("--runtime")) !== null)
763
+ args.runtime = v;
764
+ else if ((v = value("--timeout")) !== null)
765
+ args.timeout = Number(v);
766
+ else if ((v = value("--parallel")) !== null)
767
+ args.parallel = Number(v);
768
+ else if (a === "--run")
769
+ args.run = true;
770
+ else if (a === "--dry-run")
771
+ args.dryRun = true;
772
+ else if (a.startsWith("--")) {
773
+ err(`${prog}: error: unrecognized arguments: ${a}\n`);
774
+ return 2;
775
+ }
776
+ else {
777
+ positionals.push(a);
778
+ }
779
+ }
780
+ args.family = positionals[0] ?? null;
781
+ args.target = positionals[1] ?? null;
782
+ args.fixtures = positionals.slice(2);
783
+ return cmdVerify(args, io);
784
+ }
785
+ function runReport(argv, io, prog) {
786
+ const err = io.err ?? ((t) => process.stderr.write(t));
787
+ const args = {
788
+ action: null,
789
+ format: "text",
790
+ project: null,
791
+ dryRun: false,
792
+ consent: null,
793
+ projectRoot: [],
794
+ };
795
+ const positionals = [];
796
+ for (let i = 0; i < argv.length; i++) {
797
+ const a = argv[i];
798
+ const value = (name) => {
799
+ if (a === name)
800
+ return argv[++i] ?? null;
801
+ if (a.startsWith(name + "="))
802
+ return a.slice(name.length + 1);
803
+ return null;
804
+ };
805
+ let v;
806
+ if ((v = value("--format")) !== null)
807
+ args.format = v;
808
+ else if ((v = value("--project")) !== null)
809
+ args.project = v;
810
+ else if ((v = value("--consent")) !== null) {
811
+ if (v !== "local-history") {
812
+ err(`${prog}: error: argument --consent: invalid choice: '${v}' (choose from 'local-history')\n`);
813
+ return 2;
814
+ }
815
+ args.consent = v;
816
+ }
817
+ else if ((v = value("--project-root")) !== null)
818
+ args.projectRoot.push(v);
819
+ else if ((v = value("--output")) !== null)
820
+ args.output = v;
821
+ else if ((v = value("--codex-sessions-dir")) !== null)
822
+ args.codexSessionsDir = v;
823
+ else if ((v = value("--claude-projects-dir")) !== null)
824
+ args.claudeProjectsDir = v;
825
+ else if ((v = value("--opencode-conversations-dir")) !== null)
826
+ args.opencodeConversationsDir = v;
827
+ else if ((v = value("--copilot-conversations-dir")) !== null)
828
+ args.copilotConversationsDir = v;
829
+ else if ((v = value("--cursor-projects-dir")) !== null)
830
+ args.cursorProjectsDir = v;
831
+ else if ((v = value("--cursor-chats-dir")) !== null)
832
+ args.cursorChatsDir = v;
833
+ else if (a === "--no-codex")
834
+ args.noCodex = true;
835
+ else if (a === "--no-claude")
836
+ args.noClaude = true;
837
+ else if (a === "--no-opencode")
838
+ args.noOpencode = true;
839
+ else if (a === "--no-copilot")
840
+ args.noCopilot = true;
841
+ else if (a === "--no-cursor")
842
+ args.noCursor = true;
843
+ else if (a === "--dry-run")
844
+ args.dryRun = true;
845
+ else if (a.startsWith("--")) {
846
+ err(`${prog}: error: unrecognized arguments: ${a}\n`);
847
+ return 2;
848
+ }
849
+ else {
850
+ positionals.push(a);
851
+ }
852
+ }
853
+ args.action = positionals[0] ?? null;
854
+ return cmdReport(args, io);
855
+ }
856
+ export function main(argv, io = {}) {
857
+ const err = io.err ?? ((t) => process.stderr.write(t));
858
+ const args = argv.slice(2);
859
+ const command = args[0];
860
+ const rest = args.slice(1);
861
+ switch (command) {
862
+ case "prime":
863
+ return runPrime("prime", rest, io, "agentera prime");
864
+ case "doctor":
865
+ return runDoctor(rest, io, "agentera doctor");
866
+ case "usage":
867
+ return runUsage(rest, io, "agentera usage");
868
+ case "upgrade":
869
+ return runUpgrade(rest, io, "agentera upgrade");
870
+ case "verify":
871
+ emitDeprecationAlias("verify", "check verify", err);
872
+ return runVerify(rest, io, "agentera verify");
873
+ case "report":
874
+ return runReport(rest, io, "agentera report");
875
+ case "stats":
876
+ emitDeprecationAlias("stats", "report", err);
877
+ return runReport(rest, io, "agentera stats");
878
+ case "hook": {
879
+ const name = rest[0];
880
+ if (!name) {
881
+ err("agentera hook: error: the following arguments are required: hook_name\n");
882
+ return 2;
883
+ }
884
+ return runHook(name, rest.slice(1), io);
885
+ }
886
+ case "hej":
887
+ emitDeprecationAlias("hej", "prime", err);
888
+ return runPrime("hej", rest, io, "agentera hej");
889
+ case "schema":
890
+ return runSchema(rest, io, "agentera schema");
891
+ case "describe":
892
+ emitDeprecationAlias("describe", "schema", err);
893
+ return runSchema(rest, io, "agentera describe");
894
+ case "lint":
895
+ emitDeprecationAlias("lint", "check lint", err);
896
+ return runLint(rest, io);
897
+ case "check": {
898
+ const sub = rest[0];
899
+ if (!sub) {
900
+ err("agentera check: error: the following arguments are required: check_command\n");
901
+ return 2;
902
+ }
903
+ if (sub === "validate")
904
+ return runValidate(rest.slice(1), io, "agentera check validate");
905
+ if (sub === "verify")
906
+ return runVerify(rest.slice(1), io, "agentera check verify");
907
+ if (sub === "lint")
908
+ return runLint(rest.slice(1), io, "agentera check lint");
909
+ if (sub === "backfill")
910
+ return runBackfill(rest.slice(1), io, "agentera check backfill");
911
+ if (sub === "compact") {
912
+ const subArgs = rest.slice(1);
913
+ const mode = compactModeOf(subArgs);
914
+ if (mode === "fix")
915
+ return runCompact(subArgs, io, "agentera check compact");
916
+ return runGate(subArgs, io, "agentera check compact");
917
+ }
918
+ err(`agentera: unknown or not-yet-ported check subcommand: ${sub}\n`);
919
+ return 1;
920
+ }
921
+ case "state": {
922
+ const sub = rest[0];
923
+ if (!sub) {
924
+ err("agentera state: error: the following arguments are required: state_command\n");
925
+ return 2;
926
+ }
927
+ if (sub === "query")
928
+ return runQuery(rest.slice(1), io, "agentera state query");
929
+ if (isPortedStateCommand(sub))
930
+ return runState(sub, rest.slice(1), io, `agentera state ${sub}`);
931
+ err(`agentera: unknown or not-yet-ported state subcommand: ${sub}\n`);
932
+ return 1;
933
+ }
934
+ case "query":
935
+ emitDeprecationAlias("query", "state query", err);
936
+ return runQuery(rest, io, "agentera query");
937
+ case "compact":
938
+ emitDeprecationAlias("compact", "check compact", err);
939
+ return runCompact(rest, io, "agentera compact");
940
+ case "gate":
941
+ emitDeprecationAlias("gate", "check compact", err);
942
+ return runGate(rest, io, "agentera gate");
943
+ case "validate":
944
+ emitDeprecationAlias("validate", "check validate", err);
945
+ return runValidate(rest, io, "agentera validate");
946
+ default:
947
+ if (command && CAPABILITY_ROUTING_NAMES.includes(command)) {
948
+ return runCapability(command, rest, io, `agentera ${command}`);
949
+ }
950
+ if (command && isPortedStateCommand(command)) {
951
+ emitDeprecationAlias(command, `state ${command}`, err);
952
+ return runState(command, rest, io, `agentera ${command}`);
953
+ }
954
+ err(`agentera: unknown or not-yet-ported command: ${command ?? "(none)"}\n`);
955
+ return 1;
956
+ }
957
+ }
958
+ //# sourceMappingURL=dispatch.js.map