agentplane 0.2.25 → 0.3.1

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.
Files changed (221) hide show
  1. package/README.md +3 -1
  2. package/assets/AGENTS.md +123 -526
  3. package/assets/agents/UPGRADER.json +10 -9
  4. package/assets/framework.manifest.json +112 -7
  5. package/assets/policy/check-routing.mjs +180 -0
  6. package/assets/policy/dod.code.md +25 -0
  7. package/assets/policy/dod.core.md +32 -0
  8. package/assets/policy/dod.docs.md +32 -0
  9. package/assets/policy/examples/migration-note.md +6 -0
  10. package/assets/policy/examples/pr-note.md +16 -0
  11. package/assets/policy/examples/unit-test-pattern.md +19 -0
  12. package/assets/policy/governance.md +37 -0
  13. package/assets/policy/incidents.md +36 -0
  14. package/assets/policy/security.must.md +7 -0
  15. package/assets/policy/workflow.branch_pr.md +34 -0
  16. package/assets/policy/workflow.direct.md +46 -0
  17. package/assets/policy/workflow.md +9 -0
  18. package/assets/policy/workflow.release.md +31 -0
  19. package/assets/policy/workflow.upgrade.md +20 -0
  20. package/bin/agentplane.js +47 -57
  21. package/bin/dist-guard.js +124 -0
  22. package/dist/.build-manifest.json +11 -0
  23. package/dist/agents/agents-template.d.ts +7 -0
  24. package/dist/agents/agents-template.d.ts.map +1 -1
  25. package/dist/agents/agents-template.js +41 -2
  26. package/dist/backends/task-backend/local-backend.d.ts +2 -0
  27. package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
  28. package/dist/backends/task-backend/local-backend.js +12 -1
  29. package/dist/backends/task-backend/redmine/mapping.d.ts.map +1 -1
  30. package/dist/backends/task-backend/redmine/mapping.js +26 -1
  31. package/dist/backends/task-backend/redmine-backend.d.ts +4 -0
  32. package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
  33. package/dist/backends/task-backend/redmine-backend.js +92 -9
  34. package/dist/backends/task-backend/shared/types.d.ts +1 -0
  35. package/dist/backends/task-backend/shared/types.d.ts.map +1 -1
  36. package/dist/backends/task-index.d.ts.map +1 -1
  37. package/dist/backends/task-index.js +8 -1
  38. package/dist/cli/command-guide.d.ts.map +1 -1
  39. package/dist/cli/command-guide.js +39 -17
  40. package/dist/cli/command-snippets.d.ts +24 -0
  41. package/dist/cli/command-snippets.d.ts.map +1 -0
  42. package/dist/cli/command-snippets.js +23 -0
  43. package/dist/cli/reason-codes.d.ts +9 -0
  44. package/dist/cli/reason-codes.d.ts.map +1 -0
  45. package/dist/cli/reason-codes.js +79 -0
  46. package/dist/cli/recipes-bundled.d.ts +1 -0
  47. package/dist/cli/recipes-bundled.d.ts.map +1 -1
  48. package/dist/cli/recipes-bundled.js +4 -1
  49. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  50. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  51. package/dist/cli/run-cli/command-catalog.js +40 -1
  52. package/dist/cli/run-cli/commands/config.d.ts +5 -0
  53. package/dist/cli/run-cli/commands/config.d.ts.map +1 -1
  54. package/dist/cli/run-cli/commands/config.js +86 -1
  55. package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
  56. package/dist/cli/run-cli/commands/core.js +57 -2
  57. package/dist/cli/run-cli/commands/ide.d.ts.map +1 -1
  58. package/dist/cli/run-cli/commands/ide.js +8 -3
  59. package/dist/cli/run-cli/commands/init/recipes.d.ts +5 -1
  60. package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
  61. package/dist/cli/run-cli/commands/init/recipes.js +24 -4
  62. package/dist/cli/run-cli/commands/init/ui.d.ts.map +1 -1
  63. package/dist/cli/run-cli/commands/init/ui.js +1 -2
  64. package/dist/cli/run-cli/commands/init/write-agents.d.ts +2 -0
  65. package/dist/cli/run-cli/commands/init/write-agents.d.ts.map +1 -1
  66. package/dist/cli/run-cli/commands/init/write-agents.js +24 -5
  67. package/dist/cli/run-cli/commands/init/write-workflow.d.ts +12 -0
  68. package/dist/cli/run-cli/commands/init/write-workflow.d.ts.map +1 -0
  69. package/dist/cli/run-cli/commands/init/write-workflow.js +58 -0
  70. package/dist/cli/run-cli/commands/init.d.ts +4 -1
  71. package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
  72. package/dist/cli/run-cli/commands/init.js +126 -48
  73. package/dist/cli/run-cli.d.ts.map +1 -1
  74. package/dist/cli/run-cli.js +195 -8
  75. package/dist/commands/backend/sync.command.d.ts.map +1 -1
  76. package/dist/commands/backend/sync.command.js +7 -6
  77. package/dist/commands/backend.d.ts.map +1 -1
  78. package/dist/commands/backend.js +2 -0
  79. package/dist/commands/doctor.run.d.ts.map +1 -1
  80. package/dist/commands/doctor.run.js +107 -16
  81. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  82. package/dist/commands/guard/impl/commands.js +12 -6
  83. package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
  84. package/dist/commands/recipes/impl/commands/install.js +36 -13
  85. package/dist/commands/recipes/impl/scenario.d.ts.map +1 -1
  86. package/dist/commands/recipes/impl/scenario.js +25 -0
  87. package/dist/commands/recipes/impl/types.d.ts +4 -0
  88. package/dist/commands/recipes/impl/types.d.ts.map +1 -1
  89. package/dist/commands/release/apply.command.d.ts.map +1 -1
  90. package/dist/commands/release/apply.command.js +9 -4
  91. package/dist/commands/release/plan.command.d.ts.map +1 -1
  92. package/dist/commands/release/plan.command.js +9 -3
  93. package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
  94. package/dist/commands/scenario/impl/commands.js +74 -3
  95. package/dist/commands/scenario/impl/report.d.ts +8 -0
  96. package/dist/commands/scenario/impl/report.d.ts.map +1 -1
  97. package/dist/commands/scenario/impl/report.js +1 -0
  98. package/dist/commands/shared/reconcile-check.d.ts +7 -0
  99. package/dist/commands/shared/reconcile-check.d.ts.map +1 -0
  100. package/dist/commands/shared/reconcile-check.js +60 -0
  101. package/dist/commands/sync.command.d.ts.map +1 -1
  102. package/dist/commands/sync.command.js +9 -2
  103. package/dist/commands/task/add.d.ts.map +1 -1
  104. package/dist/commands/task/add.js +32 -0
  105. package/dist/commands/task/doc.command.d.ts.map +1 -1
  106. package/dist/commands/task/doc.command.js +1 -0
  107. package/dist/commands/task/finish.d.ts.map +1 -1
  108. package/dist/commands/task/finish.js +11 -1
  109. package/dist/commands/task/list.d.ts.map +1 -1
  110. package/dist/commands/task/list.js +2 -1
  111. package/dist/commands/task/list.spec.d.ts.map +1 -1
  112. package/dist/commands/task/list.spec.js +7 -0
  113. package/dist/commands/task/new.d.ts.map +1 -1
  114. package/dist/commands/task/new.js +41 -4
  115. package/dist/commands/task/next.d.ts.map +1 -1
  116. package/dist/commands/task/next.js +2 -1
  117. package/dist/commands/task/next.spec.d.ts.map +1 -1
  118. package/dist/commands/task/next.spec.js +7 -0
  119. package/dist/commands/task/plan.d.ts.map +1 -1
  120. package/dist/commands/task/plan.js +7 -1
  121. package/dist/commands/task/search.d.ts.map +1 -1
  122. package/dist/commands/task/search.js +2 -1
  123. package/dist/commands/task/search.spec.d.ts.map +1 -1
  124. package/dist/commands/task/search.spec.js +7 -0
  125. package/dist/commands/task/shared.d.ts +14 -0
  126. package/dist/commands/task/shared.d.ts.map +1 -1
  127. package/dist/commands/task/shared.js +58 -1
  128. package/dist/commands/task/start-ready.js +1 -1
  129. package/dist/commands/task/verify-record.d.ts.map +1 -1
  130. package/dist/commands/task/verify-record.js +2 -0
  131. package/dist/commands/upgrade.command.d.ts.map +1 -1
  132. package/dist/commands/upgrade.command.js +2 -2
  133. package/dist/commands/upgrade.d.ts.map +1 -1
  134. package/dist/commands/upgrade.js +263 -294
  135. package/dist/commands/workflow-build.command.d.ts +8 -0
  136. package/dist/commands/workflow-build.command.d.ts.map +1 -0
  137. package/dist/commands/workflow-build.command.js +103 -0
  138. package/dist/commands/workflow-playbook.command.d.ts +10 -0
  139. package/dist/commands/workflow-playbook.command.d.ts.map +1 -0
  140. package/dist/commands/workflow-playbook.command.js +173 -0
  141. package/dist/commands/workflow-restore.command.d.ts +5 -0
  142. package/dist/commands/workflow-restore.command.d.ts.map +1 -0
  143. package/dist/commands/workflow-restore.command.js +30 -0
  144. package/dist/commands/workflow.command.d.ts +6 -0
  145. package/dist/commands/workflow.command.d.ts.map +1 -0
  146. package/dist/commands/workflow.command.js +36 -0
  147. package/dist/harness/dynamic-tool-contract.d.ts +29 -0
  148. package/dist/harness/dynamic-tool-contract.d.ts.map +1 -0
  149. package/dist/harness/dynamic-tool-contract.js +86 -0
  150. package/dist/harness/hooks-lifecycle.d.ts +27 -0
  151. package/dist/harness/hooks-lifecycle.d.ts.map +1 -0
  152. package/dist/harness/hooks-lifecycle.js +67 -0
  153. package/dist/harness/index.d.ts +9 -0
  154. package/dist/harness/index.d.ts.map +1 -0
  155. package/dist/harness/index.js +8 -0
  156. package/dist/harness/reconcile.d.ts +37 -0
  157. package/dist/harness/reconcile.d.ts.map +1 -0
  158. package/dist/harness/reconcile.js +42 -0
  159. package/dist/harness/retry-policy.d.ts +31 -0
  160. package/dist/harness/retry-policy.d.ts.map +1 -0
  161. package/dist/harness/retry-policy.js +33 -0
  162. package/dist/harness/scheduler.d.ts +18 -0
  163. package/dist/harness/scheduler.d.ts.map +1 -0
  164. package/dist/harness/scheduler.js +55 -0
  165. package/dist/harness/state-machine.d.ts +17 -0
  166. package/dist/harness/state-machine.d.ts.map +1 -0
  167. package/dist/harness/state-machine.js +70 -0
  168. package/dist/harness/token-accounting.d.ts +19 -0
  169. package/dist/harness/token-accounting.d.ts.map +1 -0
  170. package/dist/harness/token-accounting.js +77 -0
  171. package/dist/harness/workspace-safety.d.ts +14 -0
  172. package/dist/harness/workspace-safety.d.ts.map +1 -0
  173. package/dist/harness/workspace-safety.js +62 -0
  174. package/dist/recipes/bundled-recipes.d.ts +4 -0
  175. package/dist/recipes/bundled-recipes.d.ts.map +1 -1
  176. package/dist/recipes/bundled-recipes.js +11 -0
  177. package/dist/shared/errors.d.ts +6 -0
  178. package/dist/shared/errors.d.ts.map +1 -1
  179. package/dist/shared/errors.js +1 -0
  180. package/dist/shared/policy-gateway.d.ts +15 -0
  181. package/dist/shared/policy-gateway.d.ts.map +1 -0
  182. package/dist/shared/policy-gateway.js +49 -0
  183. package/dist/shared/protected-paths.d.ts.map +1 -1
  184. package/dist/shared/protected-paths.js +1 -0
  185. package/dist/shared/runtime-artifacts.d.ts +2 -2
  186. package/dist/shared/runtime-artifacts.d.ts.map +1 -1
  187. package/dist/shared/runtime-artifacts.js +4 -0
  188. package/dist/workflow-runtime/build.d.ts +4 -0
  189. package/dist/workflow-runtime/build.d.ts.map +1 -0
  190. package/dist/workflow-runtime/build.js +126 -0
  191. package/dist/workflow-runtime/enforcement.d.ts +3 -0
  192. package/dist/workflow-runtime/enforcement.d.ts.map +1 -0
  193. package/dist/workflow-runtime/enforcement.js +10 -0
  194. package/dist/workflow-runtime/file-ops.d.ts +11 -0
  195. package/dist/workflow-runtime/file-ops.d.ts.map +1 -0
  196. package/dist/workflow-runtime/file-ops.js +248 -0
  197. package/dist/workflow-runtime/fix.d.ts +9 -0
  198. package/dist/workflow-runtime/fix.d.ts.map +1 -0
  199. package/dist/workflow-runtime/fix.js +107 -0
  200. package/dist/workflow-runtime/index.d.ts +11 -0
  201. package/dist/workflow-runtime/index.d.ts.map +1 -0
  202. package/dist/workflow-runtime/index.js +10 -0
  203. package/dist/workflow-runtime/markdown.d.ts +10 -0
  204. package/dist/workflow-runtime/markdown.d.ts.map +1 -0
  205. package/dist/workflow-runtime/markdown.js +147 -0
  206. package/dist/workflow-runtime/observability.d.ts +12 -0
  207. package/dist/workflow-runtime/observability.d.ts.map +1 -0
  208. package/dist/workflow-runtime/observability.js +14 -0
  209. package/dist/workflow-runtime/paths.d.ts +3 -0
  210. package/dist/workflow-runtime/paths.d.ts.map +1 -0
  211. package/dist/workflow-runtime/paths.js +11 -0
  212. package/dist/workflow-runtime/template.d.ts +7 -0
  213. package/dist/workflow-runtime/template.d.ts.map +1 -0
  214. package/dist/workflow-runtime/template.js +94 -0
  215. package/dist/workflow-runtime/types.d.ts +68 -0
  216. package/dist/workflow-runtime/types.d.ts.map +1 -0
  217. package/dist/workflow-runtime/types.js +1 -0
  218. package/dist/workflow-runtime/validate.d.ts +8 -0
  219. package/dist/workflow-runtime/validate.d.ts.map +1 -0
  220. package/dist/workflow-runtime/validate.js +331 -0
  221. package/package.json +3 -3
@@ -13,51 +13,47 @@ import { collectInitConflicts, handleInitConflicts } from "./init/conflicts.js";
13
13
  import { ensureGitRoot } from "./init/git.js";
14
14
  import { maybeSyncIde } from "./init/ide-sync.js";
15
15
  import { maybeInstallBundledRecipes } from "./init/recipes.js";
16
+ import { ensureInitWorkflow } from "./init/write-workflow.js";
16
17
  import { ensureAgentplaneDirs, writeBackendStubs, writeInitConfig } from "./init/write-config.js";
17
18
  import { ensureAgentsFiles } from "./init/write-agents.js";
18
19
  import { ensureInitGitignore } from "./init/write-gitignore.js";
19
20
  import { ensureInitRedmineEnvTemplate } from "./init/write-env.js";
20
21
  import { renderInitSection, renderInitWelcome } from "./init/ui.js";
22
+ import { fileExists } from "../../fs-utils.js";
23
+ import { policyGatewayFileName } from "../../../shared/policy-gateway.js";
21
24
  const setupProfilePresets = {
22
- developer: {
23
- mode: "full",
24
- description: "I am Developer (full setup questionnaire; hooks on; explicit unsafe confirmations on).",
25
- defaultHooks: true,
26
- defaultStrictUnsafeConfirm: true,
27
- defaultRequirePlanApproval: true,
28
- defaultRequireNetworkApproval: true,
29
- defaultRequireVerifyApproval: true,
30
- defaultExecutionProfile: "balanced",
31
- },
32
- vibecoder: {
25
+ light: {
33
26
  mode: "compact",
34
- description: "I am Vibecoder (compact setup; hooks off; approvals off; aggressive execution defaults).",
27
+ description: "Light profile (maximum flexibility, minimal enforcement, hooks disabled).",
35
28
  defaultHooks: false,
36
29
  defaultStrictUnsafeConfirm: false,
37
30
  defaultRequirePlanApproval: false,
38
31
  defaultRequireNetworkApproval: false,
39
32
  defaultRequireVerifyApproval: false,
40
33
  defaultExecutionProfile: "aggressive",
34
+ defaultRecipes: [],
41
35
  },
42
- manager: {
36
+ normal: {
43
37
  mode: "compact",
44
- description: "I am Manager / Product owner (compact setup; oversight defaults with approvals on, hooks off).",
45
- defaultHooks: false,
38
+ description: "Normal profile (balanced defaults and approvals enabled for standard team workflows; hooks enabled).",
39
+ defaultHooks: true,
46
40
  defaultStrictUnsafeConfirm: false,
47
41
  defaultRequirePlanApproval: true,
48
42
  defaultRequireNetworkApproval: true,
49
43
  defaultRequireVerifyApproval: true,
50
44
  defaultExecutionProfile: "balanced",
45
+ defaultRecipes: [],
51
46
  },
52
- enterprise: {
47
+ "full-harness": {
53
48
  mode: "full",
54
- description: "I am Enterprise / Regulated team (full setup; strict approvals, hooks on, conservative execution).",
49
+ description: "Full Harness profile (strict guardrails, explicit confirmations, conservative execution; hooks enabled).",
55
50
  defaultHooks: true,
56
51
  defaultStrictUnsafeConfirm: true,
57
52
  defaultRequirePlanApproval: true,
58
53
  defaultRequireNetworkApproval: true,
59
54
  defaultRequireVerifyApproval: true,
60
55
  defaultExecutionProfile: "conservative",
56
+ defaultRecipes: [],
61
57
  },
62
58
  };
63
59
  function parseBooleanValueForInit(flag, value) {
@@ -81,6 +77,22 @@ function parseRecipesSelectionForInit(value) {
81
77
  .map((item) => item.trim())
82
78
  .filter(Boolean);
83
79
  }
80
+ function normalizeSetupProfile(raw) {
81
+ if (!raw)
82
+ return undefined;
83
+ const value = raw.trim().toLowerCase();
84
+ if (value === "developer")
85
+ return "full-harness";
86
+ if (value === "enterprise")
87
+ return "full-harness";
88
+ if (value === "manager")
89
+ return "normal";
90
+ if (value === "vibecoder")
91
+ return "light";
92
+ if (value === "light" || value === "normal" || value === "full-harness")
93
+ return value;
94
+ return undefined;
95
+ }
84
96
  export const initSpec = {
85
97
  id: ["init"],
86
98
  group: "Setup",
@@ -90,9 +102,25 @@ export const initSpec = {
90
102
  {
91
103
  kind: "string",
92
104
  name: "setup-profile",
93
- valueHint: "<developer|vibecoder|manager|enterprise>",
94
- choices: ["developer", "vibecoder", "manager", "enterprise"],
95
- description: "Persona preset for init defaults and dialog depth (compact vs full questionnaire).",
105
+ valueHint: "<light|normal|full-harness>",
106
+ choices: [
107
+ "light",
108
+ "normal",
109
+ "full-harness",
110
+ "developer",
111
+ "vibecoder",
112
+ "manager",
113
+ "enterprise",
114
+ ],
115
+ description: "Setup profile preset. Preferred values: light, normal, full-harness.",
116
+ },
117
+ {
118
+ kind: "string",
119
+ name: "policy-gateway",
120
+ valueHint: "<codex|claude>",
121
+ choices: ["codex", "claude"],
122
+ coerce: (raw) => raw.trim().toLowerCase(),
123
+ description: "Policy gateway file to install (codex -> AGENTS.md, claude -> CLAUDE.md).",
96
124
  },
97
125
  {
98
126
  kind: "string",
@@ -121,7 +149,7 @@ export const initSpec = {
121
149
  kind: "string",
122
150
  name: "hooks",
123
151
  valueHint: "<true|false>",
124
- description: "Install git hooks (non-interactive requires an explicit value).",
152
+ description: "Install managed git hooks (default by setup profile: light=false, normal/full-harness=true).",
125
153
  },
126
154
  {
127
155
  kind: "string",
@@ -182,17 +210,17 @@ export const initSpec = {
182
210
  kind: "boolean",
183
211
  name: "gitignore-agents",
184
212
  default: false,
185
- description: "Add agent files (AGENTS.md and .agentplane/agents/) to .gitignore and skip the initial install commit.",
213
+ description: "Add gateway/agent files (AGENTS.md or CLAUDE.md and .agentplane/agents/) to .gitignore and skip the initial install commit.",
186
214
  },
187
215
  ],
188
216
  examples: [
189
217
  { cmd: "agentplane init", why: "Interactive setup (prompts for missing values)." },
190
218
  {
191
- cmd: "agentplane init --setup-profile vibecoder --yes",
192
- why: "Non-interactive fast setup for autonomous defaults (hooks off, approvals off).",
219
+ cmd: "agentplane init --setup-profile light --yes",
220
+ why: "Non-interactive setup with flexible defaults.",
193
221
  },
194
222
  {
195
- cmd: "agentplane init --workflow direct --backend local --hooks false --require-plan-approval true --require-network-approval true --require-verify-approval true --yes",
223
+ cmd: "agentplane init --workflow direct --backend local --hooks true --require-plan-approval true --require-network-approval true --require-verify-approval true --yes",
196
224
  why: "Non-interactive setup with explicit policy flags.",
197
225
  },
198
226
  {
@@ -220,7 +248,8 @@ export const initSpec = {
220
248
  const requireVerifyRaw = raw.opts["require-verify-approval"];
221
249
  const recipesRaw = raw.opts.recipes;
222
250
  return {
223
- setupProfile: raw.opts["setup-profile"],
251
+ setupProfile: normalizeSetupProfile(raw.opts["setup-profile"]),
252
+ policyGateway: raw.opts["policy-gateway"],
224
253
  ide: raw.opts.ide,
225
254
  workflow: raw.opts.workflow,
226
255
  backend: raw.opts.backend,
@@ -259,10 +288,11 @@ export const runInit = (ctx, flags) => cmdInit({ cwd: ctx.cwd, rootOverride: ctx
259
288
  async function cmdInit(opts) {
260
289
  const flags = opts.flags;
261
290
  const defaults = {
291
+ policyGateway: "codex",
262
292
  ide: "codex",
263
293
  workflow: "direct",
264
294
  backend: "local",
265
- hooks: false,
295
+ hooks: true,
266
296
  recipes: [],
267
297
  requirePlanApproval: true,
268
298
  requireNetworkApproval: true,
@@ -271,6 +301,7 @@ async function cmdInit(opts) {
271
301
  strictUnsafeConfirm: false,
272
302
  };
273
303
  let ide = flags.ide ?? defaults.ide;
304
+ let policyGateway = flags.policyGateway ?? defaults.policyGateway;
274
305
  let workflow = flags.workflow ?? defaults.workflow;
275
306
  let backend = flags.backend ?? defaults.backend;
276
307
  let hooks = flags.hooks ?? defaults.hooks;
@@ -283,19 +314,18 @@ async function cmdInit(opts) {
283
314
  let setupProfile = flags.setupProfile
284
315
  ? setupProfilePresets[flags.setupProfile].mode
285
316
  : "compact";
286
- let setupProfilePreset = flags.setupProfile ?? "manager";
317
+ let setupProfilePreset = flags.setupProfile ?? "normal";
287
318
  const isInteractive = process.stdin.isTTY && !flags.yes;
288
319
  if (!process.stdin.isTTY &&
289
320
  !flags.yes &&
290
321
  (!flags.workflow ||
291
- flags.hooks === undefined ||
292
322
  flags.requirePlanApproval === undefined ||
293
323
  flags.requireNetworkApproval === undefined ||
294
324
  flags.requireVerifyApproval === undefined)) {
295
325
  throw usageError({
296
326
  spec: initSpec,
297
327
  command: "init",
298
- message: "Non-interactive init requires --yes or explicit values for: --workflow, --hooks, --require-plan-approval, --require-network-approval, --require-verify-approval.",
328
+ message: "Non-interactive init requires --yes or explicit values for: --workflow, --require-plan-approval, --require-network-approval, --require-verify-approval.",
299
329
  });
300
330
  }
301
331
  if (isInteractive) {
@@ -316,19 +346,25 @@ async function cmdInit(opts) {
316
346
  };
317
347
  process.stdout.write(renderInitWelcome());
318
348
  const presetLines = Object.entries(setupProfilePresets).map(([id, preset]) => `- ${id}: ${preset.description}`);
319
- process.stdout.write(renderInitSection("Who Are You?", "Pick the persona that best matches your working style. This sets defaults and controls compact vs full questionnaire."));
349
+ process.stdout.write(renderInitSection("Setup Profile", "Pick one of three setup profiles. This controls policy strictness and questionnaire depth."));
320
350
  process.stdout.write(`${presetLines.join("\n")}\n\n`);
321
351
  if (flags.setupProfile) {
322
352
  setupProfilePreset = flags.setupProfile;
323
353
  }
324
354
  else {
325
- const selected = await askChoice("Who are you?", ["developer", "vibecoder", "manager", "enterprise"], "manager");
355
+ const selected = await askChoice("Setup profile", ["light", "normal", "full-harness"], "normal");
326
356
  setupProfilePreset = selected;
327
357
  }
328
358
  const selectedPreset = setupProfilePresets[setupProfilePreset];
329
359
  setupProfile = selectedPreset.mode;
330
- if (flags.hooks === undefined)
331
- hooks = selectedPreset.defaultHooks;
360
+ hooks = flags.hooks ?? selectedPreset.defaultHooks;
361
+ if (flags.policyGateway) {
362
+ policyGateway = flags.policyGateway;
363
+ }
364
+ else {
365
+ process.stdout.write(renderInitSection("Policy Gateway", "Choose which root policy gateway file to install for your primary agent runtime."));
366
+ policyGateway = (await askChoice("Policy gateway", ["codex", "claude"], policyGateway));
367
+ }
332
368
  if (flags.strictUnsafeConfirm === undefined) {
333
369
  strictUnsafeConfirm = selectedPreset.defaultStrictUnsafeConfirm;
334
370
  }
@@ -360,9 +396,9 @@ async function cmdInit(opts) {
360
396
  backend = choice === "redmine" ? "redmine" : "local";
361
397
  }
362
398
  if (setupProfile === "full") {
363
- if (flags.hooks === undefined) {
364
- hooks = await askYesNo("Install managed git hooks now?", hooks);
365
- }
399
+ process.stdout.write(renderInitSection("Hooks", hooks
400
+ ? "Managed git hooks are enabled and will be installed automatically."
401
+ : "Managed git hooks are disabled by profile/flag and will not be installed."));
366
402
  process.stdout.write(renderInitSection("Execution Profile", "Set default autonomy/effort for agents. You can change this later in config."));
367
403
  if (!flags.executionProfile) {
368
404
  executionProfile = (await askChoice("Execution profile", ["conservative", "balanced", "aggressive"], executionProfile));
@@ -383,18 +419,27 @@ async function cmdInit(opts) {
383
419
  process.stdout.write(renderInitSection("Recipes", "Optional: install recipe packs now (comma-separated IDs) or choose none."));
384
420
  if (!flags.recipes) {
385
421
  process.stdout.write(`${renderBundledRecipesHint()}\n`);
386
- const answer = await askInput("Install optional recipes (comma separated, or none): ");
387
- recipes = answer
388
- ? answer
422
+ const defaultRecipesLabel = selectedPreset.defaultRecipes.length > 0
423
+ ? selectedPreset.defaultRecipes.join(", ")
424
+ : "none";
425
+ const answer = await askInput(`Install optional recipes (comma separated, or none) [default: ${defaultRecipesLabel}]: `);
426
+ const normalized = answer.trim().toLowerCase();
427
+ if (normalized === "") {
428
+ recipes = [...selectedPreset.defaultRecipes];
429
+ }
430
+ else if (normalized === "none") {
431
+ recipes = [];
432
+ }
433
+ else {
434
+ recipes = answer
389
435
  .split(",")
390
436
  .map((item) => item.trim())
391
- .filter(Boolean)
392
- : [];
437
+ .filter(Boolean);
438
+ }
393
439
  }
394
440
  }
395
441
  else {
396
- hooks = flags.hooks ?? selectedPreset.defaultHooks;
397
- recipes = flags.recipes ?? defaults.recipes;
442
+ recipes = flags.recipes ?? selectedPreset.defaultRecipes;
398
443
  requirePlanApproval = flags.requirePlanApproval ?? selectedPreset.defaultRequirePlanApproval;
399
444
  requireNetworkApproval =
400
445
  flags.requireNetworkApproval ?? selectedPreset.defaultRequireNetworkApproval;
@@ -402,16 +447,17 @@ async function cmdInit(opts) {
402
447
  flags.requireVerifyApproval ?? selectedPreset.defaultRequireVerifyApproval;
403
448
  executionProfile = flags.executionProfile ?? selectedPreset.defaultExecutionProfile;
404
449
  strictUnsafeConfirm = flags.strictUnsafeConfirm ?? selectedPreset.defaultStrictUnsafeConfirm;
405
- process.stdout.write(renderInitSection("Defaults Applied", `Using compact ${setupProfilePreset} defaults for hooks, approvals, execution profile, and recipes.`));
450
+ process.stdout.write(renderInitSection("Defaults Applied", `Using compact ${setupProfilePreset} defaults for approvals, execution profile, and recipes. Hooks: ${hooks ? "enabled" : "disabled"}.`));
406
451
  }
407
452
  }
408
453
  if (flags.yes) {
409
454
  const yesPreset = setupProfilePresets[setupProfilePreset];
410
455
  ide = flags.ide ?? defaults.ide;
456
+ policyGateway = flags.policyGateway ?? defaults.policyGateway;
411
457
  workflow = flags.workflow ?? defaults.workflow;
412
458
  backend = flags.backend ?? defaults.backend;
413
459
  hooks = flags.hooks ?? yesPreset.defaultHooks;
414
- recipes = flags.recipes ?? defaults.recipes;
460
+ recipes = flags.recipes ?? yesPreset.defaultRecipes;
415
461
  requirePlanApproval = flags.requirePlanApproval ?? yesPreset.defaultRequirePlanApproval;
416
462
  requireNetworkApproval =
417
463
  flags.requireNetworkApproval ?? yesPreset.defaultRequireNetworkApproval;
@@ -446,6 +492,21 @@ async function cmdInit(opts) {
446
492
  ];
447
493
  const initFiles = [configPath, backendPath];
448
494
  const conflicts = await collectInitConflicts({ initDirs, initFiles });
495
+ const gatewayPath = path.join(resolved.gitRoot, policyGatewayFileName(policyGateway));
496
+ const agentsMissing = !(await fileExists(gatewayPath));
497
+ if (conflicts.length > 0 && agentsMissing) {
498
+ // Recovery path: if a repo already contains conflicting .agentplane config/backend files,
499
+ // still materialize missing policy/agent templates before reporting conflicts.
500
+ await ensureAgentplaneDirs(resolved.agentplaneDir, backend);
501
+ await ensureAgentsFiles({
502
+ gitRoot: resolved.gitRoot,
503
+ agentplaneDir: resolved.agentplaneDir,
504
+ workflow,
505
+ policyGateway,
506
+ configPathAbs: configPath,
507
+ backendPathAbs: backendPath,
508
+ });
509
+ }
449
510
  await handleInitConflicts({
450
511
  gitRoot: resolved.gitRoot,
451
512
  conflicts,
@@ -472,6 +533,7 @@ async function cmdInit(opts) {
472
533
  gitRoot: resolved.gitRoot,
473
534
  agentplaneDir: resolved.agentplaneDir,
474
535
  workflow,
536
+ policyGateway,
475
537
  configPathAbs: configPath,
476
538
  backendPathAbs: backendPath,
477
539
  });
@@ -483,6 +545,18 @@ async function cmdInit(opts) {
483
545
  includeAgentPromptFiles: flags.gitignoreAgents === true,
484
546
  });
485
547
  installPaths.push(".gitignore");
548
+ const workflowInit = await ensureInitWorkflow({
549
+ gitRoot: resolved.gitRoot,
550
+ workflowMode: workflow,
551
+ approvals: {
552
+ requirePlanApproval,
553
+ requireVerifyApproval,
554
+ requireNetworkApproval,
555
+ },
556
+ });
557
+ for (const abs of workflowInit.installPaths) {
558
+ installPaths.push(path.relative(resolved.gitRoot, abs));
559
+ }
486
560
  if (flags.gitignoreAgents) {
487
561
  await setPinnedBaseBranch({
488
562
  cwd: resolved.gitRoot,
@@ -501,14 +575,18 @@ async function cmdInit(opts) {
501
575
  gitRoot: resolved.gitRoot,
502
576
  });
503
577
  installPaths.push(...ideRes.installPaths);
504
- maybeInstallBundledRecipes(recipes);
578
+ await maybeInstallBundledRecipes({
579
+ recipes,
580
+ cwd: opts.cwd,
581
+ rootOverride: opts.rootOverride,
582
+ });
505
583
  if (!flags.gitignoreAgents) {
506
584
  await ensureInitCommit({
507
585
  gitRoot: resolved.gitRoot,
508
586
  baseBranch: initBaseBranch,
509
587
  installPaths,
510
588
  version: getVersion(),
511
- skipHooks: hooks,
589
+ skipHooks: true,
512
590
  });
513
591
  }
514
592
  process.stdout.write(`${path.relative(resolved.gitRoot, resolved.agentplaneDir)}\n`);
@@ -1 +1 @@
1
- {"version":3,"file":"run-cli.d.ts","sourceRoot":"","sources":["../../src/cli/run-cli.ts"],"names":[],"mappings":"AAibA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAiL5D"}
1
+ {"version":3,"file":"run-cli.d.ts","sourceRoot":"","sources":["../../src/cli/run-cli.ts"],"names":[],"mappings":"AA0lBA,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA6N5D"}