@riotprompt/riotdoc 1.0.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.
- package/LICENSE +190 -0
- package/README.md +42 -0
- package/dist/__vite-browser-external-l0sNRNKZ.js +2 -0
- package/dist/__vite-browser-external-l0sNRNKZ.js.map +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +5 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +353 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +361 -0
- package/dist/index.js +231 -0
- package/dist/index.js.map +1 -0
- package/dist/loader-B7ZeTPQg.js +6358 -0
- package/dist/loader-B7ZeTPQg.js.map +1 -0
- package/package.json +87 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 Tim O'Brien
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# RiotDoc
|
|
2
|
+
|
|
3
|
+
Structured document creation with AI assistance.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
RiotDoc helps you create high-quality documents through a structured workflow:
|
|
8
|
+
- Define voice and style
|
|
9
|
+
- Create outlines
|
|
10
|
+
- Generate drafts with varying AI assistance levels
|
|
11
|
+
- Manage evidence and references
|
|
12
|
+
- Revise and refine
|
|
13
|
+
- Export final documents
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g @riotprompt/riotdoc
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Create a new document
|
|
25
|
+
riotdoc create my-blog-post --type blog-post
|
|
26
|
+
|
|
27
|
+
# Generate an outline
|
|
28
|
+
riotdoc outline
|
|
29
|
+
|
|
30
|
+
# Create a draft
|
|
31
|
+
riotdoc draft --level expand
|
|
32
|
+
|
|
33
|
+
# Revise the draft
|
|
34
|
+
riotdoc revise
|
|
35
|
+
|
|
36
|
+
# Export final document
|
|
37
|
+
riotdoc export
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
Apache-2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__vite-browser-external-l0sNRNKZ.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { }
|
package/dist/bin.js
ADDED
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sources":["../src/cli/bin.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { createProgram } from \"./cli.js\";\n\nconst program = createProgram();\nprogram.parse(process.argv);\n"],"names":[],"mappings":";;AAIA,MAAM,UAAU,cAAA;AAChB,QAAQ,MAAM,QAAQ,IAAI;"}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import inquirer from "inquirer";
|
|
4
|
+
import { resolve, join } from "node:path";
|
|
5
|
+
import { stat, readFile } from "node:fs/promises";
|
|
6
|
+
import { c as createWorkspace, R as RIOTDOC_STRUCTURE, e as parse, b as loadVoice } from "./loader-B7ZeTPQg.js";
|
|
7
|
+
const DOCUMENT_TYPES = [
|
|
8
|
+
{ name: "Blog Post", value: "blog-post" },
|
|
9
|
+
{ name: "Podcast Script", value: "podcast-script" },
|
|
10
|
+
{ name: "Technical Documentation", value: "technical-doc" },
|
|
11
|
+
{ name: "Newsletter", value: "newsletter" },
|
|
12
|
+
{ name: "Custom", value: "custom" }
|
|
13
|
+
];
|
|
14
|
+
async function promptForType() {
|
|
15
|
+
const { type } = await inquirer.prompt([{
|
|
16
|
+
type: "list",
|
|
17
|
+
name: "type",
|
|
18
|
+
message: "Document type:",
|
|
19
|
+
choices: DOCUMENT_TYPES
|
|
20
|
+
}]);
|
|
21
|
+
return type;
|
|
22
|
+
}
|
|
23
|
+
async function promptForTitle(name) {
|
|
24
|
+
const defaultTitle = name.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
25
|
+
const { title } = await inquirer.prompt([{
|
|
26
|
+
type: "input",
|
|
27
|
+
name: "title",
|
|
28
|
+
message: "Document title:",
|
|
29
|
+
default: defaultTitle
|
|
30
|
+
}]);
|
|
31
|
+
return title;
|
|
32
|
+
}
|
|
33
|
+
async function promptForGoal() {
|
|
34
|
+
const { goal } = await inquirer.prompt([{
|
|
35
|
+
type: "input",
|
|
36
|
+
name: "goal",
|
|
37
|
+
message: "What is the primary goal of this document?"
|
|
38
|
+
}]);
|
|
39
|
+
return goal;
|
|
40
|
+
}
|
|
41
|
+
async function promptForAudience() {
|
|
42
|
+
const { audience } = await inquirer.prompt([{
|
|
43
|
+
type: "input",
|
|
44
|
+
name: "audience",
|
|
45
|
+
message: "Who is the target audience?"
|
|
46
|
+
}]);
|
|
47
|
+
return audience;
|
|
48
|
+
}
|
|
49
|
+
async function pathExists(path) {
|
|
50
|
+
try {
|
|
51
|
+
await stat(path);
|
|
52
|
+
return true;
|
|
53
|
+
} catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function registerCreateCommand(program) {
|
|
58
|
+
program.command("create <name>").description("Create a new document workspace").option("-t, --type <type>", "Document type (blog-post, podcast-script, technical-doc, newsletter, custom)").option("-T, --title <title>", "Document title").option("-p, --path <path>", "Base path (default: current directory)").action(async (name, options) => {
|
|
59
|
+
try {
|
|
60
|
+
const basePath = options.path || process.cwd();
|
|
61
|
+
const workspacePath = resolve(join(basePath, name));
|
|
62
|
+
if (await pathExists(workspacePath)) {
|
|
63
|
+
console.error(chalk.red(`Directory already exists: ${workspacePath}`));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
console.log(chalk.cyan("\nš Creating new document workspace\n"));
|
|
67
|
+
const type = options.type || await promptForType();
|
|
68
|
+
const title = options.title || await promptForTitle(name);
|
|
69
|
+
const goal = await promptForGoal();
|
|
70
|
+
const audience = await promptForAudience();
|
|
71
|
+
console.log(chalk.gray("\nCreating workspace..."));
|
|
72
|
+
await createWorkspace({
|
|
73
|
+
path: workspacePath,
|
|
74
|
+
id: name,
|
|
75
|
+
title,
|
|
76
|
+
type,
|
|
77
|
+
objectives: {
|
|
78
|
+
primaryGoal: goal,
|
|
79
|
+
secondaryGoals: [],
|
|
80
|
+
keyTakeaways: []
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if (audience) {
|
|
84
|
+
}
|
|
85
|
+
console.log(chalk.green(`
|
|
86
|
+
ā
Document workspace created: ${workspacePath}`));
|
|
87
|
+
console.log(chalk.cyan("\nš Next steps:\n"));
|
|
88
|
+
console.log(chalk.gray(` 1. Edit voice/tone.md to define your writing voice`));
|
|
89
|
+
console.log(chalk.gray(` 2. Edit OBJECTIVES.md to refine your goals`));
|
|
90
|
+
console.log(chalk.gray(` 3. Run: riotdoc outline ${name}`));
|
|
91
|
+
console.log(chalk.gray(` 4. Run: riotdoc draft ${name}`));
|
|
92
|
+
console.log(chalk.cyan(`
|
|
93
|
+
š Workspace structure:`));
|
|
94
|
+
console.log(chalk.gray(` ${name}/`));
|
|
95
|
+
console.log(chalk.gray(` āāā riotdoc.yaml # Configuration`));
|
|
96
|
+
console.log(chalk.gray(` āāā OBJECTIVES.md # Goals and objectives`));
|
|
97
|
+
console.log(chalk.gray(` āāā OUTLINE.md # Document outline`));
|
|
98
|
+
console.log(chalk.gray(` āāā voice/ # Voice and style`));
|
|
99
|
+
console.log(chalk.gray(` āāā evidence/ # Research and references`));
|
|
100
|
+
console.log(chalk.gray(` āāā drafts/ # Draft iterations`));
|
|
101
|
+
console.log(chalk.gray(` āāā export/ # Final output`));
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error(chalk.red("Failed to create workspace:"), error);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async function loadOutline(workspacePath) {
|
|
109
|
+
const outlinePath = join(workspacePath, RIOTDOC_STRUCTURE.outlineFile);
|
|
110
|
+
return await readFile(outlinePath, "utf-8");
|
|
111
|
+
}
|
|
112
|
+
function buildOutlinePrompt(objectives, voice, documentType) {
|
|
113
|
+
return `Generate an outline for a ${documentType}.
|
|
114
|
+
|
|
115
|
+
## Objectives
|
|
116
|
+
|
|
117
|
+
Primary Goal: ${objectives.primaryGoal}
|
|
118
|
+
|
|
119
|
+
Secondary Goals:
|
|
120
|
+
${objectives.secondaryGoals.map((g) => `- ${g}`).join("\n")}
|
|
121
|
+
|
|
122
|
+
Key Takeaways:
|
|
123
|
+
${objectives.keyTakeaways.map((t) => `- ${t}`).join("\n")}
|
|
124
|
+
|
|
125
|
+
${objectives.emotionalArc ? `Emotional Arc: ${objectives.emotionalArc}` : ""}
|
|
126
|
+
|
|
127
|
+
## Voice & Tone
|
|
128
|
+
|
|
129
|
+
Tone: ${voice.tone}
|
|
130
|
+
Point of View: ${voice.pointOfView}
|
|
131
|
+
|
|
132
|
+
## Output Format
|
|
133
|
+
|
|
134
|
+
Create a markdown outline with:
|
|
135
|
+
1. A compelling hook/introduction
|
|
136
|
+
2. 3-5 main sections with bullet points
|
|
137
|
+
3. A conclusion with call to action
|
|
138
|
+
|
|
139
|
+
Use ## for main sections, ### for subsections, and - for bullet points.
|
|
140
|
+
`;
|
|
141
|
+
}
|
|
142
|
+
async function loadDocument(workspacePath) {
|
|
143
|
+
try {
|
|
144
|
+
const configPath = join(workspacePath, RIOTDOC_STRUCTURE.configFile);
|
|
145
|
+
const content = await readFile(configPath, "utf-8");
|
|
146
|
+
const config = parse(content);
|
|
147
|
+
config.createdAt = new Date(config.createdAt);
|
|
148
|
+
config.updatedAt = new Date(config.updatedAt);
|
|
149
|
+
return {
|
|
150
|
+
config,
|
|
151
|
+
voice: { tone: "", pointOfView: "first", styleNotes: [], avoid: [] },
|
|
152
|
+
objectives: { primaryGoal: "", secondaryGoals: [], keyTakeaways: [] },
|
|
153
|
+
evidence: [],
|
|
154
|
+
drafts: [],
|
|
155
|
+
revisions: [],
|
|
156
|
+
workspacePath
|
|
157
|
+
};
|
|
158
|
+
} catch {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async function loadObjectives(workspacePath) {
|
|
163
|
+
const objectivesPath = join(workspacePath, RIOTDOC_STRUCTURE.objectivesFile);
|
|
164
|
+
try {
|
|
165
|
+
const content = await readFile(objectivesPath, "utf-8");
|
|
166
|
+
return parseObjectivesMarkdown(content);
|
|
167
|
+
} catch {
|
|
168
|
+
return {
|
|
169
|
+
primaryGoal: "",
|
|
170
|
+
secondaryGoals: [],
|
|
171
|
+
keyTakeaways: []
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function parseObjectivesMarkdown(content) {
|
|
176
|
+
const objectives = {
|
|
177
|
+
primaryGoal: "",
|
|
178
|
+
secondaryGoals: [],
|
|
179
|
+
keyTakeaways: []
|
|
180
|
+
};
|
|
181
|
+
const goalMatch = content.match(/##\s*Primary\s+Goal\s*\n+([^\n#]+)/i);
|
|
182
|
+
if (goalMatch) {
|
|
183
|
+
objectives.primaryGoal = goalMatch[1].trim().replace(/^_|_$/g, "");
|
|
184
|
+
}
|
|
185
|
+
const secondaryMatch = content.match(/##\s*Secondary\s+Goals\s*\n([\s\S]*?)(?=\n##|$)/i);
|
|
186
|
+
if (secondaryMatch) {
|
|
187
|
+
const goals = secondaryMatch[1].matchAll(/^[-*]\s+(.+)$/gm);
|
|
188
|
+
for (const goal of goals) {
|
|
189
|
+
const text = goal[1].trim().replace(/^_|_$/g, "");
|
|
190
|
+
if (text && !text.startsWith("Add")) {
|
|
191
|
+
objectives.secondaryGoals.push(text);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const takeawaysMatch = content.match(/##\s*Key\s+Takeaways\s*\n([\s\S]*?)(?=\n##|$)/i);
|
|
196
|
+
if (takeawaysMatch) {
|
|
197
|
+
const takeaways = takeawaysMatch[1].matchAll(/^\d+\.\s+(.+)$/gm);
|
|
198
|
+
for (const takeaway of takeaways) {
|
|
199
|
+
const text = takeaway[1].trim().replace(/^_|_$/g, "");
|
|
200
|
+
if (text && !text.startsWith("Define")) {
|
|
201
|
+
objectives.keyTakeaways.push(text);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const ctaMatch = content.match(/##\s*Call\s+to\s+Action\s*\n+([^\n#]+)/i);
|
|
206
|
+
if (ctaMatch) {
|
|
207
|
+
const cta = ctaMatch[1].trim().replace(/^_|_$/g, "");
|
|
208
|
+
if (cta && !cta.startsWith("What")) {
|
|
209
|
+
objectives.callToAction = cta;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const arcMatch = content.match(/##\s*Emotional\s+Arc\s*\n+([^\n#]+)/i);
|
|
213
|
+
if (arcMatch) {
|
|
214
|
+
const arc = arcMatch[1].trim().replace(/^_|_$/g, "");
|
|
215
|
+
if (arc && !arc.startsWith("Describe")) {
|
|
216
|
+
objectives.emotionalArc = arc;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return objectives;
|
|
220
|
+
}
|
|
221
|
+
function registerOutlineCommand(program) {
|
|
222
|
+
program.command("outline [path]").description("Generate or edit document outline").option("-g, --generate", "Generate outline with AI").option("-e, --edit", "Open outline for editing").action(async (pathArg, options) => {
|
|
223
|
+
try {
|
|
224
|
+
const workspacePath = resolve(pathArg || process.cwd());
|
|
225
|
+
const doc = await loadDocument(workspacePath);
|
|
226
|
+
if (!doc) {
|
|
227
|
+
console.error(chalk.red("Not a RiotDoc workspace"));
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
if (options.generate) {
|
|
231
|
+
console.log(chalk.cyan("Generating outline..."));
|
|
232
|
+
const voice = await loadVoice(workspacePath);
|
|
233
|
+
const objectives = await loadObjectives(workspacePath);
|
|
234
|
+
const prompt = buildOutlinePrompt(objectives, voice, doc.config.type);
|
|
235
|
+
console.log(chalk.yellow("\nOutline generation prompt:"));
|
|
236
|
+
console.log(chalk.gray(prompt));
|
|
237
|
+
console.log(chalk.yellow("\n(AI integration pending - edit OUTLINE.md manually)"));
|
|
238
|
+
} else if (options.edit) {
|
|
239
|
+
const { spawn } = await import("./__vite-browser-external-l0sNRNKZ.js");
|
|
240
|
+
const editor = process.env.EDITOR || "vim";
|
|
241
|
+
const outlinePath = `${workspacePath}/OUTLINE.md`;
|
|
242
|
+
spawn(editor, [outlinePath], { stdio: "inherit" });
|
|
243
|
+
} else {
|
|
244
|
+
const outline = await loadOutline(workspacePath);
|
|
245
|
+
console.log(chalk.cyan("\nš Current Outline:\n"));
|
|
246
|
+
console.log(outline);
|
|
247
|
+
console.log(chalk.gray("\nOptions:"));
|
|
248
|
+
console.log(chalk.gray(" --generate Generate outline with AI"));
|
|
249
|
+
console.log(chalk.gray(" --edit Open outline in editor"));
|
|
250
|
+
}
|
|
251
|
+
} catch (error) {
|
|
252
|
+
console.error(chalk.red("Failed:"), error);
|
|
253
|
+
process.exit(1);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function registerDraftCommand(program) {
|
|
258
|
+
program.command("draft [path]").description("Create a new draft").option("-l, --level <level>", "AI assistance level (generate, expand, revise)", "expand").option("-f, --from <draft>", "Base on existing draft").action(async (_path, _options) => {
|
|
259
|
+
console.log(chalk.yellow("Draft command - AI integration pending"));
|
|
260
|
+
console.log(chalk.gray("\nThis command will:"));
|
|
261
|
+
console.log(chalk.gray(" 1. Load outline and objectives"));
|
|
262
|
+
console.log(chalk.gray(" 2. Apply voice and style rules"));
|
|
263
|
+
console.log(chalk.gray(" 3. Generate draft with specified assistance level"));
|
|
264
|
+
console.log(chalk.gray(" 4. Save to drafts/ directory"));
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function registerReviseCommand(program) {
|
|
268
|
+
program.command("revise [path]").description("Add revision feedback").option("-d, --draft <number>", "Target draft number").option("-m, --message <message>", "Revision feedback").action(async (_path, _options) => {
|
|
269
|
+
console.log(chalk.yellow("Revise command - implementation pending"));
|
|
270
|
+
console.log(chalk.gray("\nThis command will:"));
|
|
271
|
+
console.log(chalk.gray(" 1. Load specified draft"));
|
|
272
|
+
console.log(chalk.gray(" 2. Collect revision feedback"));
|
|
273
|
+
console.log(chalk.gray(" 3. Save to revisions/ directory"));
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
function registerCleanupCommand(program) {
|
|
277
|
+
program.command("cleanup [path]").description("Light editing pass (grammar, clarity)").option("-d, --draft <number>", "Target draft").action(async (_path, _options) => {
|
|
278
|
+
console.log(chalk.yellow("Cleanup command - AI integration pending"));
|
|
279
|
+
console.log(chalk.gray("\nThis command will:"));
|
|
280
|
+
console.log(chalk.gray(" 1. Load draft"));
|
|
281
|
+
console.log(chalk.gray(" 2. Apply light editing for grammar and clarity"));
|
|
282
|
+
console.log(chalk.gray(" 3. Save cleaned version"));
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function registerSpellcheckCommand(program) {
|
|
286
|
+
program.command("spellcheck [path]").description("Fix spelling and grammar only").option("-d, --draft <number>", "Target draft").action(async (_path, _options) => {
|
|
287
|
+
console.log(chalk.yellow("Spellcheck command - implementation pending"));
|
|
288
|
+
console.log(chalk.gray("\nThis command will:"));
|
|
289
|
+
console.log(chalk.gray(" 1. Load draft"));
|
|
290
|
+
console.log(chalk.gray(" 2. Check spelling and basic grammar"));
|
|
291
|
+
console.log(chalk.gray(" 3. Report or fix issues"));
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
function registerExportCommand(program) {
|
|
295
|
+
program.command("export [path]").description("Export publication-ready document").option("-d, --draft <number>", "Source draft").option("-o, --output <file>", "Output file name").action(async (_path, _options) => {
|
|
296
|
+
console.log(chalk.yellow("Export command - implementation pending"));
|
|
297
|
+
console.log(chalk.gray("\nThis command will:"));
|
|
298
|
+
console.log(chalk.gray(" 1. Load specified draft"));
|
|
299
|
+
console.log(chalk.gray(" 2. Apply final formatting"));
|
|
300
|
+
console.log(chalk.gray(" 3. Export to export/ directory"));
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
function registerStatusCommand(program) {
|
|
304
|
+
program.command("status [path]").description("Show document status").action(async (pathArg) => {
|
|
305
|
+
try {
|
|
306
|
+
const workspacePath = resolve(pathArg || process.cwd());
|
|
307
|
+
const doc = await loadDocument(workspacePath);
|
|
308
|
+
if (!doc) {
|
|
309
|
+
console.error(chalk.red("Not a RiotDoc workspace"));
|
|
310
|
+
process.exit(1);
|
|
311
|
+
}
|
|
312
|
+
console.log(chalk.cyan("\nš Document Status\n"));
|
|
313
|
+
console.log(chalk.gray(`Title: ${doc.config.title}`));
|
|
314
|
+
console.log(chalk.gray(`Type: ${doc.config.type}`));
|
|
315
|
+
console.log(chalk.gray(`Status: ${doc.config.status}`));
|
|
316
|
+
console.log(chalk.gray(`Created: ${doc.config.createdAt.toLocaleDateString()}`));
|
|
317
|
+
console.log(chalk.gray(`Updated: ${doc.config.updatedAt.toLocaleDateString()}`));
|
|
318
|
+
if (doc.config.targetWordCount) {
|
|
319
|
+
console.log(chalk.gray(`Target: ${doc.config.targetWordCount} words`));
|
|
320
|
+
}
|
|
321
|
+
console.log(chalk.cyan("\nš Workspace: ") + chalk.gray(workspacePath));
|
|
322
|
+
} catch (error) {
|
|
323
|
+
console.error(chalk.red("Failed:"), error);
|
|
324
|
+
process.exit(1);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
const VERSION = "1.0.0-dev.0";
|
|
329
|
+
function createProgram() {
|
|
330
|
+
const program = new Command();
|
|
331
|
+
program.name("riotdoc").description("Structured document creation with AI assistance").version(VERSION).configureHelp({
|
|
332
|
+
sortSubcommands: true
|
|
333
|
+
});
|
|
334
|
+
registerCreateCommand(program);
|
|
335
|
+
registerOutlineCommand(program);
|
|
336
|
+
registerDraftCommand(program);
|
|
337
|
+
registerReviseCommand(program);
|
|
338
|
+
registerCleanupCommand(program);
|
|
339
|
+
registerSpellcheckCommand(program);
|
|
340
|
+
registerExportCommand(program);
|
|
341
|
+
registerStatusCommand(program);
|
|
342
|
+
program.option("-v, --verbose", "Verbose output").option("--json", "Output as JSON").option("--no-color", "Disable colored output");
|
|
343
|
+
program.on("command:*", () => {
|
|
344
|
+
console.error(chalk.red(`Unknown command: ${program.args.join(" ")}`));
|
|
345
|
+
console.log(`Run ${chalk.cyan("riotdoc --help")} for usage.`);
|
|
346
|
+
process.exit(1);
|
|
347
|
+
});
|
|
348
|
+
return program;
|
|
349
|
+
}
|
|
350
|
+
export {
|
|
351
|
+
createProgram
|
|
352
|
+
};
|
|
353
|
+
//# sourceMappingURL=cli.js.map
|