@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.
@@ -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 (validate if provided)
83
- const schemaName = options.schema ?? DEFAULT_SCHEMA;
84
- validateSchemaName(schemaName);
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fission-ai/openspec",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "AI-native system for spec-driven development",
5
5
  "keywords": [
6
6
  "openspec",