@polymorphism-tech/morph-spec 4.9.0 → 4.10.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 (124) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +30 -0
  3. package/bin/task-manager.js +34 -22
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +99 -98
  8. package/framework/agents.json +37 -7
  9. package/framework/commands/commit.md +166 -0
  10. package/framework/commands/morph-apply.md +13 -2
  11. package/framework/commands/morph-archive.md +8 -2
  12. package/framework/commands/morph-infra.md +6 -0
  13. package/framework/commands/morph-preflight.md +6 -0
  14. package/framework/commands/morph-proposal.md +56 -7
  15. package/framework/commands/morph-status.md +6 -0
  16. package/framework/commands/morph-troubleshoot.md +6 -0
  17. package/framework/hooks/claude-code/notification/approval-reminder.js +3 -2
  18. package/framework/hooks/claude-code/post-tool-use/dispatch.js +154 -31
  19. package/framework/hooks/claude-code/post-tool-use/skill-reminder.js +7 -84
  20. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +8 -17
  21. package/framework/hooks/claude-code/pre-compact/save-morph-context.js +16 -3
  22. package/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +4 -3
  23. package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +3 -2
  24. package/framework/hooks/claude-code/pre-tool-use/task-tracking-guard.js +60 -0
  25. package/framework/hooks/claude-code/session-start/inject-morph-context.js +55 -2
  26. package/framework/hooks/claude-code/session-start/post-compact-restore.js +41 -0
  27. package/framework/hooks/claude-code/stop/validate-completion.js +2 -15
  28. package/framework/hooks/claude-code/user-prompt/enrich-prompt.js +23 -5
  29. package/framework/hooks/shared/compact-restore.js +100 -0
  30. package/framework/hooks/shared/dispatch-helpers.js +116 -0
  31. package/framework/hooks/shared/phase-utils.js +9 -5
  32. package/framework/hooks/shared/state-reader.js +27 -3
  33. package/framework/phases.json +30 -7
  34. package/framework/rules/morph-workflow.md +88 -86
  35. package/framework/skills/level-0-meta/mcp-registry.json +86 -51
  36. package/framework/skills/level-0-meta/{brainstorming → morph-brainstorming}/SKILL.md +13 -16
  37. package/framework/skills/level-0-meta/{code-review → morph-code-review}/SKILL.md +1 -1
  38. package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/SKILL.md +2 -2
  39. package/framework/skills/level-0-meta/{frontend-review → morph-frontend-review}/SKILL.md +5 -5
  40. package/framework/skills/level-0-meta/morph-init/SKILL.md +72 -7
  41. package/framework/skills/level-0-meta/{post-implementation → morph-post-implementation}/SKILL.md +9 -9
  42. package/framework/skills/level-0-meta/morph-replicate/SKILL.md +1 -1
  43. package/framework/skills/level-0-meta/{terminal-title → morph-terminal-title}/SKILL.md +1 -1
  44. package/framework/skills/level-0-meta/{tool-usage-guide → morph-tool-usage-guide}/SKILL.md +2 -3
  45. package/framework/skills/level-0-meta/{tool-usage-guide → morph-tool-usage-guide}/references/tools-per-phase.md +1 -2
  46. package/framework/skills/level-0-meta/{verification-before-completion → morph-verification-before-completion}/SKILL.md +1 -1
  47. package/framework/skills/level-0-meta/{verification-before-completion → morph-verification-before-completion}/scripts/check-phase-outputs.mjs +2 -2
  48. package/framework/skills/level-1-workflows/morph-phase-clarify/SKILL.md +238 -0
  49. package/framework/skills/level-1-workflows/{phase-codebase-analysis → morph-phase-codebase-analysis}/SKILL.md +251 -251
  50. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +507 -0
  51. package/framework/skills/level-1-workflows/{phase-implement → morph-phase-implement}/SKILL.md +590 -491
  52. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/code-quality-reviewer-prompt.md +50 -0
  53. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/implementer-prompt.md +45 -0
  54. package/framework/skills/level-1-workflows/morph-phase-implement/prompts/spec-reviewer-prompt.md +47 -0
  55. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +254 -0
  56. package/framework/skills/level-1-workflows/{phase-setup → morph-phase-setup}/SKILL.md +237 -194
  57. package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/SKILL.md +307 -270
  58. package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/scripts/validate-tasks.mjs +3 -3
  59. package/framework/skills/level-1-workflows/{phase-uiux → morph-phase-uiux}/SKILL.md +320 -285
  60. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +97 -0
  61. package/framework/standards/integration/mcp/mcp-tools.md +25 -7
  62. package/framework/templates/docs/onboarding.md +2 -2
  63. package/package.json +1 -2
  64. package/src/commands/agents/dispatch-agents.js +50 -3
  65. package/src/commands/mcp/mcp-setup.js +39 -2
  66. package/src/commands/phase/phase-reset.js +74 -0
  67. package/src/commands/project/doctor.js +19 -5
  68. package/src/commands/scope/escalate.js +215 -0
  69. package/src/commands/state/advance-phase.js +27 -53
  70. package/src/commands/state/state.js +1 -1
  71. package/src/commands/task/expand.js +100 -0
  72. package/src/core/paths/output-schema.js +4 -3
  73. package/src/core/state/phase-state-machine.js +7 -4
  74. package/src/core/state/state-manager.js +4 -3
  75. package/src/lib/detectors/claude-config-detector.js +93 -347
  76. package/src/lib/detectors/design-system-detector.js +189 -189
  77. package/src/lib/detectors/index.js +155 -57
  78. package/src/lib/generators/context-generator.js +2 -2
  79. package/src/lib/installers/mcp-installer.js +37 -5
  80. package/src/lib/phase-chain/phase-validator.js +22 -16
  81. package/src/lib/scope/impact-analyzer.js +106 -0
  82. package/src/lib/tasks/task-parser.js +1 -1
  83. package/src/lib/validators/shared/emit-validator-dispatch.js +64 -0
  84. package/src/scripts/setup-infra.js +15 -0
  85. package/src/utils/agents-installer.js +32 -12
  86. package/src/utils/file-copier.js +0 -1
  87. package/src/utils/hooks-installer.js +15 -1
  88. package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +0 -216
  89. package/framework/skills/level-1-workflows/phase-design/SKILL.md +0 -383
  90. package/src/commands/project/index.js +0 -8
  91. package/src/core/index.js +0 -10
  92. package/src/core/state/index.js +0 -8
  93. package/src/core/templates/index.js +0 -9
  94. package/src/core/templates/template-data-sources.js +0 -325
  95. package/src/core/workflows/index.js +0 -7
  96. package/src/lib/detectors/config-detector.js +0 -223
  97. package/src/lib/detectors/standards-generator.js +0 -335
  98. package/src/lib/detectors/structure-detector.js +0 -275
  99. package/src/lib/monitor/agent-resolver.js +0 -144
  100. package/src/lib/monitor/renderer.js +0 -230
  101. package/src/lib/orchestration/index.js +0 -7
  102. package/src/lib/orchestration/team-orchestrator.js +0 -404
  103. package/src/sanitizer/context-sanitizer.js +0 -221
  104. package/src/sanitizer/patterns.js +0 -163
  105. package/src/writer/file-writer.js +0 -86
  106. /package/framework/skills/level-0-meta/{brainstorming → morph-brainstorming}/references/proposal-example.md +0 -0
  107. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/references/review-example.md +0 -0
  108. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/references/review-guidelines.md +0 -0
  109. /package/framework/skills/level-0-meta/{code-review → morph-code-review}/scripts/scan-csharp.mjs +0 -0
  110. /package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/references/review-example-nextjs.md +0 -0
  111. /package/framework/skills/level-0-meta/{code-review-nextjs → morph-code-review-nextjs}/scripts/scan-nextjs.mjs +0 -0
  112. /package/framework/skills/level-0-meta/{frontend-review → morph-frontend-review}/scripts/scan-accessibility.mjs +0 -0
  113. /package/framework/skills/level-0-meta/{post-implementation → morph-post-implementation}/scripts/detect-dev-server.mjs +0 -0
  114. /package/framework/skills/level-0-meta/{post-implementation → morph-post-implementation}/scripts/detect-stack.mjs +0 -0
  115. /package/framework/skills/level-0-meta/{simulation-checklist → morph-simulation-checklist}/SKILL.md +0 -0
  116. /package/framework/skills/level-0-meta/{terminal-title → morph-terminal-title}/scripts/set_title.sh +0 -0
  117. /package/framework/skills/level-1-workflows/{phase-clarify → morph-phase-clarify}/references/clarifications-example.md +0 -0
  118. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/architecture-analysis-guide.md +0 -0
  119. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/spec-authoring-guide.md +0 -0
  120. /package/framework/skills/level-1-workflows/{phase-design → morph-phase-design}/references/spec-example.md +0 -0
  121. /package/framework/skills/level-1-workflows/{phase-implement → morph-phase-implement}/references/recap-example.md +0 -0
  122. /package/framework/skills/level-1-workflows/{phase-implement → morph-phase-implement}/references/vsa-implementation-guide.md +0 -0
  123. /package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/references/task-planning-patterns.md +0 -0
  124. /package/framework/skills/level-1-workflows/{phase-tasks → morph-phase-tasks}/references/tasks-example.md +0 -0
@@ -1,163 +0,0 @@
1
- /**
2
- * @fileoverview Sanitization patterns - Whitelists, Blacklists, Secret patterns
3
- * @module morph-spec/sanitizer/patterns
4
- */
5
-
6
- /**
7
- * Whitelist: Files explicitly allowed to be read and sent to LLM
8
- */
9
- export const WHITELIST_FILES = [
10
- 'package.json',
11
- 'package-lock.json',
12
- 'yarn.lock',
13
- 'pnpm-lock.yaml',
14
- '*.csproj',
15
- '*.sln',
16
- 'README.md',
17
- 'CLAUDE.md',
18
- 'Dockerfile',
19
- 'docker-compose.yml',
20
- 'docker-compose.*.yml',
21
- '*.bicep',
22
- 'azure-pipelines.yml',
23
- '.github/workflows/*.yml',
24
- '.gitlab-ci.yml',
25
- 'tsconfig.json',
26
- 'jsconfig.json',
27
- '.eslintrc*',
28
- '.prettierrc*',
29
- 'vite.config.*',
30
- 'next.config.*',
31
- 'nuxt.config.*'
32
- ];
33
-
34
- /**
35
- * Blacklist: Directories to NEVER scan or read
36
- */
37
- export const BLACKLIST_DIRECTORIES = [
38
- 'node_modules',
39
- '.git',
40
- '.svn',
41
- '.hg',
42
- 'bin',
43
- 'obj',
44
- 'dist',
45
- 'build',
46
- 'out',
47
- '.next',
48
- '.nuxt',
49
- 'coverage',
50
- '__pycache__',
51
- '.pytest_cache',
52
- 'venv',
53
- 'env',
54
- '.venv',
55
- '.env.*',
56
- 'temp',
57
- 'tmp',
58
- '.cache'
59
- ];
60
-
61
- /**
62
- * Blacklist: File patterns to NEVER read (even if matched by whitelist)
63
- */
64
- export const BLACKLIST_FILES = [
65
- '.env',
66
- '.env.local',
67
- '.env.*.local',
68
- '.env.production',
69
- '*.key',
70
- '*.pem',
71
- '*.pfx',
72
- '*.p12',
73
- '*.cert',
74
- '*.crt',
75
- '*secret*',
76
- '*password*',
77
- '*credentials*',
78
- '*token*',
79
- 'secrets.json',
80
- 'appsettings.Production.json',
81
- 'appsettings.Staging.json',
82
- '*.log',
83
- '*.sqlite',
84
- '*.db'
85
- ];
86
-
87
- /**
88
- * Secret patterns to redact from file contents
89
- * Each pattern has: regex, replacement text, description
90
- */
91
- export const SECRET_PATTERNS = [
92
- {
93
- name: 'api-key',
94
- regex: /(?:api[_-]?key|apikey|api[_-]?secret)[\s:=]+["']?([a-zA-Z0-9_\-]{20,})["']?/gi,
95
- replacement: 'API_KEY=***REDACTED***',
96
- description: 'API keys'
97
- },
98
- {
99
- name: 'bearer-token',
100
- regex: /(?:bearer|authorization)[\s:=]+["']?([a-zA-Z0-9_\-\.]{20,})["']?/gi,
101
- replacement: 'Bearer ***REDACTED***',
102
- description: 'Bearer tokens'
103
- },
104
- {
105
- name: 'connection-string',
106
- regex: /(?:connection[_-]?string|connectionstring)[\s:=]+["']?([^"'\n]{30,})["']?/gi,
107
- replacement: 'ConnectionString=***REDACTED***',
108
- description: 'Connection strings'
109
- },
110
- {
111
- name: 'sql-password',
112
- regex: /(?:password|pwd)=([^;"\s]{6,})/gi,
113
- replacement: 'Password=***REDACTED***',
114
- description: 'SQL passwords in connection strings'
115
- },
116
- {
117
- name: 'azure-key',
118
- regex: /(?:account[_-]?key|accountkey)[\s:=]+["']?([a-zA-Z0-9+/=]{40,})["']?/gi,
119
- replacement: 'AccountKey=***REDACTED***',
120
- description: 'Azure Storage Account Keys'
121
- },
122
- {
123
- name: 'jwt-secret',
124
- regex: /(?:jwt[_-]?secret|jwtsecret)[\s:=]+["']?([a-zA-Z0-9_\-]{16,})["']?/gi,
125
- replacement: 'JwtSecret=***REDACTED***',
126
- description: 'JWT secrets'
127
- },
128
- {
129
- name: 'private-key',
130
- regex: /-----BEGIN (?:RSA |EC )?PRIVATE KEY-----[\s\S]+?-----END (?:RSA |EC )?PRIVATE KEY-----/gi,
131
- replacement: '-----BEGIN PRIVATE KEY-----\n***REDACTED***\n-----END PRIVATE KEY-----',
132
- description: 'Private keys (PEM format)'
133
- },
134
- {
135
- name: 'github-token',
136
- regex: /gh[pousr]_[a-zA-Z0-9]{36,}/gi,
137
- replacement: 'ghp_***REDACTED***',
138
- description: 'GitHub personal access tokens'
139
- },
140
- {
141
- name: 'npm-token',
142
- regex: /npm_[a-zA-Z0-9]{36,}/gi,
143
- replacement: 'npm_***REDACTED***',
144
- description: 'NPM tokens'
145
- },
146
- {
147
- name: 'generic-secret',
148
- regex: /(?:secret|password|pwd|pass|token)[\s:=]+["']([^"'\n]{8,})["']/gi,
149
- replacement: 'secret=***REDACTED***',
150
- description: 'Generic secrets'
151
- }
152
- ];
153
-
154
- /**
155
- * Maximum file size to include (50KB)
156
- * Files larger than this are truncated with a summary
157
- */
158
- export const MAX_FILE_SIZE = 50 * 1024; // 50KB
159
-
160
- /**
161
- * Maximum content length for README/CLAUDE.md summaries
162
- */
163
- export const MAX_SUMMARY_LENGTH = 500; // 500 chars
@@ -1,86 +0,0 @@
1
- /**
2
- * @fileoverview FileWriter - Saves generated configs to filesystem
3
- * @module morph-spec/writer/file-writer
4
- */
5
-
6
- import { writeFile, mkdir, access } from 'fs/promises';
7
- import { join, dirname } from 'path';
8
- import chalk from 'chalk';
9
-
10
- /**
11
- * @typedef {import('../types/index.js').GeneratedConfigs} GeneratedConfigs
12
- */
13
-
14
- /**
15
- * FileWriter - Saves configuration files to .morph/ directory
16
- * @class
17
- */
18
- export class FileWriter {
19
- /**
20
- * Save generated configs to filesystem
21
- * @param {string} cwd - Current working directory
22
- * @param {GeneratedConfigs} configs - Configs to save
23
- * @returns {Promise<void>}
24
- */
25
- async save(cwd, configs) {
26
- const morphDir = join(cwd, '.morph');
27
- const configDir = join(morphDir, 'config');
28
-
29
- // Ensure directories exist
30
- await this.ensureDirectoryExists(morphDir);
31
- await this.ensureDirectoryExists(configDir);
32
-
33
- // Write files
34
- const projectMdPath = join(morphDir, 'project.md');
35
- const configJsonPath = join(configDir, 'config.json');
36
-
37
- await Promise.all([
38
- this.writeProjectMd(projectMdPath, configs.projectMd),
39
- this.writeConfigJson(configJsonPath, configs.configJson)
40
- ]);
41
-
42
- // Display success message
43
- console.log(chalk.bold.green('\n✅ Configuration files saved:\n'));
44
- console.log(chalk.cyan(` 📄 ${projectMdPath}`));
45
- console.log(chalk.cyan(` ⚙️ ${configJsonPath}`));
46
- console.log();
47
- }
48
-
49
- /**
50
- * Write project.md file
51
- * @param {string} filepath - File path
52
- * @param {string} content - File content
53
- * @returns {Promise<void>}
54
- */
55
- async writeProjectMd(filepath, content) {
56
- await writeFile(filepath, content, 'utf-8');
57
- }
58
-
59
- /**
60
- * Write config.json file (with pretty formatting)
61
- * @param {string} filepath - File path
62
- * @param {string} content - File content (JSON string)
63
- * @returns {Promise<void>}
64
- */
65
- async writeConfigJson(filepath, content) {
66
- // Parse and re-stringify with pretty formatting
67
- const parsed = JSON.parse(content);
68
- const formatted = JSON.stringify(parsed, null, 2);
69
-
70
- await writeFile(filepath, formatted, 'utf-8');
71
- }
72
-
73
- /**
74
- * Ensure directory exists (create if not)
75
- * @param {string} dirPath - Directory path
76
- * @returns {Promise<void>}
77
- */
78
- async ensureDirectoryExists(dirPath) {
79
- try {
80
- await access(dirPath);
81
- } catch (error) {
82
- // Directory doesn't exist, create it
83
- await mkdir(dirPath, { recursive: true });
84
- }
85
- }
86
- }