@autohq/cli 0.1.280 → 0.1.281
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/dist/agent-bridge.js +1 -1
- package/dist/index.js +113 -16
- package/package.json +1 -1
package/dist/agent-bridge.js
CHANGED
|
@@ -23353,7 +23353,7 @@ Object.assign(lookup, {
|
|
|
23353
23353
|
// package.json
|
|
23354
23354
|
var package_default = {
|
|
23355
23355
|
name: "@autohq/cli",
|
|
23356
|
-
version: "0.1.
|
|
23356
|
+
version: "0.1.281",
|
|
23357
23357
|
license: "SEE LICENSE IN README.md",
|
|
23358
23358
|
publishConfig: {
|
|
23359
23359
|
access: "public"
|
package/dist/index.js
CHANGED
|
@@ -22999,7 +22999,7 @@ var init_package = __esm({
|
|
|
22999
22999
|
"package.json"() {
|
|
23000
23000
|
package_default = {
|
|
23001
23001
|
name: "@autohq/cli",
|
|
23002
|
-
version: "0.1.
|
|
23002
|
+
version: "0.1.281",
|
|
23003
23003
|
license: "SEE LICENSE IN README.md",
|
|
23004
23004
|
publishConfig: {
|
|
23005
23005
|
access: "public"
|
|
@@ -24183,7 +24183,12 @@ var init_helpers = __esm({
|
|
|
24183
24183
|
"../../packages/schemas/src/project-apply-files/agent-fields/helpers.ts"() {
|
|
24184
24184
|
"use strict";
|
|
24185
24185
|
init_source();
|
|
24186
|
-
CONTROL_FIELDS = /* @__PURE__ */ new Set([
|
|
24186
|
+
CONTROL_FIELDS = /* @__PURE__ */ new Set([
|
|
24187
|
+
"import",
|
|
24188
|
+
"imports",
|
|
24189
|
+
"remove",
|
|
24190
|
+
"variables"
|
|
24191
|
+
]);
|
|
24187
24192
|
AGENT_METADATA_FIELD_KEYS = ["name", "labels", "annotations"];
|
|
24188
24193
|
}
|
|
24189
24194
|
});
|
|
@@ -24620,6 +24625,87 @@ var init_agent_fields = __esm({
|
|
|
24620
24625
|
}
|
|
24621
24626
|
});
|
|
24622
24627
|
|
|
24628
|
+
// ../../packages/schemas/src/project-apply-files/template-variables.ts
|
|
24629
|
+
function readVariableScope(document, path2) {
|
|
24630
|
+
const declared = document[VARIABLE_DECLARATIONS_FIELD];
|
|
24631
|
+
if (declared === void 0) {
|
|
24632
|
+
return /* @__PURE__ */ new Map();
|
|
24633
|
+
}
|
|
24634
|
+
if (!isRecord2(declared)) {
|
|
24635
|
+
throw new Error(
|
|
24636
|
+
`Invalid variables in ${path2}: variables must be a map of name to value`
|
|
24637
|
+
);
|
|
24638
|
+
}
|
|
24639
|
+
const scope = /* @__PURE__ */ new Map();
|
|
24640
|
+
for (const [name, value] of Object.entries(declared)) {
|
|
24641
|
+
if (!VARIABLE_NAME_PATTERN.test(name)) {
|
|
24642
|
+
throw new Error(
|
|
24643
|
+
`Invalid variable name "${name}" in ${path2}: names must match [A-Za-z_][A-Za-z0-9_]*`
|
|
24644
|
+
);
|
|
24645
|
+
}
|
|
24646
|
+
scope.set(name, coerceVariableValue(name, value, path2));
|
|
24647
|
+
}
|
|
24648
|
+
return scope;
|
|
24649
|
+
}
|
|
24650
|
+
function substituteVariables(document, scope, site) {
|
|
24651
|
+
if (scope.size === 0) {
|
|
24652
|
+
return document;
|
|
24653
|
+
}
|
|
24654
|
+
return substituteValue(document, scope, site);
|
|
24655
|
+
}
|
|
24656
|
+
function substituteValue(value, scope, site) {
|
|
24657
|
+
if (typeof value === "string") {
|
|
24658
|
+
return substituteString(value, scope, site);
|
|
24659
|
+
}
|
|
24660
|
+
if (Array.isArray(value)) {
|
|
24661
|
+
return value.map((item) => substituteValue(item, scope, site));
|
|
24662
|
+
}
|
|
24663
|
+
if (isRecord2(value)) {
|
|
24664
|
+
return Object.fromEntries(
|
|
24665
|
+
Object.entries(value).map(([key, nested]) => [
|
|
24666
|
+
key,
|
|
24667
|
+
substituteValue(nested, scope, site)
|
|
24668
|
+
])
|
|
24669
|
+
);
|
|
24670
|
+
}
|
|
24671
|
+
return value;
|
|
24672
|
+
}
|
|
24673
|
+
function substituteString(value, scope, site) {
|
|
24674
|
+
return value.replace(VARIABLE_REFERENCE_PATTERN, (_match, name) => {
|
|
24675
|
+
const resolved = scope.get(name);
|
|
24676
|
+
if (resolved === void 0) {
|
|
24677
|
+
throw new Error(
|
|
24678
|
+
`Unresolved variable "{{ $${name} }}" in imported ${site.importPath}: declare it in the importing agent's variables (available: ${availableNames(scope)}).`
|
|
24679
|
+
);
|
|
24680
|
+
}
|
|
24681
|
+
return resolved;
|
|
24682
|
+
});
|
|
24683
|
+
}
|
|
24684
|
+
function coerceVariableValue(name, value, path2) {
|
|
24685
|
+
if (typeof value === "string") {
|
|
24686
|
+
return value;
|
|
24687
|
+
}
|
|
24688
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
24689
|
+
return String(value);
|
|
24690
|
+
}
|
|
24691
|
+
throw new Error(
|
|
24692
|
+
`Invalid value for variable "${name}" in ${path2}: variable values must be a string, number, or boolean`
|
|
24693
|
+
);
|
|
24694
|
+
}
|
|
24695
|
+
function availableNames(scope) {
|
|
24696
|
+
return [...scope.keys()].sort().map((name) => `{{ $${name} }}`).join(", ");
|
|
24697
|
+
}
|
|
24698
|
+
var VARIABLE_DECLARATIONS_FIELD, VARIABLE_NAME_PATTERN, VARIABLE_REFERENCE_PATTERN;
|
|
24699
|
+
var init_template_variables = __esm({
|
|
24700
|
+
"../../packages/schemas/src/project-apply-files/template-variables.ts"() {
|
|
24701
|
+
"use strict";
|
|
24702
|
+
init_source();
|
|
24703
|
+
VARIABLE_DECLARATIONS_FIELD = "variables";
|
|
24704
|
+
VARIABLE_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
24705
|
+
VARIABLE_REFERENCE_PATTERN = /\{\{\s*\$([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g;
|
|
24706
|
+
}
|
|
24707
|
+
});
|
|
24708
|
+
|
|
24623
24709
|
// ../../packages/schemas/src/project-apply-files/agent-authoring.ts
|
|
24624
24710
|
function readApplyDocument(path2, document, fileIndex) {
|
|
24625
24711
|
assertAgentAuthoringDocument(document, path2);
|
|
@@ -24647,7 +24733,8 @@ function validateAgentFragmentDocument(document, path2, context) {
|
|
|
24647
24733
|
imported,
|
|
24648
24734
|
{
|
|
24649
24735
|
fileIndex: context.fileIndex,
|
|
24650
|
-
stack: [...context.stack, normalizedPath]
|
|
24736
|
+
stack: [...context.stack, normalizedPath],
|
|
24737
|
+
variables: context.variables
|
|
24651
24738
|
}
|
|
24652
24739
|
);
|
|
24653
24740
|
}
|
|
@@ -24684,7 +24771,8 @@ function compileAgentDocumentValue(document, path2, fileIndex) {
|
|
|
24684
24771
|
return compileAgentDraftResources(
|
|
24685
24772
|
compileAgentDocument2(document, path2, {
|
|
24686
24773
|
fileIndex,
|
|
24687
|
-
stack: []
|
|
24774
|
+
stack: [],
|
|
24775
|
+
variables: /* @__PURE__ */ new Map()
|
|
24688
24776
|
}),
|
|
24689
24777
|
path2
|
|
24690
24778
|
);
|
|
@@ -24699,20 +24787,26 @@ function compileAgentDocument2(document, path2, context) {
|
|
|
24699
24787
|
if (!isRecord2(document)) {
|
|
24700
24788
|
throw new Error(`Invalid agent authoring file ${path2}: expected object`);
|
|
24701
24789
|
}
|
|
24790
|
+
const variables = context.stack.length === 0 ? readVariableScope(document, normalizedPath) : context.variables;
|
|
24702
24791
|
let merged = emptyAgentDraft();
|
|
24703
|
-
for (const
|
|
24704
|
-
|
|
24705
|
-
|
|
24792
|
+
for (const importPath of importPaths2(document)) {
|
|
24793
|
+
const imported = resolveImportPath2(
|
|
24794
|
+
importPath,
|
|
24795
|
+
normalizedPath,
|
|
24796
|
+
context.fileIndex
|
|
24797
|
+
);
|
|
24798
|
+
const importedDocument = substituteVariables(
|
|
24799
|
+
readSingleDocument2(imported, context.fileIndex),
|
|
24800
|
+
variables,
|
|
24801
|
+
{ importPath }
|
|
24802
|
+
);
|
|
24706
24803
|
merged = mergeAgentDrafts(
|
|
24707
24804
|
merged,
|
|
24708
|
-
compileAgentDocument2(
|
|
24709
|
-
|
|
24710
|
-
|
|
24711
|
-
|
|
24712
|
-
|
|
24713
|
-
stack: [...context.stack, normalizedPath]
|
|
24714
|
-
}
|
|
24715
|
-
)
|
|
24805
|
+
compileAgentDocument2(importedDocument, imported, {
|
|
24806
|
+
fileIndex: context.fileIndex,
|
|
24807
|
+
stack: [...context.stack, normalizedPath],
|
|
24808
|
+
variables
|
|
24809
|
+
})
|
|
24716
24810
|
);
|
|
24717
24811
|
}
|
|
24718
24812
|
for (const removal of removalDirectives2(document, normalizedPath)) {
|
|
@@ -24729,6 +24823,7 @@ var init_agent_authoring = __esm({
|
|
|
24729
24823
|
init_agent_document_merge();
|
|
24730
24824
|
init_agent_fields();
|
|
24731
24825
|
init_source();
|
|
24826
|
+
init_template_variables();
|
|
24732
24827
|
}
|
|
24733
24828
|
});
|
|
24734
24829
|
|
|
@@ -25116,7 +25211,8 @@ function assertValidFragmentSourceFiles(files, resourceRoot, fileIndex) {
|
|
|
25116
25211
|
}
|
|
25117
25212
|
validateAgentFragmentDocument(documents[0], file2.path, {
|
|
25118
25213
|
fileIndex,
|
|
25119
|
-
stack: []
|
|
25214
|
+
stack: [],
|
|
25215
|
+
variables: /* @__PURE__ */ new Map()
|
|
25120
25216
|
});
|
|
25121
25217
|
} catch (error51) {
|
|
25122
25218
|
throw new Error(
|
|
@@ -25142,6 +25238,7 @@ var init_project_apply_files = __esm({
|
|
|
25142
25238
|
init_template_injection();
|
|
25143
25239
|
init_template_bump_diagnostics();
|
|
25144
25240
|
init_template_staleness();
|
|
25241
|
+
init_template_variables();
|
|
25145
25242
|
}
|
|
25146
25243
|
});
|
|
25147
25244
|
|