@fission-ai/openspec 1.4.0 → 1.5.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/README.md +24 -3
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.js +94 -76
- package/dist/commands/change.d.ts +5 -1
- package/dist/commands/change.js +17 -15
- package/dist/commands/config.js +6 -65
- package/dist/commands/context.d.ts +3 -0
- package/dist/commands/context.js +155 -0
- package/dist/commands/doctor.d.ts +8 -0
- package/dist/commands/doctor.js +163 -0
- package/dist/commands/shared-gather.d.ts +14 -0
- package/dist/commands/shared-gather.js +31 -0
- package/dist/commands/shared-output.d.ts +18 -0
- package/dist/commands/shared-output.js +61 -0
- package/dist/commands/show.d.ts +11 -6
- package/dist/commands/show.js +70 -25
- package/dist/commands/spec.d.ts +5 -1
- package/dist/commands/spec.js +15 -4
- package/dist/commands/store.d.ts +3 -0
- package/dist/commands/store.js +547 -0
- package/dist/commands/validate.d.ts +2 -0
- package/dist/commands/validate.js +75 -39
- package/dist/commands/workflow/index.d.ts +0 -2
- package/dist/commands/workflow/index.js +0 -1
- package/dist/commands/workflow/instructions.d.ts +11 -1
- package/dist/commands/workflow/instructions.js +71 -22
- package/dist/commands/workflow/new-change.d.ts +6 -3
- package/dist/commands/workflow/new-change.js +42 -77
- package/dist/commands/workflow/shared.d.ts +15 -3
- package/dist/commands/workflow/shared.js +20 -3
- package/dist/commands/workflow/status.d.ts +2 -0
- package/dist/commands/workflow/status.js +19 -17
- package/dist/commands/workset-input.d.ts +19 -0
- package/dist/commands/workset-input.js +112 -0
- package/dist/commands/workset-prompts.d.ts +12 -0
- package/dist/commands/workset-prompts.js +143 -0
- package/dist/commands/workset.d.ts +25 -0
- package/dist/commands/workset.js +446 -0
- package/dist/core/archive.d.ts +17 -6
- package/dist/core/archive.js +209 -56
- package/dist/core/artifact-graph/index.d.ts +1 -1
- package/dist/core/artifact-graph/instruction-loader.d.ts +18 -13
- package/dist/core/artifact-graph/instruction-loader.js +8 -31
- package/dist/core/change-metadata/schema.d.ts +1 -0
- package/dist/core/change-metadata/schema.js +4 -2
- package/dist/core/change-status-policy.d.ts +5 -18
- package/dist/core/change-status-policy.js +2 -37
- package/dist/core/command-generation/adapters/bob.js +1 -14
- package/dist/core/command-generation/adapters/claude.js +1 -14
- package/dist/core/command-generation/adapters/cursor.js +1 -14
- package/dist/core/command-generation/adapters/pi.js +1 -14
- package/dist/core/command-generation/adapters/windsurf.js +1 -14
- package/dist/core/command-generation/yaml.d.ts +22 -0
- package/dist/core/command-generation/yaml.js +38 -0
- package/dist/core/completions/command-registry.js +87 -289
- package/dist/core/completions/generators/zsh-generator.js +3 -1
- package/dist/core/completions/installers/bash-installer.js +3 -0
- package/dist/core/completions/installers/fish-installer.js +8 -0
- package/dist/core/completions/installers/powershell-installer.js +30 -2
- package/dist/core/completions/installers/zsh-installer.js +3 -0
- package/dist/core/completions/shared-flags.d.ts +1 -0
- package/dist/core/completions/shared-flags.js +5 -0
- package/dist/core/config-schema.d.ts +2 -1
- package/dist/core/config-schema.js +26 -0
- package/dist/core/file-state.d.ts +36 -0
- package/dist/core/file-state.js +112 -0
- package/dist/core/global-config.d.ts +2 -0
- package/dist/core/id.d.ts +17 -0
- package/dist/core/id.js +30 -0
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +3 -3
- package/dist/core/init.js +24 -4
- package/dist/core/list.d.ts +2 -0
- package/dist/core/list.js +19 -5
- package/dist/core/openers.d.ts +77 -0
- package/dist/core/openers.js +251 -0
- package/dist/core/openspec-root.d.ts +45 -0
- package/dist/core/openspec-root.js +192 -0
- package/dist/core/planning-home.d.ts +1 -6
- package/dist/core/planning-home.js +2 -43
- package/dist/core/project-config.d.ts +44 -1
- package/dist/core/project-config.js +160 -10
- package/dist/core/references.d.ts +63 -0
- package/dist/core/references.js +310 -0
- package/dist/core/relationship-health.d.ts +65 -0
- package/dist/core/relationship-health.js +64 -0
- package/dist/core/root-selection.d.ts +122 -0
- package/dist/core/root-selection.js +337 -0
- package/dist/core/specs-apply.d.ts +6 -1
- package/dist/core/specs-apply.js +6 -4
- package/dist/core/store/errors.d.ts +20 -0
- package/dist/core/{context-store → store}/errors.js +3 -3
- package/dist/core/store/foundation.d.ts +56 -0
- package/dist/core/store/foundation.js +251 -0
- package/dist/core/store/git.d.ts +23 -0
- package/dist/core/store/git.js +137 -0
- package/dist/core/{context-store → store}/index.d.ts +0 -1
- package/dist/core/{context-store → store}/index.js +0 -1
- package/dist/core/store/operations.d.ts +114 -0
- package/dist/core/store/operations.js +783 -0
- package/dist/core/store/registry.d.ts +58 -0
- package/dist/core/store/registry.js +275 -0
- package/dist/core/templates/workflows/apply-change.js +5 -4
- package/dist/core/templates/workflows/archive-change.js +5 -4
- package/dist/core/templates/workflows/bulk-archive-change.js +5 -4
- package/dist/core/templates/workflows/continue-change.js +7 -2
- package/dist/core/templates/workflows/explore.js +5 -0
- package/dist/core/templates/workflows/ff-change.js +5 -0
- package/dist/core/templates/workflows/new-change.js +5 -0
- package/dist/core/templates/workflows/onboard.js +4 -1
- package/dist/core/templates/workflows/propose.js +5 -0
- package/dist/core/templates/workflows/store-selection.d.ts +8 -0
- package/dist/core/templates/workflows/store-selection.js +8 -0
- package/dist/core/templates/workflows/sync-specs.js +5 -4
- package/dist/core/templates/workflows/verify-change.js +5 -4
- package/dist/core/working-set.d.ts +47 -0
- package/dist/core/working-set.js +43 -0
- package/dist/core/worksets.d.ts +75 -0
- package/dist/core/worksets.js +245 -0
- package/dist/core/zod-issues.d.ts +4 -0
- package/dist/core/zod-issues.js +10 -0
- package/dist/utils/change-metadata.d.ts +1 -0
- package/dist/utils/change-metadata.js +1 -1
- package/dist/utils/change-utils.js +15 -0
- package/dist/utils/file-system.js +36 -17
- package/package.json +6 -6
- package/dist/commands/context-store.d.ts +0 -3
- package/dist/commands/context-store.js +0 -475
- package/dist/commands/initiative.d.ts +0 -13
- package/dist/commands/initiative.js +0 -318
- package/dist/commands/workflow/initiative-link.d.ts +0 -24
- package/dist/commands/workflow/initiative-link.js +0 -47
- package/dist/commands/workflow/set-change.d.ts +0 -13
- package/dist/commands/workflow/set-change.js +0 -87
- package/dist/commands/workspace/context-status.d.ts +0 -4
- package/dist/commands/workspace/context-status.js +0 -59
- package/dist/commands/workspace/open-target-selection.d.ts +0 -13
- package/dist/commands/workspace/open-target-selection.js +0 -146
- package/dist/commands/workspace/open-view.d.ts +0 -62
- package/dist/commands/workspace/open-view.js +0 -249
- package/dist/commands/workspace/open.d.ts +0 -37
- package/dist/commands/workspace/open.js +0 -110
- package/dist/commands/workspace/opener-selection.d.ts +0 -11
- package/dist/commands/workspace/opener-selection.js +0 -98
- package/dist/commands/workspace/operations.d.ts +0 -29
- package/dist/commands/workspace/operations.js +0 -543
- package/dist/commands/workspace/prompt-theme.d.ts +0 -29
- package/dist/commands/workspace/prompt-theme.js +0 -24
- package/dist/commands/workspace/registration.d.ts +0 -13
- package/dist/commands/workspace/registration.js +0 -84
- package/dist/commands/workspace/selection.d.ts +0 -9
- package/dist/commands/workspace/selection.js +0 -115
- package/dist/commands/workspace/setup-prompts.d.ts +0 -13
- package/dist/commands/workspace/setup-prompts.js +0 -121
- package/dist/commands/workspace/types.d.ts +0 -103
- package/dist/commands/workspace/types.js +0 -36
- package/dist/commands/workspace.d.ts +0 -6
- package/dist/commands/workspace.js +0 -587
- package/dist/core/collections/index.d.ts +0 -3
- package/dist/core/collections/index.js +0 -3
- package/dist/core/collections/initiatives/collection.d.ts +0 -4
- package/dist/core/collections/initiatives/collection.js +0 -17
- package/dist/core/collections/initiatives/index.d.ts +0 -6
- package/dist/core/collections/initiatives/index.js +0 -6
- package/dist/core/collections/initiatives/operations.d.ts +0 -49
- package/dist/core/collections/initiatives/operations.js +0 -175
- package/dist/core/collections/initiatives/resolution.d.ts +0 -87
- package/dist/core/collections/initiatives/resolution.js +0 -374
- package/dist/core/collections/initiatives/schema.d.ts +0 -41
- package/dist/core/collections/initiatives/schema.js +0 -134
- package/dist/core/collections/initiatives/templates.d.ts +0 -12
- package/dist/core/collections/initiatives/templates.js +0 -90
- package/dist/core/collections/runtime.d.ts +0 -46
- package/dist/core/collections/runtime.js +0 -194
- package/dist/core/context-store/binding.d.ts +0 -53
- package/dist/core/context-store/binding.js +0 -197
- package/dist/core/context-store/errors.d.ts +0 -20
- package/dist/core/context-store/foundation.d.ts +0 -55
- package/dist/core/context-store/foundation.js +0 -321
- package/dist/core/context-store/operations.d.ts +0 -85
- package/dist/core/context-store/operations.js +0 -528
- package/dist/core/context-store/registry.d.ts +0 -45
- package/dist/core/context-store/registry.js +0 -229
- package/dist/core/workspace/foundation.d.ts +0 -67
- package/dist/core/workspace/foundation.js +0 -295
- package/dist/core/workspace/index.d.ts +0 -8
- package/dist/core/workspace/index.js +0 -8
- package/dist/core/workspace/legacy-state.d.ts +0 -28
- package/dist/core/workspace/legacy-state.js +0 -200
- package/dist/core/workspace/link-input.d.ts +0 -9
- package/dist/core/workspace/link-input.js +0 -32
- package/dist/core/workspace/open-surface.d.ts +0 -45
- package/dist/core/workspace/open-surface.js +0 -215
- package/dist/core/workspace/openers.d.ts +0 -21
- package/dist/core/workspace/openers.js +0 -124
- package/dist/core/workspace/registry.d.ts +0 -24
- package/dist/core/workspace/registry.js +0 -146
- package/dist/core/workspace/skills.d.ts +0 -57
- package/dist/core/workspace/skills.js +0 -334
- package/dist/core/workspace/state-io.d.ts +0 -10
- package/dist/core/workspace/state-io.js +0 -119
- package/schemas/workspace-planning/schema.yaml +0 -72
- package/schemas/workspace-planning/templates/design.md +0 -33
- package/schemas/workspace-planning/templates/proposal.md +0 -28
- package/schemas/workspace-planning/templates/spec.md +0 -9
- package/schemas/workspace-planning/templates/tasks.md +0 -15
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relationship health composition (slice 3.6).
|
|
3
|
+
*
|
|
4
|
+
* One read-only answer to "are the roots this work relates to available
|
|
5
|
+
* on this machine?" — pure composition over inputs the doctor command
|
|
6
|
+
* gathers. The lock's four categories stay separated: root health,
|
|
7
|
+
* store metadata health, and reference health. Nothing here (or
|
|
8
|
+
* downstream) clones, syncs, or repairs.
|
|
9
|
+
*/
|
|
10
|
+
import { makeStoreDiagnostic } from './store/errors.js';
|
|
11
|
+
import { sanitizeInline } from './references.js';
|
|
12
|
+
import { storePointerProblem } from './project-config.js';
|
|
13
|
+
import { toRootOutput } from './root-selection.js';
|
|
14
|
+
function warning(code, message, fix) {
|
|
15
|
+
return makeStoreDiagnostic('warning', code, message, { target: 'relationships', fix });
|
|
16
|
+
}
|
|
17
|
+
export function inspectRelationships(input) {
|
|
18
|
+
const status = [];
|
|
19
|
+
if (input.registryUnreadable) {
|
|
20
|
+
status.push(warning('relationship_registry_unreadable', 'The store registry is unreadable; reference health cannot be checked.', 'Run: openspec store doctor'));
|
|
21
|
+
}
|
|
22
|
+
if (input.bothShapesPointer) {
|
|
23
|
+
status.push(warning('root_pointer_ignored', `${input.bothShapesPointer.filePath} declares store '${input.bothShapesPointer.value}', but this directory is a real OpenSpec root; the declaration is ignored.`, `Remove the store: line from ${input.bothShapesPointer.filePath}, or move the planning files into the store.`));
|
|
24
|
+
}
|
|
25
|
+
if (input.malformedPointer) {
|
|
26
|
+
status.push(warning('root_pointer_invalid', `${input.malformedPointer.filePath} declares a store: pointer that cannot be used (${storePointerProblem(input.malformedPointer.reason)}).`, `Fix or remove the store: line in ${input.malformedPointer.filePath}.`));
|
|
27
|
+
}
|
|
28
|
+
if (input.inertPointerDeclarations && input.inertPointerDeclarations.fields.length > 0) {
|
|
29
|
+
status.push(warning('pointer_declarations_inert', `${input.inertPointerDeclarations.filePath} declares ${input.inertPointerDeclarations.fields.join(' and ')}, but commands read the resolved store's config — these declarations are inert.`, `Move the ${input.inertPointerDeclarations.fields.join('/')} declarations into the store's openspec/config.yaml.`));
|
|
30
|
+
}
|
|
31
|
+
// Store section: metadata facts + the divergence info note.
|
|
32
|
+
let store = null;
|
|
33
|
+
if (input.storeFacts) {
|
|
34
|
+
const storeStatus = [];
|
|
35
|
+
if (input.storeFacts.canonicalRemote &&
|
|
36
|
+
input.storeFacts.originUrl &&
|
|
37
|
+
input.storeFacts.canonicalRemote !== input.storeFacts.originUrl) {
|
|
38
|
+
storeStatus.push(makeStoreDiagnostic('info', 'store_remote_divergence', `The store.yaml remote (${sanitizeInline(input.storeFacts.canonicalRemote, 200)}) differs from the checkout's origin (${sanitizeInline(input.storeFacts.originUrl, 200)}).`, { target: 'store.metadata' }));
|
|
39
|
+
}
|
|
40
|
+
store = {
|
|
41
|
+
id: input.storeFacts.id,
|
|
42
|
+
metadata: {
|
|
43
|
+
present: input.storeFacts.metadataPresent,
|
|
44
|
+
valid: input.storeFacts.metadataValid,
|
|
45
|
+
...(input.storeFacts.canonicalRemote
|
|
46
|
+
? { remote: input.storeFacts.canonicalRemote }
|
|
47
|
+
: {}),
|
|
48
|
+
},
|
|
49
|
+
...(input.storeFacts.originUrl ? { origin_url: input.storeFacts.originUrl } : {}),
|
|
50
|
+
status: storeStatus,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
root: {
|
|
55
|
+
...toRootOutput(input.root),
|
|
56
|
+
healthy: input.rootHealthy,
|
|
57
|
+
status: input.rootStatus ?? [],
|
|
58
|
+
},
|
|
59
|
+
store,
|
|
60
|
+
references: input.referenceEntries,
|
|
61
|
+
status,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=relationship-health.js.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared OpenSpec root resolution for normal commands.
|
|
3
|
+
*
|
|
4
|
+
* Normal commands (`new change`, `status`, `instructions`, `list`, `show`,
|
|
5
|
+
* `validate`, `archive`) resolve one OpenSpec root through this module:
|
|
6
|
+
*
|
|
7
|
+
* - `--store <id>` selects a registered store's root.
|
|
8
|
+
* - Without `--store`, the nearest ancestor containing `openspec/` wins.
|
|
9
|
+
* Leftover workspace view state is never considered a root here.
|
|
10
|
+
* - With no nearest root, registered stores produce a selection hint error;
|
|
11
|
+
* otherwise commands may treat the current directory as an implicit root.
|
|
12
|
+
*
|
|
13
|
+
* Diagnostic codes reuse the store taxonomy where an error passes
|
|
14
|
+
* through unchanged (`invalid_store_id`, metadata parse failures);
|
|
15
|
+
* resolver-specific failures use the normal-command codes below
|
|
16
|
+
* (`unknown_store`, `no_registered_stores`, `store_identity_mismatch`,
|
|
17
|
+
* `unhealthy_store_root`, `store_path_not_supported`,
|
|
18
|
+
* `invalid_store_pointer`, `no_root_with_registered_stores`,
|
|
19
|
+
* `no_openspec_root`).
|
|
20
|
+
*/
|
|
21
|
+
import { type PlanningHome } from './planning-home.js';
|
|
22
|
+
export type OpenSpecRootSource = 'store' | 'declared' | 'nearest' | 'implicit';
|
|
23
|
+
export interface StoreSelectorOptions {
|
|
24
|
+
store?: string;
|
|
25
|
+
storePath?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ResolveOpenSpecRootOptions extends StoreSelectorOptions {
|
|
28
|
+
startPath?: string;
|
|
29
|
+
allowImplicitRoot?: boolean;
|
|
30
|
+
globalDataDir?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ResolvedOpenSpecRoot {
|
|
33
|
+
path: string;
|
|
34
|
+
changesDir: string;
|
|
35
|
+
specsDir: string;
|
|
36
|
+
archiveDir: string;
|
|
37
|
+
defaultSchema: 'spec-driven';
|
|
38
|
+
source: OpenSpecRootSource;
|
|
39
|
+
storeId?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface RootSelectionDiagnostic {
|
|
42
|
+
severity: 'error';
|
|
43
|
+
code: string;
|
|
44
|
+
message: string;
|
|
45
|
+
target?: string;
|
|
46
|
+
fix?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare class RootSelectionError extends Error {
|
|
49
|
+
readonly diagnostic: RootSelectionDiagnostic;
|
|
50
|
+
constructor(message: string, code: string, options?: {
|
|
51
|
+
target?: string;
|
|
52
|
+
fix?: string;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export declare function isRootSelectionError(error: unknown): error is RootSelectionError;
|
|
56
|
+
/**
|
|
57
|
+
* The metadata-identity and root-health stages of registered-store
|
|
58
|
+
* resolution, as a non-throwing result. `resolveStoreRoot` maps each
|
|
59
|
+
* failure kind to its established error; the reference index assembler
|
|
60
|
+
* maps them to warnings. One shared inspection path — never fork it.
|
|
61
|
+
*/
|
|
62
|
+
export type RegisteredStoreInspection = {
|
|
63
|
+
kind: 'ok';
|
|
64
|
+
canonicalRoot: string;
|
|
65
|
+
} | {
|
|
66
|
+
kind: 'metadata_error';
|
|
67
|
+
error: unknown;
|
|
68
|
+
} | {
|
|
69
|
+
kind: 'metadata_missing';
|
|
70
|
+
metadataPath: string;
|
|
71
|
+
} | {
|
|
72
|
+
kind: 'metadata_id_mismatch';
|
|
73
|
+
actualId: string;
|
|
74
|
+
} | {
|
|
75
|
+
kind: 'unhealthy_root';
|
|
76
|
+
problems: string;
|
|
77
|
+
};
|
|
78
|
+
export declare function inspectRegisteredStore(id: string, storeRoot: string): Promise<RegisteredStoreInspection>;
|
|
79
|
+
export declare function resolveOpenSpecRoot(options?: ResolveOpenSpecRootOptions): Promise<ResolvedOpenSpecRoot>;
|
|
80
|
+
export interface RootOutput {
|
|
81
|
+
path: string;
|
|
82
|
+
source: OpenSpecRootSource;
|
|
83
|
+
store_id?: string;
|
|
84
|
+
}
|
|
85
|
+
export declare function toRootOutput(root: ResolvedOpenSpecRoot): RootOutput;
|
|
86
|
+
/**
|
|
87
|
+
* A store-selected root — explicit `--store` or the declared fallback.
|
|
88
|
+
* Cross-root behavior (absolute paths, --store hints, suppressed
|
|
89
|
+
* noun-form suggestions) keys on this, never on `source` directly.
|
|
90
|
+
*/
|
|
91
|
+
export declare function isStoreSelectedRoot(root: ResolvedOpenSpecRoot): root is ResolvedOpenSpecRoot & {
|
|
92
|
+
storeId: string;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Human-mode verification signal for a selected store. Written to stderr so
|
|
96
|
+
* raw-Markdown and agent-consumed stdout payloads stay clean.
|
|
97
|
+
*/
|
|
98
|
+
export declare function emitStoreRootBanner(root: ResolvedOpenSpecRoot): void;
|
|
99
|
+
/**
|
|
100
|
+
* Keeps follow-up command hints inside the selected store: a hint a user can
|
|
101
|
+
* paste verbatim must carry `--store <id>` when a store was selected.
|
|
102
|
+
*/
|
|
103
|
+
export declare function withStoreFlag(root: ResolvedOpenSpecRoot, command: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Compatibility bridge for workflow code that still expects a PlanningHome.
|
|
106
|
+
* The planning home is always repo-shaped.
|
|
107
|
+
*/
|
|
108
|
+
export declare function toPlanningHome(root: ResolvedOpenSpecRoot): PlanningHome;
|
|
109
|
+
/**
|
|
110
|
+
* CLI adapter shared by the supported commands. In JSON mode a resolution
|
|
111
|
+
* failure is reported as a machine-readable payload on stdout (no human prose
|
|
112
|
+
* or blank lines) with a non-zero exit code; the caller must return when this
|
|
113
|
+
* resolves to null. In human mode the error propagates to the command's
|
|
114
|
+
* standard error handling so message text and exit behavior stay consistent.
|
|
115
|
+
*/
|
|
116
|
+
export declare function resolveRootForCommand(selector: StoreSelectorOptions, output?: {
|
|
117
|
+
json?: boolean;
|
|
118
|
+
failurePayload?: Record<string, unknown>;
|
|
119
|
+
/** Diagnostic commands inspect what exists; they never scaffold. */
|
|
120
|
+
allowImplicitRoot?: boolean;
|
|
121
|
+
}): Promise<ResolvedOpenSpecRoot | null>;
|
|
122
|
+
//# sourceMappingURL=root-selection.d.ts.map
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared OpenSpec root resolution for normal commands.
|
|
3
|
+
*
|
|
4
|
+
* Normal commands (`new change`, `status`, `instructions`, `list`, `show`,
|
|
5
|
+
* `validate`, `archive`) resolve one OpenSpec root through this module:
|
|
6
|
+
*
|
|
7
|
+
* - `--store <id>` selects a registered store's root.
|
|
8
|
+
* - Without `--store`, the nearest ancestor containing `openspec/` wins.
|
|
9
|
+
* Leftover workspace view state is never considered a root here.
|
|
10
|
+
* - With no nearest root, registered stores produce a selection hint error;
|
|
11
|
+
* otherwise commands may treat the current directory as an implicit root.
|
|
12
|
+
*
|
|
13
|
+
* Diagnostic codes reuse the store taxonomy where an error passes
|
|
14
|
+
* through unchanged (`invalid_store_id`, metadata parse failures);
|
|
15
|
+
* resolver-specific failures use the normal-command codes below
|
|
16
|
+
* (`unknown_store`, `no_registered_stores`, `store_identity_mismatch`,
|
|
17
|
+
* `unhealthy_store_root`, `store_path_not_supported`,
|
|
18
|
+
* `invalid_store_pointer`, `no_root_with_registered_stores`,
|
|
19
|
+
* `no_openspec_root`).
|
|
20
|
+
*/
|
|
21
|
+
import * as fs from 'node:fs';
|
|
22
|
+
import * as path from 'node:path';
|
|
23
|
+
import { StoreError } from './store/errors.js';
|
|
24
|
+
import { getStoreMetadataPath, listStoreRegistryEntries, readStoreRegistryState, readOptionalStoreMetadataState, validateStoreId, } from './store/foundation.js';
|
|
25
|
+
import { getStoreRootForBackend } from './store/registry.js';
|
|
26
|
+
import { inspectOpenSpecRoot } from './openspec-root.js';
|
|
27
|
+
import { findRepoPlanningRootSync } from './planning-home.js';
|
|
28
|
+
import { classifyOpenSpecDir, storePointerProblem } from './project-config.js';
|
|
29
|
+
import { FileSystemUtils } from '../utils/file-system.js';
|
|
30
|
+
export class RootSelectionError extends Error {
|
|
31
|
+
diagnostic;
|
|
32
|
+
constructor(message, code, options = {}) {
|
|
33
|
+
super(message);
|
|
34
|
+
this.name = 'RootSelectionError';
|
|
35
|
+
this.diagnostic = {
|
|
36
|
+
severity: 'error',
|
|
37
|
+
code,
|
|
38
|
+
message,
|
|
39
|
+
...options,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function isRootSelectionError(error) {
|
|
44
|
+
return error instanceof RootSelectionError;
|
|
45
|
+
}
|
|
46
|
+
function fromStoreError(error) {
|
|
47
|
+
if (error instanceof StoreError) {
|
|
48
|
+
throw new RootSelectionError(error.message, error.diagnostic.code, {
|
|
49
|
+
...(error.diagnostic.target ? { target: error.diagnostic.target } : {}),
|
|
50
|
+
...(error.diagnostic.fix ? { fix: error.diagnostic.fix } : {}),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
function doctorFix(id) {
|
|
56
|
+
return `Run openspec store doctor ${id} to inspect it.`;
|
|
57
|
+
}
|
|
58
|
+
function makeRoot(rootPath, source, storeId) {
|
|
59
|
+
return {
|
|
60
|
+
path: rootPath,
|
|
61
|
+
changesDir: path.join(rootPath, 'openspec', 'changes'),
|
|
62
|
+
specsDir: path.join(rootPath, 'openspec', 'specs'),
|
|
63
|
+
archiveDir: path.join(rootPath, 'openspec', 'changes', 'archive'),
|
|
64
|
+
defaultSchema: 'spec-driven',
|
|
65
|
+
source,
|
|
66
|
+
...(storeId ? { storeId } : {}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function canonicalDirectory(startPath) {
|
|
70
|
+
const resolved = path.resolve(startPath);
|
|
71
|
+
try {
|
|
72
|
+
const stats = fs.statSync(resolved);
|
|
73
|
+
const dir = stats.isDirectory() ? resolved : path.dirname(resolved);
|
|
74
|
+
return FileSystemUtils.canonicalizeExistingPath(dir);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return resolved;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function resolveStoreRoot(id, globalDataDir, source = 'store') {
|
|
81
|
+
try {
|
|
82
|
+
validateStoreId(id);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
fromStoreError(error);
|
|
86
|
+
}
|
|
87
|
+
let registry;
|
|
88
|
+
try {
|
|
89
|
+
registry = await readStoreRegistryState(globalDataDir ? { globalDataDir } : {});
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
fromStoreError(error);
|
|
93
|
+
}
|
|
94
|
+
const entries = registry ? listStoreRegistryEntries(registry) : [];
|
|
95
|
+
const entry = entries.find((candidate) => candidate.id === id);
|
|
96
|
+
if (!entry) {
|
|
97
|
+
if (entries.length === 0) {
|
|
98
|
+
throw new RootSelectionError(`Unknown store '${id}'. No stores are registered.`, 'no_registered_stores', {
|
|
99
|
+
target: 'store.id',
|
|
100
|
+
fix: `Run openspec store setup ${id} or openspec store register <path> first.`,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
throw new RootSelectionError(`Unknown store '${id}'. Registered stores: ${entries
|
|
104
|
+
.map((candidate) => candidate.id)
|
|
105
|
+
.join(', ')}.`, 'unknown_store', {
|
|
106
|
+
target: 'store.id',
|
|
107
|
+
fix: 'Pass a registered store id, or run openspec store list.',
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const storeRoot = getStoreRootForBackend(entry.backend);
|
|
111
|
+
const inspection = await inspectRegisteredStore(id, storeRoot);
|
|
112
|
+
switch (inspection.kind) {
|
|
113
|
+
case 'metadata_error':
|
|
114
|
+
return fromStoreError(inspection.error);
|
|
115
|
+
case 'metadata_missing':
|
|
116
|
+
// The doctor pointer lives in the message because human-mode command
|
|
117
|
+
// wrappers print only the message, not the fix field.
|
|
118
|
+
throw new RootSelectionError(`Store '${id}' is missing identity metadata at ${inspection.metadataPath}. ${doctorFix(id)}`, 'store_identity_mismatch', { target: 'store.metadata', fix: doctorFix(id) });
|
|
119
|
+
case 'metadata_id_mismatch':
|
|
120
|
+
throw new RootSelectionError(`Store '${id}' metadata id '${inspection.actualId}' does not match its registered id. ${doctorFix(id)}`, 'store_identity_mismatch', { target: 'store.metadata', fix: doctorFix(id) });
|
|
121
|
+
case 'unhealthy_root':
|
|
122
|
+
throw new RootSelectionError(`Store '${id}' does not have a healthy OpenSpec root at ${storeRoot}: ${inspection.problems} ${doctorFix(id)}`, 'unhealthy_store_root', { target: 'openspec.root', fix: doctorFix(id) });
|
|
123
|
+
case 'ok':
|
|
124
|
+
return makeRoot(inspection.canonicalRoot, source, id);
|
|
125
|
+
default: {
|
|
126
|
+
// Exhaustiveness guard: a new inspection kind must be handled
|
|
127
|
+
// here explicitly, not fall through to an undefined root.
|
|
128
|
+
const unhandled = inspection;
|
|
129
|
+
throw new Error(`Unhandled store inspection kind: ${JSON.stringify(unhandled)}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export async function inspectRegisteredStore(id, storeRoot) {
|
|
134
|
+
// Identity (metadata) failures win before root-health diagnostics.
|
|
135
|
+
let metadata;
|
|
136
|
+
try {
|
|
137
|
+
metadata = await readOptionalStoreMetadataState(storeRoot);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
return { kind: 'metadata_error', error };
|
|
141
|
+
}
|
|
142
|
+
if (!metadata) {
|
|
143
|
+
return { kind: 'metadata_missing', metadataPath: getStoreMetadataPath(storeRoot) };
|
|
144
|
+
}
|
|
145
|
+
if (metadata.id !== id) {
|
|
146
|
+
return { kind: 'metadata_id_mismatch', actualId: metadata.id };
|
|
147
|
+
}
|
|
148
|
+
const inspection = await inspectOpenSpecRoot(storeRoot);
|
|
149
|
+
if (!inspection.healthy) {
|
|
150
|
+
const problems = inspection.diagnostics.map((diagnostic) => diagnostic.message).join(' ') ||
|
|
151
|
+
'OpenSpec root is missing or incomplete.';
|
|
152
|
+
return { kind: 'unhealthy_root', problems };
|
|
153
|
+
}
|
|
154
|
+
return { kind: 'ok', canonicalRoot: FileSystemUtils.canonicalizeExistingPath(storeRoot) };
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Classifies the nearest `openspec/` directory (slice 3.2): a planning
|
|
158
|
+
* shape (specs/ or changes/ directories) is a real root and wins —
|
|
159
|
+
* fallback never override. A config-only directory with a `store:`
|
|
160
|
+
* pointer resolves the declared store; without one, it stays a root
|
|
161
|
+
* (today's behavior for freshly initialized minimal roots).
|
|
162
|
+
*/
|
|
163
|
+
/**
|
|
164
|
+
* The nearest-root walk, qualified: an `openspec/` DIRECTORY alone is
|
|
165
|
+
* not a root — it must carry a planning shape or a config file.
|
|
166
|
+
* Without this, the recommended `~/openspec/<id>` store layout would
|
|
167
|
+
* make $HOME a phantom root that captures every command under the
|
|
168
|
+
* home tree.
|
|
169
|
+
*/
|
|
170
|
+
function findQualifyingRootSync(startPath) {
|
|
171
|
+
let candidate = findRepoPlanningRootSync(startPath);
|
|
172
|
+
while (candidate) {
|
|
173
|
+
const { hasPlanningShape, pointer } = classifyOpenSpecDir(candidate);
|
|
174
|
+
if (hasPlanningShape || pointer.filePath) {
|
|
175
|
+
return candidate;
|
|
176
|
+
}
|
|
177
|
+
const parent = path.dirname(candidate);
|
|
178
|
+
if (parent === candidate) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
candidate = findRepoPlanningRootSync(parent);
|
|
182
|
+
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
async function resolveNearestOrDeclaredRoot(nearestRoot, globalDataDir) {
|
|
186
|
+
const { hasPlanningShape, pointer } = classifyOpenSpecDir(nearestRoot);
|
|
187
|
+
if (hasPlanningShape) {
|
|
188
|
+
if (pointer.value !== undefined) {
|
|
189
|
+
console.error(`Warning: ${pointer.filePath} declares store '${pointer.value}', but this directory is a real OpenSpec root; the declaration is ignored.`);
|
|
190
|
+
}
|
|
191
|
+
return makeRoot(nearestRoot, 'nearest');
|
|
192
|
+
}
|
|
193
|
+
if (pointer.malformed) {
|
|
194
|
+
const problem = storePointerProblem(pointer.malformed);
|
|
195
|
+
throw new RootSelectionError(`Invalid store declaration in ${pointer.filePath}: ${problem}.`, 'invalid_store_pointer', {
|
|
196
|
+
target: 'store.pointer',
|
|
197
|
+
fix: pointer.malformed === 'unparseable'
|
|
198
|
+
? `Fix the YAML syntax in ${pointer.filePath}.`
|
|
199
|
+
: `Edit ${pointer.filePath} so the store key is a registered store id, or remove it.`,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (pointer.value === undefined) {
|
|
203
|
+
return makeRoot(nearestRoot, 'nearest');
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
return await resolveStoreRoot(pointer.value, globalDataDir, 'declared');
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
if (error instanceof RootSelectionError) {
|
|
210
|
+
// Rewrap with the declaration origin. The unknown-store fix is
|
|
211
|
+
// reshaped for the actual mistake: the user declared a pointer,
|
|
212
|
+
// they did not pass --store.
|
|
213
|
+
const declarationFix = error.diagnostic.code === 'unknown_store'
|
|
214
|
+
? `Register the store (openspec store register <path> --id ${pointer.value}) or edit ${pointer.filePath} to name a registered store.`
|
|
215
|
+
: error.diagnostic.fix;
|
|
216
|
+
throw new RootSelectionError(`Declared in ${pointer.filePath}: ${error.message}`, error.diagnostic.code, {
|
|
217
|
+
...(error.diagnostic.target ? { target: error.diagnostic.target } : {}),
|
|
218
|
+
...(declarationFix ? { fix: declarationFix } : {}),
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
throw error;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
export async function resolveOpenSpecRoot(options = {}) {
|
|
225
|
+
if (options.storePath !== undefined) {
|
|
226
|
+
throw new RootSelectionError('--store-path is not supported. Register the path with openspec store register <path>, then select it with --store <id>.', 'store_path_not_supported', {
|
|
227
|
+
target: 'store.id',
|
|
228
|
+
fix: 'openspec store register <path>, then rerun with --store <id>.',
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (options.store !== undefined) {
|
|
232
|
+
return resolveStoreRoot(options.store, options.globalDataDir);
|
|
233
|
+
}
|
|
234
|
+
const startPath = options.startPath ?? process.cwd();
|
|
235
|
+
const nearestRoot = findQualifyingRootSync(startPath);
|
|
236
|
+
if (nearestRoot) {
|
|
237
|
+
return resolveNearestOrDeclaredRoot(nearestRoot, options.globalDataDir);
|
|
238
|
+
}
|
|
239
|
+
let registry;
|
|
240
|
+
try {
|
|
241
|
+
registry = await readStoreRegistryState(options.globalDataDir ? { globalDataDir: options.globalDataDir } : {});
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
fromStoreError(error);
|
|
245
|
+
}
|
|
246
|
+
const registeredIds = registry
|
|
247
|
+
? listStoreRegistryEntries(registry).map((entry) => entry.id)
|
|
248
|
+
: [];
|
|
249
|
+
if (registeredIds.length > 0) {
|
|
250
|
+
throw new RootSelectionError(`No OpenSpec root found in the current directory or its ancestors. Registered stores: ${registeredIds.join(', ')}. Pass --store <id> to use one, or run openspec init to create a local root.`, 'no_root_with_registered_stores', {
|
|
251
|
+
target: 'openspec.root',
|
|
252
|
+
fix: `Rerun with --store <id> (registered: ${registeredIds.join(', ')}) or run openspec init.`,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
if (options.allowImplicitRoot === false) {
|
|
256
|
+
throw new RootSelectionError('No OpenSpec root found from the current directory.', 'no_openspec_root', { target: 'openspec.root', fix: 'Run openspec init to create a root here.' });
|
|
257
|
+
}
|
|
258
|
+
return makeRoot(canonicalDirectory(startPath), 'implicit');
|
|
259
|
+
}
|
|
260
|
+
export function toRootOutput(root) {
|
|
261
|
+
return {
|
|
262
|
+
path: root.path,
|
|
263
|
+
source: root.source,
|
|
264
|
+
...(root.storeId ? { store_id: root.storeId } : {}),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* A store-selected root — explicit `--store` or the declared fallback.
|
|
269
|
+
* Cross-root behavior (absolute paths, --store hints, suppressed
|
|
270
|
+
* noun-form suggestions) keys on this, never on `source` directly.
|
|
271
|
+
*/
|
|
272
|
+
export function isStoreSelectedRoot(root) {
|
|
273
|
+
return root.storeId !== undefined;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Human-mode verification signal for a selected store. Written to stderr so
|
|
277
|
+
* raw-Markdown and agent-consumed stdout payloads stay clean.
|
|
278
|
+
*/
|
|
279
|
+
export function emitStoreRootBanner(root) {
|
|
280
|
+
if (isStoreSelectedRoot(root)) {
|
|
281
|
+
console.error(`Using OpenSpec root: ${root.storeId} (${root.path})`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Keeps follow-up command hints inside the selected store: a hint a user can
|
|
286
|
+
* paste verbatim must carry `--store <id>` when a store was selected.
|
|
287
|
+
*/
|
|
288
|
+
export function withStoreFlag(root, command) {
|
|
289
|
+
return isStoreSelectedRoot(root)
|
|
290
|
+
? `${command} --store ${root.storeId}`
|
|
291
|
+
: command;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Compatibility bridge for workflow code that still expects a PlanningHome.
|
|
295
|
+
* The planning home is always repo-shaped.
|
|
296
|
+
*/
|
|
297
|
+
export function toPlanningHome(root) {
|
|
298
|
+
return {
|
|
299
|
+
kind: 'repo',
|
|
300
|
+
root: root.path,
|
|
301
|
+
changesDir: root.changesDir,
|
|
302
|
+
defaultSchema: root.defaultSchema,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* CLI adapter shared by the supported commands. In JSON mode a resolution
|
|
307
|
+
* failure is reported as a machine-readable payload on stdout (no human prose
|
|
308
|
+
* or blank lines) with a non-zero exit code; the caller must return when this
|
|
309
|
+
* resolves to null. In human mode the error propagates to the command's
|
|
310
|
+
* standard error handling so message text and exit behavior stay consistent.
|
|
311
|
+
*/
|
|
312
|
+
export async function resolveRootForCommand(selector, output = {}) {
|
|
313
|
+
try {
|
|
314
|
+
const root = await resolveOpenSpecRoot({
|
|
315
|
+
...(selector.store !== undefined ? { store: selector.store } : {}),
|
|
316
|
+
...(selector.storePath !== undefined ? { storePath: selector.storePath } : {}),
|
|
317
|
+
...(output.allowImplicitRoot !== undefined
|
|
318
|
+
? { allowImplicitRoot: output.allowImplicitRoot }
|
|
319
|
+
: {}),
|
|
320
|
+
});
|
|
321
|
+
// Emitted at resolution time so the banner survives command failures
|
|
322
|
+
// that happen after the root was successfully selected.
|
|
323
|
+
if (!output.json) {
|
|
324
|
+
emitStoreRootBanner(root);
|
|
325
|
+
}
|
|
326
|
+
return root;
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
if (output.json && isRootSelectionError(error)) {
|
|
330
|
+
console.log(JSON.stringify({ ...(output.failurePayload ?? {}), status: [error.diagnostic] }, null, 2));
|
|
331
|
+
process.exitCode = 1;
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
throw error;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=root-selection.js.map
|
|
@@ -35,7 +35,9 @@ export declare function findSpecUpdates(changeDir: string, mainSpecsDir: string)
|
|
|
35
35
|
* Build an updated spec by applying delta operations.
|
|
36
36
|
* Returns the rebuilt content and counts of operations.
|
|
37
37
|
*/
|
|
38
|
-
export declare function buildUpdatedSpec(update: SpecUpdate, changeName: string
|
|
38
|
+
export declare function buildUpdatedSpec(update: SpecUpdate, changeName: string, options?: {
|
|
39
|
+
silent?: boolean;
|
|
40
|
+
}): Promise<{
|
|
39
41
|
rebuilt: string;
|
|
40
42
|
counts: {
|
|
41
43
|
added: number;
|
|
@@ -52,6 +54,9 @@ export declare function writeUpdatedSpec(update: SpecUpdate, rebuilt: string, co
|
|
|
52
54
|
modified: number;
|
|
53
55
|
removed: number;
|
|
54
56
|
renamed: number;
|
|
57
|
+
}, options?: {
|
|
58
|
+
silent?: boolean;
|
|
59
|
+
displayPath?: string;
|
|
55
60
|
}): Promise<void>;
|
|
56
61
|
/**
|
|
57
62
|
* Build a skeleton spec for new capabilities.
|
package/dist/core/specs-apply.js
CHANGED
|
@@ -57,7 +57,7 @@ export async function findSpecUpdates(changeDir, mainSpecsDir) {
|
|
|
57
57
|
* Build an updated spec by applying delta operations.
|
|
58
58
|
* Returns the rebuilt content and counts of operations.
|
|
59
59
|
*/
|
|
60
|
-
export async function buildUpdatedSpec(update, changeName) {
|
|
60
|
+
export async function buildUpdatedSpec(update, changeName, options = {}) {
|
|
61
61
|
// Read change spec content (delta-format expected)
|
|
62
62
|
const changeContent = await fs.readFile(update.source, 'utf-8');
|
|
63
63
|
// Parse deltas from the change spec file
|
|
@@ -148,7 +148,7 @@ export async function buildUpdatedSpec(update, changeName) {
|
|
|
148
148
|
throw new Error(`${specName}: target spec does not exist; only ADDED requirements are allowed for new specs. MODIFIED and RENAMED operations require an existing spec.`);
|
|
149
149
|
}
|
|
150
150
|
// Warn about REMOVED requirements being ignored for new specs
|
|
151
|
-
if (plan.removed.length > 0) {
|
|
151
|
+
if (plan.removed.length > 0 && !options.silent) {
|
|
152
152
|
console.log(chalk.yellow(`⚠️ Warning: ${specName} - ${plan.removed.length} REMOVED requirement(s) ignored for new spec (nothing to remove).`));
|
|
153
153
|
}
|
|
154
154
|
isNewSpec = true;
|
|
@@ -265,13 +265,15 @@ export async function buildUpdatedSpec(update, changeName) {
|
|
|
265
265
|
/**
|
|
266
266
|
* Write an updated spec to disk.
|
|
267
267
|
*/
|
|
268
|
-
export async function writeUpdatedSpec(update, rebuilt, counts) {
|
|
268
|
+
export async function writeUpdatedSpec(update, rebuilt, counts, options = {}) {
|
|
269
269
|
// Create target directory if needed
|
|
270
270
|
const targetDir = path.dirname(update.target);
|
|
271
271
|
await fs.mkdir(targetDir, { recursive: true });
|
|
272
272
|
await fs.writeFile(update.target, rebuilt);
|
|
273
|
+
if (options.silent)
|
|
274
|
+
return;
|
|
273
275
|
const specName = path.basename(path.dirname(update.target));
|
|
274
|
-
console.log(`Applying changes to openspec/specs/${specName}/spec.md:`);
|
|
276
|
+
console.log(`Applying changes to ${options.displayPath ?? `openspec/specs/${specName}/spec.md`}:`);
|
|
275
277
|
if (counts.added)
|
|
276
278
|
console.log(` + ${counts.added} added`);
|
|
277
279
|
if (counts.modified)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type StoreDiagnosticSeverity = 'error' | 'warning' | 'info';
|
|
2
|
+
export interface StoreDiagnostic {
|
|
3
|
+
severity: StoreDiagnosticSeverity;
|
|
4
|
+
code: string;
|
|
5
|
+
message: string;
|
|
6
|
+
target?: string;
|
|
7
|
+
fix?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class StoreError extends Error {
|
|
10
|
+
readonly diagnostic: StoreDiagnostic;
|
|
11
|
+
constructor(message: string, code: string, options?: {
|
|
12
|
+
target?: string;
|
|
13
|
+
fix?: string;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export declare function makeStoreDiagnostic(severity: StoreDiagnosticSeverity, code: string, message: string, options?: {
|
|
17
|
+
target?: string;
|
|
18
|
+
fix?: string;
|
|
19
|
+
}): StoreDiagnostic;
|
|
20
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class StoreError extends Error {
|
|
2
2
|
diagnostic;
|
|
3
3
|
constructor(message, code, options = {}) {
|
|
4
4
|
super(message);
|
|
5
|
-
this.name = '
|
|
5
|
+
this.name = 'StoreError';
|
|
6
6
|
this.diagnostic = {
|
|
7
7
|
severity: 'error',
|
|
8
8
|
code,
|
|
@@ -11,7 +11,7 @@ export class ContextStoreError extends Error {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
export function
|
|
14
|
+
export function makeStoreDiagnostic(severity, code, message, options = {}) {
|
|
15
15
|
return {
|
|
16
16
|
severity,
|
|
17
17
|
code,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare const STORE_METADATA_DIR_NAME = ".openspec-store";
|
|
2
|
+
export declare const STORE_METADATA_FILE_NAME = "store.yaml";
|
|
3
|
+
export declare const STORES_DIR_NAME = "stores";
|
|
4
|
+
export declare const STORE_REGISTRY_FILE_NAME = "registry.yaml";
|
|
5
|
+
export interface StorePathOptions {
|
|
6
|
+
globalDataDir?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface StoreGitBackendConfig {
|
|
9
|
+
type: 'git';
|
|
10
|
+
local_path: string;
|
|
11
|
+
remote?: string;
|
|
12
|
+
branch?: string;
|
|
13
|
+
}
|
|
14
|
+
export type StoreBackendConfig = StoreGitBackendConfig;
|
|
15
|
+
export interface StoreRegistryEntryState {
|
|
16
|
+
backend: StoreBackendConfig;
|
|
17
|
+
}
|
|
18
|
+
export interface StoreRegistryState {
|
|
19
|
+
version: 1;
|
|
20
|
+
stores: Record<string, StoreRegistryEntryState>;
|
|
21
|
+
}
|
|
22
|
+
export interface StoreRegistryEntry {
|
|
23
|
+
id: string;
|
|
24
|
+
backend: StoreBackendConfig;
|
|
25
|
+
}
|
|
26
|
+
export interface StoreMetadataState {
|
|
27
|
+
version: 1;
|
|
28
|
+
id: string;
|
|
29
|
+
/** Canonical clone source, team-authored. Optional (slice 3.3). */
|
|
30
|
+
remote?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ResolveGitStoreBackendInput {
|
|
33
|
+
localPath: string;
|
|
34
|
+
remote?: string;
|
|
35
|
+
branch?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare function getStoresDir(options?: StorePathOptions): string;
|
|
38
|
+
export declare function getStoreRegistryPath(options?: StorePathOptions): string;
|
|
39
|
+
export declare function getStoreMetadataDir(storeRoot: string): string;
|
|
40
|
+
export declare function getStoreMetadataPath(storeRoot: string): string;
|
|
41
|
+
export declare function validateStoreId(id: string): string;
|
|
42
|
+
export declare function isValidStoreId(id: string): boolean;
|
|
43
|
+
export declare function parseStoreRegistryState(content: string): StoreRegistryState;
|
|
44
|
+
export declare function parseStoreMetadataState(content: string): StoreMetadataState;
|
|
45
|
+
export declare function serializeStoreRegistryState(state: StoreRegistryState): string;
|
|
46
|
+
export declare function serializeStoreMetadataState(state: StoreMetadataState): string;
|
|
47
|
+
export declare function listStoreRegistryEntries(registry: StoreRegistryState): StoreRegistryEntry[];
|
|
48
|
+
export declare function isStoreRoot(candidateRoot: string): Promise<boolean>;
|
|
49
|
+
export declare function readStoreRegistryState(options?: StorePathOptions): Promise<StoreRegistryState | null>;
|
|
50
|
+
export declare function writeStoreRegistryState(state: StoreRegistryState, options?: StorePathOptions): Promise<void>;
|
|
51
|
+
export declare function updateStoreRegistryState(updater: (state: StoreRegistryState | null) => StoreRegistryState | Promise<StoreRegistryState>, options?: StorePathOptions): Promise<StoreRegistryState>;
|
|
52
|
+
export declare function readStoreMetadataState(storeRoot: string): Promise<StoreMetadataState>;
|
|
53
|
+
export declare function readOptionalStoreMetadataState(storeRoot: string): Promise<StoreMetadataState | null>;
|
|
54
|
+
export declare function writeStoreMetadataState(storeRoot: string, state: StoreMetadataState): Promise<void>;
|
|
55
|
+
export declare function resolveGitStoreBackendConfig(input: ResolveGitStoreBackendInput, cwd?: string): Promise<StoreGitBackendConfig>;
|
|
56
|
+
//# sourceMappingURL=foundation.d.ts.map
|