|
| 1 | +--- |
| 2 | +props: |
| 3 | + type: object |
| 4 | + properties: |
| 5 | + request: { type: string } |
| 6 | + syntax: { type: string } |
| 7 | + session: { type: string } |
| 8 | + required: [request, syntax, session] |
| 9 | + additionalProperties: false |
| 10 | +returns: |
| 11 | + type: string |
| 12 | +--- |
| 13 | + |
| 14 | +# The plan `xmd prompt` follows |
| 15 | + |
| 16 | +This is the policy behind `xmd prompt`, and it is a program rather than a |
| 17 | +setting: what the agent is asked, how many times a draft may be repaired, what a |
| 18 | +person is shown, and what happens when nobody approves anything are all written |
| 19 | +here, in the open, where they can be read and argued with. |
| 20 | + |
| 21 | +The command supplies three things — the request as the person typed it, the |
| 22 | +syntax catalog for this working directory, and the name of the session every |
| 23 | +turn belongs to. Nothing here runs the document being written. A candidate is |
| 24 | +text until a person approves it and the command runs it separately. |
| 25 | + |
| 26 | +<Let as="round" value={0} /> |
| 27 | + |
| 28 | +<Session name={props.session}> |
| 29 | + |
| 30 | +<Prompt as="candidate"> |
| 31 | +Write one complete Executable Markdown root document that accomplishes this: |
| 32 | + |
| 33 | +{props.request} |
| 34 | + |
| 35 | +Reply with the document source and nothing else. No enclosing code fence, no |
| 36 | +explanation before or after it, no commentary about what you did. |
| 37 | + |
| 38 | +Write it as a document a person would want to read, not as a script with |
| 39 | +comments bolted on. State what it does and why in ordinary prose, and let the |
| 40 | +components appear where that prose leads to them. The person asked for the |
| 41 | +outcome above; the document should still read as though it is about that |
| 42 | +outcome. |
| 43 | + |
| 44 | +Everything you may use is described below. Use nothing that is not here. |
| 45 | + |
| 46 | +{props.syntax} |
| 47 | +</Prompt> |
| 48 | + |
| 49 | +<Loop max={10}> |
| 50 | +<Let as="round" value={round + 1} /> |
| 51 | + |
| 52 | +Each draft gets one validation and up to three chances to fix what validation |
| 53 | +found. A revision the person asked for is a new draft, so it gets its own three. |
| 54 | + |
| 55 | +<ValidateCandidate source={candidate} as="assessment" /> |
| 56 | + |
| 57 | +<Loop max={3}> |
| 58 | +<If condition={assessment.valid}> |
| 59 | +<Break /> |
| 60 | +</If> |
| 61 | + |
| 62 | +<Prompt as="candidate"> |
| 63 | +That document does not validate. These are the exact findings: |
| 64 | + |
| 65 | +<CodeBlock value={JSON.stringify(assessment.diagnostics, null, 2)} language="json" /> |
| 66 | + |
| 67 | +Return one complete replacement root document that resolves every finding above. |
| 68 | +Source only, no enclosing fence, no explanation. Keep the narrative that explains |
| 69 | +what the document is for. |
| 70 | +</Prompt> |
| 71 | + |
| 72 | +<ValidateCandidate source={candidate} as="assessment" /> |
| 73 | +</Loop> |
| 74 | + |
| 75 | +The person decides. A valid draft can be approved; one that is still invalid |
| 76 | +after three repairs is shown with its findings and can only be sent back or |
| 77 | +abandoned. On the tenth and last presentation there is nothing left to revise |
| 78 | +into, so revision is not offered. |
| 79 | + |
| 80 | +<Elicit |
| 81 | + as="review" |
| 82 | + schema={{ |
| 83 | + type: "object", |
| 84 | + properties: { |
| 85 | + decision: { |
| 86 | + type: "string", |
| 87 | + enum: assessment.valid |
| 88 | + ? (round === 10 ? ["approve", "abort"] : ["approve", "revise", "abort"]) |
| 89 | + : (round === 10 ? ["abort"] : ["revise", "abort"]), |
| 90 | + }, |
| 91 | + feedback: { type: "string" }, |
| 92 | + }, |
| 93 | + required: ["decision"], |
| 94 | + additionalProperties: false, |
| 95 | + if: { properties: { decision: { const: "revise" } }, required: ["decision"] }, |
| 96 | + then: { required: ["feedback"], properties: { feedback: { minLength: 1 } } }, |
| 97 | + }} |
| 98 | +> |
| 99 | +This document was written for: {props.request} |
| 100 | + |
| 101 | +<CodeBlock value={candidate} language="markdown" /> |
| 102 | + |
| 103 | +<If condition={!assessment.valid}> |
| 104 | +It still does not validate after three attempts to repair it. These are the |
| 105 | +remaining findings: |
| 106 | + |
| 107 | +<CodeBlock value={JSON.stringify(assessment.diagnostics, null, 2)} language="json" /> |
| 108 | +</If> |
| 109 | +</Elicit> |
| 110 | + |
| 111 | +<If condition={review.decision === "approve"}> |
| 112 | +<Return value={candidate} /> |
| 113 | +<Break /> |
| 114 | +</If> |
| 115 | + |
| 116 | +<If condition={review.decision === "abort"}> |
| 117 | +<Fail message="xmd prompt: you ended the review, so nothing was saved and nothing ran." /> |
| 118 | +</If> |
| 119 | + |
| 120 | +<Prompt as="candidate"> |
| 121 | +The person read that document and asked for this to change: |
| 122 | + |
| 123 | +{review.feedback} |
| 124 | + |
| 125 | +Return one complete replacement root document. Source only, no enclosing fence, |
| 126 | +no explanation. Keep the narrative that explains what the document is for. |
| 127 | +</Prompt> |
| 128 | +</Loop> |
| 129 | + |
| 130 | +</Session> |
| 131 | + |
| 132 | +<Fail message="xmd prompt: ten drafts were reviewed and none was approved, so nothing was saved and nothing ran. Try again with a more specific request." /> |
0 commit comments