@fission-ai/openspec 0.9.1 → 0.9.2
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import { FileSystemUtils } from '../../../utils/file-system.js';
|
|
3
2
|
import { TemplateManager } from '../../templates/index.js';
|
|
4
3
|
import { OPENSPEC_MARKERS } from '../../config.js';
|
|
@@ -15,7 +14,7 @@ export class SlashCommandConfigurator {
|
|
|
15
14
|
const createdOrUpdated = [];
|
|
16
15
|
for (const target of this.getTargets()) {
|
|
17
16
|
const body = TemplateManager.getSlashCommandBody(target.id).trim();
|
|
18
|
-
const filePath =
|
|
17
|
+
const filePath = FileSystemUtils.joinPath(projectPath, target.path);
|
|
19
18
|
if (await FileSystemUtils.fileExists(filePath)) {
|
|
20
19
|
await this.updateBody(filePath, body);
|
|
21
20
|
}
|
|
@@ -36,7 +35,7 @@ export class SlashCommandConfigurator {
|
|
|
36
35
|
async updateExisting(projectPath, _openspecDir) {
|
|
37
36
|
const updated = [];
|
|
38
37
|
for (const target of this.getTargets()) {
|
|
39
|
-
const filePath =
|
|
38
|
+
const filePath = FileSystemUtils.joinPath(projectPath, target.path);
|
|
40
39
|
if (await FileSystemUtils.fileExists(filePath)) {
|
|
41
40
|
const body = TemplateManager.getSlashCommandBody(target.id).trim();
|
|
42
41
|
await this.updateBody(filePath, body);
|
|
@@ -49,7 +48,7 @@ export class SlashCommandConfigurator {
|
|
|
49
48
|
// to redirect to tool-specific locations (e.g., global directories).
|
|
50
49
|
resolveAbsolutePath(projectPath, id) {
|
|
51
50
|
const rel = this.getRelativePath(id);
|
|
52
|
-
return
|
|
51
|
+
return FileSystemUtils.joinPath(projectPath, rel);
|
|
53
52
|
}
|
|
54
53
|
async updateBody(filePath, body) {
|
|
55
54
|
const content = await FileSystemUtils.readFile(filePath);
|
|
@@ -44,8 +44,8 @@ $ARGUMENTS`,
|
|
|
44
44
|
getGlobalPromptsDir() {
|
|
45
45
|
const home = (process.env.CODEX_HOME && process.env.CODEX_HOME.trim())
|
|
46
46
|
? process.env.CODEX_HOME.trim()
|
|
47
|
-
:
|
|
48
|
-
return
|
|
47
|
+
: FileSystemUtils.joinPath(os.homedir(), ".codex");
|
|
48
|
+
return FileSystemUtils.joinPath(home, "prompts");
|
|
49
49
|
}
|
|
50
50
|
// Codex discovers prompts globally. Generate directly in the global directory
|
|
51
51
|
// and wrap shared body with markers.
|
|
@@ -54,7 +54,7 @@ $ARGUMENTS`,
|
|
|
54
54
|
for (const target of this.getTargets()) {
|
|
55
55
|
const body = TemplateManager.getSlashCommandBody(target.id).trim();
|
|
56
56
|
const promptsDir = this.getGlobalPromptsDir();
|
|
57
|
-
const filePath =
|
|
57
|
+
const filePath = FileSystemUtils.joinPath(promptsDir, path.basename(target.path));
|
|
58
58
|
await FileSystemUtils.createDirectory(path.dirname(filePath));
|
|
59
59
|
if (await FileSystemUtils.fileExists(filePath)) {
|
|
60
60
|
await this.updateFullFile(filePath, target.id, body);
|
|
@@ -75,7 +75,7 @@ $ARGUMENTS`,
|
|
|
75
75
|
const updated = [];
|
|
76
76
|
for (const target of this.getTargets()) {
|
|
77
77
|
const promptsDir = this.getGlobalPromptsDir();
|
|
78
|
-
const filePath =
|
|
78
|
+
const filePath = FileSystemUtils.joinPath(promptsDir, path.basename(target.path));
|
|
79
79
|
if (await FileSystemUtils.fileExists(filePath)) {
|
|
80
80
|
const body = TemplateManager.getSlashCommandBody(target.id).trim();
|
|
81
81
|
await this.updateFullFile(filePath, target.id, body);
|
|
@@ -103,7 +103,7 @@ $ARGUMENTS`,
|
|
|
103
103
|
resolveAbsolutePath(_projectPath, id) {
|
|
104
104
|
const promptsDir = this.getGlobalPromptsDir();
|
|
105
105
|
const fileName = path.basename(FILE_PATHS[id]);
|
|
106
|
-
return
|
|
106
|
+
return FileSystemUtils.joinPath(promptsDir, fileName);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
//# sourceMappingURL=codex.js.map
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare class FileSystemUtils {
|
|
2
|
+
private static isWindowsBasePath;
|
|
3
|
+
private static normalizeSegments;
|
|
4
|
+
static joinPath(basePath: string, ...segments: string[]): string;
|
|
2
5
|
static createDirectory(dirPath: string): Promise<void>;
|
|
3
6
|
static fileExists(filePath: string): Promise<boolean>;
|
|
4
7
|
static canWriteFile(filePath: string): Promise<boolean>;
|
|
@@ -30,6 +30,27 @@ function findMarkerIndex(content, marker, fromIndex = 0) {
|
|
|
30
30
|
return -1;
|
|
31
31
|
}
|
|
32
32
|
export class FileSystemUtils {
|
|
33
|
+
static isWindowsBasePath(basePath) {
|
|
34
|
+
return /^[A-Za-z]:[\\/]/.test(basePath) || basePath.startsWith('\\');
|
|
35
|
+
}
|
|
36
|
+
static normalizeSegments(segments) {
|
|
37
|
+
return segments
|
|
38
|
+
.flatMap((segment) => segment.split(/[\\/]+/u))
|
|
39
|
+
.filter((part) => part.length > 0);
|
|
40
|
+
}
|
|
41
|
+
static joinPath(basePath, ...segments) {
|
|
42
|
+
const normalizedSegments = this.normalizeSegments(segments);
|
|
43
|
+
if (this.isWindowsBasePath(basePath)) {
|
|
44
|
+
const normalizedBasePath = path.win32.normalize(basePath);
|
|
45
|
+
return normalizedSegments.length
|
|
46
|
+
? path.win32.join(normalizedBasePath, ...normalizedSegments)
|
|
47
|
+
: normalizedBasePath;
|
|
48
|
+
}
|
|
49
|
+
const posixBasePath = basePath.replace(/\\/g, '/');
|
|
50
|
+
return normalizedSegments.length
|
|
51
|
+
? path.posix.join(posixBasePath, ...normalizedSegments)
|
|
52
|
+
: path.posix.normalize(posixBasePath);
|
|
53
|
+
}
|
|
33
54
|
static async createDirectory(dirPath) {
|
|
34
55
|
await fs.mkdir(dirPath, { recursive: true });
|
|
35
56
|
}
|