agentplane 0.2.19 → 0.2.22
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/AGENTS.md +6 -4
- package/bin/agentplane.js +24 -0
- package/dist/backends/task-backend/load.d.ts +2 -0
- package/dist/backends/task-backend/load.d.ts.map +1 -1
- package/dist/backends/task-backend/load.js +38 -18
- package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
- package/dist/backends/task-backend/local-backend.js +27 -7
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +12 -11
- package/dist/cli/run-cli/command-catalog.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog.js +72 -13
- package/dist/cli/run-cli/commands/core.d.ts +11 -1
- package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/core.js +295 -8
- package/dist/cli/run-cli/commands/init/write-agents.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-agents.js +33 -1
- package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-config.js +4 -0
- package/dist/cli/run-cli/commands/init/write-gitignore.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/write-gitignore.js +3 -18
- package/dist/cli/run-cli/commands/init.d.ts +1 -0
- package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init.js +96 -31
- package/dist/cli/run-cli.d.ts.map +1 -1
- package/dist/cli/run-cli.js +86 -17
- package/dist/cli/spec/docs-render.d.ts.map +1 -1
- package/dist/cli/spec/docs-render.js +13 -6
- package/dist/commands/backend/sync.command.d.ts +3 -2
- package/dist/commands/backend/sync.command.d.ts.map +1 -1
- package/dist/commands/backend/sync.command.js +13 -15
- package/dist/commands/commit.command.d.ts.map +1 -1
- package/dist/commands/commit.command.js +2 -0
- package/dist/commands/commit.spec.d.ts +2 -0
- package/dist/commands/commit.spec.d.ts.map +1 -1
- package/dist/commands/commit.spec.js +26 -0
- package/dist/commands/doctor.run.d.ts.map +1 -1
- package/dist/commands/doctor.run.js +15 -6
- package/dist/commands/finish.run.d.ts.map +1 -1
- package/dist/commands/finish.run.js +2 -0
- package/dist/commands/finish.spec.d.ts +2 -0
- package/dist/commands/finish.spec.d.ts.map +1 -1
- package/dist/commands/finish.spec.js +36 -0
- package/dist/commands/guard/impl/allow.d.ts.map +1 -1
- package/dist/commands/guard/impl/allow.js +33 -7
- package/dist/commands/guard/impl/commands.d.ts +2 -0
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +24 -4
- package/dist/commands/guard/impl/comment-commit.d.ts +1 -0
- package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -1
- package/dist/commands/guard/impl/comment-commit.js +16 -24
- package/dist/commands/pr/pr.command.d.ts +1 -1
- package/dist/commands/pr/pr.command.d.ts.map +1 -1
- package/dist/commands/pr/pr.command.js +15 -15
- package/dist/commands/release/apply.command.d.ts.map +1 -1
- package/dist/commands/release/apply.command.js +51 -3
- package/dist/commands/release/plan.command.d.ts.map +1 -1
- package/dist/commands/release/plan.command.js +25 -1
- package/dist/commands/shared/task-backend.d.ts +3 -0
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +4 -1
- package/dist/commands/task/block.d.ts.map +1 -1
- package/dist/commands/task/block.js +16 -16
- package/dist/commands/task/close-duplicate.command.d.ts +14 -0
- package/dist/commands/task/close-duplicate.command.d.ts.map +1 -0
- package/dist/commands/task/close-duplicate.command.js +102 -0
- package/dist/commands/task/close-duplicate.d.ts +14 -0
- package/dist/commands/task/close-duplicate.d.ts.map +1 -0
- package/dist/commands/task/close-duplicate.js +90 -0
- package/dist/commands/task/close-noop.command.d.ts +14 -0
- package/dist/commands/task/close-noop.command.d.ts.map +1 -0
- package/dist/commands/task/close-noop.command.js +77 -0
- package/dist/commands/task/close-noop.d.ts +13 -0
- package/dist/commands/task/close-noop.d.ts.map +1 -0
- package/dist/commands/task/close-noop.js +77 -0
- package/dist/commands/task/finish.d.ts +2 -0
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +63 -14
- package/dist/commands/task/index.d.ts +3 -0
- package/dist/commands/task/index.d.ts.map +1 -1
- package/dist/commands/task/index.js +3 -0
- package/dist/commands/task/new.d.ts.map +1 -1
- package/dist/commands/task/new.js +34 -6
- package/dist/commands/task/new.spec.js +1 -1
- package/dist/commands/task/plan.d.ts.map +1 -1
- package/dist/commands/task/plan.js +16 -5
- package/dist/commands/task/ready.d.ts.map +1 -1
- package/dist/commands/task/ready.js +6 -8
- package/dist/commands/task/set-status.d.ts.map +1 -1
- package/dist/commands/task/set-status.js +19 -21
- package/dist/commands/task/shared.d.ts +35 -1
- package/dist/commands/task/shared.d.ts.map +1 -1
- package/dist/commands/task/shared.js +188 -0
- package/dist/commands/task/start-ready.command.d.ts +14 -0
- package/dist/commands/task/start-ready.command.d.ts.map +1 -0
- package/dist/commands/task/start-ready.command.js +77 -0
- package/dist/commands/task/start-ready.d.ts +13 -0
- package/dist/commands/task/start-ready.d.ts.map +1 -0
- package/dist/commands/task/start-ready.js +37 -0
- package/dist/commands/task/start.d.ts.map +1 -1
- package/dist/commands/task/start.js +20 -23
- package/dist/commands/task/update.command.d.ts +1 -0
- package/dist/commands/task/update.command.d.ts.map +1 -1
- package/dist/commands/task/update.command.js +8 -0
- package/dist/commands/task/update.d.ts +1 -0
- package/dist/commands/task/update.d.ts.map +1 -1
- package/dist/commands/task/update.js +19 -3
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +67 -19
- package/dist/shared/errors.d.ts +9 -1
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +3 -1
- package/dist/shared/runtime-artifacts.d.ts +3 -0
- package/dist/shared/runtime-artifacts.d.ts.map +1 -0
- package/dist/shared/runtime-artifacts.js +18 -0
- package/dist/usecases/context/resolve-context.d.ts +3 -0
- package/dist/usecases/context/resolve-context.d.ts.map +1 -1
- package/dist/usecases/context/resolve-context.js +6 -1
- package/package.json +2 -2
- package/dist/cli/parse/lifecycle.d.ts +0 -64
- package/dist/cli/parse/lifecycle.d.ts.map +0 -1
- package/dist/cli/parse/lifecycle.js +0 -285
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { readdir, readFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { resolveProject } from "@agentplaneorg/core";
|
|
3
|
+
import { loadConfig, resolveProject } from "@agentplaneorg/core";
|
|
4
|
+
import { loadTaskBackend } from "../../../backends/task-backend.js";
|
|
5
|
+
import { GitContext } from "../../../commands/shared/git-context.js";
|
|
6
|
+
import { gitCurrentBranch } from "../../../commands/shared/git-ops.js";
|
|
4
7
|
import { fileExists } from "../../fs-utils.js";
|
|
5
8
|
import { CliError } from "../../../shared/errors.js";
|
|
6
9
|
import { dedupeStrings } from "../../../shared/strings.js";
|
|
@@ -12,26 +15,283 @@ export const quickstartSpec = {
|
|
|
12
15
|
id: ["quickstart"],
|
|
13
16
|
group: "Core",
|
|
14
17
|
summary: "Print CLI quickstart and command cheat sheet.",
|
|
15
|
-
options: [
|
|
18
|
+
options: [
|
|
19
|
+
{
|
|
20
|
+
kind: "boolean",
|
|
21
|
+
name: "json",
|
|
22
|
+
default: false,
|
|
23
|
+
description: "Emit compact machine-readable output for agent runtimes.",
|
|
24
|
+
},
|
|
25
|
+
],
|
|
16
26
|
examples: [{ cmd: "agentplane quickstart", why: "Show quickstart." }],
|
|
17
|
-
parse: () => ({}),
|
|
27
|
+
parse: (raw) => ({ json: raw.opts.json === true }),
|
|
18
28
|
};
|
|
19
29
|
async function cmdQuickstart(opts) {
|
|
20
30
|
return wrapCommand({ command: "quickstart", rootOverride: opts.rootOverride }, () => {
|
|
21
|
-
|
|
31
|
+
const text = renderQuickstart();
|
|
32
|
+
if (opts.json) {
|
|
33
|
+
const lines = text
|
|
34
|
+
.split("\n")
|
|
35
|
+
.map((line) => line.trim())
|
|
36
|
+
.filter((line) => line.length > 0);
|
|
37
|
+
const payload = {
|
|
38
|
+
source_of_truth: {
|
|
39
|
+
workflow_policy: "AGENTS.md",
|
|
40
|
+
cli_syntax: "quickstart/role output",
|
|
41
|
+
},
|
|
42
|
+
lines,
|
|
43
|
+
};
|
|
44
|
+
process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
process.stdout.write(`${text}\n`);
|
|
48
|
+
return 0;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export const runQuickstart = (ctx, p) => {
|
|
52
|
+
return cmdQuickstart({ cwd: ctx.cwd, rootOverride: ctx.rootOverride, json: p.json });
|
|
53
|
+
};
|
|
54
|
+
function compactError(err) {
|
|
55
|
+
if (err instanceof Error) {
|
|
56
|
+
const first = (err.message ?? "").split("\n", 1)[0] ?? "";
|
|
57
|
+
return first.trim() || err.name;
|
|
58
|
+
}
|
|
59
|
+
return String(err);
|
|
60
|
+
}
|
|
61
|
+
function probeYesNo(probe) {
|
|
62
|
+
return probe.ok ? "yes" : "no";
|
|
63
|
+
}
|
|
64
|
+
function probeValueOrUnknown(probe) {
|
|
65
|
+
return probe.ok && probe.value !== undefined ? String(probe.value) : "unknown";
|
|
66
|
+
}
|
|
67
|
+
function inferWorkflowMode(config) {
|
|
68
|
+
if (!config)
|
|
69
|
+
return "unknown";
|
|
70
|
+
return config.workflow_mode === "direct" || config.workflow_mode === "branch_pr"
|
|
71
|
+
? config.workflow_mode
|
|
72
|
+
: "unknown";
|
|
73
|
+
}
|
|
74
|
+
function inferApprovals(config) {
|
|
75
|
+
if (!config) {
|
|
76
|
+
return {
|
|
77
|
+
require_plan: "unknown",
|
|
78
|
+
require_verify: "unknown",
|
|
79
|
+
require_network: "unknown",
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const approvals = config.agents?.approvals;
|
|
83
|
+
if (!approvals) {
|
|
84
|
+
return {
|
|
85
|
+
require_plan: "unknown",
|
|
86
|
+
require_verify: "unknown",
|
|
87
|
+
require_network: "unknown",
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
require_plan: approvals.require_plan,
|
|
92
|
+
require_verify: approvals.require_verify,
|
|
93
|
+
require_network: approvals.require_network,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async function buildPreflightReport(opts) {
|
|
97
|
+
const nextActions = [];
|
|
98
|
+
const quickstartText = renderQuickstart();
|
|
99
|
+
const quickstartLoaded = {
|
|
100
|
+
ok: quickstartText.trim().length > 0,
|
|
101
|
+
error: quickstartText.trim().length > 0 ? undefined : "quickstart renderer returned empty output",
|
|
102
|
+
};
|
|
103
|
+
let resolved = null;
|
|
104
|
+
try {
|
|
105
|
+
resolved = await resolveProject({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null });
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
nextActions.push({
|
|
109
|
+
command: "agentplane init",
|
|
110
|
+
reason: `project not resolved (${compactError(err)})`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
let config = null;
|
|
114
|
+
let configLoaded = { ok: false, error: "project not resolved" };
|
|
115
|
+
if (resolved) {
|
|
116
|
+
try {
|
|
117
|
+
const loaded = await loadConfig(resolved.agentplaneDir);
|
|
118
|
+
config = loaded.config;
|
|
119
|
+
configLoaded = { ok: true };
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
const message = compactError(err);
|
|
123
|
+
configLoaded = { ok: false, error: message };
|
|
124
|
+
nextActions.push({
|
|
125
|
+
command: "agentplane config show",
|
|
126
|
+
reason: `config failed validation (${message})`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
let taskListLoaded = {
|
|
131
|
+
ok: false,
|
|
132
|
+
error: opts.mode === "quick" ? "skipped in quick mode" : "project not resolved",
|
|
133
|
+
};
|
|
134
|
+
if (opts.mode === "full" && resolved) {
|
|
135
|
+
try {
|
|
136
|
+
const loaded = await loadTaskBackend({
|
|
137
|
+
cwd: opts.cwd,
|
|
138
|
+
rootOverride: opts.rootOverride ?? null,
|
|
139
|
+
});
|
|
140
|
+
const tasks = await loaded.backend.listTasks();
|
|
141
|
+
taskListLoaded = { ok: true, count: tasks.length };
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
const message = compactError(err);
|
|
145
|
+
taskListLoaded = { ok: false, error: message };
|
|
146
|
+
nextActions.push({
|
|
147
|
+
command: "agentplane task list",
|
|
148
|
+
reason: `task backend unavailable (${message})`,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
let workingTree = {
|
|
153
|
+
ok: false,
|
|
154
|
+
error: "project not resolved",
|
|
155
|
+
};
|
|
156
|
+
let branch = {
|
|
157
|
+
ok: false,
|
|
158
|
+
error: "project not resolved",
|
|
159
|
+
};
|
|
160
|
+
if (resolved) {
|
|
161
|
+
try {
|
|
162
|
+
const git = new GitContext({ gitRoot: resolved.gitRoot });
|
|
163
|
+
const [staged, unstagedTracked] = await Promise.all([
|
|
164
|
+
git.statusStagedPaths(),
|
|
165
|
+
git.statusUnstagedTrackedPaths(),
|
|
166
|
+
]);
|
|
167
|
+
workingTree = { ok: true, value: staged.length === 0 && unstagedTracked.length === 0 };
|
|
168
|
+
if (!workingTree.value) {
|
|
169
|
+
nextActions.push({
|
|
170
|
+
command: "git status --short --untracked-files=no",
|
|
171
|
+
reason: "tracked changes detected",
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
const message = compactError(err);
|
|
177
|
+
workingTree = { ok: false, error: message };
|
|
178
|
+
nextActions.push({
|
|
179
|
+
command: "git status --short --untracked-files=no",
|
|
180
|
+
reason: `cannot inspect git status (${message})`,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
const current = await gitCurrentBranch(resolved.gitRoot);
|
|
185
|
+
branch = { ok: true, value: current };
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
branch = { ok: false, error: compactError(err) };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
mode: opts.mode,
|
|
193
|
+
project_detected: resolved !== null,
|
|
194
|
+
config_loaded: configLoaded,
|
|
195
|
+
quickstart_loaded: quickstartLoaded,
|
|
196
|
+
task_list_loaded: taskListLoaded,
|
|
197
|
+
working_tree_clean_tracked: workingTree,
|
|
198
|
+
current_branch: branch,
|
|
199
|
+
workflow_mode: inferWorkflowMode(config),
|
|
200
|
+
approvals: inferApprovals(config),
|
|
201
|
+
outside_repo_needed: false,
|
|
202
|
+
next_actions: nextActions,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
export const preflightSpec = {
|
|
206
|
+
id: ["preflight"],
|
|
207
|
+
group: "Core",
|
|
208
|
+
summary: "Run aggregated preflight checks and print a deterministic readiness report.",
|
|
209
|
+
options: [
|
|
210
|
+
{
|
|
211
|
+
kind: "string",
|
|
212
|
+
name: "mode",
|
|
213
|
+
valueHint: "<quick|full>",
|
|
214
|
+
choices: ["quick", "full"],
|
|
215
|
+
default: "quick",
|
|
216
|
+
description: "Preflight depth. quick skips backend task-list probe; full includes backend readiness.",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
kind: "boolean",
|
|
220
|
+
name: "full",
|
|
221
|
+
default: false,
|
|
222
|
+
description: "Shortcut for --mode full.",
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
kind: "boolean",
|
|
226
|
+
name: "json",
|
|
227
|
+
default: false,
|
|
228
|
+
description: "Emit machine-readable JSON report.",
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
examples: [
|
|
232
|
+
{ cmd: "agentplane preflight --json", why: "Produce one-shot agent-readable preflight." },
|
|
233
|
+
{
|
|
234
|
+
cmd: "agentplane preflight --json --mode full",
|
|
235
|
+
why: "Run full preflight including backend task-list probe.",
|
|
236
|
+
},
|
|
237
|
+
],
|
|
238
|
+
parse: (raw) => ({
|
|
239
|
+
json: raw.opts.json === true,
|
|
240
|
+
mode: raw.opts.full === true ? "full" : (raw.opts.mode ?? "quick"),
|
|
241
|
+
}),
|
|
242
|
+
};
|
|
243
|
+
async function cmdPreflight(opts) {
|
|
244
|
+
return wrapCommand({ command: "preflight", rootOverride: opts.rootOverride }, async () => {
|
|
245
|
+
const report = await buildPreflightReport({
|
|
246
|
+
cwd: opts.cwd,
|
|
247
|
+
rootOverride: opts.rootOverride,
|
|
248
|
+
mode: opts.mode,
|
|
249
|
+
});
|
|
250
|
+
if (opts.json) {
|
|
251
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
252
|
+
return 0;
|
|
253
|
+
}
|
|
254
|
+
process.stdout.write("Preflight Summary\n");
|
|
255
|
+
process.stdout.write(`- mode: ${report.mode}\n`);
|
|
256
|
+
process.stdout.write(`- project detected: ${report.project_detected ? "yes" : "no"}\n`);
|
|
257
|
+
process.stdout.write(`- config loaded: ${probeYesNo(report.config_loaded)}\n`);
|
|
258
|
+
process.stdout.write(`- quickstart loaded: ${probeYesNo(report.quickstart_loaded)}\n`);
|
|
259
|
+
process.stdout.write(`- task list loaded: ${probeYesNo(report.task_list_loaded)}\n`);
|
|
260
|
+
process.stdout.write(`- working tree clean (tracked-only): ${probeValueOrUnknown(report.working_tree_clean_tracked)}\n`);
|
|
261
|
+
process.stdout.write(`- current git branch: ${probeValueOrUnknown(report.current_branch)}\n`);
|
|
262
|
+
process.stdout.write(`- workflow_mode: ${report.workflow_mode}\n`);
|
|
263
|
+
process.stdout.write("- approval gates:\n");
|
|
264
|
+
process.stdout.write(` - require_plan: ${String(report.approvals.require_plan)}\n`);
|
|
265
|
+
process.stdout.write(` - require_verify: ${String(report.approvals.require_verify)}\n`);
|
|
266
|
+
process.stdout.write(` - require_network: ${String(report.approvals.require_network)}\n`);
|
|
267
|
+
process.stdout.write("- outside-repo: not needed\n");
|
|
268
|
+
if (report.next_actions.length > 0) {
|
|
269
|
+
process.stdout.write("Next actions:\n");
|
|
270
|
+
for (const action of report.next_actions) {
|
|
271
|
+
process.stdout.write(`- ${action.command}: ${action.reason}\n`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
22
274
|
return 0;
|
|
23
275
|
});
|
|
24
276
|
}
|
|
25
|
-
export const
|
|
26
|
-
return
|
|
277
|
+
export const runPreflight = (ctx, p) => {
|
|
278
|
+
return cmdPreflight({ cwd: ctx.cwd, rootOverride: ctx.rootOverride, json: p.json, mode: p.mode });
|
|
27
279
|
};
|
|
28
280
|
export const roleSpec = {
|
|
29
281
|
id: ["role"],
|
|
30
282
|
group: "Core",
|
|
31
283
|
summary: "Show role-specific workflow guidance.",
|
|
32
284
|
args: [{ name: "role", required: true, valueHint: "<role>" }],
|
|
285
|
+
options: [
|
|
286
|
+
{
|
|
287
|
+
kind: "boolean",
|
|
288
|
+
name: "json",
|
|
289
|
+
default: false,
|
|
290
|
+
description: "Emit compact machine-readable role payload.",
|
|
291
|
+
},
|
|
292
|
+
],
|
|
33
293
|
examples: [{ cmd: "agentplane role ORCHESTRATOR", why: "Show ORCHESTRATOR guide." }],
|
|
34
|
-
parse: (raw) => ({ role: String(raw.args.role ?? "") }),
|
|
294
|
+
parse: (raw) => ({ role: String(raw.args.role ?? ""), json: raw.opts.json === true }),
|
|
35
295
|
};
|
|
36
296
|
function parseAgentProfileJson(filePath, text) {
|
|
37
297
|
let parsed;
|
|
@@ -159,6 +419,23 @@ async function cmdRole(opts) {
|
|
|
159
419
|
});
|
|
160
420
|
}
|
|
161
421
|
if (guide) {
|
|
422
|
+
if (opts.json) {
|
|
423
|
+
const payload = {
|
|
424
|
+
role: normalizedRole,
|
|
425
|
+
builtin_guide: guide
|
|
426
|
+
.split("\n")
|
|
427
|
+
.map((line) => line.trim())
|
|
428
|
+
.filter((line) => line.length > 0),
|
|
429
|
+
};
|
|
430
|
+
if (agentProfile) {
|
|
431
|
+
payload.agent_profile = {
|
|
432
|
+
filename: agentProfile.filename,
|
|
433
|
+
profile: agentProfile.profile,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
437
|
+
return 0;
|
|
438
|
+
}
|
|
162
439
|
process.stdout.write(`${guide}\n`);
|
|
163
440
|
if (agentProfile) {
|
|
164
441
|
const block = renderAgentProfileBlock({
|
|
@@ -183,12 +460,22 @@ async function cmdRole(opts) {
|
|
|
183
460
|
roleId: normalizedRole,
|
|
184
461
|
profile: agentProfile.profile,
|
|
185
462
|
});
|
|
463
|
+
if (opts.json) {
|
|
464
|
+
process.stdout.write(`${JSON.stringify({
|
|
465
|
+
role: normalizedRole,
|
|
466
|
+
agent_profile: {
|
|
467
|
+
filename: agentProfile.filename,
|
|
468
|
+
profile: agentProfile.profile,
|
|
469
|
+
},
|
|
470
|
+
}, null, 2)}\n`);
|
|
471
|
+
return 0;
|
|
472
|
+
}
|
|
186
473
|
process.stdout.write(`${block}\n`);
|
|
187
474
|
return 0;
|
|
188
475
|
});
|
|
189
476
|
}
|
|
190
477
|
export const runRole = (ctx, p) => {
|
|
191
|
-
return cmdRole({ cwd: ctx.cwd, rootOverride: ctx.rootOverride, role: p.role });
|
|
478
|
+
return cmdRole({ cwd: ctx.cwd, rootOverride: ctx.rootOverride, role: p.role, json: p.json });
|
|
192
479
|
};
|
|
193
480
|
export const agentsSpec = {
|
|
194
481
|
id: ["agents"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-agents.d.ts","sourceRoot":"","sources":["../../../../../src/cli/run-cli/commands/init/write-agents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"write-agents.d.ts","sourceRoot":"","sources":["../../../../../src/cli/run-cli/commands/init/write-agents.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAkC1E,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAuCtC"}
|
|
@@ -1,13 +1,37 @@
|
|
|
1
|
+
import { mkdir, readFile } from "node:fs/promises";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import { atomicWriteFile } from "@agentplaneorg/core";
|
|
3
4
|
import { filterAgentsByWorkflow, loadAgentTemplates, loadAgentsTemplate, } from "../../../../agents/agents-template.js";
|
|
4
5
|
import { fileExists } from "../../../fs-utils.js";
|
|
6
|
+
function toUpgradeBaselineKey(repoRelativePath) {
|
|
7
|
+
if (repoRelativePath === "AGENTS.md")
|
|
8
|
+
return "AGENTS.md";
|
|
9
|
+
if (repoRelativePath.startsWith(".agentplane/")) {
|
|
10
|
+
return repoRelativePath.slice(".agentplane/".length);
|
|
11
|
+
}
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
async function seedUpgradeBaselineForInstalledFiles(opts) {
|
|
15
|
+
const baselineDir = path.join(opts.agentplaneDir, ".upgrade", "baseline");
|
|
16
|
+
for (const relPath of opts.repoRelativePaths) {
|
|
17
|
+
const normalizedRel = relPath.replaceAll("\\", "/");
|
|
18
|
+
const baselineKey = toUpgradeBaselineKey(normalizedRel);
|
|
19
|
+
if (!baselineKey)
|
|
20
|
+
continue;
|
|
21
|
+
const srcPath = path.join(opts.gitRoot, normalizedRel);
|
|
22
|
+
const contents = await readFile(srcPath);
|
|
23
|
+
const baselinePath = path.join(baselineDir, baselineKey);
|
|
24
|
+
await mkdir(path.dirname(baselinePath), { recursive: true });
|
|
25
|
+
await atomicWriteFile(baselinePath, contents);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
5
28
|
export async function ensureAgentsFiles(opts) {
|
|
6
29
|
const agentsPath = path.join(opts.gitRoot, "AGENTS.md");
|
|
7
30
|
const installPaths = [
|
|
8
31
|
path.relative(opts.gitRoot, opts.configPathAbs),
|
|
9
32
|
path.relative(opts.gitRoot, opts.backendPathAbs),
|
|
10
33
|
];
|
|
34
|
+
const installedManagedPaths = [];
|
|
11
35
|
let wroteAgents = false;
|
|
12
36
|
if (await fileExists(agentsPath)) {
|
|
13
37
|
// nothing
|
|
@@ -20,6 +44,7 @@ export async function ensureAgentsFiles(opts) {
|
|
|
20
44
|
}
|
|
21
45
|
if (wroteAgents) {
|
|
22
46
|
installPaths.push(path.relative(opts.gitRoot, agentsPath));
|
|
47
|
+
installedManagedPaths.push("AGENTS.md");
|
|
23
48
|
}
|
|
24
49
|
const agentTemplates = await loadAgentTemplates();
|
|
25
50
|
for (const agent of agentTemplates) {
|
|
@@ -27,7 +52,14 @@ export async function ensureAgentsFiles(opts) {
|
|
|
27
52
|
if (await fileExists(targetPath))
|
|
28
53
|
continue;
|
|
29
54
|
await atomicWriteFile(targetPath, agent.contents, "utf8");
|
|
30
|
-
|
|
55
|
+
const relPath = path.relative(opts.gitRoot, targetPath);
|
|
56
|
+
installPaths.push(relPath);
|
|
57
|
+
installedManagedPaths.push(relPath);
|
|
31
58
|
}
|
|
59
|
+
await seedUpgradeBaselineForInstalledFiles({
|
|
60
|
+
gitRoot: opts.gitRoot,
|
|
61
|
+
agentplaneDir: opts.agentplaneDir,
|
|
62
|
+
repoRelativePaths: installedManagedPaths,
|
|
63
|
+
});
|
|
32
64
|
return { installPaths };
|
|
33
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-config.d.ts","sourceRoot":"","sources":["../../../../../src/cli/run-cli/commands/init/write-config.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,cAAc,G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AAC;IAC7B,yCAAyC,EAAE,MAAM,EAAE,CAAC;CACrD,CAAC;AAEF,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,OAAO,GAAG,SAAS,GAC3B,OAAO,CAAC,IAAI,CAAC,CAOf;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAAC;IACjC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,sBAAsB,EAAE,OAAO,CAAC;IAChC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,SAAS,EAAE,mBAAmB,CAAC;CAChC,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBhB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBhB"}
|
|
@@ -13,6 +13,10 @@ export async function ensureAgentplaneDirs(agentplaneDir, backend) {
|
|
|
13
13
|
export async function writeInitConfig(opts) {
|
|
14
14
|
const rawConfig = defaultConfig();
|
|
15
15
|
setByDottedKey(rawConfig, "workflow_mode", opts.workflow);
|
|
16
|
+
setByDottedKey(rawConfig, "status_commit_policy", opts.workflow === "branch_pr" ? "confirm" : "warn");
|
|
17
|
+
setByDottedKey(rawConfig, "commit_automation", "finish_only");
|
|
18
|
+
// Keep status commits explicit by default in all modes to reduce commit noise.
|
|
19
|
+
setByDottedKey(rawConfig, "finish_auto_status_commit", "false");
|
|
16
20
|
setByDottedKey(rawConfig, "tasks_backend.config_path", path.relative(opts.gitRoot, opts.backendConfigPathAbs));
|
|
17
21
|
setByDottedKey(rawConfig, "agents.approvals.require_plan", String(opts.requirePlanApproval));
|
|
18
22
|
setByDottedKey(rawConfig, "agents.approvals.require_network", String(opts.requireNetworkApproval));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-gitignore.d.ts","sourceRoot":"","sources":["../../../../../src/cli/run-cli/commands/init/write-gitignore.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"write-gitignore.d.ts","sourceRoot":"","sources":["../../../../../src/cli/run-cli/commands/init/write-gitignore.ts"],"names":[],"mappings":"AAmBA,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB,EAAE,OAAO,CAAC;CAClC,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { AGENT_PROMPT_GITIGNORE_LINES, RUNTIME_GITIGNORE_LINES, } from "../../../../shared/runtime-artifacts.js";
|
|
3
4
|
import { writeTextIfChanged } from "../../../../shared/write-if-changed.js";
|
|
4
5
|
async function readTextIfExists(filePath) {
|
|
5
6
|
try {
|
|
@@ -12,28 +13,12 @@ async function readTextIfExists(filePath) {
|
|
|
12
13
|
throw err;
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
const RUNTIME_IGNORE_LINES = [
|
|
16
|
-
"# agentplane: ignore runtime/transient workspace artifacts",
|
|
17
|
-
".env",
|
|
18
|
-
".agentplane/worktrees",
|
|
19
|
-
".agentplane/cache",
|
|
20
|
-
".agentplane/recipes-cache",
|
|
21
|
-
".agentplane/.upgrade",
|
|
22
|
-
".agentplane/.release",
|
|
23
|
-
".agentplane/upgrade",
|
|
24
|
-
".agentplane/tasks.json",
|
|
25
|
-
];
|
|
26
|
-
const AGENT_PROMPT_IGNORE_LINES = [
|
|
27
|
-
"# agentplane: ignore local agent prompts/templates",
|
|
28
|
-
"AGENTS.md",
|
|
29
|
-
".agentplane/agents/",
|
|
30
|
-
];
|
|
31
16
|
export async function ensureInitGitignore(opts) {
|
|
32
17
|
const gitignorePath = path.join(opts.gitRoot, ".gitignore");
|
|
33
18
|
const existing = (await readTextIfExists(gitignorePath)) ?? "";
|
|
34
19
|
const ensuredLines = opts.includeAgentPromptFiles
|
|
35
|
-
? [...
|
|
36
|
-
: [...
|
|
20
|
+
? [...RUNTIME_GITIGNORE_LINES, ...AGENT_PROMPT_GITIGNORE_LINES]
|
|
21
|
+
: [...RUNTIME_GITIGNORE_LINES];
|
|
37
22
|
const existingLines = existing.split(/\r?\n/);
|
|
38
23
|
const existingSet = new Set(existingLines.map((line) => line.trimEnd()));
|
|
39
24
|
const missing = ensuredLines.filter((line) => !existingSet.has(line));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CommandHandler, CommandSpec } from "../../spec/spec.js";
|
|
2
2
|
import { type ExecutionProfile } from "@agentplaneorg/core";
|
|
3
3
|
type InitFlags = {
|
|
4
|
+
setupProfile?: "prod" | "dev";
|
|
4
5
|
ide?: "codex" | "cursor" | "windsurf";
|
|
5
6
|
workflow?: "direct" | "branch_pr";
|
|
6
7
|
backend?: "local" | "redmine";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/cli/run-cli/commands/init.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAItE,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAa7B,KAAK,SAAS,GAAG;IACf,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;IACtC,QAAQ,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,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