---
name: project-doc
description: Use when the user wants to generate the F1 project document from Discovery artifacts. Reads the business proposal, requirements, HLA, planning, and draft PRD index, then writes docs/discovery/<project-slug>/project-doc/project.md. Triggers on "/machine-discovery:project-doc <project-slug>", "/project-doc <project-slug>", and requests for the Discovery project document.
---

# Project Document

Generate the F1 Project Document from the current Discovery artifacts. This is the consolidated document that groups the proposal, requirements, HLA, planning, milestones, draft PRDs, and other F1 source Markdown into the customer-facing general project document.

## Inputs

```text
docs/discovery/<project-slug>/inputs/business-proposal.md
docs/discovery/<project-slug>/requirements/index.json
docs/discovery/<project-slug>/requirements/requirements.md
docs/discovery/<project-slug>/hla/hla.md
docs/discovery/<project-slug>/planning/phase-plan.md
docs/discovery/<project-slug>/draft-prds/index.json
```

## Output

```text
docs/discovery/<project-slug>/project-doc/project.md
```

## Operating protocol

1. Parse `$ARGUMENTS` and resolve the output language.
   - The first token MUST be a kebab-case ASCII project slug.
   - A second token MAY be `es` or `en`; if present, it wins.
   - If a second token is present and is not `es` or `en`, stop with `NEEDS INPUT: language must be es or en`.
   - If no language argument is present, inherit `language` from `planning/phase-plan.md`; otherwise from `hla/hla.md` or `requirements/requirements.md`; if missing, use the current user request language; if ambiguous, default to `es`.
   - If missing or invalid, stop with `NEEDS INPUT: indica el project slug, por ejemplo /machine-discovery:project-doc acme-demo`.
2. Validate prerequisites:
   - Business proposal exists and is non-empty.
   - Requirements index exists and has at least one RF.
   - Consolidated requirements document exists and is non-empty.
   - HLA exists and is non-empty.
   - Phase plan exists and is non-empty.
   - Draft PRD index exists and is valid JSON. It MAY be empty only if the user explicitly wants the project document before draft PRDs.
3. If `project-doc/project.md` already exists, ask before overwriting. Do not silently replace it.
4. Write `docs/discovery/<project-slug>/project-doc/project.blocks`.
   - The content file MUST contain one `@@KEY@@` block for each placeholder in `templates/project.<lang>.md.tmpl`, including `@@LANG@@`.
   - Fill it from the validated artifacts.
5. Unknown ownership, scope, acceptance, budget, or delivery details MUST be written as `NEEDS INPUT: <specific question>`.
6. Run `bash plugins/machine-discovery/scripts/assemble-doc.sh plugins/machine-discovery/skills/project-doc/templates/project.<lang>.md.tmpl docs/discovery/<project-slug>/project-doc/project.blocks docs/discovery/<project-slug>/project-doc/project.md`.
7. Delete `project.blocks` only after validating the assembled Markdown.
8. Final report MUST print exactly `/machine-discovery:commercial-offer <project-slug>` as the next-step suggestion. Do not run it.

## Hard rules

- **Discovery artifacts required.** Do not create the project document from the proposal alone.
- **Consolidation required.** The project document MUST group the relevant content from requirements, HLA, planning, milestones, and draft PRDs instead of linking to them as separate render targets.
- **Traceability required.** Scope and deliverables MUST cite RF, RNF, HLA, phase, or PRD IDs where applicable.
- **No legal invention.** Do not invent commercial terms, payment terms, liability, or acceptance terms.
- **Script-owned Markdown.** Final Project Document Markdown MUST be assembled by `scripts/assemble-doc.sh` from `.blocks` and template.
- **Selected-language output.** Generated titles, body prose, and template-owned headings MUST match the resolved output language; verbatim source quotes stay unchanged.
- **No SOW.** Do not generate or suggest a Statement of Work in this plugin iteration.
- **No auto-chaining.** Do not run commercial offer generation automatically.
- **Namespaced next step.** Final user-facing next-step suggestion MUST be `/machine-discovery:commercial-offer <project-slug>`.

## References

- Project document templates: [templates/project.es.md.tmpl](templates/project.es.md.tmpl), [templates/project.en.md.tmpl](templates/project.en.md.tmpl)
