@smartdoc/cli 0.4.0 → 0.4.2
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/README.md +3 -1
- package/lib/agents.js +11 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Review your documents with your own AI. SmartDoc is a desktop app that shows you
|
|
|
4
4
|
|
|
5
5
|
This package is the `smartdoc` command.
|
|
6
6
|
|
|
7
|
+
SmartDoc must be installed in your Applications folder: that's where `setup` and your agents expect it. If you download it from the website, drag it into Applications.
|
|
8
|
+
|
|
7
9
|
## Install the app
|
|
8
10
|
|
|
9
11
|
```sh
|
|
@@ -18,7 +20,7 @@ Downloads the latest SmartDoc for your Mac from the project's [GitHub releases](
|
|
|
18
20
|
npx @smartdoc/cli setup
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
Finds SmartDoc
|
|
23
|
+
Finds SmartDoc in your Applications folder and adds it to Claude Desktop and Claude Code, asking before each. (`--yes` doesn't ask.) Claude Desktop's settings file keeps everything else in it, and a copy of the file as it was is saved beside it. Agents run the connection built into the app, so they don't need Node.js once they're set up. You can do the same from the app: click its MCP server status, at the top right.
|
|
22
24
|
|
|
23
25
|
## Check the connection
|
|
24
26
|
|
package/lib/agents.js
CHANGED
|
@@ -21,16 +21,19 @@ export function launcherFor(appBundle) {
|
|
|
21
21
|
// A word for a shell, quoted only if it needs it.
|
|
22
22
|
const shellWord = (word) => (/^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`);
|
|
23
23
|
|
|
24
|
+
// Each AI app knows SmartDoc by `name`: smartdoc, or smartdoc-dev for a development copy, so the
|
|
25
|
+
// two can be set up side by side.
|
|
26
|
+
|
|
24
27
|
// Claude Code's command to add it, for every project (user scope).
|
|
25
|
-
export const claudeCodeCommand = ({ command, args, env }) => [
|
|
26
|
-
|
|
28
|
+
export const claudeCodeCommand = ({ command, args, env }, name = 'smartdoc') => [
|
|
29
|
+
`claude mcp add --scope user ${name}`,
|
|
27
30
|
...Object.entries(env).map(([k, v]) => `-e ${shellWord(`${k}=${v}`)}`),
|
|
28
31
|
'--',
|
|
29
32
|
...[command, ...args].map(shellWord),
|
|
30
33
|
].join(' ');
|
|
31
34
|
|
|
32
35
|
// The JSON config entry that Claude Desktop and most other agents take.
|
|
33
|
-
export const configJson = (entry) => JSON.stringify({ mcpServers: {
|
|
36
|
+
export const configJson = (entry, name = 'smartdoc') => JSON.stringify({ mcpServers: { [name]: entry } }, null, 2);
|
|
34
37
|
|
|
35
38
|
// --- Claude Desktop ---------------------------------------------------------------------------
|
|
36
39
|
|
|
@@ -75,24 +78,24 @@ async function hasExtension(file) {
|
|
|
75
78
|
// Where Claude Desktop stands: 'not-installed' (no Claude Desktop folder), 'unreadable' (its config
|
|
76
79
|
// file isn't JSON), 'not-added', 'added', or 'different' (SmartDoc is set up differently, say from
|
|
77
80
|
// before the app moved); and whether the old extension is installed too.
|
|
78
|
-
export async function claudeDesktopStatus(file, entry) {
|
|
81
|
+
export async function claudeDesktopStatus(file, entry, name = 'smartdoc') {
|
|
79
82
|
if (!existsSync(path.dirname(file))) return { state: 'not-installed' };
|
|
80
83
|
const config = await readConfig(file);
|
|
81
84
|
const extension = await hasExtension(file);
|
|
82
85
|
if (!config) return { state: 'unreadable', file, extension };
|
|
83
|
-
const current = config.mcpServers?.
|
|
86
|
+
const current = config.mcpServers?.[name];
|
|
84
87
|
if (!current) return { state: 'not-added', extension };
|
|
85
88
|
return { state: isDeepStrictEqual(current, entry) ? 'added' : 'different', extension };
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
// Adds SmartDoc to Claude Desktop's config file, or brings its entry up to date, keeping
|
|
89
92
|
// everything else in the file. The file as it was is copied beside it first.
|
|
90
|
-
export async function addToClaudeDesktop(file, entry) {
|
|
93
|
+
export async function addToClaudeDesktop(file, entry, name = 'smartdoc') {
|
|
91
94
|
const config = await readConfig(file);
|
|
92
95
|
if (!config) throw new Error(`Claude Desktop’s settings file isn’t in a form SmartDoc can safely change, so it was left alone: ${file}`);
|
|
93
96
|
if (existsSync(file)) await fs.copyFile(file, `${file}.before-smartdoc`);
|
|
94
|
-
const updated = { ...config, mcpServers: { ...(config.mcpServers ?? {}),
|
|
97
|
+
const updated = { ...config, mcpServers: { ...(config.mcpServers ?? {}), [name]: entry } };
|
|
95
98
|
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
96
99
|
await fs.writeFile(file, `${JSON.stringify(updated, null, 2)}\n`);
|
|
97
|
-
return claudeDesktopStatus(file, entry);
|
|
100
|
+
return claudeDesktopStatus(file, entry, name);
|
|
98
101
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartdoc/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "The smartdoc command: sets up Claude Desktop and Claude Code to use the SmartDoc app, checks the connection, and runs SmartDoc's MCP connection for agents set up with npx.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|