@eddacraft/anvil-adapters 0.1.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.
Files changed (183) hide show
  1. package/AGENTS.md +180 -0
  2. package/BMAD_ADAPTER_SPEC.md +489 -0
  3. package/LICENSE +14 -0
  4. package/README.md +500 -0
  5. package/dist/aps-markdown/adapter.d.ts +102 -0
  6. package/dist/aps-markdown/adapter.d.ts.map +1 -0
  7. package/dist/aps-markdown/adapter.js +351 -0
  8. package/dist/aps-markdown/index.d.ts +8 -0
  9. package/dist/aps-markdown/index.d.ts.map +1 -0
  10. package/dist/aps-markdown/index.js +7 -0
  11. package/dist/base/file-discovery.d.ts +63 -0
  12. package/dist/base/file-discovery.d.ts.map +1 -0
  13. package/dist/base/file-discovery.js +246 -0
  14. package/dist/base/index.d.ts +10 -0
  15. package/dist/base/index.d.ts.map +1 -0
  16. package/dist/base/index.js +9 -0
  17. package/dist/base/registry.d.ts +155 -0
  18. package/dist/base/registry.d.ts.map +1 -0
  19. package/dist/base/registry.js +227 -0
  20. package/dist/base/testing.d.ts +102 -0
  21. package/dist/base/testing.d.ts.map +1 -0
  22. package/dist/base/testing.js +221 -0
  23. package/dist/base/types.d.ts +255 -0
  24. package/dist/base/types.d.ts.map +1 -0
  25. package/dist/base/types.js +78 -0
  26. package/dist/base/utils.d.ts +127 -0
  27. package/dist/base/utils.d.ts.map +1 -0
  28. package/dist/base/utils.js +254 -0
  29. package/dist/bmad/format-adapter.d.ts +76 -0
  30. package/dist/bmad/format-adapter.d.ts.map +1 -0
  31. package/dist/bmad/format-adapter.js +186 -0
  32. package/dist/bmad/index.d.ts +12 -0
  33. package/dist/bmad/index.d.ts.map +1 -0
  34. package/dist/bmad/index.js +10 -0
  35. package/dist/bmad/parser.d.ts +12 -0
  36. package/dist/bmad/parser.d.ts.map +1 -0
  37. package/dist/bmad/parser.js +181 -0
  38. package/dist/bmad/serializer.d.ts +16 -0
  39. package/dist/bmad/serializer.d.ts.map +1 -0
  40. package/dist/bmad/serializer.js +170 -0
  41. package/dist/bmad/types.d.ts +127 -0
  42. package/dist/bmad/types.d.ts.map +1 -0
  43. package/dist/bmad/types.js +47 -0
  44. package/dist/bmad/utils.d.ts +120 -0
  45. package/dist/bmad/utils.d.ts.map +1 -0
  46. package/dist/bmad/utils.js +480 -0
  47. package/dist/common/index.d.ts +3 -0
  48. package/dist/common/index.d.ts.map +1 -0
  49. package/dist/common/index.js +2 -0
  50. package/dist/common/registry.d.ts +18 -0
  51. package/dist/common/registry.d.ts.map +1 -0
  52. package/dist/common/registry.js +58 -0
  53. package/dist/common/types.d.ts +68 -0
  54. package/dist/common/types.d.ts.map +1 -0
  55. package/dist/common/types.js +12 -0
  56. package/dist/generic/format-adapter.d.ts +64 -0
  57. package/dist/generic/format-adapter.d.ts.map +1 -0
  58. package/dist/generic/format-adapter.js +159 -0
  59. package/dist/generic/index.d.ts +10 -0
  60. package/dist/generic/index.d.ts.map +1 -0
  61. package/dist/generic/index.js +9 -0
  62. package/dist/generic/parser.d.ts +11 -0
  63. package/dist/generic/parser.d.ts.map +1 -0
  64. package/dist/generic/parser.js +106 -0
  65. package/dist/generic/serializer.d.ts +11 -0
  66. package/dist/generic/serializer.d.ts.map +1 -0
  67. package/dist/generic/serializer.js +118 -0
  68. package/dist/generic/types.d.ts +52 -0
  69. package/dist/generic/types.d.ts.map +1 -0
  70. package/dist/generic/types.js +6 -0
  71. package/dist/generic/utils.d.ts +51 -0
  72. package/dist/generic/utils.d.ts.map +1 -0
  73. package/dist/generic/utils.js +232 -0
  74. package/dist/index.d.ts +15 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +31 -0
  77. package/dist/speckit/export.d.ts +22 -0
  78. package/dist/speckit/export.d.ts.map +1 -0
  79. package/dist/speckit/export.js +384 -0
  80. package/dist/speckit/format-adapter.d.ts +104 -0
  81. package/dist/speckit/format-adapter.d.ts.map +1 -0
  82. package/dist/speckit/format-adapter.js +488 -0
  83. package/dist/speckit/import-v2.d.ts +33 -0
  84. package/dist/speckit/import-v2.d.ts.map +1 -0
  85. package/dist/speckit/import-v2.js +361 -0
  86. package/dist/speckit/import.d.ts +16 -0
  87. package/dist/speckit/import.d.ts.map +1 -0
  88. package/dist/speckit/import.js +247 -0
  89. package/dist/speckit/index.d.ts +5 -0
  90. package/dist/speckit/index.d.ts.map +1 -0
  91. package/dist/speckit/index.js +4 -0
  92. package/dist/speckit/parser.d.ts +28 -0
  93. package/dist/speckit/parser.d.ts.map +1 -0
  94. package/dist/speckit/parser.js +283 -0
  95. package/dist/speckit/parsers/plan-parser.d.ts +71 -0
  96. package/dist/speckit/parsers/plan-parser.d.ts.map +1 -0
  97. package/dist/speckit/parsers/plan-parser.js +216 -0
  98. package/dist/speckit/parsers/spec-parser.d.ts +67 -0
  99. package/dist/speckit/parsers/spec-parser.d.ts.map +1 -0
  100. package/dist/speckit/parsers/spec-parser.js +255 -0
  101. package/dist/speckit/parsers/tasks-parser.d.ts +57 -0
  102. package/dist/speckit/parsers/tasks-parser.d.ts.map +1 -0
  103. package/dist/speckit/parsers/tasks-parser.js +157 -0
  104. package/package.json +23 -0
  105. package/project.json +29 -0
  106. package/src/__tests__/adapter-edge-cases.test.ts +937 -0
  107. package/src/__tests__/bmad-format-adapter.test.ts +1470 -0
  108. package/src/__tests__/fixtures/aps/expected-output.json +83 -0
  109. package/src/__tests__/fixtures/bmad/invalid-malformed-yaml.md +16 -0
  110. package/src/__tests__/fixtures/bmad/invalid-no-requirements.md +23 -0
  111. package/src/__tests__/fixtures/bmad/invalid-only-yaml.md +16 -0
  112. package/src/__tests__/fixtures/bmad/invalid-too-short.md +3 -0
  113. package/src/__tests__/fixtures/bmad/invalid-wrong-format.md +40 -0
  114. package/src/__tests__/fixtures/bmad/valid-agent.md +27 -0
  115. package/src/__tests__/fixtures/bmad/valid-architecture.md +116 -0
  116. package/src/__tests__/fixtures/bmad/valid-complex-prd.md +161 -0
  117. package/src/__tests__/fixtures/bmad/valid-epic.md +73 -0
  118. package/src/__tests__/fixtures/bmad/valid-minimal-prd.md +19 -0
  119. package/src/__tests__/fixtures/bmad/valid-prd.md +107 -0
  120. package/src/__tests__/fixtures/bmad/valid-story.md +107 -0
  121. package/src/__tests__/fixtures/bmad/valid-task.md +79 -0
  122. package/src/__tests__/fixtures/bmad/valid-v6-prd.md +35 -0
  123. package/src/__tests__/fixtures/generic/plan-detailed.md +39 -0
  124. package/src/__tests__/fixtures/generic/prd-simple.md +27 -0
  125. package/src/__tests__/fixtures/generic/rfc-example.md +26 -0
  126. package/src/__tests__/fixtures/generic/todo-list.md +23 -0
  127. package/src/__tests__/fixtures/speckit/sample-plan.md +63 -0
  128. package/src/__tests__/fixtures/speckit/sample-spec-namespaced.md +50 -0
  129. package/src/__tests__/fixtures/speckit/sample-spec.md +105 -0
  130. package/src/__tests__/fixtures/speckit/sample-tasks.md +87 -0
  131. package/src/__tests__/fixtures/speckit-official/auth-feature/plan.md +272 -0
  132. package/src/__tests__/fixtures/speckit-official/auth-feature/spec.md +149 -0
  133. package/src/__tests__/fixtures/speckit-official/auth-feature/tasks.md +169 -0
  134. package/src/__tests__/generic-format-adapter.test.ts +398 -0
  135. package/src/__tests__/speckit-export.test.ts +233 -0
  136. package/src/__tests__/speckit-format-adapter.test.ts +832 -0
  137. package/src/__tests__/speckit-import-v2.test.ts +253 -0
  138. package/src/__tests__/speckit-import.test.ts +209 -0
  139. package/src/__tests__/speckit-parser.test.ts +219 -0
  140. package/src/__tests__/speckit-spec-parser.test.ts +120 -0
  141. package/src/aps-markdown/__tests__/__fixtures__/simple-leaf.aps.md +17 -0
  142. package/src/aps-markdown/__tests__/adapter.test.ts +393 -0
  143. package/src/aps-markdown/adapter.ts +455 -0
  144. package/src/aps-markdown/index.ts +8 -0
  145. package/src/base/__tests__/registry.test.ts +515 -0
  146. package/src/base/file-discovery.ts +305 -0
  147. package/src/base/index.ts +10 -0
  148. package/src/base/registry.ts +263 -0
  149. package/src/base/testing.ts +334 -0
  150. package/src/base/types.ts +342 -0
  151. package/src/base/utils.ts +306 -0
  152. package/src/bmad/format-adapter.ts +227 -0
  153. package/src/bmad/index.ts +21 -0
  154. package/src/bmad/parser.ts +224 -0
  155. package/src/bmad/serializer.ts +206 -0
  156. package/src/bmad/types.ts +135 -0
  157. package/src/bmad/utils.ts +575 -0
  158. package/src/common/index.ts +2 -0
  159. package/src/common/registry.ts +72 -0
  160. package/src/common/types.ts +84 -0
  161. package/src/generic/__tests__/serializer.test.ts +167 -0
  162. package/src/generic/format-adapter.ts +200 -0
  163. package/src/generic/index.ts +11 -0
  164. package/src/generic/parser.ts +129 -0
  165. package/src/generic/serializer.ts +134 -0
  166. package/src/generic/types.ts +53 -0
  167. package/src/generic/utils.ts +270 -0
  168. package/src/index.ts +48 -0
  169. package/src/speckit/export.ts +489 -0
  170. package/src/speckit/format-adapter.ts +595 -0
  171. package/src/speckit/import-v2.ts +445 -0
  172. package/src/speckit/import.ts +305 -0
  173. package/src/speckit/index.ts +4 -0
  174. package/src/speckit/parser.ts +351 -0
  175. package/src/speckit/parsers/plan-parser.ts +342 -0
  176. package/src/speckit/parsers/spec-parser.ts +379 -0
  177. package/src/speckit/parsers/tasks-parser.ts +246 -0
  178. package/tsconfig.json +26 -0
  179. package/tsconfig.lib.json +21 -0
  180. package/tsconfig.lib.tsbuildinfo +1 -0
  181. package/tsconfig.spec.json +9 -0
  182. package/tsconfig.tsbuildinfo +1 -0
  183. package/vitest.config.ts +14 -0
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Generic Markdown Format Adapter
3
+ *
4
+ * FormatAdapter implementation for generic markdown planning documents.
5
+ * Serves as a fallback adapter for documents that don't match specific formats.
6
+ */
7
+ import { type APSPlan, type ValidationResult } from '@eddacraft/anvil-core';
8
+ import { BaseFormatAdapter, type AdapterMetadata, type DetectionResult, type ParseResult, type SerializeResult, type ParseContext, type AdapterOptions } from '../base/types.js';
9
+ /**
10
+ * Generic Markdown FormatAdapter implementation
11
+ *
12
+ * Converts between generic markdown documents and APS plans.
13
+ * Designed to work as a fallback for documents that don't match
14
+ * specific formats like BMAD or SpecKit.
15
+ */
16
+ export declare class GenericMarkdownAdapter extends BaseFormatAdapter {
17
+ readonly metadata: AdapterMetadata;
18
+ /**
19
+ * Detect if content is generic markdown planning document
20
+ *
21
+ * Uses lower confidence threshold (30-40%) to serve as fallback.
22
+ * This adapter should be registered last so specific adapters
23
+ * (BMAD, SpecKit) take precedence.
24
+ *
25
+ * @param content - Document content to analyze
26
+ * @returns Detection result with confidence score
27
+ */
28
+ detect(content: string): DetectionResult;
29
+ /**
30
+ * Parse generic markdown content to APS plan
31
+ *
32
+ * @param content - Markdown content
33
+ * @param context - Parse context for provenance
34
+ * @param options - Adapter options
35
+ * @returns Parse result with APS plan
36
+ */
37
+ parse(content: string, context?: ParseContext, _options?: AdapterOptions): Promise<ParseResult>;
38
+ /**
39
+ * Serialize APS plan to generic markdown format
40
+ *
41
+ * @param plan - APS plan to serialize
42
+ * @param options - Adapter options
43
+ * @returns Serialize result with markdown content
44
+ */
45
+ serialize(plan: APSPlan, _options?: AdapterOptions): Promise<SerializeResult>;
46
+ /**
47
+ * Validate generic markdown content
48
+ *
49
+ * Checks for basic markdown structure without strict requirements.
50
+ *
51
+ * @param content - Content to validate
52
+ * @param options - Validation options
53
+ * @returns Validation result
54
+ */
55
+ validate(content: string, _options?: AdapterOptions): Promise<ValidationResult>;
56
+ }
57
+ /**
58
+ * Create a new generic markdown adapter instance
59
+ *
60
+ * @param options - Adapter options
61
+ * @returns Generic markdown adapter instance
62
+ */
63
+ export declare function createGenericMarkdownAdapter(options?: AdapterOptions): GenericMarkdownAdapter;
64
+ //# sourceMappingURL=format-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-adapter.d.ts","sourceRoot":"","sources":["../../src/generic/format-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAgB,KAAK,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EACL,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAU1B;;;;;;GAMG;AACH,qBAAa,sBAAuB,SAAQ,iBAAiB;IAC3D,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAOhC;IAEF;;;;;;;;;OASG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe;IAcxC;;;;;;;OAOG;IACG,KAAK,CACT,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY,EACtB,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,WAAW,CAAC;IAwBvB;;;;;;OAMG;IACG,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAkBnF;;;;;;;;OAQG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAoDtF;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,sBAAsB,CAE7F"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Generic Markdown Format Adapter
3
+ *
4
+ * FormatAdapter implementation for generic markdown planning documents.
5
+ * Serves as a fallback adapter for documents that don't match specific formats.
6
+ */
7
+ import { generateHash } from '@eddacraft/anvil-core';
8
+ import { BaseFormatAdapter, } from '../base/types.js';
9
+ import { createDetection } from '../base/utils.js';
10
+ import { analyzeContent, calculateConfidenceScore, buildDetectionReason } from './utils.js';
11
+ import { parseGeneric } from './parser.js';
12
+ import { serializeToGeneric } from './serializer.js';
13
+ const MIN_CONTENT_LENGTH = 50;
14
+ const FALLBACK_DETECTION_THRESHOLD = 30;
15
+ const MAX_FALLBACK_CONFIDENCE = 45;
16
+ /**
17
+ * Generic Markdown FormatAdapter implementation
18
+ *
19
+ * Converts between generic markdown documents and APS plans.
20
+ * Designed to work as a fallback for documents that don't match
21
+ * specific formats like BMAD or SpecKit.
22
+ */
23
+ export class GenericMarkdownAdapter extends BaseFormatAdapter {
24
+ metadata = {
25
+ name: 'generic-markdown',
26
+ version: '1.0.0',
27
+ displayName: 'Generic Markdown',
28
+ description: 'Generic markdown adapter for PRDs, plans, todos, and other planning documents',
29
+ formats: ['generic', 'markdown', 'prd', 'plan', 'todo', 'rfc', 'adr'],
30
+ extensions: ['.md', '.markdown'],
31
+ };
32
+ /**
33
+ * Detect if content is generic markdown planning document
34
+ *
35
+ * Uses lower confidence threshold (30-40%) to serve as fallback.
36
+ * This adapter should be registered last so specific adapters
37
+ * (BMAD, SpecKit) take precedence.
38
+ *
39
+ * @param content - Document content to analyze
40
+ * @returns Detection result with confidence score
41
+ */
42
+ detect(content) {
43
+ const indicators = analyzeContent(content);
44
+ const confidence = calculateConfidenceScore(indicators);
45
+ const reason = buildDetectionReason(indicators);
46
+ const cappedConfidence = Math.min(MAX_FALLBACK_CONFIDENCE, confidence);
47
+ return createDetection(cappedConfidence >= FALLBACK_DETECTION_THRESHOLD, cappedConfidence, reason);
48
+ }
49
+ /**
50
+ * Parse generic markdown content to APS plan
51
+ *
52
+ * @param content - Markdown content
53
+ * @param context - Parse context for provenance
54
+ * @param options - Adapter options
55
+ * @returns Parse result with APS plan
56
+ */
57
+ async parse(content, context, _options) {
58
+ try {
59
+ // Parse content to APS plan
60
+ const plan = parseGeneric(content, context);
61
+ // Generate hash for the plan
62
+ const planWithHash = {
63
+ ...plan,
64
+ hash: generateHash(plan),
65
+ };
66
+ return this.createParseSuccess(planWithHash);
67
+ }
68
+ catch (error) {
69
+ return this.createParseError([
70
+ {
71
+ code: 'PARSE_ERROR',
72
+ message: error instanceof Error ? error.message : 'Failed to parse generic markdown content',
73
+ details: error,
74
+ },
75
+ ]);
76
+ }
77
+ }
78
+ /**
79
+ * Serialize APS plan to generic markdown format
80
+ *
81
+ * @param plan - APS plan to serialize
82
+ * @param options - Adapter options
83
+ * @returns Serialize result with markdown content
84
+ */
85
+ async serialize(plan, _options) {
86
+ try {
87
+ const content = serializeToGeneric(plan);
88
+ return this.createSerializeSuccess(content);
89
+ }
90
+ catch (error) {
91
+ return this.createSerializeError([
92
+ {
93
+ code: 'SERIALIZE_ERROR',
94
+ message: error instanceof Error
95
+ ? error.message
96
+ : 'Failed to serialize to generic markdown format',
97
+ details: error,
98
+ },
99
+ ]);
100
+ }
101
+ }
102
+ /**
103
+ * Validate generic markdown content
104
+ *
105
+ * Checks for basic markdown structure without strict requirements.
106
+ *
107
+ * @param content - Content to validate
108
+ * @param options - Validation options
109
+ * @returns Validation result
110
+ */
111
+ async validate(content, _options) {
112
+ const issues = [];
113
+ if (content.trim().length < MIN_CONTENT_LENGTH) {
114
+ issues.push({
115
+ code: 'CONTENT_TOO_SHORT',
116
+ path: 'content',
117
+ message: 'Content is too short to be a valid planning document',
118
+ severity: 'error',
119
+ });
120
+ }
121
+ const indicators = analyzeContent(content);
122
+ const confidence = calculateConfidenceScore(indicators);
123
+ if (confidence < FALLBACK_DETECTION_THRESHOLD) {
124
+ issues.push({
125
+ code: 'LOW_CONFIDENCE',
126
+ path: 'content',
127
+ message: `Content does not appear to be a planning document (confidence: ${confidence}%)`,
128
+ severity: 'error',
129
+ });
130
+ }
131
+ // Warn if missing common planning sections
132
+ if (!indicators.hasRequirementsSection &&
133
+ !indicators.hasTasksSection &&
134
+ !indicators.hasFeaturesSection) {
135
+ issues.push({
136
+ code: 'NO_PLANNING_SECTIONS',
137
+ path: 'content',
138
+ message: 'Document lacks common planning sections (requirements, tasks, or features)',
139
+ severity: 'warning',
140
+ });
141
+ }
142
+ return {
143
+ valid: issues.filter((i) => i.severity === 'error').length === 0,
144
+ issues: issues.length > 0 ? issues : undefined,
145
+ summary: issues.length === 0
146
+ ? 'Generic markdown document is valid'
147
+ : `Found ${issues.length} validation issue${issues.length > 1 ? 's' : ''}`,
148
+ };
149
+ }
150
+ }
151
+ /**
152
+ * Create a new generic markdown adapter instance
153
+ *
154
+ * @param options - Adapter options
155
+ * @returns Generic markdown adapter instance
156
+ */
157
+ export function createGenericMarkdownAdapter(options) {
158
+ return new GenericMarkdownAdapter(options);
159
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Generic Markdown Adapter
3
+ *
4
+ * Exports for generic markdown format adapter.
5
+ */
6
+ export { GenericMarkdownAdapter, createGenericMarkdownAdapter } from './format-adapter.js';
7
+ export type { GenericDocument, GenericIndicators } from './types.js';
8
+ export { parseGeneric } from './parser.js';
9
+ export { serializeToGeneric } from './serializer.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generic/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAC3F,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generic Markdown Adapter
3
+ *
4
+ * Exports for generic markdown format adapter.
5
+ */
6
+ export { GenericMarkdownAdapter, createGenericMarkdownAdapter } from './format-adapter.js';
7
+ export { parseGeneric } from './parser.js';
8
+ export { serializeToGeneric } from './serializer.js';
9
+ // Note: Utils are not exported to avoid conflicts with BMAD utils
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Generic Markdown Parser
3
+ *
4
+ * Parses generic markdown documents into APS plans.
5
+ */
6
+ import { type APSPlan } from '@eddacraft/anvil-core';
7
+ import type { ParseContext } from '../base/types.js';
8
+ import type { GenericDocument } from './types.js';
9
+ export declare function genericToAPS(document: GenericDocument, context?: ParseContext, originalContent?: string): APSPlan;
10
+ export declare function parseGeneric(content: string, context?: ParseContext): APSPlan;
11
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/generic/parser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAqC,MAAM,uBAAuB,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAiDlD,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,eAAe,EACzB,OAAO,CAAC,EAAE,YAAY,EACtB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CA8DT;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAG7E"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Generic Markdown Parser
3
+ *
4
+ * Parses generic markdown documents into APS plans.
5
+ */
6
+ import { validateRelativePath } from '@eddacraft/anvil-core';
7
+ import { generateDeterministicPlanId } from '../base/utils.js';
8
+ import { parseGenericDocument } from './utils.js';
9
+ /**
10
+ * Convert generic document item to APS change
11
+ */
12
+ function itemToChange(item, type) {
13
+ // Determine change type based on item type
14
+ let changeType = 'file_create';
15
+ let pathPrefix = 'src';
16
+ switch (type) {
17
+ case 'requirement':
18
+ changeType = 'file_create';
19
+ pathPrefix = 'src/features';
20
+ break;
21
+ case 'task':
22
+ changeType = 'file_update';
23
+ pathPrefix = 'src/tasks';
24
+ break;
25
+ case 'feature':
26
+ changeType = 'file_create';
27
+ pathPrefix = 'src/features';
28
+ break;
29
+ }
30
+ // Generate a reasonable path from the item description
31
+ const slug = item
32
+ .toLowerCase()
33
+ .replace(/[^a-z0-9\s]/g, '')
34
+ .replace(/\s+/g, '-')
35
+ .substring(0, 50);
36
+ const rawPath = `${pathPrefix}/${slug}.ts`;
37
+ let safePath;
38
+ try {
39
+ safePath = validateRelativePath(rawPath);
40
+ }
41
+ catch {
42
+ safePath = rawPath.replace(/\.{2,}/g, '');
43
+ }
44
+ return {
45
+ type: changeType,
46
+ path: safePath,
47
+ description: item,
48
+ };
49
+ }
50
+ export function genericToAPS(document, context, originalContent) {
51
+ const planId = context?.planId ??
52
+ (originalContent
53
+ ? generateDeterministicPlanId(originalContent)
54
+ : `aps-${Date.now().toString(16).substring(0, 8)}`);
55
+ // Collect all changes from requirements, tasks, and features
56
+ const changes = [];
57
+ // Add requirements as changes
58
+ if (document.requirements && document.requirements.length > 0) {
59
+ changes.push(...document.requirements.map((req) => itemToChange(req, 'requirement')));
60
+ }
61
+ // Add tasks as changes
62
+ if (document.tasks && document.tasks.length > 0) {
63
+ changes.push(...document.tasks.map((task) => itemToChange(task, 'task')));
64
+ }
65
+ // Add features as changes
66
+ if (document.features && document.features.length > 0) {
67
+ changes.push(...document.features.map((feat) => itemToChange(feat, 'feature')));
68
+ }
69
+ // Build intent from document
70
+ const intent = document.intent || document.title || document.overview?.substring(0, 200) || 'Generic plan';
71
+ // Build provenance
72
+ const timestamp = context?.timestamp || new Date().toISOString();
73
+ const author = context?.author || 'unknown';
74
+ // Create APS plan
75
+ const plan = {
76
+ id: planId,
77
+ schema_version: '0.1.0',
78
+ intent,
79
+ proposed_changes: changes,
80
+ provenance: {
81
+ timestamp,
82
+ author,
83
+ source: 'cli',
84
+ version: '1.0.0',
85
+ repository: context?.repositoryPath,
86
+ branch: context?.branch,
87
+ commit: context?.commit,
88
+ },
89
+ validations: {
90
+ required_checks: ['lint', 'test'],
91
+ skip_checks: [],
92
+ },
93
+ metadata: {
94
+ source_format: 'generic-markdown',
95
+ title: document.title,
96
+ overview: document.overview,
97
+ goals: document.goals,
98
+ },
99
+ hash: '0000000000000000000000000000000000000000000000000000000000000000',
100
+ };
101
+ return plan;
102
+ }
103
+ export function parseGeneric(content, context) {
104
+ const document = parseGenericDocument(content);
105
+ return genericToAPS(document, context, content);
106
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Generic Markdown Serializer
3
+ *
4
+ * Serializes APS plans to generic markdown format.
5
+ */
6
+ import type { APSPlan } from '@eddacraft/anvil-core';
7
+ /**
8
+ * Serialize APS plan to generic markdown format
9
+ */
10
+ export declare function serializeToGeneric(plan: APSPlan): string;
11
+ //# sourceMappingURL=serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../src/generic/serializer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAgBrD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CA4GxD"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Generic Markdown Serializer
3
+ *
4
+ * Serializes APS plans to generic markdown format.
5
+ */
6
+ /**
7
+ * Type guard to check if value is a string
8
+ */
9
+ function isString(value) {
10
+ return typeof value === 'string';
11
+ }
12
+ /**
13
+ * Type guard to check if value is a string array
14
+ */
15
+ function isStringArray(value) {
16
+ return Array.isArray(value) && value.every((item) => typeof item === 'string');
17
+ }
18
+ /**
19
+ * Serialize APS plan to generic markdown format
20
+ */
21
+ export function serializeToGeneric(plan) {
22
+ const lines = [];
23
+ // Title (from intent or metadata) - safely check if title is a non-empty string
24
+ const metadataTitle = plan.metadata?.['title'];
25
+ const title = isString(metadataTitle) && metadataTitle ? metadataTitle : plan.intent;
26
+ lines.push(`# ${title}`);
27
+ lines.push('');
28
+ // Overview section - safely check if overview is a string
29
+ const metadataOverview = plan.metadata?.['overview'];
30
+ if (metadataOverview && isString(metadataOverview)) {
31
+ lines.push('## Overview');
32
+ lines.push('');
33
+ lines.push(metadataOverview);
34
+ lines.push('');
35
+ }
36
+ else if (plan.intent) {
37
+ lines.push('## Purpose');
38
+ lines.push('');
39
+ lines.push(plan.intent);
40
+ lines.push('');
41
+ }
42
+ // Goals section - safely check if goals is a string array
43
+ const metadataGoals = plan.metadata?.['goals'];
44
+ if (metadataGoals && isStringArray(metadataGoals)) {
45
+ lines.push('## Goals');
46
+ lines.push('');
47
+ for (const goal of metadataGoals) {
48
+ lines.push(`- ${goal}`);
49
+ }
50
+ lines.push('');
51
+ }
52
+ // Changes section
53
+ if (plan.proposed_changes.length > 0) {
54
+ lines.push('## Changes');
55
+ lines.push('');
56
+ // Group changes by type
57
+ const creates = plan.proposed_changes.filter((c) => c.type === 'file_create');
58
+ const updates = plan.proposed_changes.filter((c) => c.type === 'file_update');
59
+ const deletes = plan.proposed_changes.filter((c) => c.type === 'file_delete');
60
+ const configs = plan.proposed_changes.filter((c) => c.type === 'config_update');
61
+ if (creates.length > 0) {
62
+ lines.push('### Files to Create');
63
+ lines.push('');
64
+ for (const change of creates) {
65
+ lines.push(`- **${change.path}**: ${change.description}`);
66
+ }
67
+ lines.push('');
68
+ }
69
+ if (updates.length > 0) {
70
+ lines.push('### Files to Update');
71
+ lines.push('');
72
+ for (const change of updates) {
73
+ lines.push(`- **${change.path}**: ${change.description}`);
74
+ }
75
+ lines.push('');
76
+ }
77
+ if (configs.length > 0) {
78
+ lines.push('### Configuration Changes');
79
+ lines.push('');
80
+ for (const change of configs) {
81
+ lines.push(`- **${change.path}**: ${change.description}`);
82
+ }
83
+ lines.push('');
84
+ }
85
+ if (deletes.length > 0) {
86
+ lines.push('### Files to Delete');
87
+ lines.push('');
88
+ for (const change of deletes) {
89
+ lines.push(`- **${change.path}**: ${change.description}`);
90
+ }
91
+ lines.push('');
92
+ }
93
+ }
94
+ // Validation requirements
95
+ if (plan.validations.required_checks.length > 0) {
96
+ lines.push('## Validation Requirements');
97
+ lines.push('');
98
+ for (const check of plan.validations.required_checks) {
99
+ lines.push(`- ${check}`);
100
+ }
101
+ lines.push('');
102
+ }
103
+ // Metadata section
104
+ if (plan.provenance) {
105
+ lines.push('## Metadata');
106
+ lines.push('');
107
+ lines.push(`- **Author**: ${plan.provenance.author || 'Unknown'}`);
108
+ lines.push(`- **Created**: ${plan.provenance.timestamp}`);
109
+ if (plan.provenance.repository) {
110
+ lines.push(`- **Repository**: ${plan.provenance.repository}`);
111
+ }
112
+ if (plan.provenance.branch) {
113
+ lines.push(`- **Branch**: ${plan.provenance.branch}`);
114
+ }
115
+ lines.push('');
116
+ }
117
+ return lines.join('\n');
118
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Generic Adapter Types
3
+ *
4
+ * Types for the generic markdown adapter that handles common planning document formats.
5
+ */
6
+ /**
7
+ * Parsed generic document structure
8
+ */
9
+ export interface GenericDocument {
10
+ /** Document title (from first # heading) */
11
+ title?: string;
12
+ /** Intent/purpose extracted from intro or objective sections */
13
+ intent?: string;
14
+ /** Overview/description */
15
+ overview?: string;
16
+ /** Goals or objectives */
17
+ goals?: string[];
18
+ /** Requirements extracted from various sections */
19
+ requirements?: string[];
20
+ /** Tasks or action items */
21
+ tasks?: string[];
22
+ /** Features or capabilities */
23
+ features?: string[];
24
+ /** Metadata from document */
25
+ metadata?: Record<string, unknown>;
26
+ /** Raw content */
27
+ raw: string;
28
+ }
29
+ /**
30
+ * Detection indicators for generic markdown
31
+ */
32
+ export interface GenericIndicators {
33
+ /** Has markdown headings */
34
+ hasHeadings: boolean;
35
+ /** Has lists (bullet or numbered) */
36
+ hasLists: boolean;
37
+ /** Has requirements-like content */
38
+ hasRequirementsSection: boolean;
39
+ /** Has goals/objectives section */
40
+ hasGoalsSection: boolean;
41
+ /** Has tasks/action items */
42
+ hasTasksSection: boolean;
43
+ /** Has features section */
44
+ hasFeaturesSection: boolean;
45
+ /** Has overview/description */
46
+ hasOverviewSection: boolean;
47
+ /** Document length */
48
+ wordCount: number;
49
+ /** Number of list items */
50
+ listItemCount: number;
51
+ }
52
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/generic/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,kBAAkB;IAClB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,qCAAqC;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,oCAAoC;IACpC,sBAAsB,EAAE,OAAO,CAAC;IAChC,mCAAmC;IACnC,eAAe,EAAE,OAAO,CAAC;IACzB,6BAA6B;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,2BAA2B;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,+BAA+B;IAC/B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,aAAa,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generic Adapter Types
3
+ *
4
+ * Types for the generic markdown adapter that handles common planning document formats.
5
+ */
6
+ export {};
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Generic Adapter Utilities
3
+ *
4
+ * Helper functions for parsing generic markdown documents.
5
+ */
6
+ import type { GenericDocument, GenericIndicators } from './types.js';
7
+ /**
8
+ * Extract document title from first heading
9
+ */
10
+ export declare function extractTitle(content: string): string | undefined;
11
+ /**
12
+ * Extract intent from common sections
13
+ */
14
+ export declare function extractIntent(content: string): string | undefined;
15
+ /**
16
+ * Extract overview/description
17
+ */
18
+ export declare function extractOverview(content: string): string | undefined;
19
+ /**
20
+ * Extract goals from lists under Goals/Objectives sections
21
+ */
22
+ export declare function extractGoals(content: string): string[];
23
+ /**
24
+ * Extract requirements from various sections
25
+ */
26
+ export declare function extractRequirements(content: string): string[];
27
+ /**
28
+ * Extract tasks from Tasks/Action Items sections
29
+ */
30
+ export declare function extractTasks(content: string): string[];
31
+ /**
32
+ * Extract features from Features/Capabilities sections
33
+ */
34
+ export declare function extractFeatures(content: string): string[];
35
+ /**
36
+ * Analyze content for generic markdown indicators
37
+ */
38
+ export declare function analyzeContent(content: string): GenericIndicators;
39
+ /**
40
+ * Calculate confidence score for generic markdown detection
41
+ */
42
+ export declare function calculateConfidenceScore(indicators: GenericIndicators): number;
43
+ /**
44
+ * Build detection reason string
45
+ */
46
+ export declare function buildDetectionReason(indicators: GenericIndicators): string;
47
+ /**
48
+ * Parse generic markdown document
49
+ */
50
+ export declare function parseGenericDocument(content: string): GenericDocument;
51
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/generic/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAErE;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGhE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgBjE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWnE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAgBtD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CA2B7D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAkBtD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAgBjE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM,CA+C9E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM,CA0B1E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAWrE"}