jettypod 4.2.4 → 4.2.6
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/jettypod.js +22 -11
- package/lib/database.js +24 -5
- package/package.json +1 -1
package/jettypod.js
CHANGED
|
@@ -17,24 +17,35 @@ try {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Ensure
|
|
20
|
+
* Ensure jettypod-specific paths are gitignored and untracked
|
|
21
21
|
* Called during init and update to fix existing projects
|
|
22
22
|
*/
|
|
23
|
-
function
|
|
23
|
+
function ensureJettypodGitignores() {
|
|
24
24
|
const gitignorePath = path.join(process.cwd(), '.gitignore');
|
|
25
|
-
const
|
|
25
|
+
const entriesToIgnore = [
|
|
26
|
+
'.claude/session.md',
|
|
27
|
+
'.jettypod-work/'
|
|
28
|
+
];
|
|
26
29
|
|
|
27
|
-
// Add to .gitignore if not present
|
|
30
|
+
// Add entries to .gitignore if not present
|
|
28
31
|
let gitignoreContent = '';
|
|
29
32
|
if (fs.existsSync(gitignorePath)) {
|
|
30
33
|
gitignoreContent = fs.readFileSync(gitignorePath, 'utf-8');
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
let modified = false;
|
|
37
|
+
for (const entry of entriesToIgnore) {
|
|
38
|
+
if (!gitignoreContent.includes(entry)) {
|
|
39
|
+
const newEntry = gitignoreContent.endsWith('\n') || gitignoreContent === ''
|
|
40
|
+
? `${entry}\n`
|
|
41
|
+
: `\n${entry}\n`;
|
|
42
|
+
gitignoreContent += newEntry;
|
|
43
|
+
modified = true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (modified) {
|
|
48
|
+
fs.writeFileSync(gitignorePath, gitignoreContent);
|
|
38
49
|
}
|
|
39
50
|
|
|
40
51
|
// Untrack session.md if it's currently tracked
|
|
@@ -656,7 +667,7 @@ async function initializeProject() {
|
|
|
656
667
|
}
|
|
657
668
|
|
|
658
669
|
// Ensure .claude/session.md is gitignored and untracked
|
|
659
|
-
|
|
670
|
+
ensureJettypodGitignores();
|
|
660
671
|
|
|
661
672
|
const claudeSettingsPath = path.join('.claude', 'settings.json');
|
|
662
673
|
if (!fs.existsSync(claudeSettingsPath)) {
|
|
@@ -1032,7 +1043,7 @@ switch (command) {
|
|
|
1032
1043
|
}
|
|
1033
1044
|
|
|
1034
1045
|
// Ensure session.md is gitignored (fixes existing projects)
|
|
1035
|
-
|
|
1046
|
+
ensureJettypodGitignores();
|
|
1036
1047
|
}
|
|
1037
1048
|
|
|
1038
1049
|
process.exit(success ? 0 : 1);
|
package/lib/database.js
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
const sqlite3 = require('sqlite3').verbose();
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fs = require('fs');
|
|
4
|
+
const { getGitRoot } = require('./git-root');
|
|
4
5
|
|
|
5
6
|
// Singleton database connection
|
|
6
7
|
let db = null;
|
|
7
8
|
let cachedJettypodDir = null;
|
|
8
9
|
let cachedDbPath = null;
|
|
10
|
+
let cachedGitRoot = null;
|
|
9
11
|
let isClosing = false;
|
|
10
12
|
let migrationPromise = null;
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Get the root directory for jettypod operations
|
|
16
|
+
* Always returns the main repo, even when called from a worktree
|
|
17
|
+
*/
|
|
18
|
+
function getRepoRoot() {
|
|
19
|
+
if (!cachedGitRoot) {
|
|
20
|
+
try {
|
|
21
|
+
cachedGitRoot = getGitRoot();
|
|
22
|
+
} catch (err) {
|
|
23
|
+
// Fall back to cwd if not in a git repo (e.g., during init)
|
|
24
|
+
cachedGitRoot = process.cwd();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return cachedGitRoot;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Dynamic getters for paths (always use main repo, not worktree)
|
|
13
31
|
function getJettypodDir() {
|
|
14
|
-
const
|
|
15
|
-
if (!cachedJettypodDir ||
|
|
16
|
-
cachedJettypodDir = path.join(
|
|
32
|
+
const root = getRepoRoot();
|
|
33
|
+
if (!cachedJettypodDir || cachedJettypodDir !== path.join(root, '.jettypod')) {
|
|
34
|
+
cachedJettypodDir = path.join(root, '.jettypod');
|
|
17
35
|
// Use separate database for tests
|
|
18
36
|
const dbFileName = process.env.NODE_ENV === 'test' ? 'test-work.db' : 'work.db';
|
|
19
37
|
cachedDbPath = path.join(cachedJettypodDir, dbFileName);
|
|
@@ -59,7 +77,7 @@ function ensureJettyPodDir() {
|
|
|
59
77
|
function getDb() {
|
|
60
78
|
// Check if directory changed - if so, reset connection
|
|
61
79
|
const dbFileName = process.env.NODE_ENV === 'test' ? 'test-work.db' : 'work.db';
|
|
62
|
-
const currentPath = path.join(
|
|
80
|
+
const currentPath = path.join(getRepoRoot(), '.jettypod', dbFileName);
|
|
63
81
|
if (db && cachedDbPath && cachedDbPath !== currentPath) {
|
|
64
82
|
// Directory changed - abandon old connection without closing
|
|
65
83
|
// Attempting to close with active prepared statements causes FATAL errors
|
|
@@ -252,6 +270,7 @@ function resetDb() {
|
|
|
252
270
|
db = null;
|
|
253
271
|
cachedJettypodDir = null;
|
|
254
272
|
cachedDbPath = null;
|
|
273
|
+
cachedGitRoot = null;
|
|
255
274
|
isClosing = false;
|
|
256
275
|
migrationPromise = null;
|
|
257
276
|
}
|