agentplane 0.3.21 → 0.3.23
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/assets/policy/incidents.md +4 -0
- package/dist/.build-manifest.json +67 -42
- package/dist/cli/bootstrap-guide.d.ts +1 -0
- package/dist/cli/bootstrap-guide.d.ts.map +1 -1
- package/dist/cli/bootstrap-guide.js +3 -2
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +5 -4
- package/dist/cli/run-cli/commands/init/orchestrate-v2.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/orchestrate-v2.js +10 -2
- package/dist/cli/run-cli/commands/init/orchestrate.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/orchestrate.js +10 -2
- package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/recipes.js +3 -1
- package/dist/cli.js +356 -341
- package/dist/commands/branch/work-start.hook-shim.d.ts.map +1 -1
- package/dist/commands/branch/work-start.hook-shim.js +16 -4
- package/dist/commands/doctor/hook-readiness.d.ts +2 -0
- package/dist/commands/doctor/hook-readiness.d.ts.map +1 -0
- package/dist/commands/doctor/hook-readiness.js +171 -0
- package/dist/commands/doctor/workspace.d.ts.map +1 -1
- package/dist/commands/doctor/workspace.js +2 -1
- package/dist/commands/guard/impl/commit.d.ts.map +1 -1
- package/dist/commands/guard/impl/commit.js +26 -0
- package/dist/commands/hooks/install.d.ts +4 -0
- package/dist/commands/hooks/install.d.ts.map +1 -1
- package/dist/commands/hooks/install.js +35 -4
- package/dist/commands/hooks/run.pre-push.d.ts.map +1 -1
- package/dist/commands/hooks/run.pre-push.js +237 -13
- package/dist/commands/recipes/impl/installed-recipes.d.ts +5 -1
- package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/installed-recipes.js +38 -19
- package/dist/commands/release/apply.mutation.d.ts.map +1 -1
- package/dist/commands/release/apply.mutation.js +5 -4
- package/dist/commands/release/apply.pipeline/mutation.d.ts.map +1 -1
- package/dist/commands/release/apply.pipeline/mutation.js +6 -1
- package/dist/commands/release/apply.preflight.d.ts.map +1 -1
- package/dist/commands/release/apply.preflight.js +5 -4
- package/dist/commands/task/derive.command.js +1 -1
- package/dist/commands/task/finish-execute.d.ts.map +1 -1
- package/dist/commands/task/finish-execute.js +8 -1
- package/dist/commands/task/shared/transitions.d.ts.map +1 -1
- package/dist/commands/task/shared/transitions.js +11 -2
- package/dist/commands/task/verify-command-shared.d.ts.map +1 -1
- package/dist/commands/task/verify-command-shared.js +8 -2
- package/dist/runtime/prompt-modules/index.d.ts +3 -0
- package/dist/runtime/prompt-modules/index.d.ts.map +1 -0
- package/dist/runtime/prompt-modules/index.js +1 -0
- package/dist/runtime/prompt-modules/model.d.ts +89 -0
- package/dist/runtime/prompt-modules/model.d.ts.map +1 -0
- package/dist/runtime/prompt-modules/model.js +1 -0
- package/dist/runtime/prompt-modules/mutations.d.ts +103 -0
- package/dist/runtime/prompt-modules/mutations.d.ts.map +1 -0
- package/dist/runtime/prompt-modules/mutations.js +1 -0
- package/dist/shared/runtime-env.d.ts +3 -0
- package/dist/shared/runtime-env.d.ts.map +1 -0
- package/dist/shared/runtime-env.js +73 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-start.hook-shim.d.ts","sourceRoot":"","sources":["../../../src/commands/branch/work-start.hook-shim.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"work-start.hook-shim.d.ts","sourceRoot":"","sources":["../../../src/commands/branch/work-start.hook-shim.ts"],"names":[],"mappings":"AAgDA,wBAAsB,8BAA8B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOxF"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { chmod, mkdir, writeFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileExists } from "../../cli/fs-utils.js";
|
|
4
|
+
import { resolveAgentplaneBinPath } from "../../shared/package-paths.js";
|
|
4
5
|
const HOOK_SHIM_MARKER = "agentplane-hook-shim";
|
|
5
|
-
function
|
|
6
|
+
function shellSingleQuote(value) {
|
|
7
|
+
return `'${value.replaceAll("'", String.raw `'\''`)}'`;
|
|
8
|
+
}
|
|
9
|
+
function resolveInstalledHookRunnerPath() {
|
|
10
|
+
const activeBin = String(process.env.AGENTPLANE_RUNTIME_ACTIVE_BIN ?? "").trim();
|
|
11
|
+
return activeBin || resolveAgentplaneBinPath();
|
|
12
|
+
}
|
|
13
|
+
function repoLocalHookShimText(installedRunnerPath) {
|
|
6
14
|
return [
|
|
7
15
|
"#!/usr/bin/env sh",
|
|
8
16
|
`# ${HOOK_SHIM_MARKER} (do not edit)`,
|
|
@@ -13,6 +21,10 @@ function repoLocalHookShimText() {
|
|
|
13
21
|
'if command -v node >/dev/null 2>&1 && [ -f "$LOCAL_BIN" ]; then',
|
|
14
22
|
' exec node "$LOCAL_BIN" "$@"',
|
|
15
23
|
"fi",
|
|
24
|
+
`INSTALL_BIN=${shellSingleQuote(installedRunnerPath)}`,
|
|
25
|
+
'if command -v node >/dev/null 2>&1 && [ -f "$INSTALL_BIN" ]; then',
|
|
26
|
+
' exec node "$INSTALL_BIN" "$@"',
|
|
27
|
+
"fi",
|
|
16
28
|
'ENV_BIN="${AGENTPLANE_HOOK_RUNNER:-}"',
|
|
17
29
|
'if [ -n "$ENV_BIN" ] && command -v node >/dev/null 2>&1 && [ -f "$ENV_BIN" ]; then',
|
|
18
30
|
' exec node "$ENV_BIN" "$@"',
|
|
@@ -20,10 +32,10 @@ function repoLocalHookShimText() {
|
|
|
20
32
|
"if command -v agentplane >/dev/null 2>&1; then",
|
|
21
33
|
' exec agentplane "$@"',
|
|
22
34
|
"fi",
|
|
23
|
-
|
|
35
|
+
'if [ "${AGENTPLANE_HOOK_ALLOW_NPX:-}" = "1" ] && command -v npx >/dev/null 2>&1; then',
|
|
24
36
|
' exec npx --yes agentplane "$@"',
|
|
25
37
|
"fi",
|
|
26
|
-
'echo "agentplane shim: runner not found (need env runner, repo-local source, agentplane in PATH, or
|
|
38
|
+
'echo "agentplane shim: runner not found (need installed runner, env runner, repo-local source, agentplane in PATH, or AGENTPLANE_HOOK_ALLOW_NPX=1)." >&2',
|
|
27
39
|
" exit 127",
|
|
28
40
|
"",
|
|
29
41
|
].join("\n");
|
|
@@ -33,6 +45,6 @@ export async function materializeHookShimForWorktree(worktreePath) {
|
|
|
33
45
|
if (await fileExists(shimPath))
|
|
34
46
|
return;
|
|
35
47
|
await mkdir(path.dirname(shimPath), { recursive: true });
|
|
36
|
-
await writeFile(shimPath, repoLocalHookShimText(), "utf8");
|
|
48
|
+
await writeFile(shimPath, repoLocalHookShimText(resolveInstalledHookRunnerPath()), "utf8");
|
|
37
49
|
await chmod(shimPath, 0o755);
|
|
38
50
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-readiness.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/hook-readiness.ts"],"names":[],"mappings":"AA4EA,wBAAsB,6BAA6B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAyIvF"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { renderDiagnosticFinding } from "../shared/diagnostics.js";
|
|
4
|
+
import { fileIsManaged, HOOK_MARKER, HOOK_NAMES, resolveGitHooksDir, SHIM_MARKER, } from "../hooks/shared.js";
|
|
5
|
+
async function pathExists(absPath) {
|
|
6
|
+
try {
|
|
7
|
+
await fs.access(absPath);
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function readTextIfExists(absPath) {
|
|
15
|
+
try {
|
|
16
|
+
return await fs.readFile(absPath, "utf8");
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function unquoteShellSingleQuoted(value) {
|
|
23
|
+
return value.replaceAll(String.raw `'\''`, "'");
|
|
24
|
+
}
|
|
25
|
+
function extractInstallBinFromShim(shimText) {
|
|
26
|
+
const match = /\nINSTALL_BIN='((?:'\\''|[^'])*)'/.exec(shimText);
|
|
27
|
+
if (!match)
|
|
28
|
+
return null;
|
|
29
|
+
return unquoteShellSingleQuoted(match[1] ?? "").trim() || null;
|
|
30
|
+
}
|
|
31
|
+
async function resolveManagedHookNames(repoRoot) {
|
|
32
|
+
let hooksDir;
|
|
33
|
+
try {
|
|
34
|
+
hooksDir = await resolveGitHooksDir(repoRoot);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return { hooksDir: null, managedHooks: [], unmanagedHooks: [] };
|
|
38
|
+
}
|
|
39
|
+
const managedHooks = [];
|
|
40
|
+
const unmanagedHooks = [];
|
|
41
|
+
for (const hook of HOOK_NAMES) {
|
|
42
|
+
const hookPath = path.join(hooksDir, hook);
|
|
43
|
+
if (!(await pathExists(hookPath)))
|
|
44
|
+
continue;
|
|
45
|
+
if (await fileIsManaged(hookPath, HOOK_MARKER))
|
|
46
|
+
managedHooks.push(hook);
|
|
47
|
+
else
|
|
48
|
+
unmanagedHooks.push(hook);
|
|
49
|
+
}
|
|
50
|
+
return { hooksDir, managedHooks, unmanagedHooks };
|
|
51
|
+
}
|
|
52
|
+
function renderUnmanagedHooksFinding(unmanagedHooks) {
|
|
53
|
+
return renderDiagnosticFinding({
|
|
54
|
+
severity: "INFO",
|
|
55
|
+
state: "unmanaged git hooks are present and will not be overwritten by AgentPlane",
|
|
56
|
+
likelyCause: "the repository has custom hook files outside the AgentPlane managed hook set",
|
|
57
|
+
nextAction: {
|
|
58
|
+
command: "agentplane hooks install",
|
|
59
|
+
reason: "refresh managed hooks only after manually reconciling custom hook files that should remain custom",
|
|
60
|
+
},
|
|
61
|
+
details: [`Unmanaged hooks: ${unmanagedHooks.join(", ")}`],
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export async function checkManagedHookShimReadiness(repoRoot) {
|
|
65
|
+
const findings = [];
|
|
66
|
+
const { managedHooks, unmanagedHooks } = await resolveManagedHookNames(repoRoot);
|
|
67
|
+
const shimRelPath = ".agentplane/bin/agentplane";
|
|
68
|
+
const shimPath = path.join(repoRoot, shimRelPath);
|
|
69
|
+
const shimText = await readTextIfExists(shimPath);
|
|
70
|
+
const managedShim = shimText?.includes(SHIM_MARKER) === true;
|
|
71
|
+
if (managedHooks.length === 0 && unmanagedHooks.length === 0 && !shimText)
|
|
72
|
+
return findings;
|
|
73
|
+
if (managedHooks.length > 0 && !shimText) {
|
|
74
|
+
findings.push(renderDiagnosticFinding({
|
|
75
|
+
severity: "WARN",
|
|
76
|
+
state: "managed git hooks are installed but the AgentPlane hook shim is missing",
|
|
77
|
+
likelyCause: "the repository hook files still call .agentplane/bin/agentplane, but that shim was deleted or never committed",
|
|
78
|
+
nextAction: {
|
|
79
|
+
command: "agentplane hooks install",
|
|
80
|
+
reason: "recreate the managed hook shim and refresh hook files",
|
|
81
|
+
},
|
|
82
|
+
details: [`Managed hooks: ${managedHooks.join(", ")}`],
|
|
83
|
+
}));
|
|
84
|
+
return findings;
|
|
85
|
+
}
|
|
86
|
+
if (shimText && !managedShim) {
|
|
87
|
+
findings.push(renderDiagnosticFinding({
|
|
88
|
+
severity: "WARN",
|
|
89
|
+
state: "AgentPlane hook shim path exists but is not managed by AgentPlane",
|
|
90
|
+
likelyCause: "a custom .agentplane/bin/agentplane file is shadowing the managed hook runner shim",
|
|
91
|
+
nextAction: {
|
|
92
|
+
command: "inspect .agentplane/bin/agentplane, remove the custom file if unintended, then run agentplane hooks install",
|
|
93
|
+
reason: "restore the managed shim without overwriting custom executable content silently",
|
|
94
|
+
},
|
|
95
|
+
details: [`Shim path: ${shimRelPath}`],
|
|
96
|
+
}));
|
|
97
|
+
return findings;
|
|
98
|
+
}
|
|
99
|
+
if (!shimText) {
|
|
100
|
+
if (unmanagedHooks.length > 0) {
|
|
101
|
+
findings.push(renderUnmanagedHooksFinding(unmanagedHooks));
|
|
102
|
+
}
|
|
103
|
+
return findings;
|
|
104
|
+
}
|
|
105
|
+
const installedBin = extractInstallBinFromShim(shimText);
|
|
106
|
+
if (!installedBin) {
|
|
107
|
+
findings.push(renderDiagnosticFinding({
|
|
108
|
+
severity: "WARN",
|
|
109
|
+
state: "managed AgentPlane hook shim uses a stale format without an installed runner fallback",
|
|
110
|
+
likelyCause: "the shim was generated by an older AgentPlane release before installed-binary fallback was embedded",
|
|
111
|
+
nextAction: {
|
|
112
|
+
command: "agentplane hooks install",
|
|
113
|
+
reason: "rewrite the managed shim with the current installed-runtime fallback contract",
|
|
114
|
+
},
|
|
115
|
+
details: [`Shim path: ${shimRelPath}`],
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
else if (!(await pathExists(installedBin))) {
|
|
119
|
+
findings.push(renderDiagnosticFinding({
|
|
120
|
+
severity: "WARN",
|
|
121
|
+
state: "managed AgentPlane hook shim points to a missing installed runner",
|
|
122
|
+
likelyCause: "AgentPlane was reinstalled, removed, or moved after hooks were installed in this repository",
|
|
123
|
+
nextAction: {
|
|
124
|
+
command: "agentplane hooks install",
|
|
125
|
+
reason: "refresh the embedded installed runner path after reinstalling or updating AgentPlane",
|
|
126
|
+
},
|
|
127
|
+
details: [`Embedded runner: ${installedBin}`, `Shim path: ${shimRelPath}`],
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
const hasEnvFallback = shimText.includes("AGENTPLANE_HOOK_RUNNER");
|
|
131
|
+
const hasNpxFallback = shimText.includes("AGENTPLANE_HOOK_ALLOW_NPX");
|
|
132
|
+
if (!hasEnvFallback || !hasNpxFallback) {
|
|
133
|
+
findings.push(renderDiagnosticFinding({
|
|
134
|
+
severity: "WARN",
|
|
135
|
+
state: "managed AgentPlane hook shim is missing current fallback branches",
|
|
136
|
+
likelyCause: "the repository still has an older managed shim that cannot use env-runner or explicit npx fallback recovery",
|
|
137
|
+
nextAction: {
|
|
138
|
+
command: "agentplane hooks install",
|
|
139
|
+
reason: "rewrite the shim with the current fallback chain",
|
|
140
|
+
},
|
|
141
|
+
details: [
|
|
142
|
+
`Shim path: ${shimRelPath}`,
|
|
143
|
+
`AGENTPLANE_HOOK_RUNNER fallback: ${hasEnvFallback ? "present" : "missing"}`,
|
|
144
|
+
`AGENTPLANE_HOOK_ALLOW_NPX fallback: ${hasNpxFallback ? "present" : "missing"}`,
|
|
145
|
+
],
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
if (managedHooks.includes("pre-push")) {
|
|
149
|
+
const repoPrePushScript = path.join(repoRoot, "scripts", "run-pre-push-hook.mjs");
|
|
150
|
+
const packageJsonText = await readTextIfExists(path.join(repoRoot, "package.json"));
|
|
151
|
+
if (!(await pathExists(repoPrePushScript)) && packageJsonText) {
|
|
152
|
+
findings.push(renderDiagnosticFinding({
|
|
153
|
+
severity: "INFO",
|
|
154
|
+
state: "managed pre-push hook will use installed clean-project fallback checks",
|
|
155
|
+
likelyCause: "this project does not ship a repository-local scripts/run-pre-push-hook.mjs",
|
|
156
|
+
nextAction: {
|
|
157
|
+
command: "add project-local package scripts such as format:check or test, or keep the installed fallback",
|
|
158
|
+
reason: "make pre-push behavior explicit when the project needs stricter repository-specific checks",
|
|
159
|
+
},
|
|
160
|
+
details: [
|
|
161
|
+
"Missing repository script: scripts/run-pre-push-hook.mjs",
|
|
162
|
+
"Installed fallback skips package scripts that are not declared by the clean project.",
|
|
163
|
+
],
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (unmanagedHooks.length > 0) {
|
|
168
|
+
findings.push(renderUnmanagedHooksFinding(unmanagedHooks));
|
|
169
|
+
}
|
|
170
|
+
return findings;
|
|
171
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/workspace.ts"],"names":[],"mappings":"AAYA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/workspace.ts"],"names":[],"mappings":"AAYA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIpF,KAAK,eAAe,GAAG;IACrB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAqFF,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,MAAM,EAAE,CAyDnF;AAED,wBAAsB,6BAA6B,CACjD,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,cAAc,GACnB,OAAO,CAAC,MAAM,EAAE,CAAC,CAOnB;AAoMD,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,cAAc,CAAA;CAAE,GAC9B,OAAO,CAAC,MAAM,EAAE,CAAC,CA4DnB"}
|
|
@@ -6,6 +6,7 @@ import { resolvePolicyGatewayForRepo } from "../../shared/policy-gateway.js";
|
|
|
6
6
|
import { GitContext } from "@agentplaneorg/core/git";
|
|
7
7
|
import { listTaskProjection } from "../shared/task-backend.js";
|
|
8
8
|
import { resolveAgentplaneAssetPath } from "../../shared/package-paths.js";
|
|
9
|
+
import { checkManagedHookShimReadiness } from "./hook-readiness.js";
|
|
9
10
|
async function pathExists(absPath) {
|
|
10
11
|
try {
|
|
11
12
|
await fs.access(absPath);
|
|
@@ -365,6 +366,6 @@ export async function checkWorkspace(repoRoot, opts) {
|
|
|
365
366
|
if (!hasJson) {
|
|
366
367
|
problems.push("No agent profiles found in .agentplane/agents (*.json expected).");
|
|
367
368
|
}
|
|
368
|
-
problems.push(...checkBackendReadiness(opts?.ctx), ...(await checkTaskReadmeMigrationState(repoRoot, opts?.ctx)), ...(await checkDoneTaskReadmeArchiveDrift(repoRoot, opts?.ctx)), ...(await checkTaskProjectionDrift(repoRoot, opts?.ctx)));
|
|
369
|
+
problems.push(...checkBackendReadiness(opts?.ctx), ...(await checkManagedHookShimReadiness(repoRoot)), ...(await checkTaskReadmeMigrationState(repoRoot, opts?.ctx)), ...(await checkDoneTaskReadmeArchiveDrift(repoRoot, opts?.ctx)), ...(await checkTaskProjectionDrift(repoRoot, opts?.ctx)));
|
|
369
370
|
return problems;
|
|
370
371
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/commit.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/commit.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAwLtC,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,GAAG,OAAO,CAAC,MAAM,CAAC,CAwIlB"}
|
|
@@ -137,6 +137,22 @@ function formatCommitRef(commit) {
|
|
|
137
137
|
return "";
|
|
138
138
|
return `${commit.hash?.slice(0, 12) ?? ""} ${commit.subject ?? ""}`.trim();
|
|
139
139
|
}
|
|
140
|
+
async function stageActiveTaskArtifactsFromAllowTasks(opts) {
|
|
141
|
+
if (!opts.allowTasks)
|
|
142
|
+
return [];
|
|
143
|
+
const changedPaths = await opts.ctx.git.statusChangedPaths();
|
|
144
|
+
const taskArtifactPaths = changedPaths.filter((relPath) => isTaskLocalAdvancePath({
|
|
145
|
+
workflowDir: opts.ctx.config.paths.workflow_dir,
|
|
146
|
+
taskId: opts.taskId,
|
|
147
|
+
tasksPath: opts.ctx.config.paths.tasks_path,
|
|
148
|
+
relPath,
|
|
149
|
+
}));
|
|
150
|
+
if (taskArtifactPaths.length === 0)
|
|
151
|
+
return [];
|
|
152
|
+
const unique = [...new Set(taskArtifactPaths)].toSorted((a, b) => a.localeCompare(b));
|
|
153
|
+
await opts.ctx.git.stage(unique);
|
|
154
|
+
return unique;
|
|
155
|
+
}
|
|
140
156
|
export async function cmdCommit(opts) {
|
|
141
157
|
try {
|
|
142
158
|
const ctx = opts.ctx ??
|
|
@@ -181,6 +197,16 @@ export async function cmdCommit(opts) {
|
|
|
181
197
|
process.stdout.write(`${infoMessage(`commit auto-staged ${autoStaged.length} path(s) from allowlist`)}\n`);
|
|
182
198
|
}
|
|
183
199
|
}
|
|
200
|
+
else {
|
|
201
|
+
autoStaged = await stageActiveTaskArtifactsFromAllowTasks({
|
|
202
|
+
ctx,
|
|
203
|
+
taskId: opts.taskId,
|
|
204
|
+
allowTasks: opts.allowTasks,
|
|
205
|
+
});
|
|
206
|
+
if (autoStaged.length > 0 && !opts.quiet) {
|
|
207
|
+
process.stdout.write(`${infoMessage(`commit auto-staged ${autoStaged.length} active task artifact path(s) from --allow-tasks`)}\n`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
184
210
|
await guardCommitCheck({
|
|
185
211
|
ctx,
|
|
186
212
|
cwd: opts.cwd,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks/install.ts"],"names":[],"mappings":"AA+CA,wBAAsB,4BAA4B,CAAC,IAAI,EAAE;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBpB;AAmDD,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmClB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4BlB"}
|
|
@@ -5,6 +5,7 @@ import { mapCoreError } from "../../cli/error-map.js";
|
|
|
5
5
|
import { fileExists } from "../../cli/fs-utils.js";
|
|
6
6
|
import { infoMessage, successMessage } from "../../cli/output.js";
|
|
7
7
|
import { CliError } from "../../shared/errors.js";
|
|
8
|
+
import { resolveAgentplaneBinPath } from "../../shared/package-paths.js";
|
|
8
9
|
import { fileIsManaged, HOOK_MARKER, HOOK_NAMES, resolveGitHooksDir, SHIM_MARKER, } from "./shared.js";
|
|
9
10
|
function hookScriptText(hook) {
|
|
10
11
|
return [
|
|
@@ -24,7 +25,33 @@ function hookScriptText(hook) {
|
|
|
24
25
|
"",
|
|
25
26
|
].join("\n");
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function shellSingleQuote(value) {
|
|
29
|
+
return `'${value.replaceAll("'", String.raw `'\''`)}'`;
|
|
30
|
+
}
|
|
31
|
+
function resolveInstalledHookRunnerPath() {
|
|
32
|
+
const activeBin = String(process.env.AGENTPLANE_RUNTIME_ACTIVE_BIN ?? "").trim();
|
|
33
|
+
return activeBin || resolveAgentplaneBinPath();
|
|
34
|
+
}
|
|
35
|
+
export async function collectHooksInstallConflicts(opts) {
|
|
36
|
+
const hooksDir = await resolveGitHooksDir(opts.gitRoot);
|
|
37
|
+
const conflicts = [];
|
|
38
|
+
const shimPath = path.join(opts.agentplaneDir, "bin", "agentplane");
|
|
39
|
+
if (await fileExists(shimPath)) {
|
|
40
|
+
const managed = await fileIsManaged(shimPath, SHIM_MARKER);
|
|
41
|
+
if (!managed)
|
|
42
|
+
conflicts.push(shimPath);
|
|
43
|
+
}
|
|
44
|
+
for (const hook of HOOK_NAMES) {
|
|
45
|
+
const hookPath = path.join(hooksDir, hook);
|
|
46
|
+
if (!(await fileExists(hookPath)))
|
|
47
|
+
continue;
|
|
48
|
+
const managed = await fileIsManaged(hookPath, HOOK_MARKER);
|
|
49
|
+
if (!managed)
|
|
50
|
+
conflicts.push(hookPath);
|
|
51
|
+
}
|
|
52
|
+
return conflicts;
|
|
53
|
+
}
|
|
54
|
+
function shimScriptText(installedRunnerPath) {
|
|
28
55
|
return [
|
|
29
56
|
"#!/usr/bin/env sh",
|
|
30
57
|
`# ${SHIM_MARKER} (do not edit)`,
|
|
@@ -35,6 +62,10 @@ function shimScriptText() {
|
|
|
35
62
|
'if command -v node >/dev/null 2>&1 && [ -f "$LOCAL_BIN" ]; then',
|
|
36
63
|
' exec node "$LOCAL_BIN" "$@"',
|
|
37
64
|
"fi",
|
|
65
|
+
`INSTALL_BIN=${shellSingleQuote(installedRunnerPath)}`,
|
|
66
|
+
'if command -v node >/dev/null 2>&1 && [ -f "$INSTALL_BIN" ]; then',
|
|
67
|
+
' exec node "$INSTALL_BIN" "$@"',
|
|
68
|
+
"fi",
|
|
38
69
|
'ENV_BIN="${AGENTPLANE_HOOK_RUNNER:-}"',
|
|
39
70
|
'if [ -n "$ENV_BIN" ] && command -v node >/dev/null 2>&1 && [ -f "$ENV_BIN" ]; then',
|
|
40
71
|
' exec node "$ENV_BIN" "$@"',
|
|
@@ -42,10 +73,10 @@ function shimScriptText() {
|
|
|
42
73
|
"if command -v agentplane >/dev/null 2>&1; then",
|
|
43
74
|
' exec agentplane "$@"',
|
|
44
75
|
"fi",
|
|
45
|
-
|
|
76
|
+
'if [ "${AGENTPLANE_HOOK_ALLOW_NPX:-}" = "1" ] && command -v npx >/dev/null 2>&1; then',
|
|
46
77
|
' exec npx --yes agentplane "$@"',
|
|
47
78
|
"fi",
|
|
48
|
-
'echo "agentplane shim: runner not found (need env runner, repo-local source, agentplane in PATH, or
|
|
79
|
+
'echo "agentplane shim: runner not found (need installed runner, env runner, repo-local source, agentplane in PATH, or AGENTPLANE_HOOK_ALLOW_NPX=1)." >&2',
|
|
49
80
|
" exit 127",
|
|
50
81
|
"",
|
|
51
82
|
].join("\n");
|
|
@@ -64,7 +95,7 @@ async function ensureShim(agentplaneDir, gitRoot) {
|
|
|
64
95
|
});
|
|
65
96
|
}
|
|
66
97
|
}
|
|
67
|
-
await writeFile(shimPath, shimScriptText(), "utf8");
|
|
98
|
+
await writeFile(shimPath, shimScriptText(resolveInstalledHookRunnerPath()), "utf8");
|
|
68
99
|
await chmod(shimPath, 0o755);
|
|
69
100
|
}
|
|
70
101
|
export async function cmdHooksInstall(opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.pre-push.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks/run.pre-push.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.pre-push.d.ts","sourceRoot":"","sources":["../../../src/commands/hooks/run.pre-push.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAyBhD,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,MAAM,EACf,IAAI,GAAE;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAO,GACxC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAMxB;AAiUD,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAuB3E"}
|