@fission-ai/openspec 0.21.0 → 0.22.0
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/cli/index.js +2 -0
- package/dist/commands/artifact-workflow.js +155 -22
- package/dist/commands/schema.d.ts +6 -0
- package/dist/commands/schema.js +869 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts +11 -2
- package/dist/core/artifact-graph/instruction-loader.js +59 -7
- package/dist/core/artifact-graph/resolver.d.ts +32 -12
- package/dist/core/artifact-graph/resolver.js +88 -18
- package/dist/core/completions/command-registry.js +76 -0
- package/dist/core/completions/types.d.ts +2 -1
- package/dist/core/config-prompts.d.ts +36 -0
- package/dist/core/config-prompts.js +151 -0
- package/dist/core/project-config.d.ts +64 -0
- package/dist/core/project-config.js +223 -0
- package/dist/utils/change-metadata.d.ts +8 -4
- package/dist/utils/change-metadata.js +27 -10
- package/dist/utils/change-utils.d.ts +14 -3
- package/dist/utils/change-utils.js +27 -6
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { FileSystemUtils } from './file-system.js';
|
|
3
3
|
import { writeChangeMetadata, validateSchemaName } from './change-metadata.js';
|
|
4
|
+
import { readProjectConfig } from '../core/project-config.js';
|
|
4
5
|
const DEFAULT_SCHEMA = 'spec-driven';
|
|
5
6
|
/**
|
|
6
7
|
* Validates that a change name follows kebab-case conventions.
|
|
@@ -65,13 +66,17 @@ export function validateChangeName(name) {
|
|
|
65
66
|
* @throws Error if the schema name is invalid
|
|
66
67
|
* @throws Error if the change directory already exists
|
|
67
68
|
*
|
|
69
|
+
* @returns Result containing the resolved schema name
|
|
70
|
+
*
|
|
68
71
|
* @example
|
|
69
72
|
* // Creates openspec/changes/add-auth/ with default schema
|
|
70
|
-
* await createChange('/path/to/project', 'add-auth')
|
|
73
|
+
* const result = await createChange('/path/to/project', 'add-auth')
|
|
74
|
+
* console.log(result.schema) // 'spec-driven' or value from config
|
|
71
75
|
*
|
|
72
76
|
* @example
|
|
73
77
|
* // Creates openspec/changes/add-auth/ with TDD schema
|
|
74
|
-
* await createChange('/path/to/project', 'add-auth', { schema: 'tdd' })
|
|
78
|
+
* const result = await createChange('/path/to/project', 'add-auth', { schema: 'tdd' })
|
|
79
|
+
* console.log(result.schema) // 'tdd'
|
|
75
80
|
*/
|
|
76
81
|
export async function createChange(projectRoot, name, options = {}) {
|
|
77
82
|
// Validate the name first
|
|
@@ -79,9 +84,24 @@ export async function createChange(projectRoot, name, options = {}) {
|
|
|
79
84
|
if (!validation.valid) {
|
|
80
85
|
throw new Error(validation.error);
|
|
81
86
|
}
|
|
82
|
-
// Determine schema
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
// Determine schema: explicit option → project config → hardcoded default
|
|
88
|
+
let schemaName;
|
|
89
|
+
if (options.schema) {
|
|
90
|
+
schemaName = options.schema;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// Try to read from project config
|
|
94
|
+
try {
|
|
95
|
+
const config = readProjectConfig(projectRoot);
|
|
96
|
+
schemaName = config?.schema ?? DEFAULT_SCHEMA;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// If config read fails, use default
|
|
100
|
+
schemaName = DEFAULT_SCHEMA;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Validate the resolved schema
|
|
104
|
+
validateSchemaName(schemaName, projectRoot);
|
|
85
105
|
// Build the change directory path
|
|
86
106
|
const changeDir = path.join(projectRoot, 'openspec', 'changes', name);
|
|
87
107
|
// Check if change already exists
|
|
@@ -95,6 +115,7 @@ export async function createChange(projectRoot, name, options = {}) {
|
|
|
95
115
|
writeChangeMetadata(changeDir, {
|
|
96
116
|
schema: schemaName,
|
|
97
117
|
created: today,
|
|
98
|
-
});
|
|
118
|
+
}, projectRoot);
|
|
119
|
+
return { schema: schemaName };
|
|
99
120
|
}
|
|
100
121
|
//# sourceMappingURL=change-utils.js.map
|