agentplane 0.3.4 → 0.3.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 +103 -75
- package/assets/AGENTS.md +4 -2
- package/bin/dist-guard.js +13 -3
- package/bin/runtime-watch.d.ts +1 -0
- package/bin/runtime-watch.js +22 -5
- package/bin/stale-dist-policy.js +9 -2
- package/dist/.build-manifest.json +220 -790
- package/dist/adapters/task-backend/task-backend-adapter.d.ts +1 -1
- package/dist/adapters/task-backend/task-backend-adapter.d.ts.map +1 -1
- package/dist/adapters/task-backend/task-backend-adapter.js +5 -2
- package/dist/backends/task-backend/local-backend.d.ts +13 -0
- package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/local-backend.js +17 -0
- package/dist/backends/task-backend/redmine-backend.d.ts +18 -0
- package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/redmine-backend.js +35 -25
- package/dist/backends/task-backend/shared/types.d.ts +20 -0
- package/dist/backends/task-backend/shared/types.d.ts.map +1 -1
- package/dist/backends/task-backend/shared.d.ts +1 -1
- package/dist/backends/task-backend/shared.d.ts.map +1 -1
- package/dist/backends/task-backend.d.ts +1 -1
- package/dist/backends/task-backend.d.ts.map +1 -1
- package/dist/backends/task-backend.test-helpers.d.ts +4 -0
- package/dist/backends/task-backend.test-helpers.d.ts.map +1 -0
- package/dist/backends/task-backend.test-helpers.js +33 -0
- package/dist/cli/bootstrap-guide.d.ts.map +1 -1
- package/dist/cli/bootstrap-guide.js +1 -0
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +3 -2
- package/dist/cli/reason-codes.d.ts.map +1 -1
- package/dist/cli/reason-codes.js +30 -0
- package/dist/cli/run-cli/command-catalog/core.d.ts +3 -0
- package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -0
- package/dist/cli/run-cli/command-catalog/core.js +137 -0
- package/dist/cli/run-cli/command-catalog/lifecycle.d.ts +3 -0
- package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -0
- package/dist/cli/run-cli/command-catalog/lifecycle.js +52 -0
- package/dist/cli/run-cli/command-catalog/project.d.ts +3 -0
- package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -0
- package/dist/cli/run-cli/command-catalog/project.js +78 -0
- package/dist/cli/run-cli/command-catalog/shared.d.ts +19 -0
- package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -0
- package/dist/cli/run-cli/command-catalog/shared.js +9 -0
- package/dist/cli/run-cli/command-catalog/task.d.ts +3 -0
- package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -0
- package/dist/cli/run-cli/command-catalog/task.js +85 -0
- package/dist/cli/run-cli/command-catalog.d.ts +3 -18
- package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog.js +8 -337
- package/dist/cli/run-cli/commands/ide.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/ide.js +64 -2
- package/dist/cli/run-cli/commands/init/ui.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/ui.js +33 -13
- package/dist/cli/run-cli.core.pr-flow.test-helpers.d.ts +3 -0
- package/dist/cli/run-cli.core.pr-flow.test-helpers.d.ts.map +1 -0
- package/dist/cli/run-cli.core.pr-flow.test-helpers.js +41 -0
- package/dist/cli/run-cli.core.tasks.test-helpers.d.ts +2 -0
- package/dist/cli/run-cli.core.tasks.test-helpers.d.ts.map +1 -0
- package/dist/cli/run-cli.core.tasks.test-helpers.js +6 -0
- package/dist/cli/run-cli.test-helpers.d.ts +3 -0
- package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
- package/dist/cli/run-cli.test-helpers.js +138 -6
- package/dist/commands/commit.spec.d.ts.map +1 -1
- package/dist/commands/commit.spec.js +2 -2
- package/dist/commands/doctor/runtime.d.ts.map +1 -1
- package/dist/commands/doctor/runtime.js +3 -6
- package/dist/commands/doctor/workspace.d.ts +4 -1
- package/dist/commands/doctor/workspace.d.ts.map +1 -1
- package/dist/commands/doctor/workspace.js +87 -4
- package/dist/commands/doctor.run.d.ts.map +1 -1
- package/dist/commands/doctor.run.js +8 -1
- package/dist/commands/guard/commit.command.js +1 -1
- package/dist/commands/guard/impl/allow.d.ts +5 -0
- package/dist/commands/guard/impl/allow.d.ts.map +1 -1
- package/dist/commands/guard/impl/allow.js +15 -10
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +137 -18
- package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -1
- package/dist/commands/guard/impl/comment-commit.js +2 -0
- package/dist/commands/hooks/index.d.ts.map +1 -1
- package/dist/commands/hooks/index.js +8 -35
- package/dist/commands/recipes/impl/apply.d.ts +4 -0
- package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
- package/dist/commands/recipes/impl/apply.js +34 -0
- package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/explain.js +70 -11
- package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/info.js +24 -12
- package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/install.js +32 -36
- package/dist/commands/recipes/impl/commands/list.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/list.js +7 -4
- package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/remove.js +9 -11
- package/dist/commands/recipes/impl/constants.d.ts +2 -0
- package/dist/commands/recipes/impl/constants.d.ts.map +1 -1
- package/dist/commands/recipes/impl/constants.js +2 -0
- package/dist/commands/recipes/impl/manifest.d.ts.map +1 -1
- package/dist/commands/recipes/impl/manifest.js +219 -23
- package/dist/commands/recipes/impl/normalize.d.ts +3 -0
- package/dist/commands/recipes/impl/normalize.d.ts.map +1 -1
- package/dist/commands/recipes/impl/normalize.js +28 -24
- package/dist/commands/recipes/impl/paths.d.ts +9 -0
- package/dist/commands/recipes/impl/paths.d.ts.map +1 -1
- package/dist/commands/recipes/impl/paths.js +10 -1
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts +7 -0
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -0
- package/dist/commands/recipes/impl/project-installed-recipes.js +102 -0
- package/dist/commands/recipes/impl/resolver.d.ts +20 -0
- package/dist/commands/recipes/impl/resolver.d.ts.map +1 -0
- package/dist/commands/recipes/impl/resolver.js +220 -0
- package/dist/commands/recipes/impl/scenario.d.ts.map +1 -1
- package/dist/commands/recipes/impl/scenario.js +40 -11
- package/dist/commands/recipes/impl/types.d.ts +145 -16
- package/dist/commands/recipes/impl/types.d.ts.map +1 -1
- package/dist/commands/recipes/install.spec.d.ts.map +1 -1
- package/dist/commands/recipes/install.spec.js +3 -2
- package/dist/commands/recipes.d.ts +6 -4
- package/dist/commands/recipes.d.ts.map +1 -1
- package/dist/commands/recipes.js +5 -3
- package/dist/commands/recipes.test-helpers.d.ts +185 -0
- package/dist/commands/recipes.test-helpers.d.ts.map +1 -0
- package/dist/commands/recipes.test-helpers.js +339 -0
- package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
- package/dist/commands/scenario/impl/commands.js +192 -336
- package/dist/commands/scenario/info.command.d.ts.map +1 -1
- package/dist/commands/scenario/info.command.js +7 -2
- package/dist/commands/scenario/list.command.js +2 -2
- package/dist/commands/scenario/run.command.d.ts.map +1 -1
- package/dist/commands/scenario/run.command.js +7 -2
- package/dist/commands/shared/git-context.d.ts +1 -0
- package/dist/commands/shared/git-context.d.ts.map +1 -1
- package/dist/commands/shared/git-context.js +4 -0
- package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
- package/dist/commands/shared/reconcile-check.js +77 -2
- package/dist/commands/shared/task-backend.d.ts +5 -0
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +24 -0
- package/dist/commands/shared/task-store.d.ts +32 -1
- package/dist/commands/shared/task-store.d.ts.map +1 -1
- package/dist/commands/shared/task-store.js +166 -42
- package/dist/commands/task/block.d.ts.map +1 -1
- package/dist/commands/task/block.js +46 -29
- package/dist/commands/task/close-duplicate.d.ts.map +1 -1
- package/dist/commands/task/close-duplicate.js +12 -37
- package/dist/commands/task/close-noop.d.ts.map +1 -1
- package/dist/commands/task/close-noop.js +12 -30
- package/dist/commands/task/close-shared.d.ts +14 -0
- package/dist/commands/task/close-shared.d.ts.map +1 -0
- package/dist/commands/task/close-shared.js +76 -0
- package/dist/commands/task/comment.d.ts.map +1 -1
- package/dist/commands/task/comment.js +35 -17
- package/dist/commands/task/doc-set.command.d.ts +2 -1
- package/dist/commands/task/doc-set.command.d.ts.map +1 -1
- package/dist/commands/task/doc-set.command.js +36 -4
- package/dist/commands/task/doc-template.d.ts.map +1 -1
- package/dist/commands/task/doc-template.js +2 -7
- package/dist/commands/task/doc.command.js +1 -1
- package/dist/commands/task/doc.d.ts +2 -1
- package/dist/commands/task/doc.d.ts.map +1 -1
- package/dist/commands/task/doc.js +123 -71
- package/dist/commands/task/export.d.ts.map +1 -1
- package/dist/commands/task/export.js +4 -4
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +141 -78
- package/dist/commands/task/migrate-doc.d.ts.map +1 -1
- package/dist/commands/task/migrate-doc.js +15 -11
- package/dist/commands/task/plan-set.command.js +1 -1
- package/dist/commands/task/plan.command.d.ts +8 -0
- package/dist/commands/task/plan.command.d.ts.map +1 -0
- package/dist/commands/task/plan.command.js +37 -0
- package/dist/commands/task/plan.d.ts.map +1 -1
- package/dist/commands/task/plan.js +190 -93
- package/dist/commands/task/set-status.command.d.ts.map +1 -1
- package/dist/commands/task/set-status.command.js +1 -1
- package/dist/commands/task/set-status.d.ts.map +1 -1
- package/dist/commands/task/set-status.js +40 -3
- package/dist/commands/task/shared/docs.d.ts +1 -0
- package/dist/commands/task/shared/docs.d.ts.map +1 -1
- package/dist/commands/task/shared/docs.js +7 -0
- package/dist/commands/task/shared/transitions.d.ts +0 -2
- package/dist/commands/task/shared/transitions.d.ts.map +1 -1
- package/dist/commands/task/shared/transitions.js +0 -6
- package/dist/commands/task/shared.d.ts +2 -2
- package/dist/commands/task/shared.d.ts.map +1 -1
- package/dist/commands/task/shared.js +2 -2
- package/dist/commands/task/start.d.ts.map +1 -1
- package/dist/commands/task/start.js +88 -63
- package/dist/commands/task/task.command.d.ts +8 -0
- package/dist/commands/task/task.command.d.ts.map +1 -0
- package/dist/commands/task/task.command.js +71 -0
- package/dist/commands/task/verify-command-shared.d.ts +16 -0
- package/dist/commands/task/verify-command-shared.d.ts.map +1 -0
- package/dist/commands/task/verify-command-shared.js +53 -0
- package/dist/commands/task/verify-ok.command.d.ts +2 -6
- package/dist/commands/task/verify-ok.command.d.ts.map +1 -1
- package/dist/commands/task/verify-ok.command.js +8 -50
- package/dist/commands/task/verify-record.d.ts.map +1 -1
- package/dist/commands/task/verify-record.js +119 -140
- package/dist/commands/task/verify-rework.command.d.ts +2 -6
- package/dist/commands/task/verify-rework.command.d.ts.map +1 -1
- package/dist/commands/task/verify-rework.command.js +8 -50
- package/dist/commands/verify.spec.d.ts.map +1 -1
- package/dist/commands/verify.spec.js +3 -12
- package/dist/policy/rules/allowlist.d.ts.map +1 -1
- package/dist/policy/rules/allowlist.js +13 -4
- package/dist/policy/rules/protected-paths.d.ts.map +1 -1
- package/dist/policy/rules/protected-paths.js +6 -1
- package/dist/ports/task-backend-port.d.ts +1 -1
- package/dist/ports/task-backend-port.d.ts.map +1 -1
- package/dist/shared/agent-emoji.d.ts.map +1 -1
- package/dist/shared/protected-paths.d.ts +7 -0
- package/dist/shared/protected-paths.d.ts.map +1 -1
- package/dist/shared/protected-paths.js +26 -10
- package/dist/shared/repo-cli-version.d.ts.map +1 -1
- package/dist/shared/repo-cli-version.js +9 -3
- package/package.json +2 -2
|
@@ -6,7 +6,7 @@ import path from "node:path";
|
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { promisify } from "node:util";
|
|
8
8
|
import { gzipSync } from "node:zlib";
|
|
9
|
-
import { afterAll, afterEach, beforeAll } from "vitest";
|
|
9
|
+
import { afterAll, afterEach, beforeAll, beforeEach, vi } from "vitest";
|
|
10
10
|
import { defaultConfig } from "@agentplaneorg/core";
|
|
11
11
|
import { runCli } from "./run-cli.js";
|
|
12
12
|
const execFileAsync = promisify(execFile);
|
|
@@ -98,6 +98,17 @@ export function registerAgentplaneHome() {
|
|
|
98
98
|
}));
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
+
export function installRunCliIntegrationHarness() {
|
|
102
|
+
registerAgentplaneHome();
|
|
103
|
+
let restoreStdIO = null;
|
|
104
|
+
beforeEach(() => {
|
|
105
|
+
restoreStdIO = silenceStdIO();
|
|
106
|
+
});
|
|
107
|
+
afterEach(() => {
|
|
108
|
+
restoreStdIO?.();
|
|
109
|
+
restoreStdIO = null;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
101
112
|
export function getAgentplaneHome() {
|
|
102
113
|
return agentplaneHome;
|
|
103
114
|
}
|
|
@@ -150,6 +161,26 @@ export function silenceStdIO() {
|
|
|
150
161
|
}
|
|
151
162
|
};
|
|
152
163
|
}
|
|
164
|
+
export function stubTaskBackend(overrides = {}) {
|
|
165
|
+
return {
|
|
166
|
+
id: "local",
|
|
167
|
+
capabilities: {
|
|
168
|
+
canonical_source: "local",
|
|
169
|
+
projection: "canonical",
|
|
170
|
+
reads_from_projection_by_default: false,
|
|
171
|
+
writes_task_readmes: true,
|
|
172
|
+
may_access_network_on_read: false,
|
|
173
|
+
may_access_network_on_write: false,
|
|
174
|
+
supports_projection_refresh: false,
|
|
175
|
+
supports_push_sync: false,
|
|
176
|
+
supports_snapshot_export: false,
|
|
177
|
+
},
|
|
178
|
+
listTasks: vi.fn().mockResolvedValue([]),
|
|
179
|
+
getTask: vi.fn().mockResolvedValue(null),
|
|
180
|
+
writeTask: vi.fn().mockImplementation(() => Promise.resolve()),
|
|
181
|
+
...overrides,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
153
184
|
export async function runCliSilent(args) {
|
|
154
185
|
const io = captureStdIO();
|
|
155
186
|
try {
|
|
@@ -215,11 +246,60 @@ export async function createRecipeArchive(opts) {
|
|
|
215
246
|
name: opts?.name ?? "Viewer",
|
|
216
247
|
summary: opts?.summary ?? "Preview task artifacts",
|
|
217
248
|
description: opts?.description ?? "Provides a local viewer for task artifacts.",
|
|
218
|
-
|
|
249
|
+
compatibility: {
|
|
250
|
+
min_agentplane_version: "0.3.5",
|
|
251
|
+
manifest_api_version: "1",
|
|
252
|
+
scenario_api_version: "1",
|
|
253
|
+
runtime_api_version: "1",
|
|
254
|
+
platforms: ["darwin", "linux"],
|
|
255
|
+
repo_types: ["generic"],
|
|
256
|
+
},
|
|
257
|
+
skills: [
|
|
258
|
+
{
|
|
259
|
+
id: "RECIPE_SKILL",
|
|
260
|
+
summary: "Recipe analysis skill",
|
|
261
|
+
kind: "agent-skill",
|
|
262
|
+
file: "skills/analysis.json",
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
agents: [
|
|
266
|
+
{
|
|
267
|
+
id: "RECIPE_AGENT",
|
|
268
|
+
display_name: "Recipe Agent",
|
|
269
|
+
role: "executor",
|
|
270
|
+
summary: "Recipe agent",
|
|
271
|
+
skills: ["RECIPE_SKILL"],
|
|
272
|
+
tools: ["RECIPE_TOOL"],
|
|
273
|
+
file: "agents/recipe.json",
|
|
274
|
+
},
|
|
275
|
+
],
|
|
219
276
|
tools: [
|
|
220
277
|
{ id: "RECIPE_TOOL", summary: "Recipe tool", runtime: "node", entrypoint: "tools/run.js" },
|
|
221
278
|
],
|
|
222
|
-
scenarios: [
|
|
279
|
+
scenarios: [
|
|
280
|
+
{
|
|
281
|
+
id: "RECIPE_SCENARIO",
|
|
282
|
+
name: "Recipe Scenario",
|
|
283
|
+
summary: "Recipe scenario",
|
|
284
|
+
use_when: ["Task artifacts need local preview"],
|
|
285
|
+
required_inputs: ["task_id"],
|
|
286
|
+
outputs: ["report"],
|
|
287
|
+
permissions: ["filesystem-write"],
|
|
288
|
+
artifacts: ["artifact.txt"],
|
|
289
|
+
agents_involved: ["RECIPE_AGENT"],
|
|
290
|
+
skills_used: ["RECIPE_SKILL"],
|
|
291
|
+
tools_used: ["RECIPE_TOOL"],
|
|
292
|
+
run_profile: {
|
|
293
|
+
mode: "analysis",
|
|
294
|
+
sandbox: "workspace-write",
|
|
295
|
+
network: false,
|
|
296
|
+
requires_human_approval: false,
|
|
297
|
+
writes_artifacts_to: ["logs/", "reports/"],
|
|
298
|
+
expected_exit_contract: "report",
|
|
299
|
+
},
|
|
300
|
+
file: "scenarios/recipe-scenario.json",
|
|
301
|
+
},
|
|
302
|
+
],
|
|
223
303
|
};
|
|
224
304
|
if (normalizedTags) {
|
|
225
305
|
manifest.tags = normalizedTags;
|
|
@@ -232,6 +312,13 @@ export async function createRecipeArchive(opts) {
|
|
|
232
312
|
role: "Recipe agent",
|
|
233
313
|
description: "Example agent installed from a recipe.",
|
|
234
314
|
}, null, 2), "utf8");
|
|
315
|
+
const skillsDir = path.join(recipeDir, "skills");
|
|
316
|
+
await mkdir(skillsDir, { recursive: true });
|
|
317
|
+
await writeFile(path.join(skillsDir, "analysis.json"), JSON.stringify({
|
|
318
|
+
id: "RECIPE_SKILL",
|
|
319
|
+
summary: "Recipe analysis skill",
|
|
320
|
+
kind: "agent-skill",
|
|
321
|
+
}, null, 2), "utf8");
|
|
235
322
|
const toolsDir = path.join(recipeDir, "tools");
|
|
236
323
|
await mkdir(toolsDir, { recursive: true });
|
|
237
324
|
await writeFile(path.join(toolsDir, "run.js"), [
|
|
@@ -302,22 +389,67 @@ export async function createUnsafeRecipeArchive(opts) {
|
|
|
302
389
|
name: "Unsafe",
|
|
303
390
|
summary: "Unsafe recipe",
|
|
304
391
|
description: "Used for archive validation tests.",
|
|
305
|
-
|
|
392
|
+
skills: [
|
|
393
|
+
{
|
|
394
|
+
id: "RECIPE_SKILL",
|
|
395
|
+
summary: "Recipe skill",
|
|
396
|
+
kind: "agent-skill",
|
|
397
|
+
file: "skills/recipe.json",
|
|
398
|
+
},
|
|
399
|
+
],
|
|
400
|
+
agents: [
|
|
401
|
+
{
|
|
402
|
+
id: "RECIPE_AGENT",
|
|
403
|
+
display_name: "Recipe Agent",
|
|
404
|
+
role: "executor",
|
|
405
|
+
summary: "Recipe agent",
|
|
406
|
+
skills: ["RECIPE_SKILL"],
|
|
407
|
+
tools: ["RECIPE_TOOL"],
|
|
408
|
+
file: "agents/recipe.json",
|
|
409
|
+
},
|
|
410
|
+
],
|
|
306
411
|
tools: [
|
|
307
412
|
{ id: "RECIPE_TOOL", summary: "Recipe tool", runtime: "bash", entrypoint: "tools/run.sh" },
|
|
308
413
|
],
|
|
309
|
-
scenarios: [
|
|
414
|
+
scenarios: [
|
|
415
|
+
{
|
|
416
|
+
id: "RECIPE_SCENARIO",
|
|
417
|
+
name: "Recipe Scenario",
|
|
418
|
+
summary: "Recipe scenario",
|
|
419
|
+
use_when: ["Unsafe validation fixture"],
|
|
420
|
+
required_inputs: [],
|
|
421
|
+
outputs: [],
|
|
422
|
+
permissions: [],
|
|
423
|
+
artifacts: [],
|
|
424
|
+
agents_involved: ["RECIPE_AGENT"],
|
|
425
|
+
skills_used: ["RECIPE_SKILL"],
|
|
426
|
+
tools_used: ["RECIPE_TOOL"],
|
|
427
|
+
run_profile: { mode: "analysis" },
|
|
428
|
+
file: "scenarios/recipe-scenario.json",
|
|
429
|
+
},
|
|
430
|
+
],
|
|
310
431
|
};
|
|
311
432
|
await writeFile(path.join(recipeDir, "manifest.json"), JSON.stringify(manifest, null, 2), "utf8");
|
|
312
433
|
const agentsDir = path.join(recipeDir, "agents");
|
|
313
434
|
await mkdir(agentsDir, { recursive: true });
|
|
314
435
|
await writeFile(path.join(agentsDir, "recipe.json"), JSON.stringify({ id: "RECIPE_AGENT", role: "Recipe agent" }, null, 2), "utf8");
|
|
436
|
+
const skillsDir = path.join(recipeDir, "skills");
|
|
437
|
+
await mkdir(skillsDir, { recursive: true });
|
|
438
|
+
await writeFile(path.join(skillsDir, "recipe.json"), JSON.stringify({ id: "RECIPE_SKILL" }), "utf8");
|
|
315
439
|
const toolsDir = path.join(recipeDir, "tools");
|
|
316
440
|
await mkdir(toolsDir, { recursive: true });
|
|
317
441
|
await writeFile(path.join(toolsDir, "run.sh"), "#!/usr/bin/env bash\n", "utf8");
|
|
318
442
|
const scenariosDir = path.join(recipeDir, "scenarios");
|
|
319
443
|
await mkdir(scenariosDir, { recursive: true });
|
|
320
|
-
await writeFile(path.join(scenariosDir, "recipe-scenario.json"), JSON.stringify({
|
|
444
|
+
await writeFile(path.join(scenariosDir, "recipe-scenario.json"), JSON.stringify({
|
|
445
|
+
schema_version: "1",
|
|
446
|
+
id: "RECIPE_SCENARIO",
|
|
447
|
+
summary: "Recipe scenario",
|
|
448
|
+
goal: "Exercise unsafe archive validation.",
|
|
449
|
+
inputs: [],
|
|
450
|
+
outputs: [],
|
|
451
|
+
steps: [{ tool: "RECIPE_TOOL" }],
|
|
452
|
+
}, null, 2), "utf8");
|
|
321
453
|
const entryPath = opts.entryPath ?? "../evil.txt";
|
|
322
454
|
await writeFile(path.join(baseDir, "evil.txt"), "evil", "utf8");
|
|
323
455
|
const archivePath = opts.format === "zip" ? path.join(baseDir, "unsafe.zip") : path.join(baseDir, "unsafe.tar.gz");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit.spec.d.ts","sourceRoot":"","sources":["../../src/commands/commit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,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;CACzB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"commit.spec.d.ts","sourceRoot":"","sources":["../../src/commands/commit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,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;CACzB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,YAAY,CA+JhD,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { findRepoWideAllowPrefixes, repoWideAllowPrefixMessage, } from "../share
|
|
|
3
3
|
export const commitSpec = {
|
|
4
4
|
id: ["commit"],
|
|
5
5
|
group: "Guard",
|
|
6
|
-
summary: "Create a git commit after validating policy and allowlist
|
|
6
|
+
summary: "Create a git commit after validating policy and allowlist; if the index is empty, stage matching allowlist paths first.",
|
|
7
7
|
args: [{ name: "task-id", required: true, valueHint: "<task-id>" }],
|
|
8
8
|
options: [
|
|
9
9
|
{
|
|
@@ -49,7 +49,7 @@ export const commitSpec = {
|
|
|
49
49
|
kind: "boolean",
|
|
50
50
|
name: "allow-tasks",
|
|
51
51
|
default: false,
|
|
52
|
-
description: "Allow
|
|
52
|
+
description: "Allow the tasks export snapshot plus artifacts under the active task subtree.",
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
kind: "boolean",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAsB5D,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,MAAM,EAAE,CA+BxF;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAM1E"}
|
|
@@ -10,10 +10,7 @@ function renderCliVersionFacts(expectation) {
|
|
|
10
10
|
...(expectation.recovery ? [`[WARN] Recovery: ${expectation.recovery}`] : []),
|
|
11
11
|
];
|
|
12
12
|
}
|
|
13
|
-
return [
|
|
14
|
-
`[INFO] Repository expected agentplane CLI: ${expectation.expectedVersion}`,
|
|
15
|
-
...(expectation.summary ? [`[INFO] ${expectation.summary}`] : []),
|
|
16
|
-
];
|
|
13
|
+
return [];
|
|
17
14
|
}
|
|
18
15
|
export function checkRuntimeSourceFacts(cwd, config) {
|
|
19
16
|
const report = resolveRuntimeSourceInfo({ cwd, entryModuleUrl: import.meta.url });
|
|
@@ -25,9 +22,9 @@ export function checkRuntimeSourceFacts(cwd, config) {
|
|
|
25
22
|
}
|
|
26
23
|
const warning = report.mode === "global-in-framework"
|
|
27
24
|
? "[WARN] Framework checkout detected but the active runtime is still a global installed binary. " +
|
|
28
|
-
"
|
|
25
|
+
"Run scripts/reinstall-global-agentplane.sh to refresh the wrapper, or run the repo-local binary directly."
|
|
29
26
|
: report.mode === "global-forced-in-framework"
|
|
30
|
-
? "[WARN] Framework checkout is forcing the global installed binary via AGENTPLANE_USE_GLOBAL_IN_FRAMEWORK=1."
|
|
27
|
+
? "[WARN] Framework checkout is forcing the global installed binary via AGENTPLANE_USE_GLOBAL_IN_FRAMEWORK=1. Unset it unless that override is intentional."
|
|
31
28
|
: null;
|
|
32
29
|
return [
|
|
33
30
|
...(warning ? [warning] : []),
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type CommandContext } from "../shared/task-backend.js";
|
|
2
|
+
export declare function checkWorkspace(repoRoot: string, opts?: {
|
|
3
|
+
ctx?: CommandContext;
|
|
4
|
+
}): Promise<string[]>;
|
|
2
5
|
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/workspace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/workspace.ts"],"names":[],"mappings":"AAQA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AA6NpF,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,cAAc,CAAA;CAAE,GAC9B,OAAO,CAAC,MAAM,EAAE,CAAC,CAyDnB"}
|
|
@@ -3,6 +3,8 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { renderDiagnosticFinding } from "../../shared/diagnostics.js";
|
|
5
5
|
import { resolvePolicyGatewayForRepo } from "../../shared/policy-gateway.js";
|
|
6
|
+
import { GitContext } from "../shared/git-context.js";
|
|
7
|
+
import { listTaskProjection } from "../shared/task-backend.js";
|
|
6
8
|
async function pathExists(absPath) {
|
|
7
9
|
try {
|
|
8
10
|
await fs.access(absPath);
|
|
@@ -44,7 +46,14 @@ async function listMissingManagedPolicyFiles(repoRoot) {
|
|
|
44
46
|
}
|
|
45
47
|
return missing.toSorted();
|
|
46
48
|
}
|
|
47
|
-
|
|
49
|
+
function taskDataToSnapshot(task) {
|
|
50
|
+
return {
|
|
51
|
+
id: task.id,
|
|
52
|
+
status: task.status,
|
|
53
|
+
doc_version: task.doc_version,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async function readTaskDocSnapshotsFromTasksJson(repoRoot) {
|
|
48
57
|
const tasksPath = path.join(repoRoot, ".agentplane", "tasks.json");
|
|
49
58
|
let raw = "";
|
|
50
59
|
try {
|
|
@@ -60,7 +69,22 @@ async function checkTaskReadmeMigrationState(repoRoot) {
|
|
|
60
69
|
catch {
|
|
61
70
|
return [];
|
|
62
71
|
}
|
|
63
|
-
|
|
72
|
+
return Array.isArray(parsed.tasks) ? parsed.tasks : [];
|
|
73
|
+
}
|
|
74
|
+
async function readTaskDocSnapshotsFromProjection(ctx) {
|
|
75
|
+
if (!ctx)
|
|
76
|
+
return null;
|
|
77
|
+
try {
|
|
78
|
+
const tasks = await listTaskProjection(ctx);
|
|
79
|
+
if (tasks === null)
|
|
80
|
+
return null;
|
|
81
|
+
return tasks.map((task) => taskDataToSnapshot(task));
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function buildTaskReadmeMigrationFindings(tasks) {
|
|
64
88
|
if (tasks.length === 0)
|
|
65
89
|
return [];
|
|
66
90
|
const legacy = tasks.filter((task) => task.doc_version !== 3);
|
|
@@ -114,7 +138,66 @@ async function checkTaskReadmeMigrationState(repoRoot) {
|
|
|
114
138
|
}),
|
|
115
139
|
];
|
|
116
140
|
}
|
|
117
|
-
|
|
141
|
+
async function checkTaskReadmeMigrationState(repoRoot, ctx) {
|
|
142
|
+
const projectionTasks = await readTaskDocSnapshotsFromProjection(ctx);
|
|
143
|
+
const tasks = projectionTasks && projectionTasks.length > 0
|
|
144
|
+
? projectionTasks
|
|
145
|
+
: await readTaskDocSnapshotsFromTasksJson(repoRoot);
|
|
146
|
+
return buildTaskReadmeMigrationFindings(tasks);
|
|
147
|
+
}
|
|
148
|
+
async function readUntrackedPaths(repoRoot, ctx) {
|
|
149
|
+
try {
|
|
150
|
+
const git = ctx?.git ?? new GitContext({ gitRoot: repoRoot });
|
|
151
|
+
return new Set(await git.statusUntrackedPaths());
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return new Set();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function checkDoneTaskReadmeArchiveDrift(repoRoot, ctx) {
|
|
158
|
+
const projectionTasks = await readTaskDocSnapshotsFromProjection(ctx);
|
|
159
|
+
const tasks = projectionTasks && projectionTasks.length > 0
|
|
160
|
+
? projectionTasks
|
|
161
|
+
: await readTaskDocSnapshotsFromTasksJson(repoRoot);
|
|
162
|
+
if (tasks.length === 0)
|
|
163
|
+
return [];
|
|
164
|
+
const workflowDir = (ctx?.config.paths.workflow_dir ?? ".agentplane/tasks").replaceAll("\\", "/");
|
|
165
|
+
const untracked = await readUntrackedPaths(repoRoot, ctx);
|
|
166
|
+
if (untracked.size === 0)
|
|
167
|
+
return [];
|
|
168
|
+
const affected = tasks
|
|
169
|
+
.filter((task) => {
|
|
170
|
+
const status = typeof task.status === "string" ? task.status.trim().toUpperCase() : "";
|
|
171
|
+
const taskId = typeof task.id === "string" ? task.id.trim() : "";
|
|
172
|
+
if (status !== "DONE" || !taskId)
|
|
173
|
+
return false;
|
|
174
|
+
return untracked.has(`${workflowDir}/${taskId}/README.md`);
|
|
175
|
+
})
|
|
176
|
+
.map((task) => String(task.id))
|
|
177
|
+
.toSorted();
|
|
178
|
+
if (affected.length === 0)
|
|
179
|
+
return [];
|
|
180
|
+
const examples = affected.slice(0, 5).join(", ");
|
|
181
|
+
const stagedCommand = `git add ${affected
|
|
182
|
+
.map((taskId) => `${workflowDir}/${taskId}/README.md`)
|
|
183
|
+
.join(" ")}`;
|
|
184
|
+
return [
|
|
185
|
+
renderDiagnosticFinding({
|
|
186
|
+
severity: "WARN",
|
|
187
|
+
state: "DONE task archive README files exist on disk but are missing from the git index",
|
|
188
|
+
likelyCause: "task metadata reached DONE state, but the human-readable task README archive never landed in a tracked close commit",
|
|
189
|
+
nextAction: {
|
|
190
|
+
command: stagedCommand,
|
|
191
|
+
reason: "stage the missing archived task README files and commit them before continuing",
|
|
192
|
+
},
|
|
193
|
+
details: [
|
|
194
|
+
`Affected DONE tasks: ${affected.length}`,
|
|
195
|
+
examples ? `Examples: ${examples}` : "Examples unavailable.",
|
|
196
|
+
],
|
|
197
|
+
}),
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
export async function checkWorkspace(repoRoot, opts) {
|
|
118
201
|
const problems = [];
|
|
119
202
|
const requiredFiles = [path.join(repoRoot, ".agentplane", "config.json")];
|
|
120
203
|
for (const filePath of requiredFiles) {
|
|
@@ -160,6 +243,6 @@ export async function checkWorkspace(repoRoot) {
|
|
|
160
243
|
if (!hasJson) {
|
|
161
244
|
problems.push("No agent profiles found in .agentplane/agents (*.json expected).");
|
|
162
245
|
}
|
|
163
|
-
problems.push(...(await checkTaskReadmeMigrationState(repoRoot)));
|
|
246
|
+
problems.push(...(await checkTaskReadmeMigrationState(repoRoot, opts?.ctx)), ...(await checkDoneTaskReadmeArchiveDrift(repoRoot, opts?.ctx)));
|
|
164
247
|
return problems;
|
|
165
248
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.run.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.run.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"doctor.run.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.run.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAarD,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,YAAY,CA6DlD,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { loadConfig, resolveProject } from "@agentplaneorg/core";
|
|
2
2
|
import { warnMessage, successMessage } from "../cli/output.js";
|
|
3
|
+
import { loadCommandContext } from "./shared/task-backend.js";
|
|
3
4
|
import { checkDoneTaskCommitInvariants } from "./doctor/archive.js";
|
|
4
5
|
import { safeFixGitignore, safeFixTaskIndex } from "./doctor/fixes.js";
|
|
5
6
|
import { checkLayering } from "./doctor/layering.js";
|
|
@@ -11,9 +12,15 @@ export const runDoctor = async (ctx, p) => {
|
|
|
11
12
|
const resolved = await resolveProject({ cwd: ctx.cwd, rootOverride: ctx.rootOverride ?? null });
|
|
12
13
|
const repoRoot = resolved.gitRoot;
|
|
13
14
|
const loadedConfig = await loadConfig(resolved.agentplaneDir);
|
|
15
|
+
const commandCtx = await loadCommandContext({
|
|
16
|
+
cwd: ctx.cwd,
|
|
17
|
+
rootOverride: ctx.rootOverride ?? null,
|
|
18
|
+
resolvedProject: resolved,
|
|
19
|
+
config: loadedConfig.config,
|
|
20
|
+
});
|
|
14
21
|
const runChecks = async () => {
|
|
15
22
|
let checks = [
|
|
16
|
-
...(await checkWorkspace(repoRoot)),
|
|
23
|
+
...(await checkWorkspace(repoRoot, { ctx: commandCtx })),
|
|
17
24
|
...checkRuntimeSourceFacts(ctx.cwd, loadedConfig.config),
|
|
18
25
|
...(await checkDoneTaskCommitInvariants(repoRoot, { fullArchive: p.archiveFull })),
|
|
19
26
|
];
|
|
@@ -34,7 +34,7 @@ export const guardCommitSpec = {
|
|
|
34
34
|
kind: "boolean",
|
|
35
35
|
name: "allow-tasks",
|
|
36
36
|
default: false,
|
|
37
|
-
description: "Allow
|
|
37
|
+
description: "Allow the tasks export snapshot plus artifacts under the active task subtree.",
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
kind: "boolean",
|
|
@@ -14,5 +14,10 @@ export declare function stageAllowlist(opts: {
|
|
|
14
14
|
allow: string[];
|
|
15
15
|
allowTasks: boolean;
|
|
16
16
|
tasksPath: string;
|
|
17
|
+
workflowDir?: string;
|
|
18
|
+
taskId?: string;
|
|
19
|
+
allowTaskOnly?: boolean;
|
|
20
|
+
emptyAllowMessage?: string;
|
|
21
|
+
noMatchMessage?: string;
|
|
17
22
|
}): Promise<string[]>;
|
|
18
23
|
//# sourceMappingURL=allow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allow.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/allow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"allow.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/allow.ts"],"names":[],"mappings":"AAOA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAkBvF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAe9D;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOpB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBhB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAuDpB"}
|
|
@@ -2,6 +2,7 @@ import { resolveProject } from "@agentplaneorg/core";
|
|
|
2
2
|
import { exitCodeForError } from "../../../cli/exit-codes.js";
|
|
3
3
|
import { gitPathIsUnderPrefix, normalizeGitPathPrefix } from "../../../shared/git-path.js";
|
|
4
4
|
import { CliError } from "../../../shared/errors.js";
|
|
5
|
+
import { taskArtifactPrefixes } from "../../../shared/protected-paths.js";
|
|
5
6
|
import { GitContext } from "../../shared/git-context.js";
|
|
6
7
|
import { loadCommandContext } from "../../shared/task-backend.js";
|
|
7
8
|
function normalizeAllowPrefixes(prefixes) {
|
|
@@ -75,28 +76,32 @@ export async function stageAllowlist(opts) {
|
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
const allow = normalizeAllowPrefixes(opts.allow);
|
|
78
|
-
if (allow.
|
|
79
|
+
if (allow.includes(".")) {
|
|
79
80
|
throw new CliError({
|
|
80
81
|
exitCode: 2,
|
|
81
82
|
code: "E_USAGE",
|
|
82
|
-
message: "
|
|
83
|
+
message: "Repo-wide allowlist ('.') is not allowed; choose minimal prefixes (tip: `agentplane guard suggest-allow --format args`).",
|
|
83
84
|
});
|
|
84
85
|
}
|
|
85
|
-
|
|
86
|
+
const taskAllow = taskArtifactPrefixes({
|
|
87
|
+
tasksPath: opts.tasksPath,
|
|
88
|
+
workflowDir: opts.workflowDir,
|
|
89
|
+
taskId: opts.taskId,
|
|
90
|
+
});
|
|
91
|
+
const effectiveAllow = normalizeAllowPrefixes(opts.allowTasks ? [...allow, ...taskAllow] : allow);
|
|
92
|
+
if (effectiveAllow.length === 0 || (allow.length === 0 && opts.allowTaskOnly !== true)) {
|
|
86
93
|
throw new CliError({
|
|
87
94
|
exitCode: 2,
|
|
88
95
|
code: "E_USAGE",
|
|
89
|
-
message:
|
|
96
|
+
message: opts.emptyAllowMessage ?? "Provide at least one allowed prefix",
|
|
90
97
|
});
|
|
91
98
|
}
|
|
92
|
-
const denied =
|
|
93
|
-
if (!opts.allowTasks)
|
|
94
|
-
denied.add(opts.tasksPath);
|
|
99
|
+
const denied = opts.allowTasks ? [] : taskAllow;
|
|
95
100
|
const staged = [];
|
|
96
101
|
for (const filePath of changed) {
|
|
97
|
-
if (denied.
|
|
102
|
+
if (denied.some((prefix) => gitPathIsUnderPrefix(filePath, prefix)))
|
|
98
103
|
continue;
|
|
99
|
-
if (
|
|
104
|
+
if (effectiveAllow.some((prefix) => gitPathIsUnderPrefix(filePath, prefix))) {
|
|
100
105
|
staged.push(filePath);
|
|
101
106
|
}
|
|
102
107
|
}
|
|
@@ -105,7 +110,7 @@ export async function stageAllowlist(opts) {
|
|
|
105
110
|
throw new CliError({
|
|
106
111
|
exitCode: 2,
|
|
107
112
|
code: "E_USAGE",
|
|
108
|
-
message: "No changes matched allowed prefixes (update --commit-allow)",
|
|
113
|
+
message: opts.noMatchMessage ?? "No changes matched allowed prefixes (update --commit-allow)",
|
|
109
114
|
});
|
|
110
115
|
}
|
|
111
116
|
// `git add <pathspec>` is not reliable for staging deletes/renames across versions/configs.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/commands.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/commands.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAQvF,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAyLxE,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBlB;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBlB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAa9E;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,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;CACzB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmMlB"}
|