@peter.naydenov/morph 3.1.5 → 3.3.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 (44) hide show
  1. package/.mocharc.json +1 -0
  2. package/.opencode/command/speckit.analyze.md +184 -0
  3. package/.opencode/command/speckit.checklist.md +294 -0
  4. package/.opencode/command/speckit.clarify.md +181 -0
  5. package/.opencode/command/speckit.constitution.md +82 -0
  6. package/.opencode/command/speckit.implement.md +135 -0
  7. package/.opencode/command/speckit.plan.md +89 -0
  8. package/.opencode/command/speckit.specify.md +257 -0
  9. package/.opencode/command/speckit.tasks.md +137 -0
  10. package/.opencode/command/speckit.taskstoissues.md +28 -0
  11. package/.specify/memory/constitution.md +43 -0
  12. package/.specify/scripts/bash/check-prerequisites.sh +166 -0
  13. package/.specify/scripts/bash/common.sh +156 -0
  14. package/.specify/scripts/bash/create-new-feature.sh +305 -0
  15. package/.specify/scripts/bash/setup-plan.sh +61 -0
  16. package/.specify/scripts/bash/update-agent-context.sh +790 -0
  17. package/.specify/templates/agent-file-template.md +28 -0
  18. package/.specify/templates/checklist-template.md +40 -0
  19. package/.specify/templates/plan-template.md +104 -0
  20. package/.specify/templates/spec-template.md +115 -0
  21. package/.specify/templates/tasks-template.md +251 -0
  22. package/Changelog.md +17 -0
  23. package/README.md +184 -13
  24. package/dist/methods/build.d.ts +28 -2
  25. package/dist/methods/render.d.ts +9 -20
  26. package/dist/morph.cjs +1 -1
  27. package/dist/morph.esm.mjs +1 -1
  28. package/dist/morph.umd.js +1 -1
  29. package/morph.png +0 -0
  30. package/package.json +3 -2
  31. package/simple.js +17 -0
  32. package/specs/001-extend-templates/checklists/requirements.md +35 -0
  33. package/specs/001-extend-templates/contracts/set-method.json +39 -0
  34. package/specs/001-extend-templates/data-model.md +76 -0
  35. package/specs/001-extend-templates/plan.md +90 -0
  36. package/specs/001-extend-templates/quickstart.md +56 -0
  37. package/specs/001-extend-templates/research.md +18 -0
  38. package/specs/001-extend-templates/spec.md +139 -0
  39. package/specs/001-extend-templates/tasks.md +255 -0
  40. package/src/methods/_readTemplate.js +22 -46
  41. package/src/methods/_renderHolder.js +13 -7
  42. package/src/methods/_setupActions.js +1 -8
  43. package/src/methods/build.js +458 -321
  44. package/src/methods/render.js +23 -46
@@ -52,52 +52,28 @@ function _readTemplate ( tpl ) {
52
52
 
53
53
  if ( typeof chop === 'string' ) hasError = chop
54
54
  else {
55
- chop.forEach ( (item,i) => {
56
- const
57
- // Placeholder contains: Opening tag(TG_PRX), dataName, delimiter(:), list of operations, placeholder's name, closing tag(TG_SFX)
58
- finding = RegExp ( TG_PRX + '\\s*(.*?)\\s*(?::\\s*(.*?)\\s*)?(?::\\s*(.*?)\\s*)?' + TG_SFX, 'g' )
59
- , isPlaceholder = item.includes( TG_PRX )
60
- ;
61
-
62
- if ( isPlaceholder ) {
63
- const x = finding.exec ( item )
64
- if ( !x ) return
65
- let holder = {
66
- index: i
67
- , data : readData ( x[1] )
68
- , action : x[2] ? x[2].split(',').map ( x => x.trim()) : null
69
- , name : x[3] ? x[3].trim() : null
70
- }
71
- placeholders.push ( holder )
72
- snippets[placeholders.length-1] = holder
73
- if ( holder.name ) snippets[holder.name] = holder
74
- } // if isPlaceholder
75
- }) // forEach chop
76
- } // else error
77
-
78
-
79
-
80
- // Check helpers - sanity check
81
- placeholders.forEach ( holder => {
82
- if ( !holder.action ) return
83
- holder.action.every ( act => {
84
- if ( act === '#' ) return true
85
- if ( act === '^^' ) return true
86
- if ( act.startsWith('^') && act !== '^^' ) return true
87
- if ( act.startsWith ( '?' )) act = act.replace ( '?', '' )
88
- if ( act.startsWith ( '+' )) act = act.replace ( '+', '' )
89
- if ( act.startsWith ( '[]' )) act = act.replace ( '[]', '' )
90
- if ( act.startsWith ( '>' )) act = act.replace ( '>', '' )
91
- if ( act === '' ) return true
92
- if ( helpers[act] ) return true
93
- else {
94
- hasError = `Error: Missing helper: ${act}`
95
- return false
96
- }
97
- }) // every action
98
- }) // forEach placeholders
99
-
100
-
55
+ chop.forEach ( (item,i) => {
56
+ const
57
+ // Placeholder contains: Opening tag(TG_PRX), dataName, delimiter(:), list of operations, placeholder's name, closing tag(TG_SFX)
58
+ finding = RegExp ( TG_PRX + '\\s*(.*?)\\s*(?::\\s*(.*?)\\s*)?(?::\\s*(.*?)\\s*)?' + TG_SFX, 'g' )
59
+ , isPlaceholder = item.includes( TG_PRX )
60
+ ;
61
+
62
+ if ( isPlaceholder ) {
63
+ const x = finding.exec ( item )
64
+ if ( !x ) return
65
+ let holder = {
66
+ index: i
67
+ , data : readData ( x[1] )
68
+ , action : x[2] ? x[2].split(',').map ( x => x.trim()) : null
69
+ , name : x[3] ? x[3].trim() : null
70
+ }
71
+ placeholders.push ( holder )
72
+ snippets[placeholders.length-1] = holder
73
+ if ( holder.name ) snippets[holder.name] = holder
74
+ } // if isPlaceholder
75
+ }) // forEach chop
76
+ } // else error
101
77
 
102
78
  return {
103
79
  hasError
@@ -26,17 +26,23 @@ function _renderHolder ( template, data ) {
26
26
  chop = _chopTemplate (settings)( template )
27
27
  , set = settings
28
28
  ;
29
- chop.forEach ( (item,i) => {
30
- const isPlaceholder = item.includes ( set.TG_PRX )
31
- if ( isPlaceholder ) {
32
- const field = item.replace ( set.TG_PRX, '' ).replace ( set.TG_SFX, '' ).trim();
33
- if ( data.hasOwnProperty (field) && data[field] != null ) chop[i] = data[field]
34
- } // if isPlaceholder
35
- }) // forEach chop
29
+ if ( typeof chop === 'string' ) return chop
30
+ chop.forEach ( ( item, i ) => {
31
+ const isPlaceholder = item.includes ( set.TG_PRX )
32
+ if ( isPlaceholder ) {
33
+ const field = item.replace(set.TG_PRX, '').replace(set.TG_SFX, '').trim();
34
+ if (data.hasOwnProperty(field) && data[field] != null) {
35
+ let val = data [ field ]
36
+ if ( typeof val === 'object' && val.text ) val = val.text
37
+ chop[i] = val
38
+ }
39
+ } // if isPlaceholder
40
+ }) // forEach chop
36
41
  return chop.join ( '' )
37
42
  } // _renderHolder func.
38
43
 
39
44
 
45
+
40
46
  export default _renderHolder
41
47
 
42
48
 
@@ -40,14 +40,7 @@ function _setupActions ( actions, dataDeepLevel=10 ) {
40
40
  if ( actLevel > dataDeepLevel ) return false
41
41
  return true
42
42
  }
43
- if ( act.startsWith ( '?' ) ) { // it's a condition render action
44
- actSetup[actLevel].push ({
45
- type: 'route'
46
- , name: act.replace ( '?', '' )
47
- , level: actLevel
48
- })
49
- return true
50
- }
43
+
51
44
  if ( act.startsWith ('^') && act !== '^^' ) {
52
45
  actSetup[actLevel].push ({
53
46
  type: 'save'