enterprise-delivery 0.1.0

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 (46) hide show
  1. package/.claude-plugin/plugin.json +21 -0
  2. package/.codex-plugin/plugin.json +36 -0
  3. package/AGENTS.md +73 -0
  4. package/README.md +127 -0
  5. package/package.json +28 -0
  6. package/scripts/enterprise-delivery-validate.mjs +11 -0
  7. package/skills/add-requirement/SKILL.md +52 -0
  8. package/skills/analyze-requirement/SKILL.md +48 -0
  9. package/skills/analyze-tech-stack/SKILL.md +36 -0
  10. package/skills/change-requirement/SKILL.md +37 -0
  11. package/skills/complete-task/SKILL.md +46 -0
  12. package/skills/delivery-lead/SKILL.md +221 -0
  13. package/skills/delivery-planning/SKILL.md +27 -0
  14. package/skills/enterprise-kickoff/SKILL.md +25 -0
  15. package/skills/feature-gate/SKILL.md +22 -0
  16. package/skills/release-gate/SKILL.md +24 -0
  17. package/skills/sprint-gate/SKILL.md +23 -0
  18. package/skills/start-task/SKILL.md +39 -0
  19. package/skills/story-intake/SKILL.md +23 -0
  20. package/skills/update-coding-rules/SKILL.md +32 -0
  21. package/src/cli.mjs +220 -0
  22. package/src/frontmatter.mjs +121 -0
  23. package/src/init.mjs +54 -0
  24. package/src/install-codex.mjs +121 -0
  25. package/src/markdown.mjs +58 -0
  26. package/src/repository.mjs +59 -0
  27. package/src/rules.mjs +814 -0
  28. package/templates/docs/enterprise/architecture-overview.md +17 -0
  29. package/templates/docs/enterprise/change-log.md +4 -0
  30. package/templates/docs/enterprise/changes/CHG-0000-template.md +37 -0
  31. package/templates/docs/enterprise/current-state.md +48 -0
  32. package/templates/docs/enterprise/decision-log.md +5 -0
  33. package/templates/docs/enterprise/product-backlog.md +5 -0
  34. package/templates/docs/enterprise/project-charter.md +25 -0
  35. package/templates/docs/enterprise/project-vision.md +61 -0
  36. package/templates/docs/enterprise/releases/RELEASE-ID/release-notes.md +21 -0
  37. package/templates/docs/enterprise/releases/RELEASE-ID/release-plan.md +18 -0
  38. package/templates/docs/enterprise/releases/RELEASE-ID/traceability-matrix.md +5 -0
  39. package/templates/docs/enterprise/risk-register.md +5 -0
  40. package/templates/docs/enterprise/roadmap.md +13 -0
  41. package/templates/docs/enterprise/sprints/SPRINT-ID/sprint-plan.md +21 -0
  42. package/templates/docs/enterprise/sprints/SPRINT-ID/status-report.md +29 -0
  43. package/templates/docs/enterprise/stakeholder-register.md +6 -0
  44. package/templates/docs/enterprise/stories/STORY-0000-template.md +59 -0
  45. package/templates/docs/enterprise/task-graph.json +24 -0
  46. package/templates/docs/enterprise/test-strategy.md +15 -0
@@ -0,0 +1,221 @@
1
+ ---
2
+ name: delivery-lead
3
+ description: "Use when leading AI agents through enterprise delivery work: starting a project, adding or analyzing requirements, deciding tech stack and coding rules, starting implementation tasks, routing agents to the right repo files, or checking completion readiness."
4
+ ---
5
+
6
+ # Delivery Lead
7
+
8
+ Lead agents through repo-first delivery without adding ceremony. Use this skill when the user asks to start a project, add a requirement, analyze a requirement, choose or review tech stack, update coding rules, start a task, or coordinate completion.
9
+
10
+ ## Core Rule
11
+
12
+ `docs/enterprise/` is the source of truth. External tools may be linked, but agents must read and update repository artifacts before making delivery-impacting changes.
13
+
14
+ For uncertain facts, write `unknown` or `inferred`. Do not invent stakeholders, approvals, roadmap commitments, sprint commitments, release readiness, or history.
15
+
16
+ ## Always Read First
17
+
18
+ For any meaningful work, read these files before proposing or editing:
19
+
20
+ - `AGENTS.md`: local agent rules and required gates.
21
+ - `docs/enterprise/project-vision.md`: goals, non-goals, principles, forbidden patterns, quality bar, AI collaboration rules.
22
+ - `docs/enterprise/current-state.md`: active stories, changes, failing tests, unresolved bugs, next commands.
23
+ - `docs/enterprise/task-graph.json`: task status, dependencies, story/change links, evidence.
24
+
25
+ If the work touches architecture, stack, risks, or delivery state, also read:
26
+
27
+ - `docs/enterprise/architecture-overview.md`
28
+ - `docs/enterprise/test-strategy.md`
29
+ - `docs/enterprise/risk-register.md`
30
+ - `docs/enterprise/decision-log.md`
31
+ - `docs/enterprise/product-backlog.md`
32
+
33
+ ## Workflow Router
34
+
35
+ ### 1. Start Or Onboard A Project
36
+
37
+ Read:
38
+
39
+ - `README.md`
40
+ - package/build files such as `package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`
41
+ - existing docs and tests
42
+ - `AGENTS.md` if present
43
+
44
+ Update:
45
+
46
+ - `docs/enterprise/project-charter.md`
47
+ - `docs/enterprise/project-vision.md`
48
+ - `docs/enterprise/architecture-overview.md`
49
+ - `docs/enterprise/test-strategy.md`
50
+ - `docs/enterprise/current-state.md`
51
+ - `docs/enterprise/task-graph.json`
52
+ - `docs/enterprise/risk-register.md`
53
+ - `docs/enterprise/decision-log.md`
54
+
55
+ Run:
56
+
57
+ ```bash
58
+ node scripts/enterprise-delivery-validate.mjs validate repo
59
+ ```
60
+
61
+ For brownfield projects, create or update `docs/enterprise/onboarding-audit.md` with confirmed, inferred, and unknown facts.
62
+
63
+ ### 2. Add A Requirement
64
+
65
+ Read:
66
+
67
+ - `docs/enterprise/project-vision.md`
68
+ - `docs/enterprise/product-backlog.md`
69
+ - relevant existing `docs/enterprise/stories/STORY-*.md`
70
+ - relevant existing `docs/enterprise/changes/CHG-*.md`
71
+
72
+ Update:
73
+
74
+ - create or update `docs/enterprise/stories/STORY-<next>-<slug>.md`
75
+ - create or update linked `docs/enterprise/changes/CHG-<next>-<slug>.md`
76
+ - add `linked_changes` in story frontmatter
77
+ - add `related_stories` in change frontmatter
78
+ - update `docs/enterprise/product-backlog.md`
79
+ - update `docs/enterprise/current-state.md`
80
+
81
+ Required story content:
82
+
83
+ - Requirement source
84
+ - Business value
85
+ - Acceptance criteria
86
+ - Non-functional criteria
87
+ - Dependencies
88
+ - Docs impact
89
+ - Risk impact
90
+ - Planned test evidence
91
+
92
+ Keep status `draft` until requirement source and acceptance criteria are explicit.
93
+
94
+ ### 3. Analyze A Requirement
95
+
96
+ Read:
97
+
98
+ - target `STORY-*`
99
+ - linked `CHG-*`
100
+ - `docs/enterprise/project-vision.md`
101
+ - `docs/enterprise/architecture-overview.md`
102
+ - `docs/enterprise/test-strategy.md`
103
+ - `docs/enterprise/risk-register.md`
104
+ - `docs/enterprise/decision-log.md`
105
+
106
+ Do:
107
+
108
+ - clarify ambiguity as assumptions, questions, or `unknown`
109
+ - split broad work into smaller stories when one story has multiple independent outcomes
110
+ - map each acceptance criterion to implementation tasks and verification commands
111
+ - identify docs, risk, and decision impacts
112
+
113
+ Update:
114
+
115
+ - target `STORY-*`
116
+ - linked `CHG-*`
117
+ - `docs/enterprise/task-graph.json`
118
+ - `docs/enterprise/risk-register.md` if risk changes
119
+ - `docs/enterprise/decision-log.md` if architecture, stack, delivery, or governance decisions change
120
+
121
+ ### 4. Analyze Or Choose Tech Stack
122
+
123
+ Read:
124
+
125
+ - `docs/enterprise/project-charter.md`
126
+ - `docs/enterprise/project-vision.md`
127
+ - `docs/enterprise/architecture-overview.md`
128
+ - `docs/enterprise/test-strategy.md`
129
+ - package/build files
130
+ - existing source layout
131
+
132
+ Update:
133
+
134
+ - `docs/enterprise/architecture-overview.md` with confirmed, inferred, and unknown stack facts
135
+ - `docs/enterprise/decision-log.md` for durable choices
136
+ - `docs/enterprise/test-strategy.md` for chosen verification commands
137
+ - `docs/enterprise/risk-register.md` for stack risks
138
+
139
+ Decision-log entries should include the decision, reason, and status. Do not mark a tech choice accepted unless the user confirmed it or it is already implemented in the repo.
140
+
141
+ ### 5. Update Coding Rules
142
+
143
+ Read:
144
+
145
+ - `AGENTS.md`
146
+ - `docs/enterprise/project-vision.md`
147
+ - `docs/enterprise/architecture-overview.md`
148
+ - `docs/enterprise/test-strategy.md`
149
+
150
+ Update:
151
+
152
+ - `AGENTS.md` for operational instructions agents must follow
153
+ - `docs/enterprise/project-vision.md` for durable principles, forbidden patterns, coding philosophy, quality bar, and AI collaboration rules
154
+ - `docs/enterprise/decision-log.md` for rule changes that affect architecture, delivery, release readiness, governance, or team behavior
155
+
156
+ Keep rules concrete and enforceable. Prefer "Run `npm test` and feature gate before completion" over vague rules like "write high quality code."
157
+
158
+ ### 6. Start A Task
159
+
160
+ Read:
161
+
162
+ - `AGENTS.md`
163
+ - `docs/enterprise/project-vision.md`
164
+ - `docs/enterprise/current-state.md`
165
+ - `docs/enterprise/task-graph.json`
166
+ - target `STORY-*`
167
+ - linked `CHG-*`
168
+
169
+ Before coding:
170
+
171
+ - confirm the story has acceptance criteria
172
+ - confirm the story and change are bidirectionally linked
173
+ - update or create task entries in `task-graph.json`
174
+ - identify the focused verification commands
175
+
176
+ Implementation rule:
177
+
178
+ - use TDD for behavior changes
179
+ - keep edits scoped to the story/change
180
+ - update risk and decision logs when scope changes
181
+
182
+ ### 7. Complete A Task
183
+
184
+ Read:
185
+
186
+ - target `STORY-*`
187
+ - linked `CHG-*`
188
+ - `docs/enterprise/task-graph.json`
189
+ - `docs/enterprise/current-state.md`
190
+
191
+ Update:
192
+
193
+ - story `Test Evidence` with actual commands and results
194
+ - change `Evidence` with actual commands and results
195
+ - story `Implementation Links`
196
+ - change status to `implemented` or `verified`
197
+ - task status and evidence in `task-graph.json`
198
+ - `current-state.md` for failing tests, unresolved bugs, active work, and next commands
199
+
200
+ Run:
201
+
202
+ ```bash
203
+ npm test
204
+ node scripts/enterprise-delivery-validate.mjs validate repo
205
+ node scripts/enterprise-delivery-validate.mjs validate feature --story STORY-0001
206
+ ```
207
+
208
+ Only use sprint or release gates when the user is asking about sprint or release readiness.
209
+
210
+ ## Leadership Prompt Pattern
211
+
212
+ When delegating to an agent, include:
213
+
214
+ ```text
215
+ Read AGENTS.md plus docs/enterprise/project-vision.md, current-state.md, and task-graph.json first.
216
+ Use STORY-____ and CHG-____ as the delivery source of truth.
217
+ Before coding, confirm acceptance criteria and planned evidence.
218
+ During work, update task-graph.json if task status or dependencies change.
219
+ Before completion, run tests, validate repo, validate feature, and record evidence.
220
+ Do not invent unknown facts; mark them unknown or inferred.
221
+ ```
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: delivery-planning
3
+ description: Map accepted Enterprise Delivery stories into implementation tasks, planned evidence, documentation updates, risks, and release or sprint traceability before coding starts.
4
+ ---
5
+
6
+ # Delivery Planning
7
+
8
+ Use this skill after a story and linked change record exist, and before implementation begins.
9
+
10
+ ## Checklist
11
+
12
+ 1. Read the story under `docs/enterprise/stories/` and each linked change under `docs/enterprise/changes/`.
13
+ 2. Confirm the story has acceptance criteria, business value, docs impact, risk impact, and planned test evidence.
14
+ 3. Break the acceptance criteria into small implementation tasks.
15
+ 4. Record each task in `docs/enterprise/task-graph.json` with `story_id`, `change_id`, dependencies, status, and expected evidence.
16
+ 5. Update `docs/enterprise/current-state.md` with active story, active change, and next verification commands.
17
+ 6. Update `docs/enterprise/risk-register.md` or `docs/enterprise/decision-log.md` when planning reveals a new delivery risk or decision.
18
+
19
+ ## Output
20
+
21
+ Produce a concise task plan that preserves this chain:
22
+
23
+ ```text
24
+ Requirement -> STORY-* -> CHG-* -> tests/evidence -> sprint/release traceability
25
+ ```
26
+
27
+ Do not invent commitments, stakeholders, approvals, or historical facts. Mark uncertain facts as `unknown` or `inferred`.
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: enterprise-kickoff
3
+ description: Use when adding Enterprise Delivery to a greenfield or brownfield repository, initializing docs/enterprise, auditing current project facts, or establishing baseline agile delivery artifacts
4
+ ---
5
+
6
+ # Enterprise Kickoff
7
+
8
+ Initialize or audit repo-first enterprise delivery artifacts.
9
+
10
+ ## Rules
11
+
12
+ - Do not invent project history, stakeholders, roadmap, sprint commitments, release state, or approvals.
13
+ - In brownfield repositories, label facts as confirmed, inferred, or unknown.
14
+ - Create baseline artifacts under `docs/enterprise/`.
15
+ - Create the AI-native state layer under `docs/enterprise/`: `project-vision.md`, `current-state.md`, and `task-graph.json`.
16
+ - Run repository validation before claiming kickoff is complete.
17
+
18
+ ## Workflow
19
+
20
+ 1. Detect whether the repository is greenfield or brownfield by inspecting README, docs, source files, tests, package metadata, and recent commits.
21
+ 2. Create missing baseline artifacts from Enterprise Delivery templates, including project vision, current state, and task graph.
22
+ 3. For greenfield projects, ask for project charter facts before recording them as confirmed.
23
+ 4. For brownfield projects, create `docs/enterprise/onboarding-audit.md` with confirmed, inferred, and unknown facts.
24
+ 5. From the target repository, run `node <plugin-install-dir>/scripts/enterprise-delivery-validate.mjs validate repo` or equivalent installed command.
25
+ 6. Report validation failures as documentation gaps, not as implementation success.
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: feature-gate
3
+ description: Use before claiming a story, feature, or delivery-impacting change is complete
4
+ ---
5
+
6
+ # Feature Gate
7
+
8
+ Validate story completion evidence before any completion claim.
9
+
10
+ ## Rules
11
+
12
+ - Run feature validation before moving a story to `done`.
13
+ - Treat validation exit code `1` as a blocker, not a tool failure.
14
+ - Do not claim completion while story, change, acceptance, test, docs, or implementation evidence is missing.
15
+
16
+ ## Workflow
17
+
18
+ 1. Identify the story ID.
19
+ 2. Run the installed plugin validator, for example `node <plugin-install-dir>/scripts/enterprise-delivery-validate.mjs validate feature --story <story-id>`, or an equivalent installed command using the identified story ID.
20
+ 3. If validation fails, update the story, linked change records, evidence, docs impact, risks, or decisions.
21
+ 4. Re-run validation.
22
+ 5. Only after validation passes may the story move to `done` or the agent claim the feature complete.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: release-gate
3
+ description: Use before claiming a release candidate, release plan, or release package is ready
4
+ ---
5
+
6
+ # Release Gate
7
+
8
+ Validate release traceability and evidence.
9
+
10
+ ## Rules
11
+
12
+ - Releases must include release plan, release notes, and traceability matrix.
13
+ - Included stories must pass feature validation.
14
+ - Included changes must be verified before release.
15
+ - Open risks and blockers must be acknowledged.
16
+
17
+ ## Workflow
18
+
19
+ 1. Read `docs/enterprise/releases/<release>/release-plan.md`.
20
+ 2. Read `docs/enterprise/releases/<release>/release-notes.md`.
21
+ 3. Read `docs/enterprise/releases/<release>/traceability-matrix.md`.
22
+ 4. Run the installed plugin validator, for example `node <plugin-install-dir>/scripts/enterprise-delivery-validate.mjs validate release --release <release>`, or an equivalent installed command.
23
+ 5. Fix missing traceability, unverified changes, failing stories, risks, blockers, or missing test evidence.
24
+ 6. Re-run validation before claiming release readiness.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: sprint-gate
3
+ description: Use when starting, reviewing, updating, or closing a sprint
4
+ ---
5
+
6
+ # Sprint Gate
7
+
8
+ Validate sprint delivery state and reporting.
9
+
10
+ ## Rules
11
+
12
+ - Sprint plans must reference committed story IDs.
13
+ - Done stories inside a sprint must pass feature validation.
14
+ - Blocked stories require a next action; carry-over should be called out in sprint reporting.
15
+ - Risk and decision status must be updated or explicitly marked unchanged.
16
+
17
+ ## Workflow
18
+
19
+ 1. Read `docs/enterprise/sprints/<sprint>/sprint-plan.md`.
20
+ 2. Read `docs/enterprise/sprints/<sprint>/status-report.md`.
21
+ 3. Run the installed plugin validator, for example `node <plugin-install-dir>/scripts/enterprise-delivery-validate.mjs validate sprint --sprint <sprint>`, or an equivalent installed command.
22
+ 4. Fix missing sprint artifacts, story links, change links, blocked next actions, risk updates, or decision updates.
23
+ 5. Re-run validation before claiming sprint state is ready, reviewed, or closed.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: start-task
3
+ description: Use when the user says start task, begin implementation, pick next task, work on STORY-*, implement CHG-*, or asks an agent to begin coding from existing delivery artifacts.
4
+ ---
5
+
6
+ # Start Task
7
+
8
+ Prepare implementation from the repo source of truth.
9
+
10
+ ## Read
11
+
12
+ - `AGENTS.md`
13
+ - `docs/enterprise/project-vision.md`
14
+ - `docs/enterprise/current-state.md`
15
+ - `docs/enterprise/task-graph.json`
16
+ - target `docs/enterprise/stories/STORY-*.md`
17
+ - linked `docs/enterprise/changes/CHG-*.md`
18
+ - `docs/enterprise/test-strategy.md`
19
+ - relevant source and test files
20
+
21
+ ## Before Coding
22
+
23
+ - Confirm the story has acceptance criteria.
24
+ - Confirm story `linked_changes` and change `related_stories` are bidirectional.
25
+ - Identify the task entry in `task-graph.json` or create one.
26
+ - Set task status to `in_progress`.
27
+ - Identify focused test commands.
28
+ - Use TDD for behavior changes.
29
+
30
+ ## Update
31
+
32
+ - `docs/enterprise/task-graph.json`
33
+ - `docs/enterprise/current-state.md`
34
+ - target `STORY-*` and `CHG-*` if planned evidence, scope, risk, or docs impact changes
35
+
36
+ ## Do Not
37
+
38
+ - Start implementation when no story/change exists for delivery-impacting work.
39
+ - Broaden scope beyond the story without updating delivery artifacts.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: story-intake
3
+ description: Use before starting any feature, bugfix, or delivery-impacting work to create or update a STORY-* artifact and mandatory linked CHG-* record
4
+ ---
5
+
6
+ # Story Intake
7
+
8
+ Every delivery-impacting task starts with a story and a change record.
9
+
10
+ ## Rules
11
+
12
+ - Do not begin implementation until the story has a requirement, acceptance criteria, and at least one linked `CHG-*`.
13
+ - Every story must have a linked change record from creation, including draft stories.
14
+ - External tools may be linked but are not the source of truth.
15
+
16
+ ## Workflow
17
+
18
+ 1. Find or create `docs/enterprise/stories/STORY-<next>-<slug>.md`.
19
+ 2. Find or create `docs/enterprise/changes/CHG-<next>-<slug>.md`.
20
+ 3. Link the change ID in story frontmatter under `linked_changes`.
21
+ 4. Link the story ID in change frontmatter under `related_stories`.
22
+ 5. Record requirement source, business value, acceptance criteria, docs impact, risk impact, and test evidence plan.
23
+ 6. Keep status as `draft` until acceptance criteria and requirement source are explicit.
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: update-coding-rules
3
+ description: Use when the user asks to add, change, tighten, or review coding rules, AI agent rules, architecture principles, forbidden patterns, quality gates, or repository workflow instructions.
4
+ ---
5
+
6
+ # Update Coding Rules
7
+
8
+ Update durable rules where agents will actually read them.
9
+
10
+ ## Read
11
+
12
+ - `AGENTS.md`
13
+ - `docs/enterprise/project-vision.md`
14
+ - `docs/enterprise/architecture-overview.md`
15
+ - `docs/enterprise/test-strategy.md`
16
+ - `docs/enterprise/decision-log.md`
17
+ - `docs/enterprise/current-state.md`
18
+
19
+ ## Update
20
+
21
+ - `AGENTS.md` for operational instructions agents must follow.
22
+ - `docs/enterprise/project-vision.md` for principles, forbidden patterns, coding philosophy, quality bar, and AI collaboration rules.
23
+ - `docs/enterprise/test-strategy.md` for required verification commands.
24
+ - `docs/enterprise/decision-log.md` for durable decisions.
25
+ - active `STORY-*` and `CHG-*` if this is part of delivery-impacting work.
26
+
27
+ ## Rules
28
+
29
+ - Make rules concrete and enforceable.
30
+ - Prefer exact commands and file paths.
31
+ - Avoid vague rules like "write clean code" unless paired with observable behavior.
32
+ - Do not conflict with higher-priority user instructions in `AGENTS.md`.
package/src/cli.mjs ADDED
@@ -0,0 +1,220 @@
1
+ import path from 'node:path';
2
+ import { initializeEnterprise } from './init.mjs';
3
+ import { installClaudePlaceholder, installCodexPlugin } from './install-codex.mjs';
4
+ import { validateFeature, validateRelease, validateRepo, validateSprint } from './rules.mjs';
5
+
6
+ export async function runCli(argv, cwd) {
7
+ const parsed = parseArgs(argv, cwd);
8
+ if (parsed.error) {
9
+ console.error(parsed.error);
10
+ printUsage();
11
+ return 2;
12
+ }
13
+
14
+ let validationResult;
15
+ if (parsed.command === 'init') {
16
+ validationResult = initializeEnterprise(parsed.root);
17
+ } else if (parsed.command === 'install' && parsed.adapter === 'codex') {
18
+ validationResult = installCodexPlugin();
19
+ } else if (parsed.command === 'install' && parsed.adapter === 'claude') {
20
+ validationResult = installClaudePlaceholder();
21
+ } else if (parsed.command === 'validate' && parsed.gate === 'repo') {
22
+ validationResult = validateRepo(parsed.root);
23
+ } else if (parsed.command === 'validate' && parsed.gate === 'feature') {
24
+ if (!parsed.story) {
25
+ console.error('Missing required --story for feature validation.');
26
+ printUsage();
27
+ return 2;
28
+ }
29
+ validationResult = validateFeature(parsed.root, parsed.story);
30
+ } else if (parsed.command === 'validate' && parsed.gate === 'sprint') {
31
+ if (!parsed.sprint) {
32
+ console.error('Missing required --sprint for sprint validation.');
33
+ printUsage();
34
+ return 2;
35
+ }
36
+ validationResult = validateSprint(parsed.root, parsed.sprint);
37
+ } else if (parsed.command === 'validate' && parsed.gate === 'release') {
38
+ if (!parsed.release) {
39
+ console.error('Missing required --release for release validation.');
40
+ printUsage();
41
+ return 2;
42
+ }
43
+ validationResult = validateRelease(parsed.root, parsed.release);
44
+ } else {
45
+ console.error(`Unsupported command: ${argv.join(' ')}`);
46
+ printUsage();
47
+ return 2;
48
+ }
49
+
50
+ if (parsed.json) {
51
+ console.log(JSON.stringify(validationResult, null, 2));
52
+ } else {
53
+ printHuman(validationResult);
54
+ }
55
+
56
+ return validationResult.status === 'pass' ? 0 : 1;
57
+ }
58
+
59
+ function parseArgs(argv, cwd) {
60
+ if (argv.length < 1) {
61
+ return { error: 'Expected command and gate.' };
62
+ }
63
+
64
+ const [command, gate, ...rest] = argv;
65
+ const parsed = {
66
+ command,
67
+ gate,
68
+ adapter: gate,
69
+ root: cwd,
70
+ story: '',
71
+ sprint: '',
72
+ release: '',
73
+ json: false
74
+ };
75
+
76
+ const optionTokens = command === 'init' ? argv.slice(1) : rest;
77
+ for (let index = 0; index < optionTokens.length; index += 1) {
78
+ const token = optionTokens[index];
79
+ if (token === '--root') {
80
+ const value = optionTokens[index + 1];
81
+ if (!value || value.startsWith('--')) {
82
+ return { error: 'Missing value for --root.' };
83
+ }
84
+ parsed.root = path.resolve(cwd, value);
85
+ index += 1;
86
+ } else if (token === '--story') {
87
+ const value = optionTokens[index + 1];
88
+ if (!value || value.startsWith('--')) {
89
+ return { error: 'Missing value for --story.' };
90
+ }
91
+ parsed.story = value;
92
+ index += 1;
93
+ } else if (token === '--sprint') {
94
+ const value = optionTokens[index + 1];
95
+ if (!value || value.startsWith('--')) {
96
+ return { error: 'Missing value for --sprint.' };
97
+ }
98
+ parsed.sprint = value;
99
+ index += 1;
100
+ } else if (token === '--release') {
101
+ const value = optionTokens[index + 1];
102
+ if (!value || value.startsWith('--')) {
103
+ return { error: 'Missing value for --release.' };
104
+ }
105
+ parsed.release = value;
106
+ index += 1;
107
+ } else if (token === '--json') {
108
+ parsed.json = true;
109
+ } else {
110
+ return { error: `Unknown argument: ${token}` };
111
+ }
112
+ }
113
+
114
+ if (!['init', 'validate', 'install'].includes(command)) {
115
+ return { error: `Unknown command: ${command}` };
116
+ }
117
+
118
+ if (command === 'install') {
119
+ if (!['codex', 'claude'].includes(parsed.adapter)) {
120
+ return { error: 'Install adapter must be one of: codex, claude.' };
121
+ }
122
+ for (const option of ['story', 'sprint', 'release']) {
123
+ if (parsed[option]) {
124
+ return { error: `Option --${option} is not allowed for install.` };
125
+ }
126
+ }
127
+ return parsed;
128
+ }
129
+
130
+ if (command === 'init') {
131
+ for (const option of ['story', 'sprint', 'release']) {
132
+ if (parsed[option]) {
133
+ return { error: `Option --${option} is not allowed for init.` };
134
+ }
135
+ }
136
+ return parsed;
137
+ }
138
+
139
+ const allowedOptionsByGate = {
140
+ repo: new Set(['root', 'json']),
141
+ feature: new Set(['root', 'json', 'story']),
142
+ sprint: new Set(['root', 'json', 'sprint']),
143
+ release: new Set(['root', 'json', 'release'])
144
+ };
145
+ const allowedOptions = allowedOptionsByGate[gate];
146
+ if (allowedOptions) {
147
+ for (const option of ['story', 'sprint', 'release']) {
148
+ if (parsed[option] && !allowedOptions.has(option)) {
149
+ return { error: `Option --${option} is not allowed for ${gate} validation.` };
150
+ }
151
+ }
152
+ }
153
+
154
+ return parsed;
155
+ }
156
+
157
+ function printHuman(validationResult) {
158
+ if (validationResult.command === 'install') {
159
+ if (validationResult.adapter === 'codex') {
160
+ console.log(`Installed Enterprise Delivery Codex plugin at ${validationResult.pluginDir}`);
161
+ console.log(`Updated marketplace at ${validationResult.marketplacePath}`);
162
+ return;
163
+ }
164
+
165
+ console.log(validationResult.message);
166
+ return;
167
+ }
168
+
169
+ if (validationResult.command === 'init') {
170
+ console.log(`Initialized Enterprise Delivery at ${validationResult.target}`);
171
+ if (validationResult.created.length > 0) {
172
+ console.log('');
173
+ console.log('Created:');
174
+ for (const artifact of validationResult.created) {
175
+ console.log(`- ${artifact}`);
176
+ }
177
+ }
178
+ if (validationResult.skipped.length > 0) {
179
+ console.log('');
180
+ for (const artifact of validationResult.skipped) {
181
+ console.log(`Skipped existing: ${artifact}`);
182
+ }
183
+ }
184
+ return;
185
+ }
186
+
187
+ const label = validationResult.target === validationResult.gate
188
+ ? validationResult.gate
189
+ : `${validationResult.gate} ${validationResult.target}`;
190
+
191
+ if (validationResult.status === 'pass') {
192
+ console.log(`PASS ${label}`);
193
+ return;
194
+ }
195
+
196
+ console.log(`FAIL ${label}`);
197
+ console.log('');
198
+ console.log('Missing:');
199
+ for (const error of validationResult.errors) {
200
+ console.log(`- ${error.message}`);
201
+ }
202
+
203
+ if (validationResult.nextActions.length > 0) {
204
+ console.log('');
205
+ console.log('Next actions:');
206
+ for (const action of validationResult.nextActions) {
207
+ console.log(`- ${action}`);
208
+ }
209
+ }
210
+ }
211
+
212
+ function printUsage() {
213
+ console.error('Usage: enterprise-delivery init [--root PATH] [--json]');
214
+ console.error(' enterprise-delivery install codex [--json]');
215
+ console.error(' enterprise-delivery install claude [--json]');
216
+ console.error(' enterprise-delivery validate repo [--root PATH] [--json]');
217
+ console.error(' enterprise-delivery validate feature --story STORY-0001 [--root PATH] [--json]');
218
+ console.error(' enterprise-delivery validate sprint --sprint 2026-W20 [--root PATH] [--json]');
219
+ console.error(' enterprise-delivery validate release --release 2026.05.0 [--root PATH] [--json]');
220
+ }