@specmind/format 0.1.3 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@specmind/format",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": ".sm file format parser and writer",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/dist/writer.d.ts DELETED
@@ -1,37 +0,0 @@
1
- import { SmFile } from './schemas.js';
2
- /**
3
- * Converts a SmFile object to markdown format
4
- *
5
- * Generates .sm file content according to CONSTITUTION.md Section 4.2 format:
6
- * - Feature name as # heading
7
- * - Overview section with markdown content
8
- * - Requirements as bulleted list
9
- * - Architecture with mermaid code block
10
- * - Design decisions as markdown
11
- * - Integration points as bulleted list
12
- * - Notes as markdown
13
- */
14
- export interface WriteResult {
15
- success: boolean;
16
- content?: string;
17
- error?: string;
18
- }
19
- export declare function writeSmFile(smFile: SmFile): WriteResult;
20
- /**
21
- * Formats a SmFile for display with metadata
22
- *
23
- * @param smFile SmFile object
24
- * @returns Formatted content with metadata comments
25
- */
26
- export declare function writeSmFileWithMetadata(smFile: SmFile): WriteResult;
27
- /**
28
- * Validates that a SmFile can be written without data loss
29
- *
30
- * @param smFile SmFile to validate
31
- * @returns Validation result
32
- */
33
- export declare function validateSmFileForWriting(smFile: SmFile): {
34
- valid: boolean;
35
- issues: string[];
36
- };
37
- //# sourceMappingURL=writer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CA8EvD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CA2BnE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAgC7F"}
package/dist/writer.js DELETED
@@ -1,135 +0,0 @@
1
- export function writeSmFile(smFile) {
2
- try {
3
- const sections = [];
4
- // Feature name as main heading
5
- sections.push(`# ${smFile.name}`);
6
- sections.push('');
7
- // Overview section
8
- if (smFile.overview) {
9
- sections.push('## Overview');
10
- sections.push('');
11
- sections.push(smFile.overview);
12
- sections.push('');
13
- }
14
- // Requirements section
15
- if (smFile.requirements.length > 0) {
16
- sections.push('## Requirements');
17
- sections.push('');
18
- for (const requirement of smFile.requirements) {
19
- sections.push(`- ${requirement}`);
20
- }
21
- sections.push('');
22
- }
23
- // Architecture section
24
- if (smFile.architecture) {
25
- sections.push('## Architecture');
26
- sections.push('');
27
- sections.push('```mermaid');
28
- sections.push(smFile.architecture);
29
- sections.push('```');
30
- sections.push('');
31
- }
32
- // Design decisions section
33
- if (smFile.designDecisions) {
34
- sections.push('## Design Decisions');
35
- sections.push('');
36
- sections.push(smFile.designDecisions);
37
- sections.push('');
38
- }
39
- // Integration points section
40
- if (smFile.integrationPoints.length > 0) {
41
- sections.push('## Integration Points');
42
- sections.push('');
43
- for (const point of smFile.integrationPoints) {
44
- sections.push(`- ${point}`);
45
- }
46
- sections.push('');
47
- }
48
- // Notes section
49
- if (smFile.notes) {
50
- sections.push('## Notes');
51
- sections.push('');
52
- sections.push(smFile.notes);
53
- }
54
- // Remove trailing empty lines
55
- while (sections.length > 0 && sections[sections.length - 1] === '') {
56
- sections.pop();
57
- }
58
- const content = sections.join('\n');
59
- return {
60
- success: true,
61
- content
62
- };
63
- }
64
- catch (error) {
65
- return {
66
- success: false,
67
- error: error instanceof Error ? error.message : 'Unknown writing error'
68
- };
69
- }
70
- }
71
- /**
72
- * Formats a SmFile for display with metadata
73
- *
74
- * @param smFile SmFile object
75
- * @returns Formatted content with metadata comments
76
- */
77
- export function writeSmFileWithMetadata(smFile) {
78
- try {
79
- const result = writeSmFile(smFile);
80
- if (!result.success || !result.content) {
81
- return result;
82
- }
83
- const metadata = [
84
- `<!-- Generated by SpecMind -->`,
85
- `<!-- Type: ${smFile.type} -->`,
86
- `<!-- Created: ${smFile.createdAt.toISOString()} -->`,
87
- `<!-- Updated: ${smFile.updatedAt.toISOString()} -->`,
88
- ''
89
- ];
90
- const content = metadata.join('\n') + result.content;
91
- return {
92
- success: true,
93
- content
94
- };
95
- }
96
- catch (error) {
97
- return {
98
- success: false,
99
- error: error instanceof Error ? error.message : 'Unknown writing error'
100
- };
101
- }
102
- }
103
- /**
104
- * Validates that a SmFile can be written without data loss
105
- *
106
- * @param smFile SmFile to validate
107
- * @returns Validation result
108
- */
109
- export function validateSmFileForWriting(smFile) {
110
- const issues = [];
111
- if (!smFile.name.trim()) {
112
- issues.push('Feature name is required');
113
- }
114
- if (smFile.architecture && !smFile.architecture.trim()) {
115
- issues.push('Architecture section is empty but present');
116
- }
117
- if (smFile.requirements.some(req => !req.trim())) {
118
- issues.push('One or more requirements are empty');
119
- }
120
- if (smFile.integrationPoints.some(point => !point.trim())) {
121
- issues.push('One or more integration points are empty');
122
- }
123
- // Check for potentially problematic content
124
- if (smFile.name.includes('\n')) {
125
- issues.push('Feature name contains newlines');
126
- }
127
- if (smFile.architecture.includes('```')) {
128
- issues.push('Architecture contains code block markers (``` will be added automatically)');
129
- }
130
- return {
131
- valid: issues.length === 0,
132
- issues
133
- };
134
- }
135
- //# sourceMappingURL=writer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writer.js","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,WAAW,CAAC,M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