@doquflow/cli 0.1.1 → 0.3.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.
@@ -0,0 +1,327 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runInteractive = runInteractive;
7
+ const promises_1 = __importDefault(require("node:fs/promises"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const node_readline_1 = __importDefault(require("node:readline"));
10
+ async function prompt(question) {
11
+ const rl = node_readline_1.default.createInterface({
12
+ input: process.stdin,
13
+ output: process.stdout,
14
+ });
15
+ return new Promise((resolve) => {
16
+ rl.question(question, (answer) => {
17
+ rl.close();
18
+ resolve(answer);
19
+ });
20
+ });
21
+ }
22
+ async function selectDomain() {
23
+ console.log("\nšŸ“š What domain is your wiki for?");
24
+ console.log(" 1) Code & Architecture");
25
+ console.log(" 2) Research & Analysis");
26
+ console.log(" 3) Business & Markets");
27
+ console.log(" 4) Personal Knowledge");
28
+ let selection = "";
29
+ while (!["1", "2", "3", "4"].includes(selection)) {
30
+ selection = await prompt("Select (1-4): ");
31
+ }
32
+ const domains = {
33
+ "1": "code",
34
+ "2": "research",
35
+ "3": "business",
36
+ "4": "personal",
37
+ };
38
+ return domains[selection];
39
+ }
40
+ async function getProjectInfo(domain) {
41
+ console.log(`\nšŸ“ Tell me about your ${domain} wiki`);
42
+ const name = await prompt("Project name (e.g., 'MyProject', 'Research2026'): ");
43
+ const description = await prompt("Brief description (what will this wiki track?): ");
44
+ return { name, description };
45
+ }
46
+ function getSchemaForDomain(domain) {
47
+ const schemas = {
48
+ code: `# Docuflow Wiki Schema - Code/Architecture
49
+
50
+ ## Domain
51
+ Architecture and codebase documentation.
52
+
53
+ ## Wiki Structure
54
+
55
+ ### Entities (entities/)
56
+ - Services: key microservices and components
57
+ - APIs: public interfaces and endpoints
58
+ - Databases: data models and schemas
59
+ - Frameworks: libraries and tools used
60
+
61
+ ### Concepts (concepts/)
62
+ - Design Patterns: architectural and coding patterns
63
+ - Principles: design principles and guidelines
64
+ - Integrations: how components work together
65
+ - Configuration: important settings and options
66
+
67
+ ### Syntheses (syntheses/)
68
+ - Architecture Overview: system design
69
+ - Decision Records: design decisions
70
+ - Deployment Guide: how to deploy
71
+ - API Reference: complete API docs
72
+
73
+ ### Timelines (timelines/)
74
+ - Version History: evolution of the system
75
+ - Roadmap: planned changes
76
+
77
+ ## Cross-Reference Patterns
78
+ - "integrates with" - components/services that work together
79
+ - "implemented by" - which entities implement a concept
80
+ - "uses pattern" - which architecture patterns apply
81
+ - "depends on" - dependencies between components
82
+
83
+ ## Metadata
84
+ Each page should include:
85
+ - created_at: when first documented
86
+ - updated_at: last update date
87
+ - tech_stack: relevant technologies
88
+ - contributors: who wrote/contributed
89
+ `,
90
+ research: `# Docuflow Wiki Schema - Research
91
+
92
+ ## Domain
93
+ Research findings and analysis.
94
+
95
+ ## Wiki Structure
96
+
97
+ ### Entities (entities/)
98
+ - Papers: academic papers and articles
99
+ - Researchers: key people in the field
100
+ - Conferences: important venues
101
+ - Datasets: data sources used
102
+
103
+ ### Concepts (concepts/)
104
+ - Methodologies: research methods
105
+ - Theories: key theories and frameworks
106
+ - Open Problems: unsolved questions
107
+ - Keywords: important terms
108
+
109
+ ### Syntheses (syntheses/)
110
+ - Literature Review: synthesis of papers
111
+ - Findings: key discoveries
112
+ - Future Work: research directions
113
+ - Contradictions: areas of disagreement
114
+
115
+ ### Timelines (timelines/)
116
+ - Research Evolution: how field evolved
117
+ - Timeline of Discoveries: key milestones
118
+
119
+ ## Cross-Reference Patterns
120
+ - "cites" - references between papers
121
+ - "extends" - builds on prior work
122
+ - "contradicts" - disagreement between sources
123
+ - "validates" - experimental confirmation
124
+ - "relates to" - topical connection
125
+
126
+ ## Metadata
127
+ Each page should include:
128
+ - created_at: when added
129
+ - updated_at: last refresh
130
+ - sources: which papers/sources
131
+ - citations: number of times cited
132
+ - confidence: how confident in findings
133
+ `,
134
+ business: `# Docuflow Wiki Schema - Business
135
+
136
+ ## Domain
137
+ Business and competitive analysis.
138
+
139
+ ## Wiki Structure
140
+
141
+ ### Entities (entities/)
142
+ - Companies: competitors and partners
143
+ - Products: key offerings
144
+ - Markets: market segments
145
+ - Customers: customer types
146
+
147
+ ### Concepts (concepts/)
148
+ - Business Models: how companies make money
149
+ - Market Segments: addressable markets
150
+ - Capabilities: key competitive advantages
151
+ - Trends: market trends
152
+
153
+ ### Syntheses (syntheses/)
154
+ - Competitive Analysis: comparison matrix
155
+ - Market Overview: market positioning
156
+ - Opportunities: growth opportunities
157
+ - Risks: market risks
158
+
159
+ ### Timelines (timelines/)
160
+ - Market Evolution: how market changed
161
+ - Competitive Timeline: competitor moves
162
+
163
+ ## Cross-Reference Patterns
164
+ - "competes with" - direct competitors
165
+ - "targets" - goes after customer/market
166
+ - "partners with" - partnerships
167
+ - "disrupts" - disruption threat
168
+ - "complements" - complementary products
169
+
170
+ ## Metadata
171
+ Each page should include:
172
+ - created_at: when first documented
173
+ - updated_at: last update
174
+ - market_size: TAM/SAM/SOM if known
175
+ - growth_rate: annual growth
176
+ - sources: where info came from
177
+ `,
178
+ personal: `# Docuflow Wiki Schema - Personal
179
+
180
+ ## Domain
181
+ Personal knowledge, learning, and goals.
182
+
183
+ ## Wiki Structure
184
+
185
+ ### Entities (entities/)
186
+ - Topics: areas of interest/expertise
187
+ - Resources: books, courses, websites
188
+ - People: mentors, collaborators
189
+ - Projects: personal projects
190
+
191
+ ### Concepts (concepts/)
192
+ - Learning Goals: what to learn
193
+ - Skills: competencies to develop
194
+ - Insights: key personal learnings
195
+ - Practices: habits and routines
196
+
197
+ ### Syntheses (syntheses/)
198
+ - Reflections: deeper thinking
199
+ - Progress Updates: tracking learning
200
+ - Connections: how ideas relate
201
+ - Action Plans: what to do next
202
+
203
+ ### Timelines (timelines/)
204
+ - Learning Journey: personal evolution
205
+ - Milestones: key achievements
206
+
207
+ ## Cross-Reference Patterns
208
+ - "builds on" - prerequisite knowledge
209
+ - "connects to" - related topics
210
+ - "informs" - influences thinking
211
+ - "inspires" - inspiration source
212
+ - "applies to" - practical application
213
+
214
+ ## Metadata
215
+ Each page should include:
216
+ - created_at: when started learning
217
+ - updated_at: last review
218
+ - relevance: importance (high/medium/low)
219
+ - mastery_level: expertise level (beginner/intermediate/expert)
220
+ - time_invested: hours spent
221
+ `,
222
+ };
223
+ return schemas[domain];
224
+ }
225
+ function getPlanningTemplate(domain, projectName) {
226
+ return `# ${projectName} Wiki Plan
227
+
228
+ ## Goal
229
+ Document and organize knowledge for ${projectName}.
230
+
231
+ ## Initial Sources to Add
232
+ 1. [ ] README or main overview
233
+ 2. [ ] Key source file 1
234
+ 3. [ ] Key source file 2
235
+
236
+ ## Key Entities to Define
237
+ - Entity 1: [description]
238
+ - Entity 2: [description]
239
+
240
+ ## Key Concepts to Extract
241
+ - Concept 1: [description]
242
+ - Concept 2: [description]
243
+
244
+ ## First Questions to Answer
245
+ 1. [What do you want to understand first?]
246
+ 2. [What relationships are important?]
247
+
248
+ ## Success Criteria
249
+ - [ ] Successfully ingested first 3 sources
250
+ - [ ] Created 10+ wiki pages
251
+ - [ ] Can answer key questions
252
+ - [ ] Wiki is at 80%+ health score
253
+
254
+ ## Next Review Date
255
+ [Date for first maintenance check]
256
+ `;
257
+ }
258
+ async function runInteractive() {
259
+ console.log("\n🌟 Welcome to Docuflow Wiki Setup!\n");
260
+ console.log("I'll help you set up a wiki for your project.");
261
+ console.log("This should take about 2 minutes. You can customize later.\n");
262
+ // Get domain
263
+ const domain = await selectDomain();
264
+ console.log(`āœ“ Selected: ${domain}`);
265
+ // Get project info
266
+ const { name: projectName, description } = await getProjectInfo(domain);
267
+ console.log(`āœ“ Project: "${projectName}" - ${description}`);
268
+ // Confirm setup
269
+ console.log("\n✨ I'll create a wiki structure for you with recommended schema.");
270
+ const confirm = await prompt("Ready to proceed? (y/n): ");
271
+ if (confirm.toLowerCase() !== "y") {
272
+ console.log("\nšŸ‘‹ Setup cancelled.");
273
+ return;
274
+ }
275
+ // Get schema for domain
276
+ const domainSchema = getSchemaForDomain(domain);
277
+ const planTemplate = getPlanningTemplate(domain, projectName);
278
+ console.log("\nšŸ“ Creating wiki structure...");
279
+ const docuDir = node_path_1.default.join(process.cwd(), ".docuflow");
280
+ const wikiDir = node_path_1.default.join(docuDir, "wiki");
281
+ // Create directories
282
+ await promises_1.default.mkdir(node_path_1.default.join(wikiDir, "entities"), { recursive: true });
283
+ await promises_1.default.mkdir(node_path_1.default.join(wikiDir, "concepts"), { recursive: true });
284
+ await promises_1.default.mkdir(node_path_1.default.join(wikiDir, "syntheses"), { recursive: true });
285
+ await promises_1.default.mkdir(node_path_1.default.join(wikiDir, "timelines"), { recursive: true });
286
+ await promises_1.default.mkdir(node_path_1.default.join(docuDir, "sources"), { recursive: true });
287
+ await promises_1.default.mkdir(node_path_1.default.join(docuDir, "specs"), { recursive: true });
288
+ console.log(" āœ“ Created wiki directories");
289
+ // Write schema with domain-specific content
290
+ await promises_1.default.writeFile(node_path_1.default.join(docuDir, "schema.md"), domainSchema, "utf8");
291
+ console.log(" āœ“ Created schema.md with domain-specific structure");
292
+ // Write index and log
293
+ const indexContent = `# Wiki Index
294
+
295
+ Auto-maintained catalog of all wiki pages.
296
+
297
+ ## Generated: ${new Date().toISOString()}
298
+
299
+ (Index is automatically updated as you ingest sources)
300
+ `;
301
+ await promises_1.default.writeFile(node_path_1.default.join(docuDir, "index.md"), indexContent, "utf8");
302
+ console.log(" āœ“ Created index.md");
303
+ const logContent = `# Operation Log
304
+
305
+ Record of all wiki operations.
306
+
307
+ ## [${new Date().toISOString()}] init | Wiki initialized
308
+ - Domain: ${domain}
309
+ - Project: ${projectName}
310
+ - Description: ${description}
311
+ `;
312
+ await promises_1.default.writeFile(node_path_1.default.join(docuDir, "log.md"), logContent, "utf8");
313
+ console.log(" āœ“ Created log.md");
314
+ // Write planning template
315
+ const planPath = node_path_1.default.join(docuDir, "PLAN.md");
316
+ await promises_1.default.writeFile(planPath, planTemplate, "utf8");
317
+ console.log(" āœ“ Created PLAN.md (interactive planning guide)");
318
+ console.log("\nāœ… Wiki successfully initialized!\n");
319
+ // Print summary and next steps
320
+ console.log("šŸ“‹ Next Steps:");
321
+ console.log(" 1. Review your schema: .docuflow/schema.md");
322
+ console.log(" 2. Review your plan: .docuflow/PLAN.md");
323
+ console.log(" 3. Add first source: copy to .docuflow/sources/");
324
+ console.log(" 4. Ask Claude: 'Ingest README.md into my wiki'");
325
+ console.log(" 5. Ask Claude: 'What should my wiki contain?'");
326
+ console.log("\nšŸ’” Tip: Open .claude/instructions.md to understand how Claude uses Docuflow\n");
327
+ }
@@ -28,6 +28,35 @@ function resolveServerBin() {
28
28
  return node_path_1.default.resolve(__dirname, "..", "..", "server", "dist", "index.js");
29
29
  }
30
30
  }
31
+ async function copyTemplateFile(templateName, destPath) {
32
+ try {
33
+ // Try package-installed location first
34
+ const templatePath = require.resolve(`@doquflow/cli/templates/${templateName}`);
35
+ const content = await promises_1.default.readFile(templatePath, "utf8");
36
+ await promises_1.default.writeFile(destPath, content, "utf8");
37
+ }
38
+ catch {
39
+ try {
40
+ // Fallback: monorepo sibling path (dev environment)
41
+ const templatePath = node_path_1.default.resolve(__dirname, "..", "..", "templates", templateName);
42
+ const content = await promises_1.default.readFile(templatePath, "utf8");
43
+ await promises_1.default.writeFile(destPath, content, "utf8");
44
+ }
45
+ catch (err) {
46
+ // If template not found, create a minimal version
47
+ console.warn(` ⚠ Could not find template for ${templateName}, creating minimal version`);
48
+ if (templateName === "schema.md") {
49
+ await promises_1.default.writeFile(destPath, "# Docuflow Wiki Schema\n\n## Domain\n[Edit this file to customize your wiki]\n", "utf8");
50
+ }
51
+ else if (templateName === "index.md") {
52
+ await promises_1.default.writeFile(destPath, "# Wiki Index\n\nAuto-maintained catalog of pages.\n", "utf8");
53
+ }
54
+ else if (templateName === "log.md") {
55
+ await promises_1.default.writeFile(destPath, "# Operation Log\n\nRecord of wiki operations.\n", "utf8");
56
+ }
57
+ }
58
+ }
59
+ }
31
60
  async function run() {
32
61
  const configPath = getClaudeDesktopConfigPath();
33
62
  const serverBin = resolveServerBin();
@@ -46,9 +75,25 @@ async function run() {
46
75
  config.mcpServers.docuflow = { command: nodeBin, args: [serverBin] };
47
76
  await promises_1.default.mkdir(node_path_1.default.dirname(configPath), { recursive: true });
48
77
  await promises_1.default.writeFile(configPath, JSON.stringify(config, null, 2) + "\n", "utf8");
49
- // Create .docuflow/specs/ in cwd
50
- const specsDir = node_path_1.default.join(process.cwd(), ".docuflow", "specs");
78
+ // Create .docuflow/ directory structure
79
+ const docuflowDir = node_path_1.default.join(process.cwd(), ".docuflow");
80
+ const specsDir = node_path_1.default.join(docuflowDir, "specs");
81
+ const wikiDir = node_path_1.default.join(docuflowDir, "wiki");
82
+ const sourcesDir = node_path_1.default.join(docuflowDir, "sources");
83
+ const entitiesDir = node_path_1.default.join(wikiDir, "entities");
84
+ const conceptsDir = node_path_1.default.join(wikiDir, "concepts");
85
+ const timelinesDir = node_path_1.default.join(wikiDir, "timelines");
86
+ const synthesesDir = node_path_1.default.join(wikiDir, "syntheses");
51
87
  await promises_1.default.mkdir(specsDir, { recursive: true });
88
+ await promises_1.default.mkdir(entitiesDir, { recursive: true });
89
+ await promises_1.default.mkdir(conceptsDir, { recursive: true });
90
+ await promises_1.default.mkdir(timelinesDir, { recursive: true });
91
+ await promises_1.default.mkdir(synthesesDir, { recursive: true });
92
+ await promises_1.default.mkdir(sourcesDir, { recursive: true });
93
+ // Copy or create template files
94
+ await copyTemplateFile("schema.md", node_path_1.default.join(docuflowDir, "schema.md"));
95
+ await copyTemplateFile("index.md", node_path_1.default.join(docuflowDir, "index.md"));
96
+ await copyTemplateFile("log.md", node_path_1.default.join(docuflowDir, "log.md"));
52
97
  // Add .docuflow/ to .gitignore if present and not already listed
53
98
  const gitignorePath = node_path_1.default.join(process.cwd(), ".gitignore");
54
99
  if (node_fs_1.default.existsSync(gitignorePath)) {
@@ -57,11 +102,28 @@ async function run() {
57
102
  await promises_1.default.appendFile(gitignorePath, "\n# Docuflow\n.docuflow/\n");
58
103
  }
59
104
  }
60
- console.log("Docuflow initialised successfully.");
105
+ console.log("āœ“ Docuflow initialised successfully.");
106
+ console.log("");
107
+ console.log("šŸ“ Structure created:");
108
+ console.log(` ${docuflowDir}/`);
109
+ console.log(` ā”œā”€ā”€ specs/ (for legacy specs)`);
110
+ console.log(` ā”œā”€ā”€ wiki/ (LLM-generated pages)`);
111
+ console.log(` │ ā”œā”€ā”€ entities/`);
112
+ console.log(` │ ā”œā”€ā”€ concepts/`);
113
+ console.log(` │ ā”œā”€ā”€ timelines/`);
114
+ console.log(` │ └── syntheses/`);
115
+ console.log(` ā”œā”€ā”€ sources/ (immutable raw files)`);
116
+ console.log(` ā”œā”€ā”€ schema.md (wiki configuration)`);
117
+ console.log(` ā”œā”€ā”€ index.md (auto-maintained catalog)`);
118
+ console.log(` └── log.md (operation log)`);
61
119
  console.log("");
120
+ console.log("šŸ”§ MCP Configuration:");
62
121
  console.log(` MCP key: mcpServers.docuflow`);
63
122
  console.log(` Config file: ${configPath}`);
64
- console.log(` Specs dir: ${specsDir}`);
65
123
  console.log("");
66
- console.log("Restart Claude Desktop to activate.");
124
+ console.log("šŸ“– Next steps:");
125
+ console.log(" 1. Edit .docuflow/schema.md to customize your wiki");
126
+ console.log(" 2. Add source files to .docuflow/sources/");
127
+ console.log(" 3. Use LLM Wiki tools to ingest, query, and maintain wiki");
128
+ console.log(" 4. Restart Claude Desktop to activate");
67
129
  }
package/package.json CHANGED
@@ -1,16 +1,39 @@
1
1
  {
2
2
  "name": "@doquflow/cli",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "CLI for setting up Docuflow in your project",
5
5
  "author": "Docuflow <hello@doquflows.dev>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/doquflows/docuflow",
8
- "repository": { "type": "git", "url": "https://github.com/doquflows/docuflow.git" },
9
- "bugs": { "url": "https://github.com/doquflows/docuflow/issues" },
10
- "keywords": ["mcp", "ai-agents", "claude-code", "documentation", "developer-tools"],
11
- "bin": { "docuflow": "./dist/index.js" },
12
- "files": ["dist/**", "README.md"],
13
- "scripts": { "build": "tsc" },
14
- "dependencies": { "@doquflow/server": "0.1.1" },
15
- "devDependencies": { "@types/node": "^22.0.0", "typescript": "^5.6.0" }
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/doquflows/docuflow.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/doquflows/docuflow/issues"
14
+ },
15
+ "keywords": [
16
+ "mcp",
17
+ "ai-agents",
18
+ "claude-code",
19
+ "documentation",
20
+ "developer-tools"
21
+ ],
22
+ "bin": {
23
+ "docuflow": "./dist/index.js"
24
+ },
25
+ "files": [
26
+ "dist/**",
27
+ "README.md"
28
+ ],
29
+ "scripts": {
30
+ "build": "tsc"
31
+ },
32
+ "dependencies": {
33
+ "@doquflow/server": "0.3.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^22.0.0",
37
+ "typescript": "^5.6.0"
38
+ }
16
39
  }