gmc-openspec 1.1.0 → 1.4.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.
Files changed (111) hide show
  1. package/README.md +2 -2
  2. package/bin/openspec.js +3 -1
  3. package/dist/cli/index.d.ts +4 -1
  4. package/dist/cli/index.js +36 -2
  5. package/dist/commands/config.js +4 -4
  6. package/dist/commands/context-store.d.ts +3 -0
  7. package/dist/commands/context-store.js +475 -0
  8. package/dist/commands/initiative.d.ts +13 -0
  9. package/dist/commands/initiative.js +318 -0
  10. package/dist/commands/workflow/index.d.ts +2 -0
  11. package/dist/commands/workflow/index.js +1 -0
  12. package/dist/commands/workflow/initiative-link.d.ts +24 -0
  13. package/dist/commands/workflow/initiative-link.js +47 -0
  14. package/dist/commands/workflow/instructions.js +10 -2
  15. package/dist/commands/workflow/new-change.d.ts +4 -0
  16. package/dist/commands/workflow/new-change.js +72 -23
  17. package/dist/commands/workflow/set-change.d.ts +13 -0
  18. package/dist/commands/workflow/set-change.js +87 -0
  19. package/dist/commands/workflow/shared.d.ts +2 -0
  20. package/dist/commands/workflow/status.js +3 -0
  21. package/dist/commands/workspace/context-status.d.ts +4 -0
  22. package/dist/commands/workspace/context-status.js +59 -0
  23. package/dist/commands/workspace/open-target-selection.d.ts +13 -0
  24. package/dist/commands/workspace/open-target-selection.js +146 -0
  25. package/dist/commands/workspace/open-view.d.ts +62 -0
  26. package/dist/commands/workspace/open-view.js +249 -0
  27. package/dist/commands/workspace/open.d.ts +16 -8
  28. package/dist/commands/workspace/open.js +40 -14
  29. package/dist/commands/workspace/opener-selection.d.ts +11 -0
  30. package/dist/commands/workspace/opener-selection.js +98 -0
  31. package/dist/commands/workspace/operations.d.ts +14 -8
  32. package/dist/commands/workspace/operations.js +228 -160
  33. package/dist/commands/workspace/prompt-theme.d.ts +29 -0
  34. package/dist/commands/workspace/prompt-theme.js +24 -0
  35. package/dist/commands/workspace/registration.d.ts +13 -0
  36. package/dist/commands/workspace/registration.js +84 -0
  37. package/dist/commands/workspace/selection.d.ts +3 -0
  38. package/dist/commands/workspace/selection.js +42 -40
  39. package/dist/commands/workspace/setup-prompts.d.ts +13 -0
  40. package/dist/commands/workspace/setup-prompts.js +121 -0
  41. package/dist/commands/workspace/types.d.ts +15 -0
  42. package/dist/commands/workspace.js +59 -340
  43. package/dist/core/artifact-graph/index.d.ts +2 -1
  44. package/dist/core/artifact-graph/instruction-loader.d.ts +10 -23
  45. package/dist/core/artifact-graph/instruction-loader.js +28 -89
  46. package/dist/core/artifact-graph/types.d.ts +0 -7
  47. package/dist/core/artifact-graph/types.js +0 -19
  48. package/dist/core/change-metadata/index.d.ts +2 -0
  49. package/dist/core/change-metadata/index.js +2 -0
  50. package/dist/core/change-metadata/schema.d.ts +18 -0
  51. package/dist/core/change-metadata/schema.js +28 -0
  52. package/dist/core/change-status-policy.d.ts +50 -0
  53. package/dist/core/change-status-policy.js +70 -0
  54. package/dist/core/collections/index.d.ts +3 -0
  55. package/dist/core/collections/index.js +3 -0
  56. package/dist/core/collections/initiatives/collection.d.ts +4 -0
  57. package/dist/core/collections/initiatives/collection.js +17 -0
  58. package/dist/core/collections/initiatives/index.d.ts +6 -0
  59. package/dist/core/collections/initiatives/index.js +6 -0
  60. package/dist/core/collections/initiatives/operations.d.ts +49 -0
  61. package/dist/core/collections/initiatives/operations.js +175 -0
  62. package/dist/core/collections/initiatives/resolution.d.ts +87 -0
  63. package/dist/core/collections/initiatives/resolution.js +374 -0
  64. package/dist/core/collections/initiatives/schema.d.ts +41 -0
  65. package/dist/core/collections/initiatives/schema.js +134 -0
  66. package/dist/core/collections/initiatives/templates.d.ts +12 -0
  67. package/dist/core/collections/initiatives/templates.js +90 -0
  68. package/dist/core/collections/runtime.d.ts +46 -0
  69. package/dist/core/collections/runtime.js +194 -0
  70. package/dist/core/completions/command-registry.d.ts +1 -5
  71. package/dist/core/completions/command-registry.js +475 -70
  72. package/dist/core/completions/shared-flags.d.ts +12 -0
  73. package/dist/core/completions/shared-flags.js +28 -0
  74. package/dist/core/config.js +2 -1
  75. package/dist/core/context-store/binding.d.ts +53 -0
  76. package/dist/core/context-store/binding.js +197 -0
  77. package/dist/core/context-store/errors.d.ts +20 -0
  78. package/dist/core/context-store/errors.js +22 -0
  79. package/dist/core/context-store/foundation.d.ts +55 -0
  80. package/dist/core/context-store/foundation.js +321 -0
  81. package/dist/core/context-store/index.d.ts +6 -0
  82. package/dist/core/context-store/index.js +6 -0
  83. package/dist/core/context-store/operations.d.ts +85 -0
  84. package/dist/core/context-store/operations.js +528 -0
  85. package/dist/core/context-store/registry.d.ts +45 -0
  86. package/dist/core/context-store/registry.js +229 -0
  87. package/dist/core/index.d.ts +2 -0
  88. package/dist/core/index.js +2 -0
  89. package/dist/core/jira/templates.js +14 -5
  90. package/dist/core/planning-home.js +5 -21
  91. package/dist/core/validation/validator.d.ts +11 -0
  92. package/dist/core/validation/validator.js +19 -2
  93. package/dist/core/workspace/foundation.d.ts +28 -48
  94. package/dist/core/workspace/foundation.js +130 -214
  95. package/dist/core/workspace/index.d.ts +2 -0
  96. package/dist/core/workspace/index.js +2 -0
  97. package/dist/core/workspace/legacy-state.d.ts +28 -0
  98. package/dist/core/workspace/legacy-state.js +200 -0
  99. package/dist/core/workspace/open-surface.d.ts +29 -8
  100. package/dist/core/workspace/open-surface.js +122 -44
  101. package/dist/core/workspace/openers.js +11 -6
  102. package/dist/core/workspace/registry.d.ts +24 -0
  103. package/dist/core/workspace/registry.js +146 -0
  104. package/dist/core/workspace/skills.d.ts +4 -2
  105. package/dist/core/workspace/skills.js +2 -2
  106. package/dist/core/workspace/state-io.d.ts +10 -0
  107. package/dist/core/workspace/state-io.js +119 -0
  108. package/dist/utils/change-metadata.d.ts +5 -2
  109. package/dist/utils/change-metadata.js +6 -12
  110. package/dist/utils/change-utils.d.ts +2 -2
  111. package/package.json +1 -1
@@ -0,0 +1,90 @@
1
+ import { INITIATIVE_DECISIONS_FILE_NAME, INITIATIVE_DESIGN_FILE_NAME, INITIATIVE_MARKDOWN_FILE_NAMES, INITIATIVE_QUESTIONS_FILE_NAME, INITIATIVE_REQUIREMENTS_FILE_NAME, INITIATIVE_TASKS_FILE_NAME, } from './schema.js';
2
+ function withTrailingNewline(content) {
3
+ return content.endsWith('\n') ? content : `${content}\n`;
4
+ }
5
+ export function buildInitiativeRequirementsTemplate(state) {
6
+ return withTrailingNewline(`# Requirements
7
+
8
+ ## Product Intent
9
+
10
+ ${state.summary}
11
+
12
+ ## Accepted Requirements
13
+
14
+ - TBD
15
+
16
+ ## Out Of Scope
17
+
18
+ - TBD
19
+ `);
20
+ }
21
+ export function buildInitiativeDesignTemplate(state) {
22
+ return withTrailingNewline(`# Design
23
+
24
+ ## Context
25
+
26
+ ${state.summary}
27
+
28
+ ## Approach
29
+
30
+ TBD
31
+
32
+ ## Affected Areas
33
+
34
+ - TBD
35
+
36
+ ## Dependencies
37
+
38
+ - TBD
39
+
40
+ ## Risks
41
+
42
+ - TBD
43
+ `);
44
+ }
45
+ export function buildInitiativeDecisionsTemplate(state) {
46
+ return withTrailingNewline(`# Decisions
47
+
48
+ ## Accepted Decisions
49
+
50
+ ### ${state.created}: ${state.title}
51
+
52
+ - Decision: TBD
53
+ - Why: TBD
54
+ - Implications: TBD
55
+ `);
56
+ }
57
+ export function buildInitiativeQuestionsTemplate() {
58
+ return withTrailingNewline(`# Questions
59
+
60
+ ## Open Questions
61
+
62
+ - TBD
63
+
64
+ ## Resolved Questions
65
+
66
+ - TBD
67
+ `);
68
+ }
69
+ export function buildInitiativeTasksTemplate() {
70
+ return withTrailingNewline(`# Tasks
71
+
72
+ ## Coordination Tasks
73
+
74
+ - [ ] TBD
75
+ `);
76
+ }
77
+ export function buildDefaultInitiativeFiles(state) {
78
+ const templates = {
79
+ [INITIATIVE_REQUIREMENTS_FILE_NAME]: buildInitiativeRequirementsTemplate(state),
80
+ [INITIATIVE_DESIGN_FILE_NAME]: buildInitiativeDesignTemplate(state),
81
+ [INITIATIVE_DECISIONS_FILE_NAME]: buildInitiativeDecisionsTemplate(state),
82
+ [INITIATIVE_QUESTIONS_FILE_NAME]: buildInitiativeQuestionsTemplate(),
83
+ [INITIATIVE_TASKS_FILE_NAME]: buildInitiativeTasksTemplate(),
84
+ };
85
+ return INITIATIVE_MARKDOWN_FILE_NAMES.map((fileName) => ({
86
+ fileName,
87
+ content: templates[fileName],
88
+ }));
89
+ }
90
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1,46 @@
1
+ export type CollectionMetadata = Readonly<Record<string, unknown>>;
2
+ export type CollectionHooks = Readonly<Record<string, unknown>>;
3
+ export interface CollectionDefinition<THandle = unknown> {
4
+ id: string;
5
+ mount: string;
6
+ metadata?: CollectionMetadata;
7
+ hooks?: CollectionHooks;
8
+ createHandle?: (context: MountedCollectionContext) => THandle;
9
+ }
10
+ export interface CollectionRegistry {
11
+ list(): readonly CollectionDefinition[];
12
+ get<THandle = unknown>(collectionId: string): CollectionDefinition<THandle> | undefined;
13
+ require<THandle = unknown>(collectionId: string): CollectionDefinition<THandle>;
14
+ }
15
+ export interface MountedCollectionContext {
16
+ storeRoot: string;
17
+ collectionId: string;
18
+ mount: string;
19
+ mountRoot: string;
20
+ resolvePath(relativePath?: string): string;
21
+ toStorePath(relativePath?: string): string;
22
+ }
23
+ export interface MountedCollection<THandle = unknown> {
24
+ collectionId: string;
25
+ mount: string;
26
+ mountRoot: string;
27
+ context: MountedCollectionContext;
28
+ handle: THandle | undefined;
29
+ resolvePath(relativePath?: string): string;
30
+ toStorePath(relativePath?: string): string;
31
+ }
32
+ export interface MountedCollectionRegistry {
33
+ list(): readonly MountedCollection[];
34
+ get<THandle = unknown>(collectionId: string): MountedCollection<THandle> | undefined;
35
+ require<THandle = unknown>(collectionId: string): MountedCollection<THandle>;
36
+ }
37
+ export interface MountCollectionsInput {
38
+ storeRoot: string;
39
+ collections: CollectionRegistry;
40
+ }
41
+ export declare function validateCollectionId(id: string): string;
42
+ export declare function validateMount(mount: string): string;
43
+ export declare function parseCollectionPath(input?: string): string;
44
+ export declare function createCollectionRegistry(definitions: readonly CollectionDefinition[]): CollectionRegistry;
45
+ export declare function mountCollections(input: MountCollectionsInput): MountedCollectionRegistry;
46
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1,194 @@
1
+ import * as path from 'node:path';
2
+ import { FileSystemUtils } from '../../utils/file-system.js';
3
+ function assertNoNul(value, label) {
4
+ if (value.includes('\0')) {
5
+ throw new Error(`${label} must not contain NUL bytes`);
6
+ }
7
+ }
8
+ function validateKebabSegment(value, label) {
9
+ assertNoNul(value, label);
10
+ if (value.length === 0) {
11
+ throw new Error(`${label} must not be empty`);
12
+ }
13
+ if (value === '.' || value === '..') {
14
+ throw new Error(`${label} must not be '${value}'`);
15
+ }
16
+ if (/[\\/]/u.test(value)) {
17
+ throw new Error(`${label} must not contain path separators`);
18
+ }
19
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(value)) {
20
+ throw new Error(`${label} must be kebab-case with lowercase letters, numbers, and single hyphen separators`);
21
+ }
22
+ return value;
23
+ }
24
+ export function validateCollectionId(id) {
25
+ return validateKebabSegment(id, 'Collection id');
26
+ }
27
+ export function validateMount(mount) {
28
+ assertNoNul(mount, 'Collection mount');
29
+ if (mount.startsWith('.')) {
30
+ throw new Error(`Collection mount '${mount}' is reserved`);
31
+ }
32
+ return validateKebabSegment(mount, 'Collection mount');
33
+ }
34
+ function isWindowsDrivePath(value) {
35
+ return /^[A-Za-z]:/u.test(value);
36
+ }
37
+ function isUncPath(value) {
38
+ return value.startsWith('\\\\') || value.startsWith('//');
39
+ }
40
+ export function parseCollectionPath(input = '') {
41
+ assertNoNul(input, 'Collection path');
42
+ if (input.length === 0) {
43
+ return '';
44
+ }
45
+ if (input.includes('\\')) {
46
+ throw new Error('Collection path must use forward slashes');
47
+ }
48
+ if (isWindowsDrivePath(input)) {
49
+ throw new Error('Collection path must not be a Windows drive path');
50
+ }
51
+ if (isUncPath(input) || path.posix.isAbsolute(input)) {
52
+ throw new Error('Collection path must be relative');
53
+ }
54
+ const segments = input.split('/');
55
+ for (const segment of segments) {
56
+ if (segment.length === 0) {
57
+ throw new Error('Collection path must not contain empty segments');
58
+ }
59
+ if (segment === '.' || segment === '..') {
60
+ throw new Error('Collection path must not contain dot segments');
61
+ }
62
+ }
63
+ return segments.join('/');
64
+ }
65
+ function compareCollectionDefinitions(a, b) {
66
+ return a.id.localeCompare(b.id);
67
+ }
68
+ export function createCollectionRegistry(definitions) {
69
+ const byId = new Map();
70
+ const mountOwners = new Map();
71
+ for (const definition of definitions) {
72
+ const id = validateCollectionId(definition.id);
73
+ const mount = validateMount(definition.mount);
74
+ if (byId.has(id)) {
75
+ throw new Error(`Duplicate collection id '${id}'`);
76
+ }
77
+ const existingMountOwner = mountOwners.get(mount);
78
+ if (existingMountOwner) {
79
+ throw new Error(`Duplicate collection mount '${mount}' for '${existingMountOwner}' and '${id}'`);
80
+ }
81
+ const normalizedDefinition = {
82
+ ...definition,
83
+ id,
84
+ mount,
85
+ };
86
+ byId.set(id, normalizedDefinition);
87
+ mountOwners.set(mount, id);
88
+ }
89
+ const sortedDefinitions = Array.from(byId.values()).sort(compareCollectionDefinitions);
90
+ return {
91
+ list() {
92
+ return [...sortedDefinitions];
93
+ },
94
+ get(collectionId) {
95
+ const id = validateCollectionId(collectionId);
96
+ return byId.get(id);
97
+ },
98
+ require(collectionId) {
99
+ const definition = this.get(collectionId);
100
+ if (!definition) {
101
+ throw new Error(`Unknown collection '${collectionId}'`);
102
+ }
103
+ return definition;
104
+ },
105
+ };
106
+ }
107
+ function isWindowsLikePath(candidatePath) {
108
+ return /^[A-Za-z]:[\\/]/u.test(candidatePath) || candidatePath.startsWith('\\\\');
109
+ }
110
+ function relativePath(fromPath, toPath) {
111
+ if (isWindowsLikePath(fromPath) || isWindowsLikePath(toPath)) {
112
+ return path.win32.relative(path.win32.normalize(fromPath), path.win32.normalize(toPath));
113
+ }
114
+ return path.posix.relative(fromPath.replace(/\\/g, '/'), toPath.replace(/\\/g, '/'));
115
+ }
116
+ function isRelativePathAbsolute(value, windowsLike) {
117
+ return windowsLike ? path.win32.isAbsolute(value) : path.posix.isAbsolute(value);
118
+ }
119
+ function isSameOrDescendant(rootPath, candidatePath) {
120
+ const windowsLike = isWindowsLikePath(rootPath) || isWindowsLikePath(candidatePath);
121
+ const relative = relativePath(rootPath, candidatePath);
122
+ const escapesRoot = /^\.\.(?:[\\/]|$)/u.test(relative);
123
+ return (relative === '' ||
124
+ (!escapesRoot && !isRelativePathAbsolute(relative, windowsLike)));
125
+ }
126
+ function getMountRoot(storeRoot, mount) {
127
+ return FileSystemUtils.joinPath(storeRoot, validateMount(mount));
128
+ }
129
+ function resolvePathInsideMount(mountRoot, relativePath) {
130
+ const collectionPath = parseCollectionPath(relativePath);
131
+ const resolvedPath = collectionPath.length > 0
132
+ ? FileSystemUtils.joinPath(mountRoot, collectionPath)
133
+ : mountRoot;
134
+ if (!isSameOrDescendant(mountRoot, resolvedPath)) {
135
+ throw new Error(`Collection path escapes mount: ${relativePath ?? ''}`);
136
+ }
137
+ return resolvedPath;
138
+ }
139
+ function toStorePath(mount, relativePath) {
140
+ const collectionPath = parseCollectionPath(relativePath);
141
+ return collectionPath.length > 0
142
+ ? `${validateMount(mount)}/${collectionPath}`
143
+ : validateMount(mount);
144
+ }
145
+ function createMountedCollection(storeRoot, definition) {
146
+ const mountRoot = getMountRoot(storeRoot, definition.mount);
147
+ const resolveMountedPath = (relativePath) => resolvePathInsideMount(mountRoot, relativePath);
148
+ const resolveStorePath = (relativePath) => toStorePath(definition.mount, relativePath);
149
+ const context = {
150
+ storeRoot,
151
+ collectionId: definition.id,
152
+ mount: definition.mount,
153
+ mountRoot,
154
+ resolvePath: resolveMountedPath,
155
+ toStorePath: resolveStorePath,
156
+ };
157
+ return {
158
+ collectionId: definition.id,
159
+ mount: definition.mount,
160
+ mountRoot,
161
+ context,
162
+ handle: definition.createHandle?.(context),
163
+ resolvePath: resolveMountedPath,
164
+ toStorePath: resolveStorePath,
165
+ };
166
+ }
167
+ export function mountCollections(input) {
168
+ if (input.storeRoot.length === 0) {
169
+ throw new Error('Context store root must not be empty');
170
+ }
171
+ const byId = new Map();
172
+ for (const definition of input.collections.list()) {
173
+ const mountedCollection = createMountedCollection(input.storeRoot, definition);
174
+ byId.set(mountedCollection.collectionId, mountedCollection);
175
+ }
176
+ const sortedCollections = Array.from(byId.values()).sort((a, b) => a.collectionId.localeCompare(b.collectionId));
177
+ return {
178
+ list() {
179
+ return [...sortedCollections];
180
+ },
181
+ get(collectionId) {
182
+ const id = validateCollectionId(collectionId);
183
+ return byId.get(id);
184
+ },
185
+ require(collectionId) {
186
+ const mountedCollection = this.get(collectionId);
187
+ if (!mountedCollection) {
188
+ throw new Error(`Unknown mounted collection '${collectionId}'`);
189
+ }
190
+ return mountedCollection;
191
+ },
192
+ };
193
+ }
194
+ //# sourceMappingURL=runtime.js.map
@@ -1,7 +1,3 @@
1
- import { CommandDefinition } from './types.js';
2
- /**
3
- * Registry of all OpenSpec CLI commands with their flags and metadata.
4
- * This registry is used to generate shell completion scripts.
5
- */
1
+ import type { CommandDefinition } from './types.js';
6
2
  export declare const COMMAND_REGISTRY: CommandDefinition[];
7
3
  //# sourceMappingURL=command-registry.d.ts.map