@claudetools/tools 0.3.3 → 0.3.5
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/helpers/config.d.ts +2 -1
- package/dist/helpers/config.js +14 -5
- package/dist/setup.js +8 -7
- package/package.json +1 -1
package/dist/helpers/config.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export interface ProjectsCache {
|
|
|
14
14
|
last_sync: string;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Validates that a project ID is a
|
|
17
|
+
* Validates that a project ID is in a valid format
|
|
18
|
+
* Accepts both API-registered (proj_*) and local fallback (local_*) formats
|
|
18
19
|
*/
|
|
19
20
|
export declare function isValidProjectId(id: string): boolean;
|
|
20
21
|
/**
|
package/dist/helpers/config.js
CHANGED
|
@@ -13,10 +13,19 @@ export const PROJECTS_FILE = getProjectsPath();
|
|
|
13
13
|
// Cache for resolved project ID
|
|
14
14
|
let resolvedProjectId = null;
|
|
15
15
|
/**
|
|
16
|
-
* Validates that a project ID is a
|
|
16
|
+
* Validates that a project ID is in a valid format
|
|
17
|
+
* Accepts both API-registered (proj_*) and local fallback (local_*) formats
|
|
17
18
|
*/
|
|
18
19
|
export function isValidProjectId(id) {
|
|
19
|
-
|
|
20
|
+
// API-registered format: proj_ followed by 20 hex chars
|
|
21
|
+
if (/^proj_[a-f0-9]{20}$/.test(id)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
// Local fallback format: local_ followed by sanitized project name
|
|
25
|
+
if (/^local_[a-z0-9_]+$/.test(id)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
20
29
|
}
|
|
21
30
|
/**
|
|
22
31
|
* Finds a project binding in the cache by directory path
|
|
@@ -78,7 +87,7 @@ export async function resolveProjectIdAsync() {
|
|
|
78
87
|
// Validate UUID format
|
|
79
88
|
if (!isValidProjectId(envProjectId)) {
|
|
80
89
|
throw new Error(`Invalid project ID format in CLAUDETOOLS_PROJECT_ID: ${envProjectId}. ` +
|
|
81
|
-
`Expected format: proj_xxxxxxxxxxxxxxxxxxxx
|
|
90
|
+
`Expected format: proj_xxxxxxxxxxxxxxxxxxxx or local_projectname`);
|
|
82
91
|
}
|
|
83
92
|
resolvedProjectId = envProjectId;
|
|
84
93
|
mcpLogger.debug('MEMORY', `Using project ID from env: ${resolvedProjectId}`);
|
|
@@ -135,7 +144,7 @@ export function getDefaultProjectId() {
|
|
|
135
144
|
if (config.defaultProjectId) {
|
|
136
145
|
if (!isValidProjectId(config.defaultProjectId)) {
|
|
137
146
|
throw new Error(`Invalid defaultProjectId in config: ${config.defaultProjectId}. ` +
|
|
138
|
-
`Expected format: proj_xxxxxxxxxxxxxxxxxxxx
|
|
147
|
+
`Expected format: proj_xxxxxxxxxxxxxxxxxxxx or local_projectname`);
|
|
139
148
|
}
|
|
140
149
|
_defaultProjectId = config.defaultProjectId;
|
|
141
150
|
return _defaultProjectId;
|
|
@@ -155,7 +164,7 @@ export async function getDefaultProjectIdAsync() {
|
|
|
155
164
|
if (config.defaultProjectId) {
|
|
156
165
|
if (!isValidProjectId(config.defaultProjectId)) {
|
|
157
166
|
throw new Error(`Invalid defaultProjectId in config: ${config.defaultProjectId}. ` +
|
|
158
|
-
`Expected format: proj_xxxxxxxxxxxxxxxxxxxx
|
|
167
|
+
`Expected format: proj_xxxxxxxxxxxxxxxxxxxx or local_projectname`);
|
|
159
168
|
}
|
|
160
169
|
_defaultProjectId = config.defaultProjectId;
|
|
161
170
|
return _defaultProjectId;
|
package/dist/setup.js
CHANGED
|
@@ -527,10 +527,11 @@ PROJECT_ID=""
|
|
|
527
527
|
PROJECT_NAME=""
|
|
528
528
|
|
|
529
529
|
if [ -f "$PROJECTS_FILE" ]; then
|
|
530
|
-
# Find project by path prefix match
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
530
|
+
# Find project by path prefix match (use variable binding for jq startswith)
|
|
531
|
+
# Use -c for compact output so head -1 gets complete JSON object
|
|
532
|
+
PROJECT_DATA=$(jq -c --arg cwd "$CWD" '
|
|
533
|
+
.bindings[]? | select(.local_path) |
|
|
534
|
+
. as $b | select($cwd | startswith($b.local_path)) |
|
|
534
535
|
{project_id, project_name}' "$PROJECTS_FILE" 2>/dev/null | head -1)
|
|
535
536
|
|
|
536
537
|
if [ -n "$PROJECT_DATA" ]; then
|
|
@@ -626,10 +627,10 @@ CWD=$(pwd)
|
|
|
626
627
|
PROJECT_ID=""
|
|
627
628
|
|
|
628
629
|
if [ -f "$PROJECT_FILE" ]; then
|
|
629
|
-
# Try to find project by path prefix
|
|
630
|
+
# Try to find project by path prefix (use variable binding for jq startswith)
|
|
630
631
|
PROJECT_ID=$(jq -r --arg cwd "$CWD" '
|
|
631
|
-
.bindings[]? | select(.local_path
|
|
632
|
-
select($cwd | startswith(.local_path)) |
|
|
632
|
+
.bindings[]? | select(.local_path) |
|
|
633
|
+
. as $b | select($cwd | startswith($b.local_path)) |
|
|
633
634
|
.project_id' "$PROJECT_FILE" 2>/dev/null | head -1)
|
|
634
635
|
fi
|
|
635
636
|
|