@aaac/contracts 0.1.12 → 0.1.14
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/{chunk-MWZFJ2VL.js → chunk-JWJLY3HJ.js} +467 -5
- package/dist/chunk-JWJLY3HJ.js.map +1 -0
- package/dist/cli/index.js +47 -285
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +93 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-MWZFJ2VL.js.map +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -3,18 +3,26 @@ import {
|
|
|
3
3
|
ComponentCompileError,
|
|
4
4
|
ComponentParseError,
|
|
5
5
|
ComponentValidationError,
|
|
6
|
+
GOVERNANCE_LOCK_PATH,
|
|
6
7
|
RefResolutionError,
|
|
8
|
+
SCAFFOLD_PROJECT_YAML,
|
|
7
9
|
compileComponent,
|
|
8
10
|
compileComponentFile,
|
|
11
|
+
copyCLIBinary,
|
|
9
12
|
generateAll,
|
|
13
|
+
loadHookBindings,
|
|
14
|
+
loadInitConfig,
|
|
15
|
+
materializeHooks,
|
|
10
16
|
parseComponentFile,
|
|
17
|
+
readGovernanceLock,
|
|
18
|
+
unmaterializeHooks,
|
|
11
19
|
validateComponent,
|
|
12
20
|
writeGeneratedFiles
|
|
13
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-JWJLY3HJ.js";
|
|
14
22
|
|
|
15
23
|
// src/cli/index.ts
|
|
16
24
|
import { readFileSync } from "fs";
|
|
17
|
-
import { dirname as
|
|
25
|
+
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
18
26
|
import { fileURLToPath } from "url";
|
|
19
27
|
|
|
20
28
|
// ../../node_modules/commander/lib/error.js
|
|
@@ -3800,260 +3808,10 @@ function createProgram(handlers2, version) {
|
|
|
3800
3808
|
}
|
|
3801
3809
|
|
|
3802
3810
|
// src/cli/handlers.ts
|
|
3803
|
-
import { existsSync as existsSync2 } from "fs";
|
|
3804
|
-
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
3805
|
-
import { dirname as dirname2, join as join2, resolve as resolve2 } from "path";
|
|
3806
|
-
import { stringify as stringifyYaml } from "yaml";
|
|
3807
|
-
|
|
3808
|
-
// src/cli/governance.ts
|
|
3809
|
-
import { createHash } from "crypto";
|
|
3810
3811
|
import { existsSync } from "fs";
|
|
3811
|
-
import {
|
|
3812
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
3812
3813
|
import { dirname, join, resolve } from "path";
|
|
3813
|
-
import {
|
|
3814
|
-
import { z } from "zod";
|
|
3815
|
-
var MANAGED_BLOCK_START = "# >>> aaac-governance:managed (do not edit) >>>";
|
|
3816
|
-
var MANAGED_BLOCK_END = "# <<< aaac-governance:managed <<<";
|
|
3817
|
-
var GOVERNANCE_LOCK_PATH = ".agent-logs/governance-manifest.lock";
|
|
3818
|
-
var DEFAULT_RECORDER = ".cursor/hooks/observ-record.sh";
|
|
3819
|
-
var DEFAULT_CURSOR_HOOKS_JSON = ".cursor/hooks.json";
|
|
3820
|
-
var DEFAULT_BINARY_DEST = "bin/aaac.js";
|
|
3821
|
-
var EnvironmentsSchema = z.object({
|
|
3822
|
-
git: z.object({ hooks: z.array(z.string()).optional() }).optional(),
|
|
3823
|
-
cursor: z.object({ hooks_json: z.string().optional() }).optional()
|
|
3824
|
-
}).optional();
|
|
3825
|
-
var BindingsObservabilitySchema = z.object({
|
|
3826
|
-
event_mapping: z.string().optional(),
|
|
3827
|
-
recorder: z.string().optional()
|
|
3828
|
-
}).optional();
|
|
3829
|
-
var BindingsSchema = z.object({
|
|
3830
|
-
observability: BindingsObservabilitySchema
|
|
3831
|
-
}).optional();
|
|
3832
|
-
var InitProjectConfigSchema = z.object({
|
|
3833
|
-
environments: EnvironmentsSchema,
|
|
3834
|
-
bindings: BindingsSchema
|
|
3835
|
-
});
|
|
3836
|
-
async function loadInitConfig(configPath) {
|
|
3837
|
-
const absPath = resolve(configPath);
|
|
3838
|
-
const raw = await readFile(absPath, "utf8");
|
|
3839
|
-
const parsed = parseYaml(raw);
|
|
3840
|
-
return InitProjectConfigSchema.parse(parsed ?? {});
|
|
3841
|
-
}
|
|
3842
|
-
function escapeRegex(value) {
|
|
3843
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3844
|
-
}
|
|
3845
|
-
function createManagedBlockRegex() {
|
|
3846
|
-
return new RegExp(
|
|
3847
|
-
`${escapeRegex(MANAGED_BLOCK_START)}[\\s\\S]*?${escapeRegex(MANAGED_BLOCK_END)}\\n?`,
|
|
3848
|
-
"g"
|
|
3849
|
-
);
|
|
3850
|
-
}
|
|
3851
|
-
function buildManagedBlock(blockContent) {
|
|
3852
|
-
return `${MANAGED_BLOCK_START}
|
|
3853
|
-
${blockContent.trimEnd()}
|
|
3854
|
-
${MANAGED_BLOCK_END}
|
|
3855
|
-
`;
|
|
3856
|
-
}
|
|
3857
|
-
function injectManagedBlock(existingContent, blockContent) {
|
|
3858
|
-
const managedBlock = buildManagedBlock(blockContent);
|
|
3859
|
-
const re = createManagedBlockRegex();
|
|
3860
|
-
if (re.test(existingContent)) {
|
|
3861
|
-
return existingContent.replace(createManagedBlockRegex(), managedBlock);
|
|
3862
|
-
}
|
|
3863
|
-
const trimmed = existingContent.replace(/\s+$/, "");
|
|
3864
|
-
if (trimmed.length === 0) {
|
|
3865
|
-
return `#!/bin/sh
|
|
3866
|
-
${managedBlock}`;
|
|
3867
|
-
}
|
|
3868
|
-
const separator = trimmed.endsWith("\n") ? "" : "\n";
|
|
3869
|
-
return `${trimmed}${separator}${managedBlock}`;
|
|
3870
|
-
}
|
|
3871
|
-
function removeManagedBlock(existingContent) {
|
|
3872
|
-
if (!existingContent.includes(MANAGED_BLOCK_START)) {
|
|
3873
|
-
return existingContent;
|
|
3874
|
-
}
|
|
3875
|
-
const withoutBlock = existingContent.replace(createManagedBlockRegex(), "");
|
|
3876
|
-
const meaningful = withoutBlock.split("\n").filter((line) => {
|
|
3877
|
-
const t = line.trim();
|
|
3878
|
-
return t.length > 0 && t !== "#!/bin/sh" && t !== "#!/bin/bash";
|
|
3879
|
-
});
|
|
3880
|
-
if (meaningful.length === 0) {
|
|
3881
|
-
return "";
|
|
3882
|
-
}
|
|
3883
|
-
return withoutBlock.replace(/\n{3,}/g, "\n\n").replace(/\s+$/, "\n");
|
|
3884
|
-
}
|
|
3885
|
-
function mergeCursorHooks(existing, newEntries) {
|
|
3886
|
-
const byCommand = /* @__PURE__ */ new Map();
|
|
3887
|
-
for (const entry of existing) byCommand.set(entry.command, entry);
|
|
3888
|
-
for (const entry of newEntries) byCommand.set(entry.command, entry);
|
|
3889
|
-
return Array.from(byCommand.values());
|
|
3890
|
-
}
|
|
3891
|
-
function removeCursorHooks(existing, commands) {
|
|
3892
|
-
const removeSet = new Set(commands);
|
|
3893
|
-
return existing.filter((entry) => !removeSet.has(entry.command));
|
|
3894
|
-
}
|
|
3895
|
-
function buildDefaultCursorHooks(recorder) {
|
|
3896
|
-
return [
|
|
3897
|
-
{ event: "beforeSubmitPrompt", command: `${recorder} beforeSubmitPrompt` },
|
|
3898
|
-
{ event: "afterShellExecution", command: `${recorder} afterShellExecution` }
|
|
3899
|
-
];
|
|
3900
|
-
}
|
|
3901
|
-
async function ensureParentDir(filePath) {
|
|
3902
|
-
await mkdir(dirname(filePath), { recursive: true });
|
|
3903
|
-
}
|
|
3904
|
-
async function readTextFileIfExists(filePath) {
|
|
3905
|
-
if (!existsSync(filePath)) return void 0;
|
|
3906
|
-
return readFile(filePath, "utf8");
|
|
3907
|
-
}
|
|
3908
|
-
async function writeGovernanceLock(projectRoot, entries) {
|
|
3909
|
-
const lockPath = join(projectRoot, GOVERNANCE_LOCK_PATH);
|
|
3910
|
-
const lock = {
|
|
3911
|
-
materialized_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3912
|
-
entries
|
|
3913
|
-
};
|
|
3914
|
-
await ensureParentDir(lockPath);
|
|
3915
|
-
await writeFile(lockPath, JSON.stringify(lock, null, 2) + "\n", "utf8");
|
|
3916
|
-
return GOVERNANCE_LOCK_PATH;
|
|
3917
|
-
}
|
|
3918
|
-
async function readGovernanceLock(projectRoot) {
|
|
3919
|
-
const lockPath = join(projectRoot, GOVERNANCE_LOCK_PATH);
|
|
3920
|
-
if (!existsSync(lockPath)) return void 0;
|
|
3921
|
-
const raw = await readFile(lockPath, "utf8");
|
|
3922
|
-
if (!raw.trim()) return void 0;
|
|
3923
|
-
return JSON.parse(raw);
|
|
3924
|
-
}
|
|
3925
|
-
async function materializeHooks(options) {
|
|
3926
|
-
const projectRoot = resolve(options.projectRoot);
|
|
3927
|
-
const result = { materialized: [], lockEntries: [] };
|
|
3928
|
-
const recorder = options.observabilityBinding?.recorder ?? DEFAULT_RECORDER;
|
|
3929
|
-
if (options.environments.git?.hooks?.length) {
|
|
3930
|
-
for (const hookName of options.environments.git.hooks) {
|
|
3931
|
-
const relPath = join(".git/hooks", hookName);
|
|
3932
|
-
const absPath = join(projectRoot, relPath);
|
|
3933
|
-
const blockContent = `exec ${recorder} ${hookName} "$@"`;
|
|
3934
|
-
const existing = await readTextFileIfExists(absPath) ?? "";
|
|
3935
|
-
const updated = injectManagedBlock(existing, blockContent);
|
|
3936
|
-
let action = "unchanged";
|
|
3937
|
-
if (!existsSync(absPath)) {
|
|
3938
|
-
action = "created";
|
|
3939
|
-
} else if (updated !== existing) {
|
|
3940
|
-
action = "updated";
|
|
3941
|
-
}
|
|
3942
|
-
if (action !== "unchanged") {
|
|
3943
|
-
await ensureParentDir(absPath);
|
|
3944
|
-
await writeFile(absPath, updated, "utf8");
|
|
3945
|
-
await chmod(absPath, 493);
|
|
3946
|
-
}
|
|
3947
|
-
result.materialized.push({ path: relPath, action });
|
|
3948
|
-
result.lockEntries.push({ path: relPath, type: "git-hook" });
|
|
3949
|
-
}
|
|
3950
|
-
}
|
|
3951
|
-
if (options.environments.cursor) {
|
|
3952
|
-
const rawHooksJsonValue = options.environments.cursor.hooks_json;
|
|
3953
|
-
const hooksJsonPath = rawHooksJsonValue ? resolve(projectRoot, rawHooksJsonValue) : join(projectRoot, DEFAULT_CURSOR_HOOKS_JSON);
|
|
3954
|
-
const relPath = hooksJsonPath.startsWith(projectRoot + "/") ? hooksJsonPath.slice(projectRoot.length + 1) : DEFAULT_CURSOR_HOOKS_JSON;
|
|
3955
|
-
const newEntries = buildDefaultCursorHooks(recorder);
|
|
3956
|
-
const existingRaw = await readTextFileIfExists(hooksJsonPath);
|
|
3957
|
-
const existing = existingRaw ? JSON.parse(existingRaw) : [];
|
|
3958
|
-
const merged = mergeCursorHooks(existing, newEntries);
|
|
3959
|
-
const serialized = JSON.stringify(merged, null, 2) + "\n";
|
|
3960
|
-
let action = "unchanged";
|
|
3961
|
-
if (!existsSync(hooksJsonPath)) {
|
|
3962
|
-
action = "created";
|
|
3963
|
-
} else if (serialized !== existingRaw) {
|
|
3964
|
-
action = "updated";
|
|
3965
|
-
}
|
|
3966
|
-
if (action !== "unchanged") {
|
|
3967
|
-
await ensureParentDir(hooksJsonPath);
|
|
3968
|
-
await writeFile(hooksJsonPath, serialized, "utf8");
|
|
3969
|
-
}
|
|
3970
|
-
result.materialized.push({ path: relPath, action });
|
|
3971
|
-
result.lockEntries.push({ path: relPath, type: "cursor-hook" });
|
|
3972
|
-
}
|
|
3973
|
-
if (result.lockEntries.length > 0) {
|
|
3974
|
-
const lockExisted = existsSync(join(projectRoot, GOVERNANCE_LOCK_PATH));
|
|
3975
|
-
await writeGovernanceLock(projectRoot, result.lockEntries);
|
|
3976
|
-
result.materialized.push({
|
|
3977
|
-
path: GOVERNANCE_LOCK_PATH,
|
|
3978
|
-
action: lockExisted ? "updated" : "created"
|
|
3979
|
-
});
|
|
3980
|
-
result.lockEntries.push({ path: GOVERNANCE_LOCK_PATH, type: "generated" });
|
|
3981
|
-
}
|
|
3982
|
-
return result;
|
|
3983
|
-
}
|
|
3984
|
-
async function unmaterializeHooks(projectRoot, lockEntries) {
|
|
3985
|
-
const root = resolve(projectRoot);
|
|
3986
|
-
for (const entry of lockEntries) {
|
|
3987
|
-
if (entry.type === "generated") {
|
|
3988
|
-
const absPath = join(root, entry.path);
|
|
3989
|
-
if (existsSync(absPath)) {
|
|
3990
|
-
await writeFile(absPath, "", "utf8");
|
|
3991
|
-
}
|
|
3992
|
-
continue;
|
|
3993
|
-
}
|
|
3994
|
-
if (entry.type === "git-hook") {
|
|
3995
|
-
const absPath = join(root, entry.path);
|
|
3996
|
-
const existing = await readTextFileIfExists(absPath);
|
|
3997
|
-
if (existing === void 0) continue;
|
|
3998
|
-
const updated = removeManagedBlock(existing);
|
|
3999
|
-
await writeFile(absPath, updated, "utf8");
|
|
4000
|
-
continue;
|
|
4001
|
-
}
|
|
4002
|
-
if (entry.type === "cursor-hook") {
|
|
4003
|
-
const absPath = join(root, entry.path);
|
|
4004
|
-
const existingRaw = await readTextFileIfExists(absPath);
|
|
4005
|
-
if (existingRaw === void 0) continue;
|
|
4006
|
-
const existing = JSON.parse(existingRaw);
|
|
4007
|
-
const commandsToRemove = buildDefaultCursorHooks(DEFAULT_RECORDER).map((h) => h.command);
|
|
4008
|
-
const updated = removeCursorHooks(existing, commandsToRemove);
|
|
4009
|
-
await writeFile(
|
|
4010
|
-
absPath,
|
|
4011
|
-
updated.length === 0 ? "[]\n" : JSON.stringify(updated, null, 2) + "\n",
|
|
4012
|
-
"utf8"
|
|
4013
|
-
);
|
|
4014
|
-
}
|
|
4015
|
-
}
|
|
4016
|
-
const lockPath = join(root, GOVERNANCE_LOCK_PATH);
|
|
4017
|
-
if (existsSync(lockPath)) {
|
|
4018
|
-
await writeFile(lockPath, "", "utf8");
|
|
4019
|
-
}
|
|
4020
|
-
}
|
|
4021
|
-
async function copyCLIBinary(srcPath, projectRoot, destRelPath = DEFAULT_BINARY_DEST) {
|
|
4022
|
-
const dstPath = join(projectRoot, destRelPath);
|
|
4023
|
-
const srcContent = await readFile(srcPath);
|
|
4024
|
-
const srcHash = createHash("sha256").update(srcContent).digest("hex");
|
|
4025
|
-
if (existsSync(dstPath)) {
|
|
4026
|
-
const dstContent = await readFile(dstPath);
|
|
4027
|
-
const dstHash = createHash("sha256").update(dstContent).digest("hex");
|
|
4028
|
-
if (srcHash === dstHash) {
|
|
4029
|
-
return { path: destRelPath, action: "unchanged" };
|
|
4030
|
-
}
|
|
4031
|
-
await writeFile(dstPath, srcContent);
|
|
4032
|
-
await chmod(dstPath, 493);
|
|
4033
|
-
return { path: destRelPath, action: "updated" };
|
|
4034
|
-
}
|
|
4035
|
-
await ensureParentDir(dstPath);
|
|
4036
|
-
await writeFile(dstPath, srcContent);
|
|
4037
|
-
await chmod(dstPath, 493);
|
|
4038
|
-
return { path: destRelPath, action: "created" };
|
|
4039
|
-
}
|
|
4040
|
-
var SCAFFOLD_PROJECT_YAML = `schema: aaac/project/0.1
|
|
4041
|
-
|
|
4042
|
-
# Uncomment and configure to enable git hook governance:
|
|
4043
|
-
#
|
|
4044
|
-
# environments:
|
|
4045
|
-
# git:
|
|
4046
|
-
# hooks: [pre-commit, pre-push, post-commit]
|
|
4047
|
-
# cursor:
|
|
4048
|
-
# hooks_json: .cursor/hooks.json
|
|
4049
|
-
#
|
|
4050
|
-
# bindings:
|
|
4051
|
-
# observability:
|
|
4052
|
-
# event_mapping: ./bindings/observability.yaml
|
|
4053
|
-
# recorder: aaac-observ
|
|
4054
|
-
`;
|
|
4055
|
-
|
|
4056
|
-
// src/cli/handlers.ts
|
|
3814
|
+
import { stringify as stringifyYaml } from "yaml";
|
|
4057
3815
|
function formatError(err, file) {
|
|
4058
3816
|
if (err instanceof ComponentParseError) {
|
|
4059
3817
|
return err.message;
|
|
@@ -4081,10 +3839,10 @@ function resolveComponentPath(file) {
|
|
|
4081
3839
|
if (!file) {
|
|
4082
3840
|
fail("Error: component file path is required");
|
|
4083
3841
|
}
|
|
4084
|
-
return
|
|
3842
|
+
return resolve(file);
|
|
4085
3843
|
}
|
|
4086
3844
|
function defaultOutputDir(componentPath) {
|
|
4087
|
-
return
|
|
3845
|
+
return join(dirname(componentPath), "generated");
|
|
4088
3846
|
}
|
|
4089
3847
|
function buildIntrospectionDump(ir) {
|
|
4090
3848
|
const operations = {};
|
|
@@ -4119,10 +3877,10 @@ var handleCompile = async (file, options, parentOpts) => {
|
|
|
4119
3877
|
const ir = await compileComponentFile(componentPath);
|
|
4120
3878
|
const json = JSON.stringify(ir, null, 2);
|
|
4121
3879
|
if (options.output) {
|
|
4122
|
-
await
|
|
3880
|
+
await writeFile(resolve(options.output), `${json}
|
|
4123
3881
|
`, "utf-8");
|
|
4124
3882
|
if (!parentOpts.quiet) {
|
|
4125
|
-
process.stdout.write(`Wrote IR to ${
|
|
3883
|
+
process.stdout.write(`Wrote IR to ${resolve(options.output)}
|
|
4126
3884
|
`);
|
|
4127
3885
|
}
|
|
4128
3886
|
return;
|
|
@@ -4137,7 +3895,7 @@ async function resolveEmbeddedDslData(ir, componentPath) {
|
|
|
4137
3895
|
if (!ir.embeddedDslDir || !ir.implementation) {
|
|
4138
3896
|
return void 0;
|
|
4139
3897
|
}
|
|
4140
|
-
const implPath =
|
|
3898
|
+
const implPath = resolve(dirname(componentPath), ir.implementation);
|
|
4141
3899
|
const { resolve: resolveDsl } = await import("agent-contracts");
|
|
4142
3900
|
const dslResult = await resolveDsl(implPath);
|
|
4143
3901
|
return dslResult.data;
|
|
@@ -4156,7 +3914,7 @@ function splitGeneratedFiles(files) {
|
|
|
4156
3914
|
}
|
|
4157
3915
|
var handleGenerate = async (file, options, parentOpts) => {
|
|
4158
3916
|
const componentPath = resolveComponentPath(file);
|
|
4159
|
-
const outputDir =
|
|
3917
|
+
const outputDir = resolve(options.outputDir ?? defaultOutputDir(componentPath));
|
|
4160
3918
|
const dryRun = Boolean(options.dryRun);
|
|
4161
3919
|
try {
|
|
4162
3920
|
const ir = await compileComponentFile(componentPath);
|
|
@@ -4181,10 +3939,10 @@ var handleGenerate = async (file, options, parentOpts) => {
|
|
|
4181
3939
|
}
|
|
4182
3940
|
}
|
|
4183
3941
|
for (const generated of embedded) {
|
|
4184
|
-
const embeddedDir =
|
|
3942
|
+
const embeddedDir = resolve(dirname(componentPath), generated.targetDir);
|
|
4185
3943
|
const action = generated.overwrite ? "write" : "create";
|
|
4186
3944
|
process.stdout.write(
|
|
4187
|
-
` ${action}: ${
|
|
3945
|
+
` ${action}: ${join(embeddedDir, generated.path)} (embedded DSL)
|
|
4188
3946
|
`
|
|
4189
3947
|
);
|
|
4190
3948
|
}
|
|
@@ -4193,10 +3951,10 @@ var handleGenerate = async (file, options, parentOpts) => {
|
|
|
4193
3951
|
}
|
|
4194
3952
|
const result = await writeGeneratedFiles(main, outputDir);
|
|
4195
3953
|
for (const generated of embedded) {
|
|
4196
|
-
const embeddedDir =
|
|
4197
|
-
await
|
|
4198
|
-
await
|
|
4199
|
-
result.written.push(
|
|
3954
|
+
const embeddedDir = resolve(dirname(componentPath), generated.targetDir);
|
|
3955
|
+
await mkdir(embeddedDir, { recursive: true });
|
|
3956
|
+
await writeFile(join(embeddedDir, generated.path), generated.content, "utf-8");
|
|
3957
|
+
result.written.push(join(generated.targetDir, generated.path));
|
|
4200
3958
|
}
|
|
4201
3959
|
if (!parentOpts.quiet) {
|
|
4202
3960
|
if (result.written.length > 0) {
|
|
@@ -4226,7 +3984,7 @@ var handleGenerate = async (file, options, parentOpts) => {
|
|
|
4226
3984
|
};
|
|
4227
3985
|
var handleValidate = async (file, options, parentOpts) => {
|
|
4228
3986
|
const componentPath = resolveComponentPath(file);
|
|
4229
|
-
const basePath =
|
|
3987
|
+
const basePath = dirname(componentPath);
|
|
4230
3988
|
try {
|
|
4231
3989
|
const dsl = await parseComponentFile(componentPath);
|
|
4232
3990
|
const ir = compileComponent(dsl, { basePath });
|
|
@@ -4260,24 +4018,24 @@ var handleIntrospect = async (file, options, _parentOpts) => {
|
|
|
4260
4018
|
};
|
|
4261
4019
|
var DEFAULT_PROJECT_YAML = "project.yaml";
|
|
4262
4020
|
var handleInit = async (projectRoot, options, parentOpts) => {
|
|
4263
|
-
const root =
|
|
4021
|
+
const root = resolve(projectRoot ?? ".");
|
|
4264
4022
|
const quiet = Boolean(parentOpts.quiet);
|
|
4265
|
-
const projectYamlPath =
|
|
4266
|
-
const srcBinary =
|
|
4023
|
+
const projectYamlPath = join(root, options.projectYaml ?? DEFAULT_PROJECT_YAML);
|
|
4024
|
+
const srcBinary = resolve(options.binaryPath ?? process.argv[1]);
|
|
4267
4025
|
const binaryResult = await copyCLIBinary(srcBinary, root);
|
|
4268
4026
|
if (!quiet && binaryResult.action !== "unchanged") {
|
|
4269
4027
|
process.stdout.write(` ${binaryResult.action}: ${binaryResult.path}
|
|
4270
4028
|
`);
|
|
4271
4029
|
}
|
|
4272
|
-
if (!
|
|
4273
|
-
await
|
|
4030
|
+
if (!existsSync(projectYamlPath)) {
|
|
4031
|
+
await writeFile(projectYamlPath, SCAFFOLD_PROJECT_YAML, "utf8");
|
|
4274
4032
|
if (!quiet) {
|
|
4275
4033
|
process.stdout.write(` created: ${DEFAULT_PROJECT_YAML}
|
|
4276
4034
|
`);
|
|
4277
4035
|
}
|
|
4278
4036
|
}
|
|
4279
|
-
const gitDir =
|
|
4280
|
-
if (!
|
|
4037
|
+
const gitDir = join(root, ".git");
|
|
4038
|
+
if (!existsSync(gitDir)) {
|
|
4281
4039
|
process.stderr.write(
|
|
4282
4040
|
`Warning: .git/ not found in ${root}; skipping hook materialization
|
|
4283
4041
|
`
|
|
@@ -4313,10 +4071,12 @@ var handleInit = async (projectRoot, options, parentOpts) => {
|
|
|
4313
4071
|
}
|
|
4314
4072
|
return;
|
|
4315
4073
|
}
|
|
4074
|
+
const hookCommands = await loadHookBindings(root, config.bindings?.hooks);
|
|
4316
4075
|
const result = await materializeHooks({
|
|
4317
4076
|
projectRoot: root,
|
|
4318
4077
|
environments: config.environments,
|
|
4319
|
-
observabilityBinding: config.bindings?.observability
|
|
4078
|
+
observabilityBinding: config.bindings?.observability,
|
|
4079
|
+
hookCommands
|
|
4320
4080
|
});
|
|
4321
4081
|
if (!quiet) {
|
|
4322
4082
|
for (const m of result.materialized) {
|
|
@@ -4330,16 +4090,16 @@ var handleInit = async (projectRoot, options, parentOpts) => {
|
|
|
4330
4090
|
}
|
|
4331
4091
|
};
|
|
4332
4092
|
var handleUpdate = async (projectRoot, options, parentOpts) => {
|
|
4333
|
-
const root =
|
|
4093
|
+
const root = resolve(projectRoot ?? ".");
|
|
4334
4094
|
const quiet = Boolean(parentOpts.quiet);
|
|
4335
|
-
const projectYamlPath =
|
|
4336
|
-
if (!
|
|
4095
|
+
const projectYamlPath = join(root, options.projectYaml ?? DEFAULT_PROJECT_YAML);
|
|
4096
|
+
if (!existsSync(projectYamlPath)) {
|
|
4337
4097
|
fail(
|
|
4338
4098
|
`Error: ${DEFAULT_PROJECT_YAML} not found at ${root}. Run 'aaac init' first.`
|
|
4339
4099
|
);
|
|
4340
4100
|
}
|
|
4341
|
-
const gitDir =
|
|
4342
|
-
if (!
|
|
4101
|
+
const gitDir = join(root, ".git");
|
|
4102
|
+
if (!existsSync(gitDir)) {
|
|
4343
4103
|
process.stderr.write(
|
|
4344
4104
|
`Warning: .git/ not found in ${root}; skipping hook materialization
|
|
4345
4105
|
`
|
|
@@ -4361,10 +4121,12 @@ var handleUpdate = async (projectRoot, options, parentOpts) => {
|
|
|
4361
4121
|
}
|
|
4362
4122
|
return;
|
|
4363
4123
|
}
|
|
4124
|
+
const hookCommands = await loadHookBindings(root, config.bindings?.hooks);
|
|
4364
4125
|
const result = await materializeHooks({
|
|
4365
4126
|
projectRoot: root,
|
|
4366
4127
|
environments: config.environments,
|
|
4367
|
-
observabilityBinding: config.bindings?.observability
|
|
4128
|
+
observabilityBinding: config.bindings?.observability,
|
|
4129
|
+
hookCommands
|
|
4368
4130
|
});
|
|
4369
4131
|
if (!quiet) {
|
|
4370
4132
|
for (const m of result.materialized) {
|
|
@@ -4376,13 +4138,13 @@ var handleUpdate = async (projectRoot, options, parentOpts) => {
|
|
|
4376
4138
|
}
|
|
4377
4139
|
};
|
|
4378
4140
|
var handleUninstall = async (projectRoot, _options, parentOpts) => {
|
|
4379
|
-
const root =
|
|
4141
|
+
const root = resolve(projectRoot ?? ".");
|
|
4380
4142
|
const quiet = Boolean(parentOpts.quiet);
|
|
4381
4143
|
const lock = await readGovernanceLock(root);
|
|
4382
4144
|
if (!lock || lock.entries.length === 0) {
|
|
4383
4145
|
if (!quiet) {
|
|
4384
4146
|
process.stdout.write(
|
|
4385
|
-
`Nothing to uninstall (no governance lock found at ${
|
|
4147
|
+
`Nothing to uninstall (no governance lock found at ${join(root, GOVERNANCE_LOCK_PATH)})
|
|
4386
4148
|
`
|
|
4387
4149
|
);
|
|
4388
4150
|
}
|
|
@@ -4405,9 +4167,9 @@ var handlers = {
|
|
|
4405
4167
|
};
|
|
4406
4168
|
|
|
4407
4169
|
// src/cli/index.ts
|
|
4408
|
-
var __dirname =
|
|
4170
|
+
var __dirname = dirname2(fileURLToPath(import.meta.url));
|
|
4409
4171
|
var pkg = JSON.parse(
|
|
4410
|
-
readFileSync(
|
|
4172
|
+
readFileSync(resolve2(__dirname, "../../package.json"), "utf8")
|
|
4411
4173
|
);
|
|
4412
4174
|
var program2 = createProgram(handlers, pkg.version);
|
|
4413
4175
|
await program2.parseAsync();
|