citeclaw 2.0.6 → 2.0.8

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 CHANGED
@@ -15,7 +15,7 @@ It is designed for two related jobs:
15
15
  - an HTTP service compatible with Citoid-style API flows
16
16
  - an MCP server mode for agent/tool integrations
17
17
  - Zotero automation for query, cite, add, update, notes, dedup, enrichment, and export
18
- - vendored translator and CSL style assets for reproducible local runs
18
+ - optional translator/style sync commands for broader coverage and local CSL rendering
19
19
 
20
20
  ## Fast Start
21
21
 
@@ -23,7 +23,6 @@ Run from npm:
23
23
 
24
24
  ```bash
25
25
  npx citeclaw --help
26
- npx citeclaw translators sync
27
26
  npx citeclaw citoid formats
28
27
  npx citeclaw cite bibtex 10.48550/arXiv.1706.03762
29
28
  npx citeclaw crossref "10.1021/acsomega.2c05310"
@@ -38,11 +37,18 @@ npx citeclaw citoid bibtex "https://aclanthology.org/2023.emnlp-main.398/"
38
37
  npx citeclaw cite mediawiki "https://arxiv.org/abs/1706.03762"
39
38
  ```
40
39
 
41
- Fresh npm installs need translator runtime sync before citation commands that depend on Zotero translators:
40
+ Fresh npm installs can run normal citation commands directly. `CiteClaw` will bootstrap Zotero and build a local translator runtime automatically from Zotero's bundled translator set.
42
41
 
43
- ```bash
44
- npx citeclaw translators sync
45
- ```
42
+ Runtime state is persisted in a user-level cache directory by default:
43
+
44
+ - Linux: `~/.cache/citeclaw`
45
+ - macOS: `~/Library/Caches/citeclaw`
46
+ - Windows: `%LOCALAPPDATA%\\citeclaw`
47
+
48
+ Override it with `CITECLAW_HOME=/path/to/runtime`.
49
+
50
+ By default, the Zotero translation server checkout is also stored under this runtime root, at `runtime/zotero`.
51
+ Override it with `ZOTERO_DIR=/path/to/zotero`.
46
52
 
47
53
  ## Local Service
48
54
 
@@ -125,7 +131,7 @@ Safety defaults:
125
131
 
126
132
  ## Runtime Sync
127
133
 
128
- For npm installs, runtime assets are synced explicitly instead of silently bundled:
134
+ For npm installs, extra runtime assets can be synced explicitly when you want broader translator coverage or local style rendering:
129
135
 
130
136
  ```bash
131
137
  npx citeclaw translators sync
@@ -135,7 +141,9 @@ npx citeclaw styles sync
135
141
  Notes:
136
142
 
137
143
  - `translators sync` will clone or update the translator sources with `git` when needed
138
- - `styles sync` will clone or update style repositories with `git` when bundled styles are unavailable
144
+ - `styles sync` will clone or update style repositories with `git` when local CSL styles are unavailable
145
+ - normal `cite` commands can run without manually syncing translators first
146
+ - `cite-style` will fetch style sources on demand if local styles are missing
139
147
  - if `git` is not installed, the commands fail with an explicit message
140
148
 
141
149
  ## Bibliography Curation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "citeclaw",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "Citation and bibliography toolkit for DOI, URL, arXiv, PDF, Zotero, and MCP workflows.",
5
5
  "homepage": "https://github.com/trotsky1997/citeclaw",
6
6
  "license": "Apache-2.0",
@@ -19,13 +19,31 @@ const yaml = require( 'js-yaml' );
19
19
  const citoidApp = require( '../app.js' );
20
20
 
21
21
  const rootDir = path.resolve( __dirname, '..' );
22
- const zoteroDir = process.env.ZOTERO_DIR || path.join( rootDir, 'vendor', 'zotero' );
23
22
  const cnTranslatorsDir = process.env.CN_TRANSLATORS_DIR || path.join( rootDir, 'vendor', 'translators_CN' );
24
23
  const officialTranslatorsDir = process.env.OFFICIAL_TRANSLATORS_DIR ||
25
24
  path.join( rootDir, 'vendor', 'translators-official' );
26
25
  const vendoredStylesDir = path.join( rootDir, 'vendor', 'styles' );
27
26
  const vendoredOfficialStylesDir = path.join( rootDir, 'vendor', 'styles-official' );
28
- const localDir = path.join( rootDir, '.local' );
27
+
28
+ function defaultRuntimeRoot() {
29
+ if ( process.env.CITECLAW_HOME ) {
30
+ return path.resolve( process.env.CITECLAW_HOME );
31
+ }
32
+ if ( process.env.XDG_CACHE_HOME ) {
33
+ return path.join( process.env.XDG_CACHE_HOME, 'citeclaw' );
34
+ }
35
+ if ( process.platform === 'win32' ) {
36
+ const base = process.env.LOCALAPPDATA || process.env.APPDATA || path.join( os.homedir(), 'AppData', 'Local' );
37
+ return path.join( base, 'citeclaw' );
38
+ }
39
+ if ( process.platform === 'darwin' ) {
40
+ return path.join( os.homedir(), 'Library', 'Caches', 'citeclaw' );
41
+ }
42
+ return path.join( os.homedir(), '.cache', 'citeclaw' );
43
+ }
44
+
45
+ const localDir = defaultRuntimeRoot();
46
+ const zoteroDir = process.env.ZOTERO_DIR || path.join( localDir, 'runtime', 'zotero' );
29
47
  const logDir = path.join( localDir, 'logs' );
30
48
  const stateDir = path.join( localDir, 'state' );
31
49
  const localTranslatorSourcesDir = path.join( localDir, 'translator-sources' );
@@ -165,7 +183,7 @@ function usageZotero( subAction = '' ) {
165
183
  console.error( ' citeclaw zotero login --library-type groups --library-id <group-id> --api-key <key>' );
166
184
  console.error( 'notes:' );
167
185
  console.error( ' - personal library defaults to library-type users' );
168
- console.error( ' - credentials are saved to .local/state/zotero-auth.json' );
186
+ console.error( ` - credentials are saved to ${ zoteroAuthPath }` );
169
187
  console.error( ' - API key can be created at https://www.zotero.org/settings/keys' );
170
188
  return;
171
189
  }
@@ -173,7 +191,7 @@ function usageZotero( subAction = '' ) {
173
191
  console.error( 'usage:' );
174
192
  console.error( ' citeclaw zotero logout' );
175
193
  console.error( 'notes:' );
176
- console.error( ' - removes local credentials from .local/state/zotero-auth.json' );
194
+ console.error( ` - removes local credentials from ${ zoteroAuthPath }` );
177
195
  return;
178
196
  }
179
197
  if ( action === 'whoami' ) {
@@ -639,14 +657,13 @@ function bootstrapLocalEnvironment() {
639
657
  runCommandOrThrow( installer.command, installer.args, rootDir );
640
658
  }
641
659
  if ( !fileExists( path.join( zoteroDir, 'modules', 'translators' ) ) ) {
642
- throw new Error( 'missing vendored zotero contents under vendor/zotero/modules/translators' );
660
+ throw new Error( `missing zotero translator contents under ${ path.join( zoteroDir, 'modules', 'translators' ) }` );
643
661
  }
644
662
  if ( !fileExists( path.join( zoteroDir, 'node_modules' ) ) ) {
645
663
  runCommandOrThrow( installer.command, installer.args, zoteroDir );
646
664
  }
647
- if ( !fileExists( mergedTranslatorsDir ) ||
648
- !fs.readdirSync( mergedTranslatorsDir, { withFileTypes: true } ).some( ( entry ) => entry.isFile() && entry.name.endsWith( '.js' ) ) ) {
649
- throw new Error( 'translators are not synced. Run: citeclaw translators sync' );
665
+ if ( translatorsNeedSync() ) {
666
+ syncMergedTranslators();
650
667
  }
651
668
  }
652
669
 
@@ -670,7 +687,7 @@ function ensureStyleRuntime() {
670
687
  if ( fileExists( cslDir ) && fileExists( localeDir ) ) {
671
688
  return;
672
689
  }
673
- throw new Error( 'Styles are not synced. Run: citeclaw styles sync' );
690
+ syncStyles( {} );
674
691
  }
675
692
 
676
693
  function ensureDefaultStyleSources() {
@@ -1505,7 +1522,7 @@ async function runCitationFromPdf( pdfPath, options ) {
1505
1522
  } );
1506
1523
  }
1507
1524
 
1508
- async function syncStyles( options ) {
1525
+ function syncStyles( options ) {
1509
1526
  ensureDirs();
1510
1527
  fs.mkdirSync( cslDir, { recursive: true } );
1511
1528
  fs.mkdirSync( localeDir, { recursive: true } );