openwriter 0.1.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/dist/bin/pad.js +64 -0
- package/dist/client/assets/index-DNJs7lC-.js +205 -0
- package/dist/client/assets/index-WweytMO1.css +1 -0
- package/dist/client/index.html +16 -0
- package/dist/server/compact.js +214 -0
- package/dist/server/documents.js +230 -0
- package/dist/server/export-html-template.js +109 -0
- package/dist/server/export-routes.js +96 -0
- package/dist/server/gdoc-import.js +200 -0
- package/dist/server/git-sync.js +272 -0
- package/dist/server/helpers.js +87 -0
- package/dist/server/image-upload.js +55 -0
- package/dist/server/index.js +315 -0
- package/dist/server/link-routes.js +116 -0
- package/dist/server/markdown-parse.js +405 -0
- package/dist/server/markdown-serialize.js +263 -0
- package/dist/server/markdown.js +6 -0
- package/dist/server/mcp-client.js +37 -0
- package/dist/server/mcp.js +457 -0
- package/dist/server/plugin-loader.js +36 -0
- package/dist/server/plugin-types.js +5 -0
- package/dist/server/state.js +749 -0
- package/dist/server/sync-routes.js +75 -0
- package/dist/server/text-edit.js +249 -0
- package/dist/server/version-routes.js +79 -0
- package/dist/server/versions.js +198 -0
- package/dist/server/workspace-routes.js +176 -0
- package/dist/server/workspace-tags.js +33 -0
- package/dist/server/workspace-tree.js +200 -0
- package/dist/server/workspace-types.js +38 -0
- package/dist/server/workspaces.js +257 -0
- package/dist/server/ws.js +211 -0
- package/package.json +88 -0
package/dist/bin/pad.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI entry point for OpenWriter.
|
|
4
|
+
* Usage: npx openwriter [--api-key av_live_xxx] [--port 5050] [--no-open] [--av-url URL] [--plugins name1,name2]
|
|
5
|
+
*
|
|
6
|
+
* API key resolution (first wins):
|
|
7
|
+
* 1. --api-key CLI flag
|
|
8
|
+
* 2. AV_API_KEY environment variable
|
|
9
|
+
* 3. Saved in ~/.openwriter/config.json (from a previous --api-key)
|
|
10
|
+
*
|
|
11
|
+
* If no key found, server starts anyway — plugins that need it will report errors.
|
|
12
|
+
*/
|
|
13
|
+
// Redirect all console output to stderr so MCP stdio protocol stays clean on stdout
|
|
14
|
+
const originalLog = console.log;
|
|
15
|
+
console.log = (...args) => console.error(...args);
|
|
16
|
+
import { startServer } from '../server/index.js';
|
|
17
|
+
import { readConfig, saveConfig } from '../server/helpers.js';
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
let port = 5050;
|
|
20
|
+
let noOpen = false;
|
|
21
|
+
let cliApiKey;
|
|
22
|
+
let cliAvUrl;
|
|
23
|
+
let plugins = [];
|
|
24
|
+
for (let i = 0; i < args.length; i++) {
|
|
25
|
+
if (args[i] === '--port' && args[i + 1]) {
|
|
26
|
+
port = parseInt(args[i + 1], 10);
|
|
27
|
+
i++;
|
|
28
|
+
}
|
|
29
|
+
if (args[i] === '--no-open') {
|
|
30
|
+
noOpen = true;
|
|
31
|
+
}
|
|
32
|
+
if (args[i] === '--api-key' && args[i + 1]) {
|
|
33
|
+
cliApiKey = args[i + 1];
|
|
34
|
+
i++;
|
|
35
|
+
}
|
|
36
|
+
if (args[i] === '--av-url' && args[i + 1]) {
|
|
37
|
+
cliAvUrl = args[i + 1];
|
|
38
|
+
i++;
|
|
39
|
+
}
|
|
40
|
+
if (args[i] === '--plugins' && args[i + 1]) {
|
|
41
|
+
plugins = args[i + 1].split(',').map((s) => s.trim()).filter(Boolean);
|
|
42
|
+
i++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Resolve API key: CLI flag → env var → saved config
|
|
46
|
+
const config = readConfig();
|
|
47
|
+
const avApiKey = cliApiKey || process.env.AV_API_KEY || config.avApiKey || '';
|
|
48
|
+
const avBackendUrl = cliAvUrl || process.env.AV_BACKEND_URL || config.avBackendUrl;
|
|
49
|
+
// Persist new values to config so future starts don't need them
|
|
50
|
+
const updates = {};
|
|
51
|
+
if (cliApiKey && cliApiKey !== config.avApiKey)
|
|
52
|
+
updates.avApiKey = cliApiKey;
|
|
53
|
+
if (cliAvUrl && cliAvUrl !== config.avBackendUrl)
|
|
54
|
+
updates.avBackendUrl = cliAvUrl;
|
|
55
|
+
if (Object.keys(updates).length > 0) {
|
|
56
|
+
saveConfig(updates);
|
|
57
|
+
console.log('Config saved to ~/.openwriter/config.json');
|
|
58
|
+
}
|
|
59
|
+
// Set env vars for downstream code (plugins read process.env)
|
|
60
|
+
if (avApiKey)
|
|
61
|
+
process.env.AV_API_KEY = avApiKey;
|
|
62
|
+
if (avBackendUrl)
|
|
63
|
+
process.env.AV_BACKEND_URL = avBackendUrl;
|
|
64
|
+
startServer({ port, noOpen, plugins });
|