shiva-code 0.3.0 → 0.4.1
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/chunk-3RG5ZIWI.js +10 -0
- package/dist/chunk-ZWOPK4GS.js +604 -0
- package/dist/{github-R3I7U2DQ.js → github-Y3HFZXPK.js} +1 -0
- package/dist/index.js +12333 -4110
- package/dist/{package-manager-OOJUNEKG.js → package-manager-QICNAFP2.js} +1 -0
- package/dist/project-config-7TQGEQNB.js +83 -0
- package/dist/{session-manager-THTEDIUG.js → session-manager-EWKQLXNA.js} +1 -0
- package/dist/{tags-P6L3BWO7.js → tags-QCU75GRW.js} +1 -0
- package/package.json +2 -1
- package/dist/chunk-KXYP4OCK.js +0 -236
- package/dist/project-config-GELL5QUH.js +0 -40
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addDockerMount,
|
|
3
|
+
addToGitignore,
|
|
4
|
+
cacheGitHubContext,
|
|
5
|
+
clearContextCache,
|
|
6
|
+
getAllBranchSessions,
|
|
7
|
+
getAnalyticsConfig,
|
|
8
|
+
getAnalyticsFilePath,
|
|
9
|
+
getAnalyticsSummaryPath,
|
|
10
|
+
getCachedGitHubContext,
|
|
11
|
+
getContextCacheAge,
|
|
12
|
+
getProjectConfig,
|
|
13
|
+
getProjectConfigV2,
|
|
14
|
+
getProjectDockerConfig,
|
|
15
|
+
getSecurityConfig,
|
|
16
|
+
getSessionConfig,
|
|
17
|
+
getSessionForBranch,
|
|
18
|
+
getShivaDir,
|
|
19
|
+
hasShivaDir,
|
|
20
|
+
initShivaDir,
|
|
21
|
+
isV2Config,
|
|
22
|
+
mapBranchToSession,
|
|
23
|
+
removeBranchSession,
|
|
24
|
+
removeDockerMount,
|
|
25
|
+
removeFromGitignore,
|
|
26
|
+
removeShivaDir,
|
|
27
|
+
resetSessionBudget,
|
|
28
|
+
saveProjectConfig,
|
|
29
|
+
saveProjectConfigV2,
|
|
30
|
+
updateAnalyticsConfig,
|
|
31
|
+
updateApproval,
|
|
32
|
+
updateBranchSession,
|
|
33
|
+
updatePermissions,
|
|
34
|
+
updateProjectConfig,
|
|
35
|
+
updateProjectConfigV2,
|
|
36
|
+
updateProjectDockerConfig,
|
|
37
|
+
updateSecurityConfig,
|
|
38
|
+
updateSessionBudget,
|
|
39
|
+
updateSessionLimits,
|
|
40
|
+
updateTimeControl
|
|
41
|
+
} from "./chunk-ZWOPK4GS.js";
|
|
42
|
+
import "./chunk-3RG5ZIWI.js";
|
|
43
|
+
export {
|
|
44
|
+
addDockerMount,
|
|
45
|
+
addToGitignore,
|
|
46
|
+
cacheGitHubContext,
|
|
47
|
+
clearContextCache,
|
|
48
|
+
getAllBranchSessions,
|
|
49
|
+
getAnalyticsConfig,
|
|
50
|
+
getAnalyticsFilePath,
|
|
51
|
+
getAnalyticsSummaryPath,
|
|
52
|
+
getCachedGitHubContext,
|
|
53
|
+
getContextCacheAge,
|
|
54
|
+
getProjectConfig,
|
|
55
|
+
getProjectConfigV2,
|
|
56
|
+
getProjectDockerConfig,
|
|
57
|
+
getSecurityConfig,
|
|
58
|
+
getSessionConfig,
|
|
59
|
+
getSessionForBranch,
|
|
60
|
+
getShivaDir,
|
|
61
|
+
hasShivaDir,
|
|
62
|
+
initShivaDir,
|
|
63
|
+
isV2Config,
|
|
64
|
+
mapBranchToSession,
|
|
65
|
+
removeBranchSession,
|
|
66
|
+
removeDockerMount,
|
|
67
|
+
removeFromGitignore,
|
|
68
|
+
removeShivaDir,
|
|
69
|
+
resetSessionBudget,
|
|
70
|
+
saveProjectConfig,
|
|
71
|
+
saveProjectConfigV2,
|
|
72
|
+
updateAnalyticsConfig,
|
|
73
|
+
updateApproval,
|
|
74
|
+
updateBranchSession,
|
|
75
|
+
updatePermissions,
|
|
76
|
+
updateProjectConfig,
|
|
77
|
+
updateProjectConfigV2,
|
|
78
|
+
updateProjectDockerConfig,
|
|
79
|
+
updateSecurityConfig,
|
|
80
|
+
updateSessionBudget,
|
|
81
|
+
updateSessionLimits,
|
|
82
|
+
updateTimeControl
|
|
83
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shiva-code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Makes Claude Code Persistent - Cross-Project Memory CLI",
|
|
5
5
|
"author": "SHIVA AI",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"commander": "^12.1.0",
|
|
27
27
|
"conf": "^13.0.1",
|
|
28
28
|
"inquirer": "^12.3.0",
|
|
29
|
+
"minimatch": "^10.0.1",
|
|
29
30
|
"open": "^10.1.0",
|
|
30
31
|
"ora": "^8.1.1"
|
|
31
32
|
},
|
package/dist/chunk-KXYP4OCK.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
// src/services/project-config.ts
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
var SHIVA_DIR = ".shiva";
|
|
5
|
-
var CONFIG_FILE = "config.json";
|
|
6
|
-
var SESSIONS_DIR = "sessions";
|
|
7
|
-
var CONTEXT_DIR = "context";
|
|
8
|
-
var GITHUB_CONTEXT_FILE = "github.md";
|
|
9
|
-
var DEFAULT_CONFIG = {
|
|
10
|
-
version: 1,
|
|
11
|
-
autoInjectContext: true,
|
|
12
|
-
branchSessions: {}
|
|
13
|
-
};
|
|
14
|
-
function getShivaDir(projectPath) {
|
|
15
|
-
return path.join(projectPath, SHIVA_DIR);
|
|
16
|
-
}
|
|
17
|
-
function getConfigPath(projectPath) {
|
|
18
|
-
return path.join(getShivaDir(projectPath), CONFIG_FILE);
|
|
19
|
-
}
|
|
20
|
-
function getSessionsDir(projectPath) {
|
|
21
|
-
return path.join(getShivaDir(projectPath), SESSIONS_DIR);
|
|
22
|
-
}
|
|
23
|
-
function getContextDir(projectPath) {
|
|
24
|
-
return path.join(getShivaDir(projectPath), CONTEXT_DIR);
|
|
25
|
-
}
|
|
26
|
-
function hasShivaDir(projectPath) {
|
|
27
|
-
return fs.existsSync(getShivaDir(projectPath));
|
|
28
|
-
}
|
|
29
|
-
function initShivaDir(projectPath) {
|
|
30
|
-
const shivaDir = getShivaDir(projectPath);
|
|
31
|
-
const sessionsDir = getSessionsDir(projectPath);
|
|
32
|
-
const contextDir = getContextDir(projectPath);
|
|
33
|
-
if (!fs.existsSync(shivaDir)) {
|
|
34
|
-
fs.mkdirSync(shivaDir, { recursive: true });
|
|
35
|
-
}
|
|
36
|
-
if (!fs.existsSync(sessionsDir)) {
|
|
37
|
-
fs.mkdirSync(sessionsDir, { recursive: true });
|
|
38
|
-
}
|
|
39
|
-
if (!fs.existsSync(contextDir)) {
|
|
40
|
-
fs.mkdirSync(contextDir, { recursive: true });
|
|
41
|
-
}
|
|
42
|
-
const configPath = getConfigPath(projectPath);
|
|
43
|
-
if (!fs.existsSync(configPath)) {
|
|
44
|
-
fs.writeFileSync(configPath, JSON.stringify(DEFAULT_CONFIG, null, 2), "utf-8");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function addToGitignore(projectPath) {
|
|
48
|
-
const gitignorePath = path.join(projectPath, ".gitignore");
|
|
49
|
-
let content = "";
|
|
50
|
-
if (fs.existsSync(gitignorePath)) {
|
|
51
|
-
content = fs.readFileSync(gitignorePath, "utf-8");
|
|
52
|
-
if (content.includes(".shiva") || content.includes("/.shiva")) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const newEntry = "\n# SHIVA Code local config\n.shiva/\n";
|
|
57
|
-
fs.writeFileSync(gitignorePath, content + newEntry, "utf-8");
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
function removeFromGitignore(projectPath) {
|
|
61
|
-
const gitignorePath = path.join(projectPath, ".gitignore");
|
|
62
|
-
if (!fs.existsSync(gitignorePath)) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
let content = fs.readFileSync(gitignorePath, "utf-8");
|
|
66
|
-
const lines = content.split("\n");
|
|
67
|
-
const filtered = lines.filter((line) => {
|
|
68
|
-
const trimmed = line.trim();
|
|
69
|
-
return trimmed !== ".shiva/" && trimmed !== ".shiva" && trimmed !== "/.shiva/";
|
|
70
|
-
});
|
|
71
|
-
const finalLines = filtered.filter((line, i, arr) => {
|
|
72
|
-
return !(line.includes("# SHIVA Code") && arr[i + 1]?.trim() === "");
|
|
73
|
-
});
|
|
74
|
-
const newContent = finalLines.join("\n");
|
|
75
|
-
if (newContent !== content) {
|
|
76
|
-
fs.writeFileSync(gitignorePath, newContent, "utf-8");
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
function getProjectConfig(projectPath) {
|
|
82
|
-
const configPath = getConfigPath(projectPath);
|
|
83
|
-
if (!fs.existsSync(configPath)) {
|
|
84
|
-
return { ...DEFAULT_CONFIG };
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
const content = fs.readFileSync(configPath, "utf-8");
|
|
88
|
-
const config = JSON.parse(content);
|
|
89
|
-
return { ...DEFAULT_CONFIG, ...config };
|
|
90
|
-
} catch {
|
|
91
|
-
return { ...DEFAULT_CONFIG };
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function saveProjectConfig(projectPath, config) {
|
|
95
|
-
initShivaDir(projectPath);
|
|
96
|
-
const configPath = getConfigPath(projectPath);
|
|
97
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
98
|
-
}
|
|
99
|
-
function updateProjectConfig(projectPath, updates) {
|
|
100
|
-
const current = getProjectConfig(projectPath);
|
|
101
|
-
const updated = { ...current, ...updates };
|
|
102
|
-
saveProjectConfig(projectPath, updated);
|
|
103
|
-
return updated;
|
|
104
|
-
}
|
|
105
|
-
function sanitizeBranchName(branch) {
|
|
106
|
-
return branch.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
107
|
-
}
|
|
108
|
-
function mapBranchToSession(projectPath, branch, sessionId, metadata) {
|
|
109
|
-
initShivaDir(projectPath);
|
|
110
|
-
const config = getProjectConfig(projectPath);
|
|
111
|
-
config.branchSessions[branch] = {
|
|
112
|
-
branch,
|
|
113
|
-
sessionId,
|
|
114
|
-
lastAccessed: (/* @__PURE__ */ new Date()).toISOString(),
|
|
115
|
-
...metadata
|
|
116
|
-
};
|
|
117
|
-
saveProjectConfig(projectPath, config);
|
|
118
|
-
const sessionsDir = getSessionsDir(projectPath);
|
|
119
|
-
const sessionFile = path.join(sessionsDir, `${sanitizeBranchName(branch)}.json`);
|
|
120
|
-
fs.writeFileSync(
|
|
121
|
-
sessionFile,
|
|
122
|
-
JSON.stringify(config.branchSessions[branch], null, 2),
|
|
123
|
-
"utf-8"
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
function getSessionForBranch(projectPath, branch) {
|
|
127
|
-
const config = getProjectConfig(projectPath);
|
|
128
|
-
if (config.branchSessions[branch]) {
|
|
129
|
-
return config.branchSessions[branch];
|
|
130
|
-
}
|
|
131
|
-
const sessionsDir = getSessionsDir(projectPath);
|
|
132
|
-
const sessionFile = path.join(sessionsDir, `${sanitizeBranchName(branch)}.json`);
|
|
133
|
-
if (fs.existsSync(sessionFile)) {
|
|
134
|
-
try {
|
|
135
|
-
const content = fs.readFileSync(sessionFile, "utf-8");
|
|
136
|
-
return JSON.parse(content);
|
|
137
|
-
} catch {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
function getAllBranchSessions(projectPath) {
|
|
144
|
-
const config = getProjectConfig(projectPath);
|
|
145
|
-
return config.branchSessions || {};
|
|
146
|
-
}
|
|
147
|
-
function updateBranchSession(projectPath, branch, updates) {
|
|
148
|
-
const existing = getSessionForBranch(projectPath, branch);
|
|
149
|
-
if (!existing) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
mapBranchToSession(projectPath, branch, existing.sessionId, {
|
|
153
|
-
...existing,
|
|
154
|
-
...updates,
|
|
155
|
-
lastAccessed: (/* @__PURE__ */ new Date()).toISOString()
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
function removeBranchSession(projectPath, branch) {
|
|
159
|
-
const config = getProjectConfig(projectPath);
|
|
160
|
-
if (config.branchSessions[branch]) {
|
|
161
|
-
delete config.branchSessions[branch];
|
|
162
|
-
saveProjectConfig(projectPath, config);
|
|
163
|
-
}
|
|
164
|
-
const sessionsDir = getSessionsDir(projectPath);
|
|
165
|
-
const sessionFile = path.join(sessionsDir, `${sanitizeBranchName(branch)}.json`);
|
|
166
|
-
if (fs.existsSync(sessionFile)) {
|
|
167
|
-
fs.unlinkSync(sessionFile);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function cacheGitHubContext(projectPath, context) {
|
|
171
|
-
initShivaDir(projectPath);
|
|
172
|
-
const contextDir = getContextDir(projectPath);
|
|
173
|
-
const contextFile = path.join(contextDir, GITHUB_CONTEXT_FILE);
|
|
174
|
-
fs.writeFileSync(contextFile, context, "utf-8");
|
|
175
|
-
return contextFile;
|
|
176
|
-
}
|
|
177
|
-
function getCachedGitHubContext(projectPath) {
|
|
178
|
-
const contextDir = getContextDir(projectPath);
|
|
179
|
-
const contextFile = path.join(contextDir, GITHUB_CONTEXT_FILE);
|
|
180
|
-
if (!fs.existsSync(contextFile)) {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
try {
|
|
184
|
-
return fs.readFileSync(contextFile, "utf-8");
|
|
185
|
-
} catch {
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
function getContextCacheAge(projectPath) {
|
|
190
|
-
const contextDir = getContextDir(projectPath);
|
|
191
|
-
const contextFile = path.join(contextDir, GITHUB_CONTEXT_FILE);
|
|
192
|
-
if (!fs.existsSync(contextFile)) {
|
|
193
|
-
return Infinity;
|
|
194
|
-
}
|
|
195
|
-
try {
|
|
196
|
-
const stats = fs.statSync(contextFile);
|
|
197
|
-
const ageMs = Date.now() - stats.mtimeMs;
|
|
198
|
-
return Math.floor(ageMs / (1e3 * 60));
|
|
199
|
-
} catch {
|
|
200
|
-
return Infinity;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function clearContextCache(projectPath) {
|
|
204
|
-
const contextDir = getContextDir(projectPath);
|
|
205
|
-
const contextFile = path.join(contextDir, GITHUB_CONTEXT_FILE);
|
|
206
|
-
if (fs.existsSync(contextFile)) {
|
|
207
|
-
fs.unlinkSync(contextFile);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function removeShivaDir(projectPath) {
|
|
211
|
-
const shivaDir = getShivaDir(projectPath);
|
|
212
|
-
if (fs.existsSync(shivaDir)) {
|
|
213
|
-
fs.rmSync(shivaDir, { recursive: true, force: true });
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export {
|
|
218
|
-
getShivaDir,
|
|
219
|
-
hasShivaDir,
|
|
220
|
-
initShivaDir,
|
|
221
|
-
addToGitignore,
|
|
222
|
-
removeFromGitignore,
|
|
223
|
-
getProjectConfig,
|
|
224
|
-
saveProjectConfig,
|
|
225
|
-
updateProjectConfig,
|
|
226
|
-
mapBranchToSession,
|
|
227
|
-
getSessionForBranch,
|
|
228
|
-
getAllBranchSessions,
|
|
229
|
-
updateBranchSession,
|
|
230
|
-
removeBranchSession,
|
|
231
|
-
cacheGitHubContext,
|
|
232
|
-
getCachedGitHubContext,
|
|
233
|
-
getContextCacheAge,
|
|
234
|
-
clearContextCache,
|
|
235
|
-
removeShivaDir
|
|
236
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
addToGitignore,
|
|
3
|
-
cacheGitHubContext,
|
|
4
|
-
clearContextCache,
|
|
5
|
-
getAllBranchSessions,
|
|
6
|
-
getCachedGitHubContext,
|
|
7
|
-
getContextCacheAge,
|
|
8
|
-
getProjectConfig,
|
|
9
|
-
getSessionForBranch,
|
|
10
|
-
getShivaDir,
|
|
11
|
-
hasShivaDir,
|
|
12
|
-
initShivaDir,
|
|
13
|
-
mapBranchToSession,
|
|
14
|
-
removeBranchSession,
|
|
15
|
-
removeFromGitignore,
|
|
16
|
-
removeShivaDir,
|
|
17
|
-
saveProjectConfig,
|
|
18
|
-
updateBranchSession,
|
|
19
|
-
updateProjectConfig
|
|
20
|
-
} from "./chunk-KXYP4OCK.js";
|
|
21
|
-
export {
|
|
22
|
-
addToGitignore,
|
|
23
|
-
cacheGitHubContext,
|
|
24
|
-
clearContextCache,
|
|
25
|
-
getAllBranchSessions,
|
|
26
|
-
getCachedGitHubContext,
|
|
27
|
-
getContextCacheAge,
|
|
28
|
-
getProjectConfig,
|
|
29
|
-
getSessionForBranch,
|
|
30
|
-
getShivaDir,
|
|
31
|
-
hasShivaDir,
|
|
32
|
-
initShivaDir,
|
|
33
|
-
mapBranchToSession,
|
|
34
|
-
removeBranchSession,
|
|
35
|
-
removeFromGitignore,
|
|
36
|
-
removeShivaDir,
|
|
37
|
-
saveProjectConfig,
|
|
38
|
-
updateBranchSession,
|
|
39
|
-
updateProjectConfig
|
|
40
|
-
};
|