@fission-ai/openspec 1.4.1 → 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 +95 -95
- 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 -8
- package/dist/commands/workspace/selection.js +0 -104
- 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 -5
- package/dist/commands/workspace.js +0 -574
- 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 -121
- 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
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import type { ChangeMetadata } from './change-metadata/index.js';
|
|
2
1
|
import type { PlanningHome } from './planning-home.js';
|
|
3
2
|
export interface PlanningHomeSummary {
|
|
4
|
-
kind: 'repo'
|
|
3
|
+
kind: 'repo';
|
|
5
4
|
root: string;
|
|
6
5
|
changesDir: string;
|
|
7
6
|
defaultSchema: string;
|
|
8
|
-
workspaceName?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface AffectedAreasSummary {
|
|
11
|
-
known: string[];
|
|
12
|
-
unresolved: boolean;
|
|
13
|
-
invalid: string[];
|
|
14
7
|
}
|
|
15
8
|
export interface ActionContext {
|
|
16
|
-
mode: 'repo-local'
|
|
17
|
-
sourceOfTruth: 'repo'
|
|
9
|
+
mode: 'repo-local';
|
|
10
|
+
sourceOfTruth: 'repo';
|
|
18
11
|
planningArtifacts: string[];
|
|
19
12
|
linkedContext: Array<{
|
|
20
13
|
name: string;
|
|
@@ -27,24 +20,18 @@ export interface ChangeStatusPolicyArtifact {
|
|
|
27
20
|
id: string;
|
|
28
21
|
status: 'done' | 'ready' | 'blocked';
|
|
29
22
|
}
|
|
30
|
-
export interface AffectedAreasInput {
|
|
31
|
-
planningHome?: PlanningHome;
|
|
32
|
-
metadata?: ChangeMetadata;
|
|
33
|
-
}
|
|
34
23
|
export interface ChangeNextStepsInput {
|
|
35
24
|
changeName: string;
|
|
36
|
-
planningHome?: PlanningHome;
|
|
37
25
|
artifactStatuses: ChangeStatusPolicyArtifact[];
|
|
38
|
-
affectedAreas?: AffectedAreasSummary;
|
|
39
26
|
allArtifactsComplete: boolean;
|
|
27
|
+
/** Selected store id; next-step commands must carry it. */
|
|
28
|
+
storeId?: string;
|
|
40
29
|
}
|
|
41
30
|
export interface ActionContextInput {
|
|
42
|
-
planningHome?: PlanningHome;
|
|
43
31
|
projectRoot: string;
|
|
44
32
|
artifactIds: string[];
|
|
45
33
|
}
|
|
46
34
|
export declare function summarizePlanningHome(planningHome: PlanningHome | undefined): PlanningHomeSummary | undefined;
|
|
47
|
-
export declare function summarizeAffectedAreas(input: AffectedAreasInput): AffectedAreasSummary | undefined;
|
|
48
35
|
export declare function buildActionContext(input: ActionContextInput): ActionContext;
|
|
49
36
|
export declare function buildNextSteps(input: ChangeNextStepsInput): string[];
|
|
50
37
|
//# sourceMappingURL=change-status-policy.d.ts.map
|
|
@@ -7,39 +7,9 @@ export function summarizePlanningHome(planningHome) {
|
|
|
7
7
|
root: planningHome.root,
|
|
8
8
|
changesDir: planningHome.changesDir,
|
|
9
9
|
defaultSchema: planningHome.defaultSchema,
|
|
10
|
-
...(planningHome.workspace ? { workspaceName: planningHome.workspace.name } : {}),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export function summarizeAffectedAreas(input) {
|
|
14
|
-
if (input.planningHome?.kind !== 'workspace') {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
const known = Array.from(new Set(input.metadata?.affected_areas ?? [])).sort((a, b) => a.localeCompare(b));
|
|
18
|
-
const validAreas = new Set(input.planningHome.workspace?.links ?? []);
|
|
19
|
-
const invalid = known.filter((areaName) => validAreas.size > 0 && !validAreas.has(areaName));
|
|
20
|
-
return {
|
|
21
|
-
known,
|
|
22
|
-
unresolved: known.length === 0,
|
|
23
|
-
invalid,
|
|
24
10
|
};
|
|
25
11
|
}
|
|
26
12
|
export function buildActionContext(input) {
|
|
27
|
-
if (input.planningHome?.kind === 'workspace') {
|
|
28
|
-
return {
|
|
29
|
-
mode: 'workspace-planning',
|
|
30
|
-
sourceOfTruth: 'workspace-local',
|
|
31
|
-
planningArtifacts: input.artifactIds,
|
|
32
|
-
linkedContext: (input.planningHome.workspace?.links ?? []).map((name) => ({ name })),
|
|
33
|
-
allowedEditRoots: [],
|
|
34
|
-
requiresAffectedAreaSelection: true,
|
|
35
|
-
constraints: [
|
|
36
|
-
'Treat workspace-local planning artifacts as compatibility context for this local view.',
|
|
37
|
-
'Use initiatives for durable coordination when initiative context exists.',
|
|
38
|
-
'Treat linked repos and folders as context until an explicit edit root is selected.',
|
|
39
|
-
'Do not make implementation edits without an explicit allowed edit root.',
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
13
|
return {
|
|
44
14
|
mode: 'repo-local',
|
|
45
15
|
sourceOfTruth: 'repo',
|
|
@@ -54,17 +24,12 @@ export function buildNextSteps(input) {
|
|
|
54
24
|
const readyArtifact = input.artifactStatuses.find((artifact) => artifact.status === 'ready');
|
|
55
25
|
const steps = [];
|
|
56
26
|
if (readyArtifact) {
|
|
57
|
-
|
|
27
|
+
const storeFlag = input.storeId ? ` --store ${input.storeId}` : '';
|
|
28
|
+
steps.push(`Run openspec instructions ${readyArtifact.id} --change "${input.changeName}"${storeFlag} --json before writing that artifact.`);
|
|
58
29
|
}
|
|
59
30
|
else if (input.allArtifactsComplete) {
|
|
60
31
|
steps.push('All planning artifacts are complete; review tasks before implementation.');
|
|
61
32
|
}
|
|
62
|
-
if (input.planningHome?.kind === 'workspace') {
|
|
63
|
-
if (input.affectedAreas?.unresolved) {
|
|
64
|
-
steps.push('Identify affected areas in change metadata or coordination tasks as planning continues.');
|
|
65
|
-
}
|
|
66
|
-
steps.push('Select an affected area and allowed edit root before implementation edits.');
|
|
67
|
-
}
|
|
68
33
|
return steps;
|
|
69
34
|
}
|
|
70
35
|
//# sourceMappingURL=change-status-policy.js.map
|
|
@@ -6,20 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { transformToHyphenCommands } from '../../../utils/command-references.js';
|
|
9
|
-
|
|
10
|
-
* Escapes a string value for safe YAML output.
|
|
11
|
-
* Quotes the string if it contains special YAML characters.
|
|
12
|
-
*/
|
|
13
|
-
function escapeYamlValue(value) {
|
|
14
|
-
// Check if value needs quoting (contains special YAML characters or starts/ends with whitespace)
|
|
15
|
-
const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
|
|
16
|
-
if (needsQuoting) {
|
|
17
|
-
// Use double quotes and escape internal double quotes and backslashes
|
|
18
|
-
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
|
|
19
|
-
return `"${escaped}"`;
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
9
|
+
import { escapeYamlValue } from '../yaml.js';
|
|
23
10
|
/**
|
|
24
11
|
* Bob Shell adapter for command generation.
|
|
25
12
|
* File path: .bob/commands/opsx-<id>.md
|
|
@@ -4,20 +4,7 @@
|
|
|
4
4
|
* Formats commands for Claude Code following its frontmatter specification.
|
|
5
5
|
*/
|
|
6
6
|
import path from 'path';
|
|
7
|
-
|
|
8
|
-
* Escapes a string value for safe YAML output.
|
|
9
|
-
* Quotes the string if it contains special YAML characters.
|
|
10
|
-
*/
|
|
11
|
-
function escapeYamlValue(value) {
|
|
12
|
-
// Check if value needs quoting (contains special YAML characters or starts/ends with whitespace)
|
|
13
|
-
const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
|
|
14
|
-
if (needsQuoting) {
|
|
15
|
-
// Use double quotes and escape internal double quotes and backslashes
|
|
16
|
-
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
|
|
17
|
-
return `"${escaped}"`;
|
|
18
|
-
}
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
7
|
+
import { escapeYamlValue } from '../yaml.js';
|
|
21
8
|
/**
|
|
22
9
|
* Formats a tags array as a YAML array with proper escaping.
|
|
23
10
|
*/
|
|
@@ -5,20 +5,7 @@
|
|
|
5
5
|
* Cursor uses a different frontmatter format and file naming convention.
|
|
6
6
|
*/
|
|
7
7
|
import path from 'path';
|
|
8
|
-
|
|
9
|
-
* Escapes a string value for safe YAML output.
|
|
10
|
-
* Quotes the string if it contains special YAML characters.
|
|
11
|
-
*/
|
|
12
|
-
function escapeYamlValue(value) {
|
|
13
|
-
// Check if value needs quoting (contains special YAML characters or starts/ends with whitespace)
|
|
14
|
-
const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
|
|
15
|
-
if (needsQuoting) {
|
|
16
|
-
// Use double quotes and escape internal double quotes and backslashes
|
|
17
|
-
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
|
|
18
|
-
return `"${escaped}"`;
|
|
19
|
-
}
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
8
|
+
import { escapeYamlValue } from '../yaml.js';
|
|
22
9
|
/**
|
|
23
10
|
* Cursor adapter for command generation.
|
|
24
11
|
* File path: .cursor/commands/opsx-<id>.md
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { transformToHyphenCommands } from '../../../utils/command-references.js';
|
|
9
|
+
import { escapeYamlValue } from '../yaml.js';
|
|
9
10
|
const PI_INPUT_HEADING = /^\*\*Input\*\*:[^\n]*$/m;
|
|
10
11
|
function injectPiArgs(body) {
|
|
11
12
|
if (body.includes('$@') || body.includes('$ARGUMENTS')) {
|
|
@@ -13,20 +14,6 @@ function injectPiArgs(body) {
|
|
|
13
14
|
}
|
|
14
15
|
return body.replace(PI_INPUT_HEADING, (heading) => `${heading}\n**Provided arguments**: $@`);
|
|
15
16
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Escapes a string value for safe YAML output.
|
|
18
|
-
* Quotes the string if it contains special YAML characters.
|
|
19
|
-
*/
|
|
20
|
-
function escapeYamlValue(value) {
|
|
21
|
-
// Check if value needs quoting (contains special YAML characters or starts/ends with whitespace)
|
|
22
|
-
const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
|
|
23
|
-
if (needsQuoting) {
|
|
24
|
-
// Use double quotes and escape internal double quotes and backslashes
|
|
25
|
-
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
|
|
26
|
-
return `"${escaped}"`;
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
17
|
/**
|
|
31
18
|
* Pi adapter for prompt template generation.
|
|
32
19
|
* File path: .pi/prompts/opsx-<id>.md
|
|
@@ -5,20 +5,7 @@
|
|
|
5
5
|
* Windsurf uses a similar format to Claude but may have different conventions.
|
|
6
6
|
*/
|
|
7
7
|
import path from 'path';
|
|
8
|
-
|
|
9
|
-
* Escapes a string value for safe YAML output.
|
|
10
|
-
* Quotes the string if it contains special YAML characters.
|
|
11
|
-
*/
|
|
12
|
-
function escapeYamlValue(value) {
|
|
13
|
-
// Check if value needs quoting (contains special YAML characters or starts/ends with whitespace)
|
|
14
|
-
const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
|
|
15
|
-
if (needsQuoting) {
|
|
16
|
-
// Use double quotes and escape internal double quotes and backslashes
|
|
17
|
-
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n');
|
|
18
|
-
return `"${escaped}"`;
|
|
19
|
-
}
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
8
|
+
import { escapeYamlValue } from '../yaml.js';
|
|
22
9
|
/**
|
|
23
10
|
* Formats a tags array as a YAML array with proper escaping.
|
|
24
11
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared YAML frontmatter helpers for command adapters.
|
|
3
|
+
*
|
|
4
|
+
* Several tool adapters emit YAML frontmatter and need to escape
|
|
5
|
+
* user-facing strings (name, description, category, tags) so the
|
|
6
|
+
* generated file stays valid YAML. This module centralizes that logic
|
|
7
|
+
* so the behavior is identical across adapters and fixed in one place.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Escapes a string value for safe YAML output.
|
|
11
|
+
*
|
|
12
|
+
* Quotes the value with double quotes when it contains characters that
|
|
13
|
+
* carry special meaning in YAML (or leading/trailing whitespace), and
|
|
14
|
+
* escapes the characters that are not representable verbatim inside a
|
|
15
|
+
* double-quoted scalar: backslash, double quote, line feed and carriage
|
|
16
|
+
* return. Values without special characters are returned unquoted.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The raw string to embed in YAML frontmatter.
|
|
19
|
+
* @returns The value, double-quoted and escaped when necessary.
|
|
20
|
+
*/
|
|
21
|
+
export declare function escapeYamlValue(value: string): string;
|
|
22
|
+
//# sourceMappingURL=yaml.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared YAML frontmatter helpers for command adapters.
|
|
3
|
+
*
|
|
4
|
+
* Several tool adapters emit YAML frontmatter and need to escape
|
|
5
|
+
* user-facing strings (name, description, category, tags) so the
|
|
6
|
+
* generated file stays valid YAML. This module centralizes that logic
|
|
7
|
+
* so the behavior is identical across adapters and fixed in one place.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Escapes a string value for safe YAML output.
|
|
11
|
+
*
|
|
12
|
+
* Quotes the value with double quotes when it contains characters that
|
|
13
|
+
* carry special meaning in YAML (or leading/trailing whitespace), and
|
|
14
|
+
* escapes the characters that are not representable verbatim inside a
|
|
15
|
+
* double-quoted scalar: backslash, double quote, line feed and carriage
|
|
16
|
+
* return. Values without special characters are returned unquoted.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The raw string to embed in YAML frontmatter.
|
|
19
|
+
* @returns The value, double-quoted and escaped when necessary.
|
|
20
|
+
*/
|
|
21
|
+
export function escapeYamlValue(value) {
|
|
22
|
+
// Check if value needs quoting (contains special YAML characters or starts/ends with whitespace)
|
|
23
|
+
const needsQuoting = /[:\n\r#{}[\],&*!|>'"%@`]|^\s|\s$/.test(value);
|
|
24
|
+
if (needsQuoting) {
|
|
25
|
+
// Use double quotes and escape characters that are not safe to emit
|
|
26
|
+
// verbatim inside a double-quoted YAML scalar. Carriage returns must be
|
|
27
|
+
// escaped too: a literal CR inside double quotes is subject to YAML line
|
|
28
|
+
// folding/normalization and would silently corrupt the round-tripped value.
|
|
29
|
+
const escaped = value
|
|
30
|
+
.replace(/\\/g, '\\\\')
|
|
31
|
+
.replace(/"/g, '\\"')
|
|
32
|
+
.replace(/\n/g, '\\n')
|
|
33
|
+
.replace(/\r/g, '\\r');
|
|
34
|
+
return `"${escaped}"`;
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=yaml.js.map
|