agentera 3.0.0-dev.5 → 3.0.0-dev.6
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.
- package/README.md +4 -3
- package/bundle/references/adapters/opencode.md +1 -1
- package/bundle/references/adapters/package-registry.yaml +0 -1
- package/bundle/references/adapters/package-surface-characterization.md +1 -2
- package/bundle/references/analysis/startup-measurement-contract.yaml +11 -11
- package/bundle/references/cli/audience-namespace-cli-migration.yaml +40 -26
- package/bundle/references/cli/bundle-skill-vocabulary.yaml +1 -29
- package/bundle/references/cli/coexistence-probe.yaml +9 -0
- package/bundle/references/cli/single-name-protocol.yaml +42 -0
- package/bundle/references/cli/update-channels.yaml +1 -0
- package/bundle/references/cli/upgrade-repair-wording.md +31 -0
- package/bundle/references/cli/v3-handoff-manifest.schema.yaml +98 -0
- package/bundle/references/cli/vocabulary.md +12 -10
- package/bundle/references/meta/documentation-inventory.md +9 -3
- package/bundle/skills/agentera/SKILL.md +14 -14
- package/dist/analytics/extractCorpus/cli.js +101 -0
- package/dist/analytics/extractCorpus/cli.js.map +1 -0
- package/dist/analytics/extractCorpus/copilotSessions.js +231 -0
- package/dist/analytics/extractCorpus/copilotSessions.js.map +1 -0
- package/dist/analytics/extractCorpus/core.js +357 -0
- package/dist/analytics/extractCorpus/core.js.map +1 -0
- package/dist/analytics/extractCorpus/corpus.js +132 -0
- package/dist/analytics/extractCorpus/corpus.js.map +1 -0
- package/dist/analytics/extractCorpus/cursorSessions.js +420 -0
- package/dist/analytics/extractCorpus/cursorSessions.js.map +1 -0
- package/dist/analytics/extractCorpus/filesystemSources.js +122 -0
- package/dist/analytics/extractCorpus/filesystemSources.js.map +1 -0
- package/dist/analytics/extractCorpus/index.js +9 -0
- package/dist/analytics/extractCorpus/index.js.map +1 -0
- package/dist/analytics/extractCorpus/jsonlSessions.js +185 -0
- package/dist/analytics/extractCorpus/jsonlSessions.js.map +1 -0
- package/dist/analytics/extractCorpus/sqliteSessions.js +275 -0
- package/dist/analytics/extractCorpus/sqliteSessions.js.map +1 -0
- package/dist/analytics/extractCorpus.js +2 -1790
- package/dist/analytics/extractCorpus.js.map +1 -1
- package/dist/analytics/usageStats.js +1 -1
- package/dist/analytics/usageStats.js.map +1 -1
- package/dist/cli/capabilityContext/benchmark.js +557 -0
- package/dist/cli/capabilityContext/benchmark.js.map +1 -0
- package/dist/cli/capabilityContext/bespoke.js +25 -0
- package/dist/cli/capabilityContext/bespoke.js.map +1 -0
- package/dist/cli/capabilityContext/closeout.js +230 -0
- package/dist/cli/capabilityContext/closeout.js.map +1 -0
- package/dist/cli/capabilityContext/contract.js +186 -0
- package/dist/cli/capabilityContext/contract.js.map +1 -0
- package/dist/cli/capabilityContext/evidence.js +446 -0
- package/dist/cli/capabilityContext/evidence.js.map +1 -0
- package/dist/cli/capabilityContext/index.js +4 -0
- package/dist/cli/capabilityContext/index.js.map +1 -0
- package/dist/cli/capabilityContext/orchestration.js +107 -0
- package/dist/cli/capabilityContext/orchestration.js.map +1 -0
- package/dist/cli/capabilityContext/planState.js +271 -0
- package/dist/cli/capabilityContext/planState.js.map +1 -0
- package/dist/cli/capabilityContext/progress.js +96 -0
- package/dist/cli/capabilityContext/progress.js.map +1 -0
- package/dist/cli/capabilityContext/realisera.js +174 -0
- package/dist/cli/capabilityContext/realisera.js.map +1 -0
- package/dist/cli/capabilityContext/shared.js +94 -0
- package/dist/cli/capabilityContext/shared.js.map +1 -0
- package/dist/cli/capabilityContext/slim.js +106 -0
- package/dist/cli/capabilityContext/slim.js.map +1 -0
- package/dist/cli/capabilityContext/startup.js +208 -0
- package/dist/cli/capabilityContext/startup.js.map +1 -0
- package/dist/cli/capabilityContext/types.js +43 -0
- package/dist/cli/capabilityContext/types.js.map +1 -0
- package/dist/cli/capabilityContext.js +1 -2486
- package/dist/cli/capabilityContext.js.map +1 -1
- package/dist/cli/commands/backfill.js +84 -0
- package/dist/cli/commands/backfill.js.map +1 -0
- package/dist/cli/commands/compact.js +1 -1
- package/dist/cli/commands/compact.js.map +1 -1
- package/dist/cli/commands/doctor.js +24 -7
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/lint.js +4 -36
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/query.js +1 -1
- package/dist/cli/commands/query.js.map +1 -1
- package/dist/cli/commands/report.js +11 -2
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/schema.js +1 -2
- package/dist/cli/commands/schema.js.map +1 -1
- package/dist/cli/commands/state/decisions.js +397 -0
- package/dist/cli/commands/state/decisions.js.map +1 -0
- package/dist/cli/commands/state/docs.js +93 -0
- package/dist/cli/commands/state/docs.js.map +1 -0
- package/dist/cli/commands/state/experiments.js +67 -0
- package/dist/cli/commands/state/experiments.js.map +1 -0
- package/dist/cli/commands/state/health.js +114 -0
- package/dist/cli/commands/state/health.js.map +1 -0
- package/dist/cli/commands/state/index.js +51 -0
- package/dist/cli/commands/state/index.js.map +1 -0
- package/dist/cli/commands/state/objective.js +68 -0
- package/dist/cli/commands/state/objective.js.map +1 -0
- package/dist/cli/commands/state/plan.js +172 -0
- package/dist/cli/commands/state/plan.js.map +1 -0
- package/dist/cli/commands/state/progress.js +47 -0
- package/dist/cli/commands/state/progress.js.map +1 -0
- package/dist/cli/commands/state/shared.js +15 -0
- package/dist/cli/commands/state/shared.js.map +1 -0
- package/dist/cli/commands/state/todo.js +121 -0
- package/dist/cli/commands/state/todo.js.map +1 -0
- package/dist/cli/commands/state.js +7 -7
- package/dist/cli/commands/state.js.map +1 -1
- package/dist/cli/commands/validate.js +32 -18
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/dispatch/check.js +328 -0
- package/dist/cli/dispatch/check.js.map +1 -0
- package/dist/cli/dispatch/index.js +177 -0
- package/dist/cli/dispatch/index.js.map +1 -0
- package/dist/cli/dispatch/lifecycle.js +492 -0
- package/dist/cli/dispatch/lifecycle.js.map +1 -0
- package/dist/cli/dispatch/prime.js +100 -0
- package/dist/cli/dispatch/prime.js.map +1 -0
- package/dist/cli/dispatch/shared.js +64 -0
- package/dist/cli/dispatch/shared.js.map +1 -0
- package/dist/cli/dispatch/state.js +149 -0
- package/dist/cli/dispatch/state.js.map +1 -0
- package/dist/cli/dispatch.js +1 -1293
- package/dist/cli/dispatch.js.map +1 -1
- package/dist/cli/help.js +0 -2
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/orientation.js +1 -1
- package/dist/cli/orientation.js.map +1 -1
- package/dist/core/git.js +43 -0
- package/dist/core/git.js.map +1 -0
- package/dist/hooks/common.js +8 -23
- package/dist/hooks/common.js.map +1 -1
- package/dist/hooks/compaction/apply.js +244 -0
- package/dist/hooks/compaction/apply.js.map +1 -0
- package/dist/hooks/compaction/dryRun.js +181 -0
- package/dist/hooks/compaction/dryRun.js.map +1 -0
- package/dist/hooks/compaction/index.js +23 -0
- package/dist/hooks/compaction/index.js.map +1 -0
- package/dist/hooks/compaction/parse.js +129 -0
- package/dist/hooks/compaction/parse.js.map +1 -0
- package/dist/hooks/compaction/retention.js +197 -0
- package/dist/hooks/compaction/retention.js.map +1 -0
- package/dist/hooks/compaction/status.js +243 -0
- package/dist/hooks/compaction/status.js.map +1 -0
- package/dist/hooks/compaction/types.js +6 -0
- package/dist/hooks/compaction/types.js.map +1 -0
- package/dist/hooks/compaction.js +20 -20
- package/dist/hooks/compaction.js.map +1 -1
- package/dist/hooks/cursorPreToolUse.js +1 -1
- package/dist/hooks/cursorPreToolUse.js.map +1 -1
- package/dist/hooks/sessionStart.js +4 -4
- package/dist/hooks/sessionStart.js.map +1 -1
- package/dist/hooks/sessionStop.js +3 -12
- package/dist/hooks/sessionStop.js.map +1 -1
- package/dist/hooks/validateArtifact/agentFacing.js +10 -0
- package/dist/hooks/validateArtifact/agentFacing.js.map +1 -0
- package/dist/hooks/validateArtifact/index.js +149 -0
- package/dist/hooks/validateArtifact/index.js.map +1 -0
- package/dist/hooks/validateArtifact/markdown.js +95 -0
- package/dist/hooks/validateArtifact/markdown.js.map +1 -0
- package/dist/hooks/validateArtifact/runtime.js +83 -0
- package/dist/hooks/validateArtifact/runtime.js.map +1 -0
- package/dist/hooks/validateArtifact/schema.js +455 -0
- package/dist/hooks/validateArtifact/schema.js.map +1 -0
- package/dist/hooks/validateArtifact/traversal.js +105 -0
- package/dist/hooks/validateArtifact/traversal.js.map +1 -0
- package/dist/hooks/validateArtifact/violations.js +105 -0
- package/dist/hooks/validateArtifact/violations.js.map +1 -0
- package/dist/hooks/validateArtifact.js +29 -40
- package/dist/hooks/validateArtifact.js.map +1 -1
- package/dist/migrate/v2HandoffManifest.js +333 -0
- package/dist/migrate/v2HandoffManifest.js.map +1 -0
- package/dist/registries/artifactProtocolIds.js +77 -0
- package/dist/registries/artifactProtocolIds.js.map +1 -0
- package/dist/release/releaseMetadata.js +235 -0
- package/dist/release/releaseMetadata.js.map +1 -0
- package/dist/setup/codex/agents.js +96 -0
- package/dist/setup/codex/agents.js.map +1 -0
- package/dist/setup/codex/cli.js +161 -0
- package/dist/setup/codex/cli.js.map +1 -0
- package/dist/setup/codex/configToml.js +644 -0
- package/dist/setup/codex/configToml.js.map +1 -0
- package/dist/setup/codex/constants.js +29 -0
- package/dist/setup/codex/constants.js.map +1 -0
- package/dist/setup/codex/installRoot.js +64 -0
- package/dist/setup/codex/installRoot.js.map +1 -0
- package/dist/setup/codex/state.js +270 -0
- package/dist/setup/codex/state.js.map +1 -0
- package/dist/setup/codex.js +11 -1196
- package/dist/setup/codex.js.map +1 -1
- package/dist/setup/doctor/core.js +300 -0
- package/dist/setup/doctor/core.js.map +1 -0
- package/dist/setup/doctor/diagnostics.js +247 -0
- package/dist/setup/doctor/diagnostics.js.map +1 -0
- package/dist/setup/doctor/opencode.js +281 -0
- package/dist/setup/doctor/opencode.js.map +1 -0
- package/dist/setup/doctor/report.js +474 -0
- package/dist/setup/doctor/report.js.map +1 -0
- package/dist/setup/doctor.js +9 -1296
- package/dist/setup/doctor.js.map +1 -1
- package/dist/setup/opencode.js +13 -0
- package/dist/setup/opencode.js.map +1 -0
- package/dist/setup/smokeChecks.js +1 -1
- package/dist/setup/smokeChecks.js.map +1 -1
- package/dist/state/progressCommit.js +289 -0
- package/dist/state/progressCommit.js.map +1 -0
- package/dist/state/startupAnalysis/benchmark.js +367 -0
- package/dist/state/startupAnalysis/benchmark.js.map +1 -0
- package/dist/state/startupAnalysis/contract.js +122 -0
- package/dist/state/startupAnalysis/contract.js.map +1 -0
- package/dist/state/startupAnalysis/helpers.js +332 -0
- package/dist/state/startupAnalysis/helpers.js.map +1 -0
- package/dist/state/startupAnalysis/index.js +7 -0
- package/dist/state/startupAnalysis/index.js.map +1 -0
- package/dist/state/startupAnalysis/metrics.js +334 -0
- package/dist/state/startupAnalysis/metrics.js.map +1 -0
- package/dist/state/startupAnalysis/records.js +195 -0
- package/dist/state/startupAnalysis/records.js.map +1 -0
- package/dist/state/startupAnalysis/report.js +123 -0
- package/dist/state/startupAnalysis/report.js.map +1 -0
- package/dist/state/startupAnalysis/threshold.js +500 -0
- package/dist/state/startupAnalysis/threshold.js.map +1 -0
- package/dist/state/startupAnalysis.js +2 -1952
- package/dist/state/startupAnalysis.js.map +1 -1
- package/dist/upgrade/coexistenceProbe.js +83 -0
- package/dist/upgrade/coexistenceProbe.js.map +1 -0
- package/dist/upgrade/doctor.js +41 -2
- package/dist/upgrade/doctor.js.map +1 -1
- package/dist/upgrade/migrateArtifactsV2ToV3.js +5 -83
- package/dist/upgrade/migrateArtifactsV2ToV3.js.map +1 -1
- package/dist/upgrade/nextMajorDoctor.js +16 -1
- package/dist/upgrade/nextMajorDoctor.js.map +1 -1
- package/dist/upgrade/projectIntegration.js +3 -1
- package/dist/upgrade/projectIntegration.js.map +1 -1
- package/dist/upgrade/runtimeMigration.js +13 -2
- package/dist/upgrade/runtimeMigration.js.map +1 -1
- package/dist/upgrade/v3CapabilitySurface.js +15 -0
- package/dist/upgrade/v3CapabilitySurface.js.map +1 -0
- package/dist/upgrade/versionResolution.js +8 -0
- package/dist/upgrade/versionResolution.js.map +1 -1
- package/dist/validate/appHomeContract.js +3 -3
- package/dist/validate/appHomeContract.js.map +1 -1
- package/dist/validate/selfAudit.js +62 -20
- package/dist/validate/selfAudit.js.map +1 -1
- package/dist/validate/vocabularyAuthority.js +298 -0
- package/dist/validate/vocabularyAuthority.js.map +1 -0
- package/package.json +3 -3
- package/bundle/references/v1-section-mapping.md +0 -47
- package/bundle/skills/hej/.claude-plugin/plugin.json +0 -6
- package/bundle/skills/hej/SKILL.md +0 -69
- package/bundle/skills/hej/agents/hej.toml +0 -11
- package/bundle/skills/hej/agents/openai.yaml +0 -8
package/dist/cli/dispatch.js
CHANGED
|
@@ -1,1294 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { cmdLint } from "./commands/lint.js";
|
|
3
|
-
import { cmdState, isPortedStateCommand } from "./commands/state.js";
|
|
4
|
-
import { COMMAND_FILTERS } from "./stateQuery.js";
|
|
5
|
-
import { cmdQuery } from "./commands/query.js";
|
|
6
|
-
import { cmdCompact, cmdGate } from "./commands/compact.js";
|
|
7
|
-
import { cmdSchema } from "./commands/schema.js";
|
|
8
|
-
import { cmdDoctor } from "./commands/doctor.js";
|
|
9
|
-
import { cmdUpgrade } from "./commands/upgrade.js";
|
|
10
|
-
import { cmdVerify } from "./commands/verify.js";
|
|
11
|
-
import { cmdReport } from "./commands/report.js";
|
|
12
|
-
import { runSessionStart } from "../hooks/sessionStart.js";
|
|
13
|
-
import { runSessionStop } from "../hooks/sessionStop.js";
|
|
14
|
-
import { runCursorSessionStart } from "../hooks/cursorSessionStart.js";
|
|
15
|
-
import { runCursorPreToolUse } from "../hooks/cursorPreToolUse.js";
|
|
16
|
-
import { HookCliAdapter } from "../hooks/validateArtifact.js";
|
|
17
|
-
import fsForHooks from "node:fs";
|
|
18
|
-
import { usageMain } from "../analytics/usageStats.js";
|
|
19
|
-
import { validatePathValue } from "./argvalidate.js";
|
|
20
|
-
import { emitInvalidInput, } from "./errors.js";
|
|
21
|
-
import { cmdCapability, CAPABILITY_ROUTING_NAMES } from "./commands/capability.js";
|
|
22
|
-
import { printCommandHelp, printDoctorHelp, printTopLevelHelp, printUpgradeHelp, splitHelpArgs, wantsHelp, } from "./help.js";
|
|
23
|
-
import { cmdValidate, cmdValidateCapability, cmdValidateCapabilityContract, cmdValidateArtifact, cmdValidateDescriptors, isDelegatedValidateFamily, } from "./commands/validate.js";
|
|
24
|
-
function emitDeprecationAlias(legacy, canonical, err) {
|
|
25
|
-
err(`Deprecation: agentera ${legacy} is deprecated; use agentera ${canonical}\n`);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Map a legacy parse-error string (the kind returned by `parse*Args`) to the
|
|
29
|
-
* canonical invalid-input envelope body. Lets the parse functions keep their
|
|
30
|
-
* simple `{ error: string }` shape while every surface's error path still
|
|
31
|
-
* funnels through `emitInvalidInput` for the frozen envelope contract.
|
|
32
|
-
*/
|
|
33
|
-
function classifyParseError(raw) {
|
|
34
|
-
const required = /^the following arguments are required: (.+)$/.exec(raw);
|
|
35
|
-
if (required) {
|
|
36
|
-
return { class: "missing_argument", message: raw };
|
|
37
|
-
}
|
|
38
|
-
const unrecognized = /^unrecognized arguments: (.+)$/.exec(raw);
|
|
39
|
-
if (unrecognized) {
|
|
40
|
-
return { class: "unrecognized_argument", message: raw };
|
|
41
|
-
}
|
|
42
|
-
const choice = /^argument (--[\w-]+): invalid choice: '([^']+)' \(choose from (.+)\)$/.exec(raw);
|
|
43
|
-
if (choice) {
|
|
44
|
-
const validValues = [...choice[3].matchAll(/'([^']+)'/g)].map((m) => m[1]);
|
|
45
|
-
return {
|
|
46
|
-
class: "invalid_choice",
|
|
47
|
-
message: raw,
|
|
48
|
-
valid_values: validValues,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
const intBad = /^argument (--[\w-]+): invalid int value: '([^']+)'$/.exec(raw);
|
|
52
|
-
if (intBad) {
|
|
53
|
-
return { class: "invalid_int", message: raw };
|
|
54
|
-
}
|
|
55
|
-
const mutex = /^argument (--[\w-]+): not allowed with argument (--[\w-]+)$/.exec(raw);
|
|
56
|
-
if (mutex) {
|
|
57
|
-
return { class: "mutually_exclusive", message: raw };
|
|
58
|
-
}
|
|
59
|
-
return { class: "unrecognized_argument", message: raw };
|
|
60
|
-
}
|
|
61
|
-
/** Coerce the loose `string` format field on parsed args to the literal union. */
|
|
62
|
-
function asEnvelopeFormat(format) {
|
|
63
|
-
return format === "json" ? "json" : "text";
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Scan a top-level argv slice for `--format json` (or `--format=json`) so
|
|
67
|
-
* main() can decide whether to route its error envelope to stdout or stderr.
|
|
68
|
-
* Unknown format values fall through to "text" — the user will discover the
|
|
69
|
-
* mis-spelling when the underlying command runs.
|
|
70
|
-
*/
|
|
71
|
-
function detectTopLevelFormat(args) {
|
|
72
|
-
for (let i = 0; i < args.length; i++) {
|
|
73
|
-
const a = args[i];
|
|
74
|
-
if (a === "--format") {
|
|
75
|
-
const v = args[++i];
|
|
76
|
-
if (v === "json" || v === "text" || v === "yaml")
|
|
77
|
-
return v === "json" ? "json" : "text";
|
|
78
|
-
}
|
|
79
|
-
else if (a.startsWith("--format=")) {
|
|
80
|
-
const v = a.slice("--format=".length);
|
|
81
|
-
if (v === "json" || v === "text" || v === "yaml")
|
|
82
|
-
return v === "json" ? "json" : "text";
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return "text";
|
|
86
|
-
}
|
|
87
|
-
/** Minimal flag parser for the `lint` command surface. */
|
|
88
|
-
function parseLintArgs(argv) {
|
|
89
|
-
const args = { artifact: "", file: null, text: null, strict: false, format: "text" };
|
|
90
|
-
let sawArtifact = false;
|
|
91
|
-
for (let i = 0; i < argv.length; i++) {
|
|
92
|
-
const a = argv[i];
|
|
93
|
-
const value = (name) => {
|
|
94
|
-
if (a === name)
|
|
95
|
-
return argv[++i];
|
|
96
|
-
if (a.startsWith(name + "="))
|
|
97
|
-
return a.slice(name.length + 1);
|
|
98
|
-
return null;
|
|
99
|
-
};
|
|
100
|
-
let v;
|
|
101
|
-
if ((v = value("--artifact")) !== null) {
|
|
102
|
-
args.artifact = v;
|
|
103
|
-
sawArtifact = true;
|
|
104
|
-
}
|
|
105
|
-
else if ((v = value("--file")) !== null) {
|
|
106
|
-
args.file = v;
|
|
107
|
-
}
|
|
108
|
-
else if ((v = value("--text")) !== null) {
|
|
109
|
-
args.text = v;
|
|
110
|
-
}
|
|
111
|
-
else if (a === "--strict") {
|
|
112
|
-
args.strict = true;
|
|
113
|
-
}
|
|
114
|
-
else if ((v = value("--format")) !== null) {
|
|
115
|
-
if (v !== "text" && v !== "json") {
|
|
116
|
-
return { error: `argument --format: invalid choice: '${v}' (choose from 'text', 'json')` };
|
|
117
|
-
}
|
|
118
|
-
args.format = v;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
return { error: `unrecognized arguments: ${a}` };
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (!sawArtifact)
|
|
125
|
-
return { error: "the following arguments are required: --artifact" };
|
|
126
|
-
if (args.file !== null && args.text !== null) {
|
|
127
|
-
return { error: "argument --text: not allowed with argument --file" };
|
|
128
|
-
}
|
|
129
|
-
return args;
|
|
130
|
-
}
|
|
131
|
-
function runLint(argv, io, prog = "agentera lint") {
|
|
132
|
-
const parsed = parseLintArgs(argv);
|
|
133
|
-
if ("error" in parsed) {
|
|
134
|
-
return emitInvalidInput(io, {
|
|
135
|
-
format: "text",
|
|
136
|
-
body: classifyParseError(parsed.error),
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
try {
|
|
140
|
-
return cmdLint(parsed, io);
|
|
141
|
-
}
|
|
142
|
-
catch (exc) {
|
|
143
|
-
return emitInvalidInput(io, {
|
|
144
|
-
format: asEnvelopeFormat(parsed.format),
|
|
145
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function parseStateArgs(command, argv) {
|
|
150
|
-
const args = {
|
|
151
|
-
command,
|
|
152
|
-
topic: null,
|
|
153
|
-
status: null,
|
|
154
|
-
dimension: null,
|
|
155
|
-
severity: null,
|
|
156
|
-
limit: 5,
|
|
157
|
-
format: "text",
|
|
158
|
-
fields: null,
|
|
159
|
-
};
|
|
160
|
-
const allowed = new Set([...(COMMAND_FILTERS[command] ?? []), "format", "fields"]);
|
|
161
|
-
for (let i = 0; i < argv.length; i++) {
|
|
162
|
-
const a = argv[i];
|
|
163
|
-
const value = (name) => {
|
|
164
|
-
if (a === name)
|
|
165
|
-
return argv[++i];
|
|
166
|
-
if (a.startsWith(name + "="))
|
|
167
|
-
return a.slice(name.length + 1);
|
|
168
|
-
return null;
|
|
169
|
-
};
|
|
170
|
-
const named = (flag, key) => allowed.has(key) && (a === flag || a.startsWith(flag + "="));
|
|
171
|
-
let v;
|
|
172
|
-
if (named("--topic", "topic"))
|
|
173
|
-
args.topic = value("--topic");
|
|
174
|
-
else if (named("--status", "status"))
|
|
175
|
-
args.status = value("--status");
|
|
176
|
-
else if (named("--dimension", "dimension"))
|
|
177
|
-
args.dimension = value("--dimension");
|
|
178
|
-
else if (named("--severity", "severity"))
|
|
179
|
-
args.severity = value("--severity");
|
|
180
|
-
else if (named("--limit", "limit")) {
|
|
181
|
-
v = value("--limit");
|
|
182
|
-
const n = Number(v);
|
|
183
|
-
if (!Number.isInteger(n))
|
|
184
|
-
return { error: `argument --limit: invalid int value: '${v}'` };
|
|
185
|
-
args.limit = n;
|
|
186
|
-
}
|
|
187
|
-
else if (a === "--format" || a.startsWith("--format=")) {
|
|
188
|
-
v = value("--format");
|
|
189
|
-
if (v !== "text" && v !== "json" && v !== "yaml") {
|
|
190
|
-
return { error: `argument --format: invalid choice: '${v}' (choose from 'text', 'json', 'yaml')` };
|
|
191
|
-
}
|
|
192
|
-
args.format = v;
|
|
193
|
-
}
|
|
194
|
-
else if (a === "--fields" || a.startsWith("--fields="))
|
|
195
|
-
args.fields = value("--fields");
|
|
196
|
-
else
|
|
197
|
-
return { error: `unrecognized arguments: ${a}` };
|
|
198
|
-
}
|
|
199
|
-
return args;
|
|
200
|
-
}
|
|
201
|
-
function runState(command, argv, io, prog) {
|
|
202
|
-
const parsed = parseStateArgs(command, argv);
|
|
203
|
-
if ("error" in parsed) {
|
|
204
|
-
return emitInvalidInput(io, {
|
|
205
|
-
format: "text",
|
|
206
|
-
body: classifyParseError(parsed.error),
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
try {
|
|
210
|
-
return cmdState(parsed, io);
|
|
211
|
-
}
|
|
212
|
-
catch (exc) {
|
|
213
|
-
return emitInvalidInput(io, {
|
|
214
|
-
format: asEnvelopeFormat(parsed.format),
|
|
215
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
function parseQueryArgs(argv) {
|
|
220
|
-
const args = {
|
|
221
|
-
query: null,
|
|
222
|
-
list_artifacts: false,
|
|
223
|
-
topic: null,
|
|
224
|
-
severity: null,
|
|
225
|
-
dimension: null,
|
|
226
|
-
status: null,
|
|
227
|
-
limit: null,
|
|
228
|
-
format: "text",
|
|
229
|
-
fields: null,
|
|
230
|
-
};
|
|
231
|
-
for (let i = 0; i < argv.length; i++) {
|
|
232
|
-
const a = argv[i];
|
|
233
|
-
const value = (name) => {
|
|
234
|
-
if (a === name)
|
|
235
|
-
return argv[++i];
|
|
236
|
-
if (a.startsWith(name + "="))
|
|
237
|
-
return a.slice(name.length + 1);
|
|
238
|
-
return null;
|
|
239
|
-
};
|
|
240
|
-
let v;
|
|
241
|
-
if (a === "--list-artifacts")
|
|
242
|
-
args.list_artifacts = true;
|
|
243
|
-
else if ((v = value("--topic")) !== null)
|
|
244
|
-
args.topic = v;
|
|
245
|
-
else if ((v = value("--severity")) !== null)
|
|
246
|
-
args.severity = v;
|
|
247
|
-
else if ((v = value("--dimension")) !== null)
|
|
248
|
-
args.dimension = v;
|
|
249
|
-
else if ((v = value("--status")) !== null)
|
|
250
|
-
args.status = v;
|
|
251
|
-
else if ((v = value("--limit")) !== null) {
|
|
252
|
-
const n = Number(v);
|
|
253
|
-
if (!Number.isInteger(n))
|
|
254
|
-
return { error: `argument --limit: invalid int value: '${v}'` };
|
|
255
|
-
args.limit = n;
|
|
256
|
-
}
|
|
257
|
-
else if ((v = value("--format")) !== null) {
|
|
258
|
-
if (v !== "text" && v !== "json" && v !== "yaml") {
|
|
259
|
-
return { error: `argument --format: invalid choice: '${v}' (choose from 'text', 'json', 'yaml')` };
|
|
260
|
-
}
|
|
261
|
-
args.format = v;
|
|
262
|
-
}
|
|
263
|
-
else if ((v = value("--fields")) !== null)
|
|
264
|
-
args.fields = v;
|
|
265
|
-
else if (a.startsWith("--"))
|
|
266
|
-
return { error: `unrecognized arguments: ${a}` };
|
|
267
|
-
else if (args.query === null)
|
|
268
|
-
args.query = a;
|
|
269
|
-
else
|
|
270
|
-
return { error: `unrecognized arguments: ${a}` };
|
|
271
|
-
}
|
|
272
|
-
return args;
|
|
273
|
-
}
|
|
274
|
-
function runQuery(argv, io, prog) {
|
|
275
|
-
const parsed = parseQueryArgs(argv);
|
|
276
|
-
if ("error" in parsed) {
|
|
277
|
-
return emitInvalidInput(io, {
|
|
278
|
-
format: "text",
|
|
279
|
-
body: classifyParseError(parsed.error),
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
try {
|
|
283
|
-
return cmdQuery(parsed, io);
|
|
284
|
-
}
|
|
285
|
-
catch (exc) {
|
|
286
|
-
return emitInvalidInput(io, {
|
|
287
|
-
format: asEnvelopeFormat(parsed.format),
|
|
288
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
function compactModeOf(argv) {
|
|
293
|
-
for (let i = 0; i < argv.length; i++) {
|
|
294
|
-
if (argv[i] === "--apply")
|
|
295
|
-
return "fix";
|
|
296
|
-
if (argv[i] === "--mode")
|
|
297
|
-
return argv[i + 1] ?? "check";
|
|
298
|
-
if (argv[i].startsWith("--mode="))
|
|
299
|
-
return argv[i].slice("--mode=".length);
|
|
300
|
-
}
|
|
301
|
-
return "check";
|
|
302
|
-
}
|
|
303
|
-
function parseCompactArgs(argv) {
|
|
304
|
-
const args = { project: null, mode: "check", format: "text" };
|
|
305
|
-
for (let i = 0; i < argv.length; i++) {
|
|
306
|
-
const a = argv[i];
|
|
307
|
-
const value = (name) => {
|
|
308
|
-
if (a === name)
|
|
309
|
-
return argv[++i];
|
|
310
|
-
if (a.startsWith(name + "="))
|
|
311
|
-
return a.slice(name.length + 1);
|
|
312
|
-
return null;
|
|
313
|
-
};
|
|
314
|
-
let v;
|
|
315
|
-
if (a === "--apply") {
|
|
316
|
-
args.mode = "fix";
|
|
317
|
-
}
|
|
318
|
-
else if ((v = value("--project")) !== null)
|
|
319
|
-
args.project = v;
|
|
320
|
-
else if ((v = value("--mode")) !== null) {
|
|
321
|
-
if (v !== "check" && v !== "fix") {
|
|
322
|
-
return { error: `argument --mode: invalid choice: '${v}' (choose from 'check', 'fix')` };
|
|
323
|
-
}
|
|
324
|
-
args.mode = v;
|
|
325
|
-
}
|
|
326
|
-
else if ((v = value("--format")) !== null) {
|
|
327
|
-
if (v !== "text" && v !== "json") {
|
|
328
|
-
return { error: `argument --format: invalid choice: '${v}' (choose from 'text', 'json')` };
|
|
329
|
-
}
|
|
330
|
-
args.format = v;
|
|
331
|
-
}
|
|
332
|
-
else
|
|
333
|
-
return { error: `unrecognized arguments: ${a}` };
|
|
334
|
-
}
|
|
335
|
-
return args;
|
|
336
|
-
}
|
|
337
|
-
function runCompact(argv, io, prog) {
|
|
338
|
-
const parsed = parseCompactArgs(argv);
|
|
339
|
-
if ("error" in parsed) {
|
|
340
|
-
return emitInvalidInput(io, {
|
|
341
|
-
format: "text",
|
|
342
|
-
body: classifyParseError(parsed.error),
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
try {
|
|
346
|
-
return cmdCompact(parsed, io);
|
|
347
|
-
}
|
|
348
|
-
catch (exc) {
|
|
349
|
-
return emitInvalidInput(io, {
|
|
350
|
-
format: asEnvelopeFormat(parsed.format),
|
|
351
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
function runValidate(argv, io, prog) {
|
|
356
|
-
let family = null;
|
|
357
|
-
let capabilityTarget = null;
|
|
358
|
-
let artifactFlag = null;
|
|
359
|
-
let fileFlag = null;
|
|
360
|
-
let cwdFlag = null;
|
|
361
|
-
let format = "text";
|
|
362
|
-
for (let i = 0; i < argv.length; i++) {
|
|
363
|
-
const a = argv[i];
|
|
364
|
-
if (a === "--format") {
|
|
365
|
-
const v = argv[++i];
|
|
366
|
-
if (v !== "text" && v !== "json") {
|
|
367
|
-
return emitInvalidInput(io, {
|
|
368
|
-
format,
|
|
369
|
-
body: {
|
|
370
|
-
class: "invalid_choice",
|
|
371
|
-
message: `argument --format: invalid choice: '${v}' (choose from 'text', 'json')`,
|
|
372
|
-
valid_values: ["text", "json"],
|
|
373
|
-
},
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
format = v;
|
|
377
|
-
}
|
|
378
|
-
else if (a.startsWith("--format=")) {
|
|
379
|
-
const v = a.slice("--format=".length);
|
|
380
|
-
if (v !== "text" && v !== "json") {
|
|
381
|
-
return emitInvalidInput(io, {
|
|
382
|
-
format,
|
|
383
|
-
body: {
|
|
384
|
-
class: "invalid_choice",
|
|
385
|
-
message: `argument --format: invalid choice: '${v}' (choose from 'text', 'json')`,
|
|
386
|
-
valid_values: ["text", "json"],
|
|
387
|
-
},
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
format = v;
|
|
391
|
-
}
|
|
392
|
-
else if (a === "--artifact" || a.startsWith("--artifact=")) {
|
|
393
|
-
artifactFlag = a === "--artifact" ? argv[++i] : a.slice("--artifact=".length);
|
|
394
|
-
}
|
|
395
|
-
else if (a === "--file" || a.startsWith("--file=")) {
|
|
396
|
-
fileFlag = a === "--file" ? argv[++i] : a.slice("--file=".length);
|
|
397
|
-
}
|
|
398
|
-
else if (a === "--cwd" || a.startsWith("--cwd=")) {
|
|
399
|
-
cwdFlag = a === "--cwd" ? argv[++i] : a.slice("--cwd=".length);
|
|
400
|
-
}
|
|
401
|
-
else if (a.startsWith("--")) {
|
|
402
|
-
return emitInvalidInput(io, {
|
|
403
|
-
format,
|
|
404
|
-
body: {
|
|
405
|
-
class: "unrecognized_argument",
|
|
406
|
-
message: `unrecognized arguments: ${a}`,
|
|
407
|
-
},
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
else if (family === null) {
|
|
411
|
-
family = a;
|
|
412
|
-
}
|
|
413
|
-
else if (capabilityTarget === null) {
|
|
414
|
-
capabilityTarget = a;
|
|
415
|
-
}
|
|
416
|
-
else {
|
|
417
|
-
return emitInvalidInput(io, {
|
|
418
|
-
format,
|
|
419
|
-
body: {
|
|
420
|
-
class: "unrecognized_argument",
|
|
421
|
-
message: `unrecognized arguments: ${a}`,
|
|
422
|
-
},
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
if (family === null) {
|
|
427
|
-
return emitInvalidInput(io, {
|
|
428
|
-
format,
|
|
429
|
-
body: {
|
|
430
|
-
class: "missing_argument",
|
|
431
|
-
message: "the following arguments are required: validate_family",
|
|
432
|
-
valid_values: [
|
|
433
|
-
"cross-capability",
|
|
434
|
-
"lifecycle-adapters",
|
|
435
|
-
"app-home-contract",
|
|
436
|
-
"capability",
|
|
437
|
-
"capability-contract",
|
|
438
|
-
"descriptors",
|
|
439
|
-
"artifact",
|
|
440
|
-
],
|
|
441
|
-
example: "agentera check validate cross-capability",
|
|
442
|
-
},
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
try {
|
|
446
|
-
if (family === "capability") {
|
|
447
|
-
if (capabilityTarget === null) {
|
|
448
|
-
return emitInvalidInput(io, {
|
|
449
|
-
format,
|
|
450
|
-
body: {
|
|
451
|
-
class: "missing_argument",
|
|
452
|
-
message: "the following arguments are required: target",
|
|
453
|
-
example: "agentera check validate capability planera",
|
|
454
|
-
},
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
return cmdValidateCapability(capabilityTarget, { format }, io);
|
|
458
|
-
}
|
|
459
|
-
if (family === "capability-contract") {
|
|
460
|
-
return cmdValidateCapabilityContract({ format }, io);
|
|
461
|
-
}
|
|
462
|
-
if (family === "descriptors") {
|
|
463
|
-
return cmdValidateDescriptors({ format }, io);
|
|
464
|
-
}
|
|
465
|
-
if (family === "artifact") {
|
|
466
|
-
if (artifactFlag === null) {
|
|
467
|
-
return emitInvalidInput(io, {
|
|
468
|
-
format,
|
|
469
|
-
body: {
|
|
470
|
-
class: "missing_argument",
|
|
471
|
-
message: "the following arguments are required: --artifact",
|
|
472
|
-
example: "agentera check validate artifact --artifact PLAN.md",
|
|
473
|
-
},
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
return cmdValidateArtifact({ artifact: artifactFlag, file: fileFlag, cwd: cwdFlag, format }, io);
|
|
477
|
-
}
|
|
478
|
-
if (isDelegatedValidateFamily(family)) {
|
|
479
|
-
return cmdValidate(family, { format }, io);
|
|
480
|
-
}
|
|
481
|
-
return emitInvalidInput(io, {
|
|
482
|
-
format,
|
|
483
|
-
body: {
|
|
484
|
-
class: "unsupported_target",
|
|
485
|
-
message: `validate family not yet ported: ${family}`,
|
|
486
|
-
valid_values: [
|
|
487
|
-
"cross-capability",
|
|
488
|
-
"lifecycle-adapters",
|
|
489
|
-
"app-home-contract",
|
|
490
|
-
"capability",
|
|
491
|
-
"capability-contract",
|
|
492
|
-
"descriptors",
|
|
493
|
-
"artifact",
|
|
494
|
-
],
|
|
495
|
-
},
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
catch (exc) {
|
|
499
|
-
return emitInvalidInput(io, {
|
|
500
|
-
format,
|
|
501
|
-
body: {
|
|
502
|
-
class: "unsupported_target",
|
|
503
|
-
message: exc.message,
|
|
504
|
-
},
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
function runSchema(argv, io, prog) {
|
|
509
|
-
let format = "json";
|
|
510
|
-
for (let i = 0; i < argv.length; i++) {
|
|
511
|
-
const a = argv[i];
|
|
512
|
-
let v = null;
|
|
513
|
-
if (a === "--format")
|
|
514
|
-
v = argv[++i];
|
|
515
|
-
else if (a.startsWith("--format="))
|
|
516
|
-
v = a.slice("--format=".length);
|
|
517
|
-
else {
|
|
518
|
-
return emitInvalidInput(io, {
|
|
519
|
-
format: asEnvelopeFormat(format),
|
|
520
|
-
body: { class: "unrecognized_argument", message: `unrecognized arguments: ${a}` },
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
if (v !== "json" && v !== "yaml") {
|
|
524
|
-
return emitInvalidInput(io, {
|
|
525
|
-
format: asEnvelopeFormat(format),
|
|
526
|
-
body: {
|
|
527
|
-
class: "invalid_choice",
|
|
528
|
-
message: `argument --format: invalid choice: '${v}' (choose from 'json', 'yaml')`,
|
|
529
|
-
valid_values: ["json", "yaml"],
|
|
530
|
-
},
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
format = v;
|
|
534
|
-
}
|
|
535
|
-
try {
|
|
536
|
-
return cmdSchema({ format }, io);
|
|
537
|
-
}
|
|
538
|
-
catch (exc) {
|
|
539
|
-
return emitInvalidInput(io, {
|
|
540
|
-
format: asEnvelopeFormat(format),
|
|
541
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
function runCapability(command, argv, io, prog) {
|
|
546
|
-
let format = "text";
|
|
547
|
-
for (let i = 0; i < argv.length; i++) {
|
|
548
|
-
const a = argv[i];
|
|
549
|
-
let v = null;
|
|
550
|
-
if (a === "--format")
|
|
551
|
-
v = argv[++i];
|
|
552
|
-
else if (a.startsWith("--format="))
|
|
553
|
-
v = a.slice("--format=".length);
|
|
554
|
-
else if (a === "--fields" || a.startsWith("--fields=")) {
|
|
555
|
-
// accepted by the parser but unused by capability routing
|
|
556
|
-
if (a === "--fields")
|
|
557
|
-
i++;
|
|
558
|
-
continue;
|
|
559
|
-
}
|
|
560
|
-
else {
|
|
561
|
-
return emitInvalidInput(io, {
|
|
562
|
-
format: asEnvelopeFormat(format),
|
|
563
|
-
body: { class: "unrecognized_argument", message: `unrecognized arguments: ${a}` },
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
if (v !== "text" && v !== "json" && v !== "yaml") {
|
|
567
|
-
return emitInvalidInput(io, {
|
|
568
|
-
format: asEnvelopeFormat(format),
|
|
569
|
-
body: {
|
|
570
|
-
class: "invalid_choice",
|
|
571
|
-
message: `argument --format: invalid choice: '${v}' (choose from 'text', 'json', 'yaml')`,
|
|
572
|
-
valid_values: ["text", "json", "yaml"],
|
|
573
|
-
},
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
format = v;
|
|
577
|
-
}
|
|
578
|
-
try {
|
|
579
|
-
return cmdCapability(command, { format }, io);
|
|
580
|
-
}
|
|
581
|
-
catch (exc) {
|
|
582
|
-
return emitInvalidInput(io, {
|
|
583
|
-
format: asEnvelopeFormat(format),
|
|
584
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
function runPrime(command, argv, io, prog) {
|
|
589
|
-
const args = { command, guidance: false, context: null, dashboard: false, orientation: false, format: "text" };
|
|
590
|
-
for (let i = 0; i < argv.length; i++) {
|
|
591
|
-
const a = argv[i];
|
|
592
|
-
let v = null;
|
|
593
|
-
if (a === "--guidance")
|
|
594
|
-
args.guidance = true;
|
|
595
|
-
else if (a === "--dashboard")
|
|
596
|
-
args.dashboard = true;
|
|
597
|
-
else if (a === "--orientation")
|
|
598
|
-
args.orientation = true;
|
|
599
|
-
else if (a === "--context")
|
|
600
|
-
args.context = argv[++i];
|
|
601
|
-
else if (a.startsWith("--context="))
|
|
602
|
-
args.context = a.slice("--context=".length);
|
|
603
|
-
else if (a === "--format" || a.startsWith("--format=")) {
|
|
604
|
-
v = a === "--format" ? argv[++i] : a.slice("--format=".length);
|
|
605
|
-
if (v !== "text" && v !== "json" && v !== "yaml") {
|
|
606
|
-
return emitInvalidInput(io, {
|
|
607
|
-
format: asEnvelopeFormat(args.format),
|
|
608
|
-
body: {
|
|
609
|
-
class: "invalid_choice",
|
|
610
|
-
message: `argument --format: invalid choice: '${v}' (choose from 'text', 'json', 'yaml')`,
|
|
611
|
-
valid_values: ["text", "json", "yaml"],
|
|
612
|
-
},
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
args.format = v;
|
|
616
|
-
}
|
|
617
|
-
else if (a === "--fields") {
|
|
618
|
-
args.fields = argv[++i];
|
|
619
|
-
}
|
|
620
|
-
else if (a.startsWith("--fields=")) {
|
|
621
|
-
args.fields = a.slice("--fields=".length);
|
|
622
|
-
}
|
|
623
|
-
else {
|
|
624
|
-
return emitInvalidInput(io, {
|
|
625
|
-
format: asEnvelopeFormat(args.format),
|
|
626
|
-
body: { class: "unrecognized_argument", message: `unrecognized arguments: ${a}` },
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
try {
|
|
631
|
-
return cmdPrime(args, io);
|
|
632
|
-
}
|
|
633
|
-
catch (exc) {
|
|
634
|
-
return emitInvalidInput(io, {
|
|
635
|
-
format: asEnvelopeFormat(args.format),
|
|
636
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
function runGate(argv, io, prog) {
|
|
641
|
-
const parsed = parseCompactArgs(argv);
|
|
642
|
-
if ("error" in parsed) {
|
|
643
|
-
return emitInvalidInput(io, {
|
|
644
|
-
format: "text",
|
|
645
|
-
body: classifyParseError(parsed.error),
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
try {
|
|
649
|
-
return cmdGate(parsed, io);
|
|
650
|
-
}
|
|
651
|
-
catch (exc) {
|
|
652
|
-
return emitInvalidInput(io, {
|
|
653
|
-
format: asEnvelopeFormat(parsed.format),
|
|
654
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
function runDoctor(argv, io, prog) {
|
|
659
|
-
const err = io.err ?? ((t) => process.stderr.write(t));
|
|
660
|
-
const out = io.out ?? ((t) => process.stdout.write(t));
|
|
661
|
-
if (wantsHelp(argv)) {
|
|
662
|
-
out(printDoctorHelp() + "\n");
|
|
663
|
-
return 0;
|
|
664
|
-
}
|
|
665
|
-
const args = {
|
|
666
|
-
installRoot: null,
|
|
667
|
-
home: null,
|
|
668
|
-
project: null,
|
|
669
|
-
expectedVersion: null,
|
|
670
|
-
expectCommand: [],
|
|
671
|
-
smoke: false,
|
|
672
|
-
allowLiveModel: false,
|
|
673
|
-
format: "text",
|
|
674
|
-
};
|
|
675
|
-
let jsonFlag = false;
|
|
676
|
-
for (let i = 0; i < argv.length; i++) {
|
|
677
|
-
const a = argv[i];
|
|
678
|
-
const value = (name) => {
|
|
679
|
-
if (a === name)
|
|
680
|
-
return argv[++i];
|
|
681
|
-
if (a.startsWith(name + "="))
|
|
682
|
-
return a.slice(name.length + 1);
|
|
683
|
-
return null;
|
|
684
|
-
};
|
|
685
|
-
let v;
|
|
686
|
-
if ((v = value("--install-root")) !== null)
|
|
687
|
-
args.installRoot = v;
|
|
688
|
-
else if ((v = value("--home")) !== null)
|
|
689
|
-
args.home = v;
|
|
690
|
-
else if ((v = value("--project")) !== null)
|
|
691
|
-
args.project = v;
|
|
692
|
-
else if ((v = value("--expected-version")) !== null)
|
|
693
|
-
args.expectedVersion = v;
|
|
694
|
-
else if ((v = value("--expect-command")) !== null)
|
|
695
|
-
args.expectCommand.push(v);
|
|
696
|
-
else if ((v = value("--format")) !== null) {
|
|
697
|
-
if (v !== "text" && v !== "json") {
|
|
698
|
-
return emitInvalidInput(io, {
|
|
699
|
-
format: asEnvelopeFormat(args.format),
|
|
700
|
-
body: {
|
|
701
|
-
class: "invalid_choice",
|
|
702
|
-
message: `argument --format: invalid choice: '${v}' (choose from 'text', 'json')`,
|
|
703
|
-
valid_values: ["text", "json"],
|
|
704
|
-
},
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
args.format = v;
|
|
708
|
-
}
|
|
709
|
-
else if (a === "--json")
|
|
710
|
-
jsonFlag = true;
|
|
711
|
-
else if (a === "--smoke")
|
|
712
|
-
args.smoke = true;
|
|
713
|
-
else if (a === "--allow-live-model")
|
|
714
|
-
args.allowLiveModel = true;
|
|
715
|
-
else {
|
|
716
|
-
return emitInvalidInput(io, {
|
|
717
|
-
format: asEnvelopeFormat(args.format),
|
|
718
|
-
body: { class: "unrecognized_argument", message: `unrecognized arguments: ${a}` },
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
if (jsonFlag) {
|
|
723
|
-
emitDeprecationAlias("doctor --json", "doctor --format json", err);
|
|
724
|
-
args.format = "json";
|
|
725
|
-
}
|
|
726
|
-
try {
|
|
727
|
-
return cmdDoctor(args, io);
|
|
728
|
-
}
|
|
729
|
-
catch (exc) {
|
|
730
|
-
return emitInvalidInput(io, {
|
|
731
|
-
format: asEnvelopeFormat(args.format),
|
|
732
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
733
|
-
});
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
function readStdin() {
|
|
737
|
-
try {
|
|
738
|
-
return fsForHooks.readFileSync(0, "utf8");
|
|
739
|
-
}
|
|
740
|
-
catch {
|
|
741
|
-
return "";
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
function runHook(name, argv, io) {
|
|
745
|
-
const err = io.err ?? ((t) => process.stderr.write(t));
|
|
746
|
-
const raw = io.stdin ? io.stdin() : readStdin();
|
|
747
|
-
// Each hook owns its own stdout newline convention; do not wrap stdout here.
|
|
748
|
-
switch (name) {
|
|
749
|
-
case "session-start":
|
|
750
|
-
return runSessionStart(raw);
|
|
751
|
-
case "session-stop":
|
|
752
|
-
return runSessionStop(raw);
|
|
753
|
-
case "cursor-session-start":
|
|
754
|
-
return runCursorSessionStart(raw);
|
|
755
|
-
case "cursor-pre-tool-use":
|
|
756
|
-
return runCursorPreToolUse(raw);
|
|
757
|
-
case "validate-artifact": {
|
|
758
|
-
const [rc, violations] = new HookCliAdapter().run(raw, null);
|
|
759
|
-
for (const v of violations)
|
|
760
|
-
err(`${v}\n`);
|
|
761
|
-
return rc;
|
|
762
|
-
}
|
|
763
|
-
default:
|
|
764
|
-
return emitInvalidInput(io, {
|
|
765
|
-
format: "text",
|
|
766
|
-
body: {
|
|
767
|
-
class: "unsupported_target",
|
|
768
|
-
message: `unknown hook '${name}'`,
|
|
769
|
-
valid_values: [
|
|
770
|
-
"session-start",
|
|
771
|
-
"session-stop",
|
|
772
|
-
"cursor-session-start",
|
|
773
|
-
"cursor-pre-tool-use",
|
|
774
|
-
"validate-artifact",
|
|
775
|
-
],
|
|
776
|
-
},
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
function runUsage(argv, io, prog) {
|
|
781
|
-
const realOut = io.out ?? ((t) => process.stdout.write(t));
|
|
782
|
-
const realErr = io.err ?? ((t) => process.stderr.write(t));
|
|
783
|
-
let format = "text";
|
|
784
|
-
let corpus = null;
|
|
785
|
-
let project = null;
|
|
786
|
-
for (let i = 0; i < argv.length; i++) {
|
|
787
|
-
const a = argv[i];
|
|
788
|
-
const value = (name) => {
|
|
789
|
-
if (a === name)
|
|
790
|
-
return argv[++i] ?? null;
|
|
791
|
-
if (a.startsWith(name + "="))
|
|
792
|
-
return a.slice(name.length + 1);
|
|
793
|
-
return null;
|
|
794
|
-
};
|
|
795
|
-
let v;
|
|
796
|
-
if ((v = value("--format")) !== null)
|
|
797
|
-
format = v;
|
|
798
|
-
else if ((v = value("--corpus")) !== null)
|
|
799
|
-
corpus = v;
|
|
800
|
-
else if ((v = value("--project")) !== null)
|
|
801
|
-
project = v;
|
|
802
|
-
else {
|
|
803
|
-
return emitInvalidInput(io, {
|
|
804
|
-
format: asEnvelopeFormat(format),
|
|
805
|
-
body: { class: "unrecognized_argument", message: `unrecognized arguments: ${a}` },
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
if (corpus !== null) {
|
|
810
|
-
try {
|
|
811
|
-
validatePathValue(corpus, "path");
|
|
812
|
-
}
|
|
813
|
-
catch (e) {
|
|
814
|
-
return emitInvalidInput(io, {
|
|
815
|
-
format: asEnvelopeFormat(format),
|
|
816
|
-
body: {
|
|
817
|
-
class: "invalid_format",
|
|
818
|
-
message: `argument --corpus: ${e.message}`,
|
|
819
|
-
},
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
if (format !== "text" && format !== "json") {
|
|
824
|
-
return emitInvalidInput(io, {
|
|
825
|
-
format: asEnvelopeFormat(format),
|
|
826
|
-
body: {
|
|
827
|
-
class: "invalid_choice",
|
|
828
|
-
message: `unsupported usage format '${format}'; valid formats: text, json.`,
|
|
829
|
-
valid_values: ["text", "json"],
|
|
830
|
-
syntax: "agentera usage [--format text|json] [--corpus PATH] [--project VALUE]",
|
|
831
|
-
example: "agentera usage --format json --project agentera",
|
|
832
|
-
},
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
|
-
const engineArgv = [];
|
|
836
|
-
if (corpus !== null)
|
|
837
|
-
engineArgv.push("--corpus", corpus);
|
|
838
|
-
if (project !== null)
|
|
839
|
-
engineArgv.push("--project", project);
|
|
840
|
-
if (format === "json")
|
|
841
|
-
engineArgv.push("--json");
|
|
842
|
-
return usageMain(engineArgv, {
|
|
843
|
-
out: (t) => realOut(t + "\n"),
|
|
844
|
-
err: (t) => realErr(t + "\n"),
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
function runUpgrade(argv, io, prog) {
|
|
848
|
-
const err = io.err ?? ((t) => process.stderr.write(t));
|
|
849
|
-
const out = io.out ?? ((t) => process.stdout.write(t));
|
|
850
|
-
if (wantsHelp(argv)) {
|
|
851
|
-
out(printUpgradeHelp() + "\n");
|
|
852
|
-
return 0;
|
|
853
|
-
}
|
|
854
|
-
const args = {
|
|
855
|
-
installRoot: null,
|
|
856
|
-
home: null,
|
|
857
|
-
project: null,
|
|
858
|
-
expectedVersion: null,
|
|
859
|
-
channel: null,
|
|
860
|
-
yes: false,
|
|
861
|
-
dryRun: false,
|
|
862
|
-
only: [],
|
|
863
|
-
force: false,
|
|
864
|
-
format: "text",
|
|
865
|
-
};
|
|
866
|
-
let jsonFlag = false;
|
|
867
|
-
for (let i = 0; i < argv.length; i++) {
|
|
868
|
-
const a = argv[i];
|
|
869
|
-
const value = (name) => {
|
|
870
|
-
if (a === name)
|
|
871
|
-
return argv[++i] ?? null;
|
|
872
|
-
if (a.startsWith(name + "="))
|
|
873
|
-
return a.slice(name.length + 1);
|
|
874
|
-
return null;
|
|
875
|
-
};
|
|
876
|
-
let v;
|
|
877
|
-
if ((v = value("--install-root")) !== null)
|
|
878
|
-
args.installRoot = v;
|
|
879
|
-
else if ((v = value("--home")) !== null)
|
|
880
|
-
args.home = v;
|
|
881
|
-
else if ((v = value("--project")) !== null)
|
|
882
|
-
args.project = v;
|
|
883
|
-
else if ((v = value("--expected-version")) !== null)
|
|
884
|
-
args.expectedVersion = v;
|
|
885
|
-
else if ((v = value("--channel")) !== null)
|
|
886
|
-
args.channel = v;
|
|
887
|
-
else if ((v = value("--target-major")) !== null) {
|
|
888
|
-
void v;
|
|
889
|
-
return emitInvalidInput(io, {
|
|
890
|
-
format: asEnvelopeFormat(args.format),
|
|
891
|
-
body: {
|
|
892
|
-
class: "unsupported_target",
|
|
893
|
-
message: "--target-major was removed; use --channel with dry-run preview then --yes",
|
|
894
|
-
},
|
|
895
|
-
});
|
|
896
|
-
}
|
|
897
|
-
else if ((v = value("--runtime")) !== null)
|
|
898
|
-
void v; // accepted; orchestrator uses fixture runtimes
|
|
899
|
-
else if ((v = value("--only")) !== null) {
|
|
900
|
-
if (v !== "artifacts" && v !== "runtime" && v !== "cleanup") {
|
|
901
|
-
return emitInvalidInput(io, {
|
|
902
|
-
format: asEnvelopeFormat(args.format),
|
|
903
|
-
body: {
|
|
904
|
-
class: "invalid_choice",
|
|
905
|
-
message: `argument --only: invalid choice: '${v}' (choose from 'artifacts', 'runtime', 'cleanup')`,
|
|
906
|
-
valid_values: ["artifacts", "runtime", "cleanup"],
|
|
907
|
-
},
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
args.only.push(v);
|
|
911
|
-
}
|
|
912
|
-
else if ((v = value("--opencode-config-dir")) !== null)
|
|
913
|
-
void v; // accepted; ignored
|
|
914
|
-
else if (a === "--yes")
|
|
915
|
-
args.yes = true;
|
|
916
|
-
else if (a === "--dry-run")
|
|
917
|
-
args.dryRun = true;
|
|
918
|
-
else if (a === "--force")
|
|
919
|
-
args.force = true;
|
|
920
|
-
else if (a === "--update-packages")
|
|
921
|
-
void 0; // deferred for 3.x channel model
|
|
922
|
-
else if (a === "--json")
|
|
923
|
-
jsonFlag = true;
|
|
924
|
-
else if ((v = value("--format")) !== null) {
|
|
925
|
-
if (v !== "text" && v !== "json") {
|
|
926
|
-
return emitInvalidInput(io, {
|
|
927
|
-
format: asEnvelopeFormat(args.format),
|
|
928
|
-
body: {
|
|
929
|
-
class: "invalid_choice",
|
|
930
|
-
message: `argument --format: invalid choice: '${v}' (choose from 'text', 'json')`,
|
|
931
|
-
valid_values: ["text", "json"],
|
|
932
|
-
},
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
args.format = v;
|
|
936
|
-
}
|
|
937
|
-
else {
|
|
938
|
-
return emitInvalidInput(io, {
|
|
939
|
-
format: asEnvelopeFormat(args.format),
|
|
940
|
-
body: { class: "unrecognized_argument", message: `unrecognized arguments: ${a}` },
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
if (jsonFlag)
|
|
945
|
-
args.format = "json";
|
|
946
|
-
try {
|
|
947
|
-
return cmdUpgrade(args, io);
|
|
948
|
-
}
|
|
949
|
-
catch (exc) {
|
|
950
|
-
return emitInvalidInput(io, {
|
|
951
|
-
format: asEnvelopeFormat(args.format),
|
|
952
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
953
|
-
});
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
function runVerify(argv, io, prog) {
|
|
957
|
-
const args = {
|
|
958
|
-
family: null,
|
|
959
|
-
target: null,
|
|
960
|
-
format: "text",
|
|
961
|
-
run: false,
|
|
962
|
-
dryRun: false,
|
|
963
|
-
skill: null,
|
|
964
|
-
timeout: 120,
|
|
965
|
-
parallel: 1,
|
|
966
|
-
runtime: "auto",
|
|
967
|
-
fixtures: [],
|
|
968
|
-
};
|
|
969
|
-
const positionals = [];
|
|
970
|
-
for (let i = 0; i < argv.length; i++) {
|
|
971
|
-
const a = argv[i];
|
|
972
|
-
const value = (name) => {
|
|
973
|
-
if (a === name)
|
|
974
|
-
return argv[++i] ?? null;
|
|
975
|
-
if (a.startsWith(name + "="))
|
|
976
|
-
return a.slice(name.length + 1);
|
|
977
|
-
return null;
|
|
978
|
-
};
|
|
979
|
-
let v;
|
|
980
|
-
if ((v = value("--format")) !== null) {
|
|
981
|
-
if (v !== "text" && v !== "json") {
|
|
982
|
-
return emitInvalidInput(io, {
|
|
983
|
-
format: asEnvelopeFormat(args.format),
|
|
984
|
-
body: {
|
|
985
|
-
class: "invalid_choice",
|
|
986
|
-
message: `argument --format: invalid choice: '${v}' (choose from 'text', 'json')`,
|
|
987
|
-
valid_values: ["text", "json"],
|
|
988
|
-
},
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
args.format = v;
|
|
992
|
-
}
|
|
993
|
-
else if ((v = value("--skill")) !== null)
|
|
994
|
-
args.skill = v;
|
|
995
|
-
else if ((v = value("--runtime")) !== null)
|
|
996
|
-
args.runtime = v;
|
|
997
|
-
else if ((v = value("--timeout")) !== null)
|
|
998
|
-
args.timeout = Number(v);
|
|
999
|
-
else if ((v = value("--parallel")) !== null)
|
|
1000
|
-
args.parallel = Number(v);
|
|
1001
|
-
else if (a === "--run")
|
|
1002
|
-
args.run = true;
|
|
1003
|
-
else if (a === "--dry-run")
|
|
1004
|
-
args.dryRun = true;
|
|
1005
|
-
else if (a.startsWith("--")) {
|
|
1006
|
-
return emitInvalidInput(io, {
|
|
1007
|
-
format: asEnvelopeFormat(args.format),
|
|
1008
|
-
body: { class: "unrecognized_argument", message: `unrecognized arguments: ${a}` },
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
else {
|
|
1012
|
-
positionals.push(a);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
args.family = positionals[0] ?? null;
|
|
1016
|
-
args.target = positionals[1] ?? null;
|
|
1017
|
-
args.fixtures = positionals.slice(2);
|
|
1018
|
-
try {
|
|
1019
|
-
return cmdVerify(args, io);
|
|
1020
|
-
}
|
|
1021
|
-
catch (exc) {
|
|
1022
|
-
return emitInvalidInput(io, {
|
|
1023
|
-
format: asEnvelopeFormat(args.format),
|
|
1024
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
function runReport(argv, io, prog) {
|
|
1029
|
-
const args = {
|
|
1030
|
-
action: null,
|
|
1031
|
-
format: "text",
|
|
1032
|
-
project: null,
|
|
1033
|
-
dryRun: false,
|
|
1034
|
-
consent: null,
|
|
1035
|
-
projectRoot: [],
|
|
1036
|
-
};
|
|
1037
|
-
const positionals = [];
|
|
1038
|
-
for (let i = 0; i < argv.length; i++) {
|
|
1039
|
-
const a = argv[i];
|
|
1040
|
-
const value = (name) => {
|
|
1041
|
-
if (a === name)
|
|
1042
|
-
return argv[++i] ?? null;
|
|
1043
|
-
if (a.startsWith(name + "="))
|
|
1044
|
-
return a.slice(name.length + 1);
|
|
1045
|
-
return null;
|
|
1046
|
-
};
|
|
1047
|
-
let v;
|
|
1048
|
-
if ((v = value("--format")) !== null)
|
|
1049
|
-
args.format = v;
|
|
1050
|
-
else if ((v = value("--project")) !== null)
|
|
1051
|
-
args.project = v;
|
|
1052
|
-
else if ((v = value("--consent")) !== null) {
|
|
1053
|
-
if (v !== "local-history") {
|
|
1054
|
-
return emitInvalidInput(io, {
|
|
1055
|
-
format: asEnvelopeFormat(args.format),
|
|
1056
|
-
body: {
|
|
1057
|
-
class: "invalid_choice",
|
|
1058
|
-
message: `argument --consent: invalid choice: '${v}' (choose from 'local-history')`,
|
|
1059
|
-
valid_values: ["local-history"],
|
|
1060
|
-
},
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
args.consent = v;
|
|
1064
|
-
}
|
|
1065
|
-
else if ((v = value("--project-root")) !== null)
|
|
1066
|
-
args.projectRoot.push(v);
|
|
1067
|
-
else if ((v = value("--output")) !== null)
|
|
1068
|
-
args.output = v;
|
|
1069
|
-
else if ((v = value("--codex-sessions-dir")) !== null)
|
|
1070
|
-
args.codexSessionsDir = v;
|
|
1071
|
-
else if ((v = value("--claude-projects-dir")) !== null)
|
|
1072
|
-
args.claudeProjectsDir = v;
|
|
1073
|
-
else if ((v = value("--opencode-conversations-dir")) !== null)
|
|
1074
|
-
args.opencodeConversationsDir = v;
|
|
1075
|
-
else if ((v = value("--copilot-conversations-dir")) !== null)
|
|
1076
|
-
args.copilotConversationsDir = v;
|
|
1077
|
-
else if ((v = value("--cursor-projects-dir")) !== null)
|
|
1078
|
-
args.cursorProjectsDir = v;
|
|
1079
|
-
else if ((v = value("--cursor-chats-dir")) !== null)
|
|
1080
|
-
args.cursorChatsDir = v;
|
|
1081
|
-
else if (a === "--no-codex")
|
|
1082
|
-
args.noCodex = true;
|
|
1083
|
-
else if (a === "--no-claude")
|
|
1084
|
-
args.noClaude = true;
|
|
1085
|
-
else if (a === "--no-opencode")
|
|
1086
|
-
args.noOpencode = true;
|
|
1087
|
-
else if (a === "--no-copilot")
|
|
1088
|
-
args.noCopilot = true;
|
|
1089
|
-
else if (a === "--no-cursor")
|
|
1090
|
-
args.noCursor = true;
|
|
1091
|
-
else if (a === "--dry-run")
|
|
1092
|
-
args.dryRun = true;
|
|
1093
|
-
else if (a.startsWith("--")) {
|
|
1094
|
-
return emitInvalidInput(io, {
|
|
1095
|
-
format: asEnvelopeFormat(args.format),
|
|
1096
|
-
body: { class: "unrecognized_argument", message: `unrecognized arguments: ${a}` },
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
else {
|
|
1100
|
-
positionals.push(a);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
args.action = positionals[0] ?? null;
|
|
1104
|
-
try {
|
|
1105
|
-
return cmdReport(args, io);
|
|
1106
|
-
}
|
|
1107
|
-
catch (exc) {
|
|
1108
|
-
return emitInvalidInput(io, {
|
|
1109
|
-
format: asEnvelopeFormat(args.format),
|
|
1110
|
-
body: { class: "unsupported_target", message: exc.message },
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
export function main(argv, io = {}) {
|
|
1115
|
-
const err = io.err ?? ((t) => process.stderr.write(t));
|
|
1116
|
-
const out = io.out ?? ((t) => process.stdout.write(t));
|
|
1117
|
-
const args = argv.slice(2);
|
|
1118
|
-
if (args.length === 0 || args[0] === "--help" || args[0] === "-h") {
|
|
1119
|
-
out(printTopLevelHelp() + "\n");
|
|
1120
|
-
return 0;
|
|
1121
|
-
}
|
|
1122
|
-
const command = args[0];
|
|
1123
|
-
const { args: rest, help } = splitHelpArgs(args.slice(1));
|
|
1124
|
-
if (help) {
|
|
1125
|
-
const text = printCommandHelp(command, rest);
|
|
1126
|
-
if (text) {
|
|
1127
|
-
out(text + "\n");
|
|
1128
|
-
return 0;
|
|
1129
|
-
}
|
|
1130
|
-
return emitInvalidInput(io, {
|
|
1131
|
-
format: "text",
|
|
1132
|
-
body: {
|
|
1133
|
-
class: "unsupported_target",
|
|
1134
|
-
message: `unknown or not-yet-ported command: ${command}`,
|
|
1135
|
-
},
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
switch (command) {
|
|
1139
|
-
case "prime":
|
|
1140
|
-
return runPrime("prime", rest, io, "agentera prime");
|
|
1141
|
-
case "doctor":
|
|
1142
|
-
return runDoctor(rest, io, "agentera doctor");
|
|
1143
|
-
case "usage":
|
|
1144
|
-
return runUsage(rest, io, "agentera usage");
|
|
1145
|
-
case "upgrade":
|
|
1146
|
-
return runUpgrade(rest, io, "agentera upgrade");
|
|
1147
|
-
case "verify":
|
|
1148
|
-
emitDeprecationAlias("verify", "check verify", err);
|
|
1149
|
-
return runVerify(rest, io, "agentera verify");
|
|
1150
|
-
case "report":
|
|
1151
|
-
return runReport(rest, io, "agentera report");
|
|
1152
|
-
case "stats":
|
|
1153
|
-
emitDeprecationAlias("stats", "report", err);
|
|
1154
|
-
return runReport(rest, io, "agentera stats");
|
|
1155
|
-
case "hook": {
|
|
1156
|
-
const name = rest[0];
|
|
1157
|
-
if (!name) {
|
|
1158
|
-
return emitInvalidInput(io, {
|
|
1159
|
-
format: "text",
|
|
1160
|
-
body: {
|
|
1161
|
-
class: "missing_argument",
|
|
1162
|
-
message: "the following arguments are required: hook_name",
|
|
1163
|
-
valid_values: [
|
|
1164
|
-
"session-start",
|
|
1165
|
-
"session-stop",
|
|
1166
|
-
"cursor-session-start",
|
|
1167
|
-
"cursor-pre-tool-use",
|
|
1168
|
-
"validate-artifact",
|
|
1169
|
-
],
|
|
1170
|
-
},
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
return runHook(name, rest.slice(1), io);
|
|
1174
|
-
}
|
|
1175
|
-
case "hej":
|
|
1176
|
-
emitDeprecationAlias("hej", "prime", err);
|
|
1177
|
-
return runPrime("hej", rest, io, "agentera hej");
|
|
1178
|
-
case "schema":
|
|
1179
|
-
return runSchema(rest, io, "agentera schema");
|
|
1180
|
-
case "describe":
|
|
1181
|
-
emitDeprecationAlias("describe", "schema", err);
|
|
1182
|
-
return runSchema(rest, io, "agentera describe");
|
|
1183
|
-
case "lint":
|
|
1184
|
-
emitDeprecationAlias("lint", "check lint", err);
|
|
1185
|
-
return runLint(rest, io);
|
|
1186
|
-
case "check": {
|
|
1187
|
-
const sub = rest[0];
|
|
1188
|
-
if (!sub) {
|
|
1189
|
-
return emitInvalidInput(io, {
|
|
1190
|
-
format: "text",
|
|
1191
|
-
body: {
|
|
1192
|
-
class: "missing_argument",
|
|
1193
|
-
message: "the following arguments are required: check_command",
|
|
1194
|
-
valid_values: ["validate", "verify", "lint", "compact"],
|
|
1195
|
-
},
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1198
|
-
if (sub === "validate")
|
|
1199
|
-
return runValidate(rest.slice(1), io, "agentera check validate");
|
|
1200
|
-
if (sub === "verify")
|
|
1201
|
-
return runVerify(rest.slice(1), io, "agentera check verify");
|
|
1202
|
-
if (sub === "lint")
|
|
1203
|
-
return runLint(rest.slice(1), io, "agentera check lint");
|
|
1204
|
-
if (sub === "compact") {
|
|
1205
|
-
const subArgs = rest.slice(1);
|
|
1206
|
-
const mode = compactModeOf(subArgs);
|
|
1207
|
-
if (mode === "fix")
|
|
1208
|
-
return runCompact(subArgs, io, "agentera check compact");
|
|
1209
|
-
return runGate(subArgs, io, "agentera check compact");
|
|
1210
|
-
}
|
|
1211
|
-
return emitInvalidInput(io, {
|
|
1212
|
-
format: "text",
|
|
1213
|
-
body: {
|
|
1214
|
-
class: "unsupported_target",
|
|
1215
|
-
message: `unknown or not-yet-ported check subcommand: ${sub}`,
|
|
1216
|
-
valid_values: ["validate", "verify", "lint", "compact"],
|
|
1217
|
-
},
|
|
1218
|
-
});
|
|
1219
|
-
}
|
|
1220
|
-
case "state": {
|
|
1221
|
-
const sub = rest[0];
|
|
1222
|
-
if (!sub) {
|
|
1223
|
-
return emitInvalidInput(io, {
|
|
1224
|
-
format: "text",
|
|
1225
|
-
body: {
|
|
1226
|
-
class: "missing_argument",
|
|
1227
|
-
message: "the following arguments are required: state_command",
|
|
1228
|
-
valid_values: [
|
|
1229
|
-
"progress",
|
|
1230
|
-
"plan",
|
|
1231
|
-
"health",
|
|
1232
|
-
"docs",
|
|
1233
|
-
"objective",
|
|
1234
|
-
"experiments",
|
|
1235
|
-
"todo",
|
|
1236
|
-
"decisions",
|
|
1237
|
-
"query",
|
|
1238
|
-
],
|
|
1239
|
-
},
|
|
1240
|
-
});
|
|
1241
|
-
}
|
|
1242
|
-
if (sub === "query")
|
|
1243
|
-
return runQuery(rest.slice(1), io, "agentera state query");
|
|
1244
|
-
if (isPortedStateCommand(sub))
|
|
1245
|
-
return runState(sub, rest.slice(1), io, `agentera state ${sub}`);
|
|
1246
|
-
return emitInvalidInput(io, {
|
|
1247
|
-
format: "text",
|
|
1248
|
-
body: {
|
|
1249
|
-
class: "unsupported_target",
|
|
1250
|
-
message: `unknown or not-yet-ported state subcommand: ${sub}`,
|
|
1251
|
-
valid_values: [
|
|
1252
|
-
"progress",
|
|
1253
|
-
"plan",
|
|
1254
|
-
"health",
|
|
1255
|
-
"docs",
|
|
1256
|
-
"objective",
|
|
1257
|
-
"experiments",
|
|
1258
|
-
"todo",
|
|
1259
|
-
"decisions",
|
|
1260
|
-
"query",
|
|
1261
|
-
],
|
|
1262
|
-
},
|
|
1263
|
-
});
|
|
1264
|
-
}
|
|
1265
|
-
case "query":
|
|
1266
|
-
emitDeprecationAlias("query", "state query", err);
|
|
1267
|
-
return runQuery(rest, io, "agentera query");
|
|
1268
|
-
case "compact":
|
|
1269
|
-
emitDeprecationAlias("compact", "check compact", err);
|
|
1270
|
-
return runCompact(rest, io, "agentera compact");
|
|
1271
|
-
case "gate":
|
|
1272
|
-
emitDeprecationAlias("gate", "check compact", err);
|
|
1273
|
-
return runGate(rest, io, "agentera gate");
|
|
1274
|
-
case "validate":
|
|
1275
|
-
emitDeprecationAlias("validate", "check validate", err);
|
|
1276
|
-
return runValidate(rest, io, "agentera validate");
|
|
1277
|
-
default:
|
|
1278
|
-
if (command && CAPABILITY_ROUTING_NAMES.includes(command)) {
|
|
1279
|
-
return runCapability(command, rest, io, `agentera ${command}`);
|
|
1280
|
-
}
|
|
1281
|
-
if (command && isPortedStateCommand(command)) {
|
|
1282
|
-
emitDeprecationAlias(command, `state ${command}`, err);
|
|
1283
|
-
return runState(command, rest, io, `agentera ${command}`);
|
|
1284
|
-
}
|
|
1285
|
-
return emitInvalidInput(io, {
|
|
1286
|
-
format: "text",
|
|
1287
|
-
body: {
|
|
1288
|
-
class: "unsupported_target",
|
|
1289
|
-
message: `unknown or not-yet-ported command: ${command ?? "(none)"}`,
|
|
1290
|
-
},
|
|
1291
|
-
});
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1
|
+
export { main } from "./dispatch/index.js";
|
|
1294
2
|
//# sourceMappingURL=dispatch.js.map
|