vaultctl 0.3.2 → 0.4.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/README.md +9 -11
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.js +79 -0
- package/dist/index.js +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,13 +14,10 @@ MCP servers for Obsidian + Claude Code CLI are [fundamentally broken](https://gi
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
npm install -g vaultctl
|
|
17
|
+
vaultctl config set vault ~/path/to/your/vault
|
|
17
18
|
```
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
export VAULTCTL_PATH="$HOME/path/to/your/vault"
|
|
23
|
-
```
|
|
20
|
+
That's it. The config is saved to `~/.vaultctlrc` and works everywhere — interactive shells, AI agents, cron jobs, CI.
|
|
24
21
|
|
|
25
22
|
### From Source
|
|
26
23
|
|
|
@@ -29,13 +26,8 @@ git clone https://github.com/testing-in-production/vaultctl.git
|
|
|
29
26
|
cd vaultctl
|
|
30
27
|
npm install
|
|
31
28
|
npm run build
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Then add to your shell profile:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
export VAULTCTL_PATH="$HOME/path/to/your/vault"
|
|
38
29
|
alias vaultctl="node $HOME/vaultctl/packages/cli/dist/index.js"
|
|
30
|
+
vaultctl config set vault ~/path/to/your/vault
|
|
39
31
|
```
|
|
40
32
|
|
|
41
33
|
## Usage
|
|
@@ -126,6 +118,12 @@ Exit codes: `0` = success, `1` = error, `2` = no results found.
|
|
|
126
118
|
3. Walk up from current directory looking for `.obsidian/`
|
|
127
119
|
4. `~/.vaultctlrc` config file
|
|
128
120
|
|
|
121
|
+
### Why `config set` Instead of Environment Variables?
|
|
122
|
+
|
|
123
|
+
Shell aliases and environment variables from `~/.zshrc` or `~/.bashrc` aren't available in non-interactive shells (AI agents, cron jobs, CI). `vaultctl config set vault` writes to `~/.vaultctlrc`, which is a file read — it works everywhere.
|
|
124
|
+
|
|
125
|
+
You can still use `VAULTCTL_PATH` or `--vault` if you prefer — they take higher precedence in the discovery chain.
|
|
126
|
+
|
|
129
127
|
## Features
|
|
130
128
|
|
|
131
129
|
- **Search** — Full-text content search with type, status, and tag filters
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { resolve, join } from 'path';
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { formatOutput } from '../format.js';
|
|
5
|
+
const RC_PATH = join(homedir(), '.vaultctlrc');
|
|
6
|
+
export function registerConfigCommand(program) {
|
|
7
|
+
const config = program
|
|
8
|
+
.command('config')
|
|
9
|
+
.description('Manage vaultctl configuration');
|
|
10
|
+
config
|
|
11
|
+
.command('show')
|
|
12
|
+
.description('Show current configuration and vault discovery status')
|
|
13
|
+
.action((_opts, cmd) => {
|
|
14
|
+
const globalOpts = cmd.parent.parent.opts();
|
|
15
|
+
const format = (globalOpts.format ?? 'json');
|
|
16
|
+
const rcExists = existsSync(RC_PATH);
|
|
17
|
+
const rcValue = rcExists ? readFileSync(RC_PATH, 'utf-8').trim() : null;
|
|
18
|
+
const envValue = process.env['VAULTCTL_PATH'] ?? null;
|
|
19
|
+
// Determine which method would resolve
|
|
20
|
+
let resolvedBy = 'none';
|
|
21
|
+
let resolvedPath = null;
|
|
22
|
+
if (globalOpts.vault) {
|
|
23
|
+
const abs = resolve(globalOpts.vault);
|
|
24
|
+
if (existsSync(join(abs, '.obsidian'))) {
|
|
25
|
+
resolvedBy = '--vault flag';
|
|
26
|
+
resolvedPath = abs;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!resolvedPath && envValue) {
|
|
30
|
+
const abs = resolve(envValue);
|
|
31
|
+
if (existsSync(join(abs, '.obsidian'))) {
|
|
32
|
+
resolvedBy = 'VAULTCTL_PATH env var';
|
|
33
|
+
resolvedPath = abs;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!resolvedPath && rcValue) {
|
|
37
|
+
const abs = resolve(rcValue);
|
|
38
|
+
if (existsSync(join(abs, '.obsidian'))) {
|
|
39
|
+
resolvedBy = '~/.vaultctlrc';
|
|
40
|
+
resolvedPath = abs;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const result = {
|
|
44
|
+
rc_file: RC_PATH,
|
|
45
|
+
rc_value: rcValue,
|
|
46
|
+
env_var: envValue,
|
|
47
|
+
resolved_by: resolvedBy,
|
|
48
|
+
resolved_path: resolvedPath,
|
|
49
|
+
};
|
|
50
|
+
console.log(formatOutput(result, format));
|
|
51
|
+
});
|
|
52
|
+
config
|
|
53
|
+
.command('set')
|
|
54
|
+
.description('Set a configuration value')
|
|
55
|
+
.argument('<key>', 'Configuration key (currently: vault)')
|
|
56
|
+
.argument('<value>', 'Configuration value')
|
|
57
|
+
.action((key, value, _opts, cmd) => {
|
|
58
|
+
const globalOpts = cmd.parent.parent.opts();
|
|
59
|
+
const format = (globalOpts.format ?? 'json');
|
|
60
|
+
if (key !== 'vault') {
|
|
61
|
+
console.error(`Unknown config key: "${key}". Available keys: vault`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
const abs = resolve(value);
|
|
65
|
+
if (!existsSync(join(abs, '.obsidian'))) {
|
|
66
|
+
console.error(`No .obsidian directory found at: ${abs}`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
writeFileSync(RC_PATH, abs + '\n', 'utf-8');
|
|
70
|
+
const result = {
|
|
71
|
+
saved: true,
|
|
72
|
+
key: 'vault',
|
|
73
|
+
value: abs,
|
|
74
|
+
rc_file: RC_PATH,
|
|
75
|
+
};
|
|
76
|
+
console.log(formatOutput(result, format));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=config.js.map
|
package/dist/index.js
CHANGED
|
@@ -6,11 +6,12 @@ import { registerHealthCommand } from './commands/health.js';
|
|
|
6
6
|
import { registerCreateCommand } from './commands/create.js';
|
|
7
7
|
import { registerReadCommand } from './commands/read.js';
|
|
8
8
|
import { registerInfoCommand } from './commands/info.js';
|
|
9
|
+
import { registerConfigCommand } from './commands/config.js';
|
|
9
10
|
const program = new Command();
|
|
10
11
|
program
|
|
11
12
|
.name('vaultctl')
|
|
12
13
|
.description('Structured Obsidian vault operations without MCP servers')
|
|
13
|
-
.version('0.
|
|
14
|
+
.version('0.4.0')
|
|
14
15
|
.option('--vault <path>', 'Path to Obsidian vault')
|
|
15
16
|
.option('--format <format>', 'Output format: json or table', 'json');
|
|
16
17
|
registerSearchCommand(program);
|
|
@@ -19,5 +20,6 @@ registerHealthCommand(program);
|
|
|
19
20
|
registerCreateCommand(program);
|
|
20
21
|
registerReadCommand(program);
|
|
21
22
|
registerInfoCommand(program);
|
|
23
|
+
registerConfigCommand(program);
|
|
22
24
|
program.parse();
|
|
23
25
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vaultctl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "CLI for structured Obsidian vault operations — search, tags, health checks, templates — without MCP servers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"prepublishOnly": "npm run build"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@vaultctl/core": "^0.
|
|
28
|
+
"@vaultctl/core": "^0.4.0",
|
|
29
29
|
"chalk": "^5.4.0",
|
|
30
30
|
"commander": "^13.0.0"
|
|
31
31
|
}
|