Skip to content

Commit 818fc7e

Browse files
committed
feat(export): add markdown summary exporter and demo outputs
1 parent 6511042 commit 818fc7e

19 files changed

Lines changed: 788 additions & 10 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The format is based on Keep a Changelog, and this project follows Semantic Versi
1111
- Added `orgscript check <file>` as the combined quality command for validation, linting, and formatting checks.
1212
- Added `orgscript check <file> --json` for machine-readable combined quality diagnostics.
1313
- Added `npm run check:all` and switched CI to the combined quality path.
14+
- Added `orgscript export markdown <file>` for concise Markdown summaries of OrgScript files.
15+
- Added Markdown summary golden snapshots and demo outputs.
1416
- Added `orgscript export mermaid <file>` for first-pass Mermaid exports of processes and stateflows.
1517
- Added `npm run demo:generate` plus a Mermaid demo package with generated Markdown and `.mmd` artifacts.
1618
- Added a canonical master language spec and lightweight governance guidance.

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,21 @@ process CraftBusinessLeadToOrder
7171

7272
See the full example in [`examples/craft-business-lead-to-order.orgs`](examples/craft-business-lead-to-order.orgs).
7373

74-
## From Source To Diagram
74+
## From Source To Output
7575

7676
OrgScript already generates visible downstream artifacts.
7777

78-
Minimal Mermaid demos live in [`docs/demos/mermaid/README.md`](docs/demos/mermaid/README.md):
78+
Mermaid demos live in [`docs/demos/mermaid/README.md`](docs/demos/mermaid/README.md):
7979

8080
- process demo from [`examples/lead-qualification.orgs`](examples/lead-qualification.orgs) to [`docs/demos/mermaid/lead-qualification.mermaid.md`](docs/demos/mermaid/lead-qualification.mermaid.md)
8181
- stateflow demo from [`examples/order-approval.orgs`](examples/order-approval.orgs) to [`docs/demos/mermaid/order-approval.mermaid.md`](docs/demos/mermaid/order-approval.mermaid.md)
8282

83-
Generate the demo artifacts with:
83+
Markdown summary demos live in [`docs/demos/markdown/README.md`](docs/demos/markdown/README.md):
84+
85+
- process summary from [`examples/lead-qualification.orgs`](examples/lead-qualification.orgs) to [`docs/demos/markdown/lead-qualification.summary.md`](docs/demos/markdown/lead-qualification.summary.md)
86+
- mixed summary from [`examples/order-approval.orgs`](examples/order-approval.orgs) to [`docs/demos/markdown/order-approval.summary.md`](docs/demos/markdown/order-approval.summary.md)
87+
88+
Generate both demo sets with:
8489

8590
```text
8691
npm run demo:generate
@@ -141,6 +146,7 @@ npm run demo:generate
141146
- [`docs/repository-structure.md`](docs/repository-structure.md)
142147
- [`docs/syntax.md`](docs/syntax.md)
143148
- [`docs/semantics.md`](docs/semantics.md)
149+
- [`docs/demos/markdown/README.md`](docs/demos/markdown/README.md)
144150
- [`docs/demos/mermaid/README.md`](docs/demos/mermaid/README.md)
145151
- [`examples/README.md`](examples/README.md)
146152
- [`spec/grammar.ebnf`](spec/grammar.ebnf)
@@ -169,12 +175,14 @@ npm run demo:generate
169175
- Combined quality checks: `orgscript check <file>`
170176
- Machine-readable combined checks: `orgscript check <file> --json`
171177
- Canonical JSON export: `orgscript export json <file>`
178+
- Markdown summary export: `orgscript export markdown <file>`
172179
- Mermaid export for `process` and `stateflow`: `orgscript export mermaid <file>`
173180
- Machine-readable diagnostics: `orgscript validate <file> --json`, `orgscript lint <file> --json`, `orgscript check <file> --json`
174181
- Golden snapshot tests for AST, canonical model, and formatter output
175182
- Stable lint severities: `error`, `warning`, `info`
176183
- Canonical master spec: [`spec/language-spec.md`](spec/language-spec.md)
177184
- Initial VS Code syntax-highlighting scaffold: [`editors/vscode`](editors/vscode)
185+
- Generated demo artifacts for Mermaid and Markdown summaries under [`docs/demos`](docs/demos)
178186

179187
## Quick start
180188

@@ -189,6 +197,7 @@ node ./bin/orgscript.js format ./examples/craft-business-lead-to-order.orgs --ch
189197
node ./bin/orgscript.js lint ./tests/lint/process-missing-trigger.orgs
190198
node ./bin/orgscript.js lint ./tests/lint/process-missing-trigger.orgs --json
191199
node ./bin/orgscript.js export json ./examples/craft-business-lead-to-order.orgs
200+
node ./bin/orgscript.js export markdown ./examples/craft-business-lead-to-order.orgs
192201
node ./bin/orgscript.js export mermaid ./examples/craft-business-lead-to-order.orgs
193202
```
194203

@@ -312,6 +321,13 @@ OrgScript exposes stable JSON diagnostics for CI, editors, AI systems, and downs
312321
- Example catalog: [`examples/README.md`](examples/README.md)
313322
- VS Code editor scaffold: [`editors/vscode/README.md`](editors/vscode/README.md)
314323

324+
## Visible outputs
325+
326+
OrgScript currently produces two human-facing output types from the same source file:
327+
328+
- Mermaid diagrams via `orgscript export mermaid <file>`
329+
- Markdown summaries via `orgscript export markdown <file>`
330+
315331
## Editor support
316332

317333
OrgScript now ships with a first VS Code syntax-highlighting scaffold under [`editors/vscode`](editors/vscode).
@@ -346,6 +362,7 @@ orgscript format file.orgs --check
346362
orgscript lint file.orgs
347363
orgscript lint file.orgs --json
348364
orgscript export json file.orgs
365+
orgscript export markdown file.orgs
349366
orgscript export mermaid file.orgs
350367
orgscript check file.orgs
351368
orgscript check file.orgs --json
@@ -361,6 +378,7 @@ See [`docs/cli-v0.1-plan.md`](docs/cli-v0.1-plan.md) for the implementation plan
361378

362379
```text
363380
npm test
381+
npm run export:markdown
364382
npm run export:mermaid
365383
npm run demo:generate
366384
npm run check

docs/cli-v0.1-plan.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Implemented:
1515
- `format --check`
1616
- `lint`
1717
- `export json`
18+
- `export markdown`
1819
- `export mermaid`
1920
- `validate --json`
2021
- `lint --json`
@@ -47,6 +48,27 @@ Output:
4748

4849
Exports the parsed document into the canonical JSON model.
4950

51+
### `orgscript export markdown <file>`
52+
53+
Exports the parsed document into a concise Markdown summary.
54+
55+
Current scope:
56+
57+
- `process`
58+
- `stateflow`
59+
- `rule`
60+
- `role`
61+
- `policy`
62+
- `event`
63+
- `metric`
64+
65+
Output style:
66+
67+
- human-readable
68+
- deterministic
69+
- structured for code review and docs
70+
- intentionally concise rather than prose-heavy
71+
5072
### `orgscript export mermaid <file>`
5173

5274
Exports supported blocks as a Markdown document with Mermaid code blocks.
@@ -170,5 +192,6 @@ TypeScript is the fastest start:
170192
- Lint exit codes are safe for CI use with advisory warnings.
171193
- Invalid files produce useful errors with line references.
172194
- Valid files can be exported to canonical JSON.
195+
- Valid files can be exported to concise Markdown summaries.
173196
- Formatter output is deterministic.
174197
- Linter catches at least a handful of high-value modeling mistakes.

docs/demos/markdown/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Markdown summary demos
2+
3+
This folder shows the shortest path from OrgScript source to human-readable Markdown summaries.
4+
5+
Each demo keeps the source file in `examples/` and generates one downstream artifact here:
6+
7+
- `*.summary.md`: a concise Markdown summary of the modeled logic
8+
9+
## Generate
10+
11+
```text
12+
npm run demo:generate
13+
```
14+
15+
## Demos
16+
17+
| Demo | Source | Markdown summary |
18+
| --- | --- | --- |
19+
| Lead qualification process | [lead-qualification.orgs](../../../examples/lead-qualification.orgs) | [lead-qualification.summary.md](./lead-qualification.summary.md) |
20+
| | | A compact process example that shows trigger, branching, assignment, notification, and state transition. |
21+
| Order approval stateflow | [order-approval.orgs](../../../examples/order-approval.orgs) | [order-approval.summary.md](./order-approval.summary.md) |
22+
| | | A stateflow-focused example that also demonstrates how Mermaid export skips unsupported blocks while still producing useful output. |
23+
24+
## Notes
25+
26+
- These artifacts are generated from the current Markdown summary exporter.
27+
- The summaries are intentionally concise and deterministic rather than prose-heavy.
28+
- If you change Markdown export behavior, regenerate this folder with `npm run demo:generate` and review the diffs.
29+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Process: LeadQualification
2+
3+
## Trigger
4+
- `lead.created`
5+
6+
## Summary
7+
- If `lead.source = "referral"`, assign `lead.priority` to `"high"`, assign `lead.path` to `"premium"`, and notify `sales` with `"New referral lead"`.
8+
- Else if `lead.source = "ads"`, assign `lead.priority` to `"normal"` and assign `lead.path` to `"standard"`.
9+
- If `lead.budget < 10000`, transition `lead.status` to `"disqualified"`, notify `sales` with `"Budget below threshold"`, and stop the branch.
10+
- Then transition `lead.status` to `"qualified"`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Stateflow: OrderStatus
2+
3+
## States
4+
- draft
5+
- pending_approval
6+
- approved
7+
- production
8+
- completed
9+
- cancelled
10+
11+
## Allowed transitions
12+
- `draft -> pending_approval`
13+
- `pending_approval -> approved`
14+
- `approved -> production`
15+
- `production -> completed`
16+
- `draft -> cancelled`
17+
- `pending_approval -> cancelled`
18+
19+
# Rule: NoProductionWithoutApproval
20+
21+
## Scope
22+
- `order`
23+
24+
## Summary
25+
- If `order.approved = false`, require `management_approval` and notify `operations` with `"Order cannot enter production"`.

docs/repository-structure.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ docs/
1717
governance.md
1818
cli-v0.1-plan.md
1919
demos/
20+
markdown/
21+
README.md
22+
lead-qualification.summary.md
23+
order-approval.summary.md
2024
mermaid/
2125
README.md
2226
lead-qualification.mermaid.md

docs/roadmaps/v0.4.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Make OrgScript easier to use in daily development, CI, and editor workflows with
2121
- JSON diagnostics examples in the README and diagnostics spec
2222
- canonical language spec and governance notes
2323
- initial VS Code syntax-highlighting scaffold
24+
- Markdown summary exporter
2425
- Mermaid demo package with generated Markdown and `.mmd` artifacts
2526

2627
## Non-goals

examples/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ This folder shows OrgScript at three adoption levels.
3030
```text
3131
node ./bin/orgscript.js validate ./examples/lead-qualification.orgs
3232
node ./bin/orgscript.js check ./examples/craft-business-lead-to-order.orgs
33+
node ./bin/orgscript.js export markdown ./examples/order-approval.orgs
3334
node ./bin/orgscript.js export mermaid ./examples/order-approval.orgs
3435
```
3536

3637
For generated Mermaid demo artifacts, see [`../docs/demos/mermaid/README.md`](../docs/demos/mermaid/README.md).
38+
39+
For generated Markdown summary demo artifacts, see [`../docs/demos/markdown/README.md`](../docs/demos/markdown/README.md).

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"validate:all": "node ./scripts/validate-all.js",
1818
"lint:all": "node ./scripts/lint-all.js",
1919
"export:json": "node ./bin/orgscript.js export json ./examples/craft-business-lead-to-order.orgs",
20+
"export:markdown": "node ./bin/orgscript.js export markdown ./examples/craft-business-lead-to-order.orgs",
2021
"export:mermaid": "node ./bin/orgscript.js export mermaid ./examples/craft-business-lead-to-order.orgs",
2122
"demo:generate": "node ./scripts/generate-demo.js",
2223
"golden:generate": "node ./scripts/generate-golden.js",

0 commit comments

Comments
 (0)