@urielsh/prodify 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 (273) hide show
  1. package/.prodify/AGENTS.md +56 -0
  2. package/.prodify/README.md +10 -0
  3. package/.prodify/artifacts/01-understand.md +28 -0
  4. package/.prodify/artifacts/02-diagnose.md +26 -0
  5. package/.prodify/artifacts/03-architecture.md +30 -0
  6. package/.prodify/artifacts/04-plan.md +35 -0
  7. package/.prodify/artifacts/05-refactor.md +24 -0
  8. package/.prodify/artifacts/06-validate.md +17 -0
  9. package/.prodify/artifacts/README.md +6 -0
  10. package/.prodify/artifacts/architecture_spec.md +29 -0
  11. package/.prodify/artifacts/artifact-validation-design.md +276 -0
  12. package/.prodify/artifacts/cli-command-design.md +299 -0
  13. package/.prodify/artifacts/completed-steps-tracking.md +201 -0
  14. package/.prodify/artifacts/diagnostic_report.md +45 -0
  15. package/.prodify/artifacts/hardening-patch-summary.md +57 -0
  16. package/.prodify/artifacts/hardening-verification-report.md +48 -0
  17. package/.prodify/artifacts/implementation_summary.md +19 -0
  18. package/.prodify/artifacts/improvement-evaluation-spec.md +148 -0
  19. package/.prodify/artifacts/next-step-resolver-design.md +570 -0
  20. package/.prodify/artifacts/orientation_map.md +32 -0
  21. package/.prodify/artifacts/persona-removal-audit.md +106 -0
  22. package/.prodify/artifacts/planning-alignment-report.md +189 -0
  23. package/.prodify/artifacts/refactor-plan-template-hardening.md +83 -0
  24. package/.prodify/artifacts/refactor-validate-loop-design.md +231 -0
  25. package/.prodify/artifacts/refactor_plan.md +21 -0
  26. package/.prodify/artifacts/refactor_plan.strict-example.md +31 -0
  27. package/.prodify/artifacts/run-state-design.md +292 -0
  28. package/.prodify/artifacts/run-summary-spec.md +149 -0
  29. package/.prodify/artifacts/run_state.json +14 -0
  30. package/.prodify/artifacts/sample-repo-test-plan.md +129 -0
  31. package/.prodify/artifacts/status-output-spec.md +349 -0
  32. package/.prodify/artifacts/step-selection-design.md +251 -0
  33. package/.prodify/artifacts/task-dispatcher-design.md +266 -0
  34. package/.prodify/artifacts/task-header-audit.md +42 -0
  35. package/.prodify/artifacts/task-log-enhancement-spec.md +264 -0
  36. package/.prodify/artifacts/task-protocol-hardening-plan.md +68 -0
  37. package/.prodify/artifacts/task-self-validation-spec.md +171 -0
  38. package/.prodify/artifacts/task_log.json +160 -0
  39. package/.prodify/artifacts/template-usage-audit.md +20 -0
  40. package/.prodify/artifacts/validation_report.md +22 -0
  41. package/.prodify/contracts/README.md +3 -0
  42. package/.prodify/contracts/architecture.contract.json +42 -0
  43. package/.prodify/contracts/diagnose.contract.json +42 -0
  44. package/.prodify/contracts/plan.contract.json +42 -0
  45. package/.prodify/contracts/refactor.contract.json +45 -0
  46. package/.prodify/contracts/understand.contract.json +42 -0
  47. package/.prodify/contracts/validate.contract.json +52 -0
  48. package/.prodify/contracts-src/README.md +4 -0
  49. package/.prodify/contracts-src/architecture.contract.md +29 -0
  50. package/.prodify/contracts-src/diagnose.contract.md +29 -0
  51. package/.prodify/contracts-src/plan.contract.md +29 -0
  52. package/.prodify/contracts-src/refactor.contract.md +32 -0
  53. package/.prodify/contracts-src/understand.contract.md +29 -0
  54. package/.prodify/contracts-src/validate.contract.md +35 -0
  55. package/.prodify/metrics/README.md +4 -0
  56. package/.prodify/planning.md +13 -0
  57. package/.prodify/project.md +15 -0
  58. package/.prodify/rules/01-global-operating-rules.md +21 -0
  59. package/.prodify/rules/02-analysis-discipline.md +17 -0
  60. package/.prodify/rules/03-diagnosis-severity-rules.md +42 -0
  61. package/.prodify/rules/04-architecture-rules.md +27 -0
  62. package/.prodify/rules/05-planning-rules.md +23 -0
  63. package/.prodify/rules/06-refactor-rules.md +20 -0
  64. package/.prodify/rules/07-validation-rules.md +25 -0
  65. package/.prodify/rules/08-output-format-rules.md +20 -0
  66. package/.prodify/rules/09-template-usage-rules.md +11 -0
  67. package/.prodify/rules/10-artifact-flow-and-orchestration-rules.md +40 -0
  68. package/.prodify/rules/README.md +3 -0
  69. package/.prodify/rules/example-rule.md +4 -0
  70. package/.prodify/runtime-commands.md +57 -0
  71. package/.prodify/skills/README.md +8 -0
  72. package/.prodify/skills/domain/react-frontend.skill.json +34 -0
  73. package/.prodify/skills/domain/typescript-backend.skill.json +34 -0
  74. package/.prodify/skills/quality-policy/maintainability-review.skill.json +25 -0
  75. package/.prodify/skills/quality-policy/security-hardening.skill.json +32 -0
  76. package/.prodify/skills/quality-policy/test-hardening.skill.json +23 -0
  77. package/.prodify/skills/registry.json +16 -0
  78. package/.prodify/skills/stage-method/architecture-method.skill.json +22 -0
  79. package/.prodify/skills/stage-method/codebase-scanning.skill.json +22 -0
  80. package/.prodify/skills/stage-method/diagnosis-method.skill.json +22 -0
  81. package/.prodify/skills/stage-method/planning-method.skill.json +22 -0
  82. package/.prodify/skills/stage-method/refactoring-method.skill.json +22 -0
  83. package/.prodify/skills/stage-method/validation-method.skill.json +22 -0
  84. package/.prodify/state.json +30 -0
  85. package/.prodify/tasks/01-understand.md +83 -0
  86. package/.prodify/tasks/02-diagnose.md +67 -0
  87. package/.prodify/tasks/03-architecture.md +70 -0
  88. package/.prodify/tasks/04-plan.md +71 -0
  89. package/.prodify/tasks/05-refactor.md +61 -0
  90. package/.prodify/tasks/06-validate.md +69 -0
  91. package/.prodify/tasks/README.md +3 -0
  92. package/.prodify/tasks/example-task.md +13 -0
  93. package/.prodify/templates/01-understand.template.md +18 -0
  94. package/.prodify/templates/02-diagnose.template.md +18 -0
  95. package/.prodify/templates/03-architecture.template.md +18 -0
  96. package/.prodify/templates/04-plan.template.md +22 -0
  97. package/.prodify/templates/05-refactor.template.md +19 -0
  98. package/.prodify/templates/06-validate.template.md +16 -0
  99. package/.prodify/templates/README.md +3 -0
  100. package/.prodify/templates/architecture_spec.template.md +29 -0
  101. package/.prodify/templates/diagnostic_report.template.md +45 -0
  102. package/.prodify/templates/example.template.md +5 -0
  103. package/.prodify/templates/implementation_summary.template.md +19 -0
  104. package/.prodify/templates/orientation_map.template.md +32 -0
  105. package/.prodify/templates/refactor_plan.template.md +24 -0
  106. package/.prodify/templates/validation_report.template.md +22 -0
  107. package/.prodify/version.json +5 -0
  108. package/AGENTS.md +305 -0
  109. package/LICENSE +201 -0
  110. package/README.md +118 -0
  111. package/assets/presets/default/canonical/AGENTS.md +54 -0
  112. package/assets/presets/default/canonical/artifacts/README.md +6 -0
  113. package/assets/presets/default/canonical/contracts-src/README.md +4 -0
  114. package/assets/presets/default/canonical/contracts-src/architecture.contract.md +56 -0
  115. package/assets/presets/default/canonical/contracts-src/diagnose.contract.md +49 -0
  116. package/assets/presets/default/canonical/contracts-src/plan.contract.md +42 -0
  117. package/assets/presets/default/canonical/contracts-src/refactor.contract.md +54 -0
  118. package/assets/presets/default/canonical/contracts-src/understand.contract.md +56 -0
  119. package/assets/presets/default/canonical/contracts-src/validate.contract.md +64 -0
  120. package/assets/presets/default/canonical/metrics/README.md +4 -0
  121. package/assets/presets/default/canonical/planning.md +13 -0
  122. package/assets/presets/default/canonical/project.md +15 -0
  123. package/assets/presets/default/canonical/rules/README.md +3 -0
  124. package/assets/presets/default/canonical/rules/example-rule.md +4 -0
  125. package/assets/presets/default/canonical/runtime-commands.md +57 -0
  126. package/assets/presets/default/canonical/skills/README.md +8 -0
  127. package/assets/presets/default/canonical/skills/domain/react-frontend.skill.json +34 -0
  128. package/assets/presets/default/canonical/skills/domain/typescript-backend.skill.json +34 -0
  129. package/assets/presets/default/canonical/skills/quality-policy/maintainability-review.skill.json +25 -0
  130. package/assets/presets/default/canonical/skills/quality-policy/security-hardening.skill.json +32 -0
  131. package/assets/presets/default/canonical/skills/quality-policy/test-hardening.skill.json +23 -0
  132. package/assets/presets/default/canonical/skills/registry.json +16 -0
  133. package/assets/presets/default/canonical/skills/stage-method/architecture-method.skill.json +22 -0
  134. package/assets/presets/default/canonical/skills/stage-method/codebase-scanning.skill.json +22 -0
  135. package/assets/presets/default/canonical/skills/stage-method/diagnosis-method.skill.json +22 -0
  136. package/assets/presets/default/canonical/skills/stage-method/planning-method.skill.json +22 -0
  137. package/assets/presets/default/canonical/skills/stage-method/refactoring-method.skill.json +22 -0
  138. package/assets/presets/default/canonical/skills/stage-method/validation-method.skill.json +22 -0
  139. package/assets/presets/default/canonical/state.json +30 -0
  140. package/assets/presets/default/canonical/tasks/README.md +3 -0
  141. package/assets/presets/default/canonical/tasks/example-task.md +13 -0
  142. package/assets/presets/default/canonical/templates/README.md +3 -0
  143. package/assets/presets/default/canonical/templates/example.template.md +5 -0
  144. package/assets/presets/default/preset.json +5 -0
  145. package/dist/cli.js +53 -0
  146. package/dist/commands/doctor.js +16 -0
  147. package/dist/commands/init.js +30 -0
  148. package/dist/commands/install.js +27 -0
  149. package/dist/commands/setup-agent.js +23 -0
  150. package/dist/commands/status.js +28 -0
  151. package/dist/commands/sync.js +29 -0
  152. package/dist/commands/update.js +18 -0
  153. package/dist/contracts/compiled-schema.js +37 -0
  154. package/dist/contracts/compiler.js +83 -0
  155. package/dist/contracts/freshness.js +52 -0
  156. package/dist/contracts/index.js +5 -0
  157. package/dist/contracts/parser.js +201 -0
  158. package/dist/contracts/schema.js +138 -0
  159. package/dist/contracts/source-schema.js +111 -0
  160. package/dist/core/agent-runtime.js +36 -0
  161. package/dist/core/agent-setup.js +111 -0
  162. package/dist/core/doctor.js +155 -0
  163. package/dist/core/errors.js +19 -0
  164. package/dist/core/flow-state.js +262 -0
  165. package/dist/core/fs.js +50 -0
  166. package/dist/core/install.js +44 -0
  167. package/dist/core/managed-files.js +106 -0
  168. package/dist/core/paths.js +56 -0
  169. package/dist/core/preset-validation.js +43 -0
  170. package/dist/core/prompt-builder.js +63 -0
  171. package/dist/core/repo-context.js +77 -0
  172. package/dist/core/repo-root.js +55 -0
  173. package/dist/core/skill-resolution.js +123 -0
  174. package/dist/core/state.js +220 -0
  175. package/dist/core/status.js +293 -0
  176. package/dist/core/sync.js +63 -0
  177. package/dist/core/targets.js +48 -0
  178. package/dist/core/upgrade.js +57 -0
  179. package/dist/core/validation.js +138 -0
  180. package/dist/core/version-checks.js +35 -0
  181. package/dist/generators/claude.js +14 -0
  182. package/dist/generators/codex.js +14 -0
  183. package/dist/generators/copilot.js +29 -0
  184. package/dist/generators/header.js +13 -0
  185. package/dist/generators/opencode.js +14 -0
  186. package/dist/generators/shared.js +37 -0
  187. package/dist/index.js +9 -0
  188. package/dist/legacy/targets.js +55 -0
  189. package/dist/presets/default.js +3 -0
  190. package/dist/presets/loader.js +34 -0
  191. package/dist/presets/version.js +18 -0
  192. package/dist/scoring/model.js +262 -0
  193. package/dist/skills/loader.js +40 -0
  194. package/dist/skills/schema.js +159 -0
  195. package/dist/types.js +1 -0
  196. package/docs/canonical-prodify-layout.md +87 -0
  197. package/docs/claude-support.md +22 -0
  198. package/docs/cli-doctor-spec.md +52 -0
  199. package/docs/cli-init-spec.md +70 -0
  200. package/docs/cli-install-agent-spec.md +48 -0
  201. package/docs/cli-sync-spec.md +40 -0
  202. package/docs/codex-support.md +24 -0
  203. package/docs/compatibility-targets.md +59 -0
  204. package/docs/copilot-support.md +30 -0
  205. package/docs/default-preset.md +47 -0
  206. package/docs/generated-file-headers.md +45 -0
  207. package/docs/generation-rules.md +94 -0
  208. package/docs/idempotency-guarantees.md +31 -0
  209. package/docs/managed-file-detection.md +45 -0
  210. package/docs/manual-edit-conflicts.md +37 -0
  211. package/docs/opencode-support.md +27 -0
  212. package/docs/ownership-rules.md +39 -0
  213. package/docs/path-resolution-rules.md +40 -0
  214. package/docs/preset-structure.md +49 -0
  215. package/docs/skill-system.md +67 -0
  216. package/docs/versioning-and-upgrade-strategy.md +40 -0
  217. package/package.json +22 -0
  218. package/src/README.md +11 -0
  219. package/src/cli.ts +61 -0
  220. package/src/commands/doctor.ts +20 -0
  221. package/src/commands/init.ts +37 -0
  222. package/src/commands/setup-agent.ts +28 -0
  223. package/src/commands/status.ts +34 -0
  224. package/src/commands/update.ts +23 -0
  225. package/src/contracts/README.md +10 -0
  226. package/src/contracts/compiled-schema.ts +42 -0
  227. package/src/contracts/compiler.ts +111 -0
  228. package/src/contracts/freshness.ts +58 -0
  229. package/src/contracts/index.ts +11 -0
  230. package/src/contracts/parser.ts +253 -0
  231. package/src/contracts/source-schema.ts +141 -0
  232. package/src/core/agent-runtime.ts +53 -0
  233. package/src/core/agent-setup.ts +147 -0
  234. package/src/core/doctor.ts +171 -0
  235. package/src/core/errors.ts +28 -0
  236. package/src/core/flow-state.ts +333 -0
  237. package/src/core/fs.ts +59 -0
  238. package/src/core/paths.ts +63 -0
  239. package/src/core/preset-validation.ts +47 -0
  240. package/src/core/prompt-builder.ts +73 -0
  241. package/src/core/repo-context.ts +93 -0
  242. package/src/core/repo-root.ts +74 -0
  243. package/src/core/skill-resolution.ts +151 -0
  244. package/src/core/state.ts +264 -0
  245. package/src/core/status.ts +372 -0
  246. package/src/core/targets.ts +53 -0
  247. package/src/core/upgrade.ts +66 -0
  248. package/src/core/validation.ts +233 -0
  249. package/src/core/version-checks.ts +40 -0
  250. package/src/index.ts +13 -0
  251. package/src/presets/default.ts +7 -0
  252. package/src/presets/loader.ts +46 -0
  253. package/src/presets/version.ts +31 -0
  254. package/src/scoring/model.ts +332 -0
  255. package/src/skills/loader.ts +58 -0
  256. package/src/skills/schema.ts +197 -0
  257. package/src/types.ts +329 -0
  258. package/tests/integration/cli-flows.test.js +347 -0
  259. package/tests/unit/agent-setup.test.js +81 -0
  260. package/tests/unit/cli.test.js +28 -0
  261. package/tests/unit/contracts.test.js +61 -0
  262. package/tests/unit/helpers.js +28 -0
  263. package/tests/unit/paths.test.js +52 -0
  264. package/tests/unit/preset-loader.test.js +37 -0
  265. package/tests/unit/scoring.test.js +65 -0
  266. package/tests/unit/self-hosted-workspace.test.js +22 -0
  267. package/tests/unit/skills.test.js +115 -0
  268. package/tests/unit/state-and-flow.test.js +120 -0
  269. package/tests/unit/targets.test.js +13 -0
  270. package/tests/unit/validation.test.js +73 -0
  271. package/tests/unit/version.test.js +24 -0
  272. package/tsconfig.json +23 -0
  273. package/urielsh-prodify-0.1.0.tgz +0 -0
@@ -0,0 +1,159 @@
1
+ import { normalizeRepoRelativePath } from '../core/paths.js';
2
+ import { ProdifyError } from '../core/errors.js';
3
+ import { CONTRACT_STAGE_NAMES } from '../contracts/source-schema.js';
4
+ const SKILL_CATEGORIES = ['stage-method', 'domain', 'quality-policy'];
5
+ const REPO_CONTEXT_FACTS = ['language', 'framework', 'project_type', 'architecture_pattern', 'risk_signal'];
6
+ function asString(value, fieldName) {
7
+ if (typeof value !== 'string' || value.trim() === '') {
8
+ throw new ProdifyError(`Skill field "${fieldName}" must be a non-empty string.`, {
9
+ code: 'SKILL_SCHEMA_INVALID'
10
+ });
11
+ }
12
+ return value.trim();
13
+ }
14
+ function asOptionalStringArray(value, fieldName) {
15
+ if (!Array.isArray(value) || value.length === 0) {
16
+ return [];
17
+ }
18
+ return asStringArray(value, fieldName);
19
+ }
20
+ function asStringArray(value, fieldName) {
21
+ if (!Array.isArray(value) || value.length === 0) {
22
+ throw new ProdifyError(`Skill field "${fieldName}" must be a non-empty list.`, {
23
+ code: 'SKILL_SCHEMA_INVALID'
24
+ });
25
+ }
26
+ const normalized = value.map((entry) => asString(entry, fieldName));
27
+ return [...new Set(normalized)].sort((left, right) => left.localeCompare(right));
28
+ }
29
+ function asRecord(value, fieldName) {
30
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
31
+ throw new ProdifyError(`Skill field "${fieldName}" must be a mapping.`, {
32
+ code: 'SKILL_SCHEMA_INVALID'
33
+ });
34
+ }
35
+ return value;
36
+ }
37
+ function asSkillCategory(value) {
38
+ const category = asString(value, 'category');
39
+ if (!SKILL_CATEGORIES.includes(category)) {
40
+ throw new ProdifyError(`Skill category is invalid: ${category}.`, {
41
+ code: 'SKILL_SCHEMA_INVALID'
42
+ });
43
+ }
44
+ return category;
45
+ }
46
+ function asStageList(value, fieldName) {
47
+ const stages = asStringArray(value, fieldName);
48
+ for (const stage of stages) {
49
+ if (!CONTRACT_STAGE_NAMES.includes(stage)) {
50
+ throw new ProdifyError(`Skill field "${fieldName}" contains unsupported stage "${stage}".`, {
51
+ code: 'SKILL_SCHEMA_INVALID'
52
+ });
53
+ }
54
+ }
55
+ return stages;
56
+ }
57
+ function normalizePredicate(value, fieldName) {
58
+ const record = asRecord(value, fieldName);
59
+ const fact = asString(record.fact, `${fieldName}.fact`);
60
+ if (!REPO_CONTEXT_FACTS.includes(fact)) {
61
+ throw new ProdifyError(`Skill condition fact is invalid: ${fact}.`, {
62
+ code: 'SKILL_SCHEMA_INVALID'
63
+ });
64
+ }
65
+ return {
66
+ fact,
67
+ includes: asString(record.includes, `${fieldName}.includes`)
68
+ };
69
+ }
70
+ export function normalizeSkillCondition(value, fieldName) {
71
+ const record = asRecord(value, fieldName);
72
+ const all = Array.isArray(record.all)
73
+ ? record.all.map((entry, index) => normalizePredicate(entry, `${fieldName}.all[${index}]`))
74
+ : [];
75
+ if (all.length === 0) {
76
+ throw new ProdifyError(`Skill condition "${fieldName}" must declare at least one "all" predicate.`, {
77
+ code: 'SKILL_SCHEMA_INVALID'
78
+ });
79
+ }
80
+ return {
81
+ all: all.sort((left, right) => `${left.fact}:${left.includes}`.localeCompare(`${right.fact}:${right.includes}`))
82
+ };
83
+ }
84
+ export function validateSkillDefinitionShape(value) {
85
+ const record = asRecord(value, 'skill');
86
+ return {
87
+ schema_version: asString(record.schema_version, 'schema_version'),
88
+ id: asString(record.id, 'id'),
89
+ name: asString(record.name, 'name'),
90
+ version: asString(record.version, 'version'),
91
+ category: asSkillCategory(record.category),
92
+ description: asString(record.description, 'description'),
93
+ intended_use: asStringArray(record.intended_use, 'intended_use'),
94
+ stage_compatibility: asStageList(record.stage_compatibility, 'stage_compatibility'),
95
+ activation_conditions: Array.isArray(record.activation_conditions)
96
+ ? record.activation_conditions.map((entry, index) => normalizeSkillCondition(entry, `activation_conditions[${index}]`))
97
+ : [],
98
+ execution_guidance: asStringArray(record.execution_guidance, 'execution_guidance'),
99
+ caution_guidance: asOptionalStringArray(record.caution_guidance, 'caution_guidance')
100
+ };
101
+ }
102
+ export function validateSkillRegistryManifest(value) {
103
+ const record = asRecord(value, 'skill registry');
104
+ return {
105
+ schema_version: asString(record.schema_version, 'schema_version'),
106
+ skills: asStringArray(record.skills, 'skills')
107
+ .map((entry) => normalizeRepoRelativePath(entry))
108
+ };
109
+ }
110
+ function validateRoutingSkillIds(skillIds, fieldName) {
111
+ return [...new Set(skillIds.map((entry) => asString(entry, fieldName)))].sort((left, right) => left.localeCompare(right));
112
+ }
113
+ function normalizeRoutingRule(value, fieldName) {
114
+ const record = asRecord(value, fieldName);
115
+ return {
116
+ skill: asString(record.skill, `${fieldName}.skill`),
117
+ when: normalizeSkillCondition(record.when, `${fieldName}.when`),
118
+ reason: asString(record.reason, `${fieldName}.reason`)
119
+ };
120
+ }
121
+ export function normalizeStageSkillRouting(value) {
122
+ if (value === undefined || value === null) {
123
+ return {
124
+ default_skills: [],
125
+ allowed_skills: [],
126
+ conditional_skills: []
127
+ };
128
+ }
129
+ const record = asRecord(value, 'skill_routing');
130
+ const defaultSkills = Array.isArray(record.default_skills)
131
+ ? validateRoutingSkillIds(record.default_skills, 'skill_routing.default_skills')
132
+ : [];
133
+ const allowedSkills = Array.isArray(record.allowed_skills)
134
+ ? validateRoutingSkillIds(record.allowed_skills, 'skill_routing.allowed_skills')
135
+ : [];
136
+ const conditionalSkills = Array.isArray(record.conditional_skills)
137
+ ? record.conditional_skills.map((entry, index) => normalizeRoutingRule(entry, `skill_routing.conditional_skills[${index}]`))
138
+ .sort((left, right) => left.skill.localeCompare(right.skill) || left.reason.localeCompare(right.reason))
139
+ : [];
140
+ for (const skillId of defaultSkills) {
141
+ if (!allowedSkills.includes(skillId)) {
142
+ throw new ProdifyError(`Default skill "${skillId}" must also be listed in allowed_skills.`, {
143
+ code: 'SKILL_ROUTING_INVALID'
144
+ });
145
+ }
146
+ }
147
+ for (const rule of conditionalSkills) {
148
+ if (!allowedSkills.includes(rule.skill)) {
149
+ throw new ProdifyError(`Conditional skill "${rule.skill}" must also be listed in allowed_skills.`, {
150
+ code: 'SKILL_ROUTING_INVALID'
151
+ });
152
+ }
153
+ }
154
+ return {
155
+ default_skills: defaultSkills,
156
+ allowed_skills: allowedSkills,
157
+ conditional_skills: conditionalSkills
158
+ };
159
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,87 @@
1
+ # Canonical `.prodify/` Layout
2
+
3
+ ## Goal
4
+ Define the current `.prodify`-first runtime layout and the boundary between generated product assets and repository-local self-hosted additions.
5
+
6
+ ## Canonical Directory Tree
7
+
8
+ ```text
9
+ .prodify/
10
+ AGENTS.md
11
+ project.md
12
+ planning.md
13
+ version.json
14
+ runtime-commands.md
15
+ state.json
16
+ artifacts/
17
+ README.md
18
+ <stage outputs and repo-local artifacts>
19
+ contracts-src/
20
+ README.md
21
+ *.contract.md
22
+ contracts/
23
+ *.contract.json
24
+ metrics/
25
+ README.md
26
+ tasks/
27
+ README.md
28
+ *.md
29
+ rules/
30
+ README.md
31
+ *.md
32
+ templates/
33
+ README.md
34
+ *.template.md
35
+ ```
36
+
37
+ Preset source files for Prodify itself live in the repository under `assets/presets/default/canonical/`. They are not copied into `.prodify/presets/` in the current product model.
38
+
39
+ ## Purpose Of Each Canonical Path
40
+
41
+ | Path | Purpose | User Edited |
42
+ | --- | --- | --- |
43
+ | `.prodify/AGENTS.md` | Canonical cross-agent operating instructions and repository protocol source. | Yes |
44
+ | `.prodify/project.md` | Human-readable project context, goals, scope, and conventions. | Yes |
45
+ | `.prodify/planning.md` | Human-readable roadmap, milestones, and execution backlog. | Yes |
46
+ | `.prodify/version.json` | Machine-readable preset version and schema version metadata. | Managed by Prodify upgrades |
47
+ | `.prodify/runtime-commands.md` | Canonical runtime command reference for in-agent execution. | Yes |
48
+ | `.prodify/state.json` | Durable runtime state for the agent-executed lifecycle. | Managed by runtime |
49
+ | `.prodify/contracts-src/` | User-authored stage contract sources. | Yes |
50
+ | `.prodify/contracts/` | Compiled runtime contracts consumed by validation and execution. | Managed by runtime |
51
+ | `.prodify/artifacts/` | Runtime stage outputs plus repo-local self-hosted design artifacts. | Mixed |
52
+ | `.prodify/metrics/` | Local baseline, final, and delta score artifacts. | Managed by runtime |
53
+ | `.prodify/tasks/` | Canonical task library authored by the repository owner. | Yes |
54
+ | `.prodify/rules/` | Canonical reusable rules referenced by tasks and generated outputs. | Yes |
55
+ | `.prodify/templates/` | Canonical markdown templates that define required artifact shapes. | Yes |
56
+
57
+ ## Canonical vs Generated Split
58
+
59
+ ### Canonical Files
60
+ - Live only under `.prodify/`.
61
+ - Are the only product-owned files users should edit directly when working with Prodify-managed content.
62
+ - Must remain agent-neutral unless a preset overlay explicitly defines agent-specific behavior.
63
+
64
+ ### Generated Compatibility Files
65
+ - Are not part of the current default lifecycle.
66
+ - If they exist in future or opt-in flows, they live outside `.prodify/` at agent-specific target paths.
67
+ - Must always be reproducible from canonical sources plus deterministic generation rules.
68
+
69
+ ### Repository-Local Contributor Files
70
+ - May live outside `.prodify/` in the Prodify source repository itself.
71
+ - Are not product-owned runtime outputs.
72
+ - Must be documented explicitly when their path could be mistaken for a generated compatibility file.
73
+
74
+ ## Root Cleanliness Rule
75
+ - The repository root should remain free of Prodify-owned runtime files in the default lifecycle.
76
+ - If the Prodify source repository keeps a root `AGENTS.md`, it must be treated as contributor-local guidance rather than a generated runtime file.
77
+ - No shadow copies of canonical `.prodify/` content should be stored elsewhere in the repository.
78
+
79
+ ## Separation Principle
80
+ - Canonical source content belongs in `.prodify/`.
81
+ - Future compatibility outputs, if implemented, belong at agent-required target paths.
82
+ - Generated files must never become a second source of truth.
83
+
84
+ ## Decision Summary
85
+ - `.prodify/` is canonical.
86
+ - The default supported flow does not require root-level generated agent files.
87
+ - Repository-local contributor files must be labeled explicitly when they share those legacy paths.
@@ -0,0 +1,22 @@
1
+ # Claude Support
2
+
3
+ ## Goal
4
+ Define the current Claude bootstrap path and the still-planned compatibility-file surface.
5
+
6
+ ## Current Supported Behavior
7
+ - Bootstrap path: `.prodify/AGENTS.md`
8
+ - Root compatibility file: not part of the default lifecycle
9
+
10
+ ## Planned Compatibility Surface
11
+ - Status: `planned`
12
+ - Canonical source: `.prodify/AGENTS.md`
13
+ - Future target path if enabled: `CLAUDE.md`
14
+
15
+ ## Direct Copy vs Transformation
16
+ - Planned behavior: direct copy with generated header.
17
+ - Future option: minor title normalization if Claude-specific naming proves useful.
18
+ - No semantic reduction should occur unless a later design explicitly defines it.
19
+
20
+ ## Limitation
21
+ - The bootstrap path is already `.prodify`-first.
22
+ - The compatibility file remains design-only until explicitly implemented.
@@ -0,0 +1,52 @@
1
+ # `prodify doctor` Specification
2
+
3
+ ## Goal
4
+ Define a health-check command for validating Prodify repository setup.
5
+
6
+ ## Required Checks
7
+
8
+ ### Canonical Presence
9
+ - `.prodify/` exists
10
+ - `.prodify/AGENTS.md` exists
11
+ - `.prodify/project.md` exists
12
+ - `.prodify/planning.md` exists
13
+ - `.prodify/version.json` exists
14
+
15
+ ### Canonical Structure
16
+ - `.prodify/tasks/`, `.prodify/rules/`, and `.prodify/templates/` exist
17
+ - required starter README files exist when expected
18
+
19
+ ### Compatibility Surface
20
+ - managed compatibility files exist where expected for installed or detected targets
21
+ - managed-file headers are valid
22
+ - generated files still map to known compatibility targets
23
+
24
+ ### Drift Detection
25
+ - regenerate expected content in memory
26
+ - compare it to each managed file
27
+ - report drifted files without overwriting them
28
+
29
+ ## Output Format
30
+ Doctor should report pass/fail lines grouped by category:
31
+ - `canonical`
32
+ - `compatibility`
33
+ - `drift`
34
+
35
+ Example shape:
36
+
37
+ ```text
38
+ Prodify Doctor
39
+ canonical: PASS
40
+ compatibility/codex: PASS
41
+ compatibility/copilot: SKIP
42
+ drift/AGENTS.md: FAIL
43
+ ```
44
+
45
+ ## Exit Behavior
46
+ - exit success when all required checks pass and optional checks do not fail
47
+ - exit failure when canonical setup is missing, required generated files are invalid, or drift is detected on required managed files
48
+
49
+ ## Rules
50
+ - `doctor` must not modify files
51
+ - `doctor` must report verified findings only
52
+ - `doctor` must distinguish `FAIL` from `SKIP`
@@ -0,0 +1,70 @@
1
+ # `prodify init` Specification
2
+
3
+ ## Goal
4
+ Define exactly what `prodify init` creates when bootstrapping Prodify in a repository.
5
+
6
+ ## Command Contract
7
+ - `prodify init` creates the canonical `.prodify/` structure.
8
+ - It must not create compatibility files unless the user explicitly requests agent installation in a separate command.
9
+ - It should be safe to run in an empty repository or an existing repository root.
10
+
11
+ ## Required Canonical Outputs
12
+
13
+ ### Files
14
+ - `.prodify/AGENTS.md`
15
+ - `.prodify/project.md`
16
+ - `.prodify/planning.md`
17
+ - `.prodify/version.json`
18
+
19
+ ### Directories
20
+ - `.prodify/tasks/`
21
+ - `.prodify/rules/`
22
+ - `.prodify/templates/`
23
+ - `.prodify/presets/`
24
+
25
+ ## Starter Contents
26
+
27
+ ### `.prodify/AGENTS.md`
28
+ - Canonical repository operating instructions.
29
+ - Neutral, agent-agnostic source content.
30
+ - No generated-file header because it is canonical, not generated.
31
+
32
+ ### `.prodify/project.md`
33
+ - Project name
34
+ - Summary
35
+ - Goals
36
+ - Constraints
37
+ - Team conventions
38
+
39
+ ### `.prodify/planning.md`
40
+ - Current milestone
41
+ - Backlog
42
+ - Risks
43
+ - Open decisions
44
+
45
+ ### `.prodify/tasks/`
46
+ - `README.md` describing how canonical tasks are organized
47
+ - no generated compatibility files
48
+
49
+ ### `.prodify/rules/`
50
+ - `README.md` describing reusable repository rules
51
+ - optional starter rule files if the chosen preset includes them
52
+
53
+ ### `.prodify/templates/`
54
+ - `README.md` describing canonical artifact templates
55
+ - starter markdown templates if the chosen preset includes them
56
+
57
+ ### `.prodify/version.json`
58
+ - `schema_version`
59
+ - `preset_name`
60
+ - `preset_version`
61
+
62
+ ## Preset Behavior
63
+ - `prodify init` installs the default preset into `.prodify/`.
64
+ - The default preset defines the initial contents of the canonical files and folders.
65
+ - Agent-specific compatibility files are not generated by `init`.
66
+
67
+ ## Failure Conditions
68
+ - Stop if `.prodify/` already exists and the command is not explicitly allowed to merge.
69
+ - Stop if the repository root cannot be resolved.
70
+ - Stop if the selected preset is missing required canonical files.
@@ -0,0 +1,48 @@
1
+ # `prodify setup-agent <target>` Specification
2
+
3
+ ## Goal
4
+ Define how Prodify performs global, repo-neutral agent setup for a selected coding agent.
5
+
6
+ ## Supported Invocation Shape
7
+ - `prodify setup-agent codex`
8
+ - `prodify setup-agent claude`
9
+ - `prodify setup-agent copilot`
10
+ - `prodify setup-agent opencode`
11
+
12
+ ## Command Behavior
13
+ 1. Verify the selected agent target is known.
14
+ 2. Detect the global setup root outside any repository.
15
+ 3. Register or refresh global runtime command availability for the selected agent.
16
+ 4. Record the configured agent in global setup state.
17
+ 5. Print next-step guidance for repo initialization and in-agent runtime use.
18
+
19
+ ## Per-Agent Behavior
20
+
21
+ ### Codex
22
+ - Global setup target: Codex runtime environment
23
+ - Repo impact: none
24
+ - Runtime commands exposed: `$prodify-init`, `$prodify-execute`, `$prodify-resume`
25
+
26
+ ### Claude
27
+ - Global setup target: Claude runtime environment
28
+ - Repo impact: none
29
+ - Runtime commands exposed: `$prodify-init`, `$prodify-execute`, `$prodify-resume`
30
+
31
+ ### Copilot
32
+ - Global setup target: Copilot runtime environment
33
+ - Repo impact: none
34
+ - Runtime commands exposed: `$prodify-init`, `$prodify-execute`, `$prodify-resume`
35
+
36
+ ### OpenCode
37
+ - Global setup target: OpenCode runtime environment
38
+ - Repo impact: none
39
+ - Runtime commands exposed: `$prodify-init`, `$prodify-execute`, `$prodify-resume`
40
+
41
+ ## Canonical Safety Rule
42
+ - `prodify setup-agent <target>` must not modify canonical `.prodify/` source files in any repository.
43
+ - The command writes only to global setup state outside the repo.
44
+
45
+ ## Conflict Rules
46
+ - Existing agent setup entry: may be refreshed.
47
+ - Multiple configured agents must be allowed to coexist.
48
+ - Unsupported target: stop with a clear status message rather than guess.
@@ -0,0 +1,40 @@
1
+ # `prodify sync` Specification
2
+
3
+ ## Goal
4
+ Define how Prodify regenerates managed compatibility files from canonical `.prodify/` sources.
5
+
6
+ ## Core Semantics
7
+ - `prodify sync` reads canonical `.prodify/` files.
8
+ - It regenerates managed compatibility files already installed in the repository.
9
+ - It must be deterministic and idempotent.
10
+ - It must report what changed.
11
+
12
+ ## Target Discovery
13
+ - Default behavior: sync all files that are already recognized as Prodify-managed by their headers.
14
+ - Optional behavior: `prodify sync --agent <target>` may regenerate a specific documented target.
15
+ - Sync must not guess new targets that have never been installed unless the caller explicitly requests one.
16
+
17
+ ## Sync Flow
18
+ 1. Resolve repository root.
19
+ 2. Verify `.prodify/` exists.
20
+ 3. Detect managed generated files.
21
+ 4. Recompute expected content for each managed target.
22
+ 5. Compare expected vs existing content.
23
+ 6. Rewrite only files whose canonical output has changed.
24
+ 7. Report unchanged, updated, skipped, and failed targets.
25
+
26
+ ## Managed-File Rules
27
+ - Only files with a valid Prodify header are eligible for automatic sync.
28
+ - Unmanaged files must not be overwritten by plain `sync`.
29
+ - Drifted managed files must follow the manual-edit conflict policy.
30
+
31
+ ## Reporting
32
+ The command output should include:
33
+ - repository root
34
+ - targets inspected
35
+ - targets updated
36
+ - targets unchanged
37
+ - targets skipped or blocked
38
+
39
+ ## Idempotency Rule
40
+ - Re-running `prodify sync` with unchanged canonical inputs must produce no content changes and no meaningless diffs.
@@ -0,0 +1,24 @@
1
+ # Codex Support
2
+
3
+ ## Goal
4
+ Define the current Codex bootstrap path and keep any future compatibility-file mapping clearly out of the default lifecycle.
5
+
6
+ ## Current Supported Behavior
7
+ - Status: `supported`
8
+ - Bootstrap entrypoint: `.prodify/AGENTS.md`
9
+ - Root `AGENTS.md` generation: not part of the default lifecycle
10
+
11
+ ## Current Rules
12
+ - Tell Codex to read `.prodify/AGENTS.md`.
13
+ - Keep runtime state and workflow assets under `.prodify/`.
14
+ - Do not treat repository-root `AGENTS.md` as a product-managed output in the current flow.
15
+
16
+ ## Future Compatibility Surface
17
+ - Historical or future compatibility mode could target repository-root `AGENTS.md`.
18
+ - If that mode returns, it must be explicit and opt-in rather than part of `prodify init` or `prodify update`.
19
+ - This repository's existing root `AGENTS.md` is contributor-local guidance for developing Prodify itself.
20
+
21
+ ## Why This Distinction Matters
22
+ - Codex is supported today through the canonical `.prodify/AGENTS.md` bootstrap path.
23
+ - Presenting root `AGENTS.md` generation as current behavior would contradict the tested `.prodify`-first lifecycle.
24
+ - Any future compatibility-file design must remain subordinate to the canonical `.prodify` model.
@@ -0,0 +1,59 @@
1
+ # Compatibility Targets
2
+
3
+ ## Goal
4
+ Describe possible compatibility-file targets without confusing them with the current default lifecycle.
5
+
6
+ ## Current Lifecycle
7
+ - In the current supported flow, every agent bootstraps directly from `.prodify/AGENTS.md`.
8
+ - `prodify init` and `prodify update` do not create root-level compatibility files.
9
+ - The entries below are future or non-default compatibility surfaces only.
10
+
11
+ ## Compatibility Matrix
12
+
13
+ | Agent | Agent Support | Current Bootstrap Path | Compatibility File Status | Target Path If Enabled | Notes |
14
+ | --- | --- | --- | --- | --- | --- |
15
+ | Codex | Supported | `.prodify/AGENTS.md` | Not enabled in default flow | `AGENTS.md` | Root `AGENTS.md` in this repo is contributor-local, not product-generated. |
16
+ | Claude | Supported bootstrap path, compatibility target planned | `.prodify/AGENTS.md` | Planned | `CLAUDE.md` | Same canonical source, different future target path. |
17
+ | Copilot | Supported bootstrap path, compatibility target planned | `.prodify/AGENTS.md` | Planned | `.github/copilot-instructions.md` | Would likely need a shorter transformed output. |
18
+ | OpenCode | Supported bootstrap path, compatibility target experimental | `.prodify/AGENTS.md` | Experimental | `.opencode/AGENTS.md` | Target path remains provisional until validated. |
19
+
20
+ ## Default Behavior
21
+
22
+ - Source of truth: `.prodify/AGENTS.md`
23
+ - No compatibility file is required for the current supported flow.
24
+ - Any future compatibility-file generation must remain explicit and opt-in.
25
+
26
+ ## Compatibility Surfaces
27
+
28
+ ### Codex
29
+ - Agent support: `supported`
30
+ - Current bootstrap path: `.prodify/AGENTS.md`
31
+ - Compatibility-file status: not enabled in the default lifecycle
32
+ - Future target path if enabled: `AGENTS.md`
33
+
34
+ ### Claude
35
+ - Agent support: bootstrap path supported
36
+ - Current bootstrap path: `.prodify/AGENTS.md`
37
+ - Compatibility-file status: planned
38
+ - Future target path if enabled: `CLAUDE.md`
39
+
40
+ ### Copilot
41
+ - Agent support: bootstrap path supported
42
+ - Current bootstrap path: `.prodify/AGENTS.md`
43
+ - Compatibility-file status: planned
44
+ - Future target path if enabled: `.github/copilot-instructions.md`
45
+
46
+ ### OpenCode
47
+ - Agent support: bootstrap path supported
48
+ - Current bootstrap path: `.prodify/AGENTS.md`
49
+ - Compatibility-file status: experimental
50
+ - Future target path if enabled: `.opencode/AGENTS.md`
51
+ - Limitation: target path may change if the live integration contract differs
52
+
53
+ ## Rules
54
+ - Every target path must be explicit.
55
+ - Every target must trace back to canonical `.prodify/` source files.
56
+ - Compatibility-file status controls non-default behavior:
57
+ - `not enabled in default flow`: described only as a scoped future or repo-local compatibility surface
58
+ - `planned`: documented but not implemented
59
+ - `experimental`: opt-in only, with limitations clearly reported
@@ -0,0 +1,30 @@
1
+ # Copilot Support
2
+
3
+ ## Goal
4
+ Define the compatibility target for GitHub Copilot.
5
+
6
+ ## Compatibility Mapping
7
+ - Status: `planned`
8
+ - Canonical sources:
9
+ - `.prodify/AGENTS.md`
10
+ - `.prodify/project.md`
11
+ - Generated target: `.github/copilot-instructions.md`
12
+
13
+ ## Generation Behavior
14
+ - Generate `.github/copilot-instructions.md` from canonical Prodify sources.
15
+ - Prepend the standard generated-file header for target `copilot`.
16
+ - Transform the canonical material into a concise instruction file suitable for an editor-integrated assistant.
17
+
18
+ ## Transformation Rules
19
+ - Keep repository rules, goals, and high-signal conventions.
20
+ - Include concise project context from `.prodify/project.md`.
21
+ - Remove low-signal runtime orchestration details that are only useful for the full Prodify executor.
22
+ - Preserve deterministic section ordering.
23
+
24
+ ## Sync Behavior
25
+ - `prodify sync` may update `.github/copilot-instructions.md` when it is Prodify-managed.
26
+ - `prodify doctor` must validate path existence, header validity, and content drift.
27
+
28
+ ## Notes
29
+ - The expected output path is `.github/copilot-instructions.md`.
30
+ - If the transformation rules are incomplete, generation must stop instead of producing a vague or partial file.
@@ -0,0 +1,47 @@
1
+ # Default Preset
2
+
3
+ ## Goal
4
+ Define the first stable default preset for bootstrapping repositories with Prodify.
5
+
6
+ ## Required Canonical Contents
7
+ The default preset must include:
8
+ - `.prodify/AGENTS.md`
9
+ - `.prodify/project.md`
10
+ - `.prodify/planning.md`
11
+ - starter tasks
12
+ - starter rules
13
+ - starter templates
14
+
15
+ ## Minimum Viable Default Contents
16
+
17
+ ### `.prodify/AGENTS.md`
18
+ - baseline repository operating instructions
19
+ - canonical source text for generated compatibility files
20
+
21
+ ### `.prodify/project.md`
22
+ - project summary
23
+ - goals
24
+ - constraints
25
+ - conventions
26
+
27
+ ### `.prodify/planning.md`
28
+ - milestone list
29
+ - backlog section
30
+ - open decisions section
31
+
32
+ ### Starter Tasks
33
+ - `README.md`
34
+ - at least one example task or task schema description so users understand how canonical tasks should be authored
35
+
36
+ ### Starter Rules
37
+ - `README.md`
38
+ - a small set of baseline operating rules for generated instruction files
39
+
40
+ ### Starter Templates
41
+ - `README.md`
42
+ - at least one example markdown template showing how Prodify expects structured artifacts to look
43
+
44
+ ## Preset Intent
45
+ - The default preset should be simple, stable, and agent-neutral.
46
+ - It should be sufficient for `prodify init` to leave the repository ready for later compatibility generation.
47
+ - It should not require generated compatibility files to exist immediately.