@chenguangyao/devflow-kit 0.1.43

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 (198) hide show
  1. package/CHANGELOG.md +232 -0
  2. package/LICENSE +21 -0
  3. package/README.md +539 -0
  4. package/bin/devflow.js +9 -0
  5. package/docs/RFC-001-devflow-kit.md +617 -0
  6. package/docs/RFC-002-workflow-kernel.md +134 -0
  7. package/docs/enterprise-integration-supplement.md +274 -0
  8. package/docs/internal-gitlab-setup.md +426 -0
  9. package/docs/marketplace-skills.md +231 -0
  10. package/docs/migration-from-arb.md +232 -0
  11. package/docs/tooling-overview.md +774 -0
  12. package/docs/workflow-orchestration.md +695 -0
  13. package/docs/workflow-ui-prototype.html +271 -0
  14. package/package.json +52 -0
  15. package/schemas/config.schema.json +51 -0
  16. package/schemas/delta.schema.json +22 -0
  17. package/schemas/state.schema.json +130 -0
  18. package/schemas/status-surface.schema.json +197 -0
  19. package/schemas/workflow-confirmation-surface.schema.json +70 -0
  20. package/schemas/workflow-picker.schema.json +94 -0
  21. package/scripts/postinstall.js +101 -0
  22. package/scripts/render-workflow-ui-prototype.js +271 -0
  23. package/skills/apply/SKILL.md +313 -0
  24. package/skills/apply/references/discipline-checklist.md +145 -0
  25. package/skills/apply/references/subagent-implementer-prompt.md +113 -0
  26. package/skills/apply/references/subagent-orchestration.md +150 -0
  27. package/skills/apply/references/subagent-reviewer-prompt.md +180 -0
  28. package/skills/apply/references/tdd-loop.md +287 -0
  29. package/skills/apply/references/when-plan-is-wrong.md +279 -0
  30. package/skills/apply/references/worktree-swarm.md +292 -0
  31. package/skills/archive/SKILL.md +229 -0
  32. package/skills/archive/references/conflict-resolution.md +336 -0
  33. package/skills/archive/references/knowledge-deposit.md +381 -0
  34. package/skills/archive/references/spec-merge.md +365 -0
  35. package/skills/brainstorm/SKILL.md +123 -0
  36. package/skills/brainstorm/references/proposal-template.md +244 -0
  37. package/skills/brainstorm/references/question-catalog.md +168 -0
  38. package/skills/brainstorm/references/session-template.md +184 -0
  39. package/skills/ci-fix/SKILL.md +63 -0
  40. package/skills/ci-fix/references/loop.md +25 -0
  41. package/skills/code-review/SKILL.md +279 -0
  42. package/skills/code-review/references/escalation-playbook.md +192 -0
  43. package/skills/code-review/references/language-cheatsheets/go.md +175 -0
  44. package/skills/code-review/references/language-cheatsheets/java-spring-mybatis.md +246 -0
  45. package/skills/code-review/references/language-cheatsheets/python.md +170 -0
  46. package/skills/code-review/references/language-cheatsheets/vue.md +199 -0
  47. package/skills/code-review/references/output-template.md +275 -0
  48. package/skills/code-review/references/review-checklist.md +251 -0
  49. package/skills/complexity-grading/SKILL.md +259 -0
  50. package/skills/deliver/SKILL.md +271 -0
  51. package/skills/deliver/references/delivery-modes.md +299 -0
  52. package/skills/deliver/references/notify.md +359 -0
  53. package/skills/deliver/references/pr-description.md +319 -0
  54. package/skills/dependency-upgrade/SKILL.md +57 -0
  55. package/skills/dependency-upgrade/references/risk-matrix.md +38 -0
  56. package/skills/df-orchestrator/SKILL.md +407 -0
  57. package/skills/df-orchestrator/references/complexity-grading.md +177 -0
  58. package/skills/df-orchestrator/references/escalation-matrix.md +191 -0
  59. package/skills/df-orchestrator/references/routing-rules.md +290 -0
  60. package/skills/df-orchestrator/references/workflow-state-machine.md +208 -0
  61. package/skills/frontend-quality/SKILL.md +61 -0
  62. package/skills/frontend-quality/references/checklist.md +35 -0
  63. package/skills/handoff-resume/SKILL.md +59 -0
  64. package/skills/handoff-resume/references/handoff-template.md +54 -0
  65. package/skills/plan/SKILL.md +166 -0
  66. package/skills/plan/references/task-breakdown.md +207 -0
  67. package/skills/plan/references/task-sequencing.md +143 -0
  68. package/skills/plan/references/task-template.md +248 -0
  69. package/skills/requirement-analysis/SKILL.md +499 -0
  70. package/skills/requirement-analysis/references/acceptance-criteria.md +183 -0
  71. package/skills/requirement-analysis/references/code-recon.md +151 -0
  72. package/skills/requirement-analysis/references/edge-case-catalog.md +164 -0
  73. package/skills/requirement-analysis/references/requirement-template.md +339 -0
  74. package/skills/requirement-analysis/references/scope-negotiation.md +162 -0
  75. package/skills/security-hardening/SKILL.md +60 -0
  76. package/skills/security-hardening/references/checklist.md +42 -0
  77. package/skills/tech-spec/SKILL.md +388 -0
  78. package/skills/tech-spec/references/api-contract-design.md +172 -0
  79. package/skills/tech-spec/references/decision-records.md +110 -0
  80. package/skills/tech-spec/references/design-template.md +301 -0
  81. package/skills/tech-spec/references/rollout-and-rollback.md +203 -0
  82. package/skills/tech-spec/references/spec-delta-conventions.md +250 -0
  83. package/skills/tech-spec/references/transaction-patterns.md +212 -0
  84. package/skills/test-spec/SKILL.md +219 -0
  85. package/skills/test-spec/references/coverage-strategy.md +218 -0
  86. package/skills/test-spec/references/edge-case-to-test.md +143 -0
  87. package/skills/test-spec/references/test-case-template.md +276 -0
  88. package/skills/verify/SKILL.md +232 -0
  89. package/skills/verify/references/nfr-verification.md +292 -0
  90. package/skills/verify/references/report-templates.md +510 -0
  91. package/skills/verify/references/self-test-guide.md +240 -0
  92. package/skills/verify/references/verify-rollback-map.md +247 -0
  93. package/src/cli/commands/_helpers.js +108 -0
  94. package/src/cli/commands/_submit.js +718 -0
  95. package/src/cli/commands/apply.js +198 -0
  96. package/src/cli/commands/archive.js +180 -0
  97. package/src/cli/commands/checkpoint.js +113 -0
  98. package/src/cli/commands/deliver.js +377 -0
  99. package/src/cli/commands/deploy.js +504 -0
  100. package/src/cli/commands/design.js +158 -0
  101. package/src/cli/commands/disable.js +21 -0
  102. package/src/cli/commands/doctor.js +178 -0
  103. package/src/cli/commands/enable.js +21 -0
  104. package/src/cli/commands/flow.js +645 -0
  105. package/src/cli/commands/help.js +93 -0
  106. package/src/cli/commands/ingest.js +602 -0
  107. package/src/cli/commands/init.js +341 -0
  108. package/src/cli/commands/knowledge.js +523 -0
  109. package/src/cli/commands/logs.js +43 -0
  110. package/src/cli/commands/new.js +202 -0
  111. package/src/cli/commands/plan.js +49 -0
  112. package/src/cli/commands/propose.js +27 -0
  113. package/src/cli/commands/provider.js +698 -0
  114. package/src/cli/commands/report.js +143 -0
  115. package/src/cli/commands/requirement.js +227 -0
  116. package/src/cli/commands/review.js +301 -0
  117. package/src/cli/commands/skills.js +457 -0
  118. package/src/cli/commands/status.js +925 -0
  119. package/src/cli/commands/switch.js +27 -0
  120. package/src/cli/commands/sync.js +47 -0
  121. package/src/cli/commands/test.js +366 -0
  122. package/src/cli/commands/uninstall.js +32 -0
  123. package/src/cli/commands/update.js +74 -0
  124. package/src/cli/commands/verify.js +354 -0
  125. package/src/cli/commands/worktree.js +78 -0
  126. package/src/cli/index.js +72 -0
  127. package/src/cli/parse-args.js +102 -0
  128. package/src/core/autodetect.js +271 -0
  129. package/src/core/change.js +208 -0
  130. package/src/core/checkpoint.js +217 -0
  131. package/src/core/config.js +60 -0
  132. package/src/core/delta.js +290 -0
  133. package/src/core/markers.js +59 -0
  134. package/src/core/paths.js +173 -0
  135. package/src/core/plan-tasks.js +36 -0
  136. package/src/core/project-routing.js +285 -0
  137. package/src/core/projects.js +200 -0
  138. package/src/core/state.js +200 -0
  139. package/src/core/workflow-check.js +177 -0
  140. package/src/core/workflow-init.js +34 -0
  141. package/src/core/workflow-picker.js +154 -0
  142. package/src/core/workflow-policy.js +119 -0
  143. package/src/core/workflow-suggest.js +181 -0
  144. package/src/core/workflow-verify.js +88 -0
  145. package/src/core/workflow.js +433 -0
  146. package/src/core/worktree.js +241 -0
  147. package/src/knowledge/categories.js +107 -0
  148. package/src/knowledge/classify.js +125 -0
  149. package/src/knowledge/deposit.js +414 -0
  150. package/src/knowledge/migrate.js +149 -0
  151. package/src/knowledge/mr.js +219 -0
  152. package/src/knowledge/query.js +131 -0
  153. package/src/knowledge/registry.js +151 -0
  154. package/src/knowledge/sync.js +179 -0
  155. package/src/providers/base.js +74 -0
  156. package/src/providers/drivers/api-yapi.js +78 -0
  157. package/src/providers/drivers/ci-jenkins.js +109 -0
  158. package/src/providers/drivers/intake-confluence.js +544 -0
  159. package/src/providers/drivers/kb-git.js +549 -0
  160. package/src/providers/drivers/kb-weknora.js +472 -0
  161. package/src/providers/drivers/notify-smtp.js +515 -0
  162. package/src/providers/drivers/observability-oss.js +43 -0
  163. package/src/providers/drivers/observability-sls.js +50 -0
  164. package/src/providers/lifecycle.js +135 -0
  165. package/src/providers/loader.js +132 -0
  166. package/src/providers/local.js +190 -0
  167. package/src/providers/userconfig.js +283 -0
  168. package/src/reports/aggregate.js +185 -0
  169. package/src/reports/coverage.js +163 -0
  170. package/src/reports/detect.js +143 -0
  171. package/src/reports/parse.js +236 -0
  172. package/src/templates/files/ci/github.yml +38 -0
  173. package/src/templates/files/ci/gitlab.yml +27 -0
  174. package/src/templates/files/design.md +63 -0
  175. package/src/templates/files/ide/devflow-workflow.md +58 -0
  176. package/src/templates/files/ide/project-overview-reference.md +1 -0
  177. package/src/templates/files/ide/project-overview.md +27 -0
  178. package/src/templates/files/knowledge-index.json +17 -0
  179. package/src/templates/files/knowledge.md +28 -0
  180. package/src/templates/files/meta.json +8 -0
  181. package/src/templates/files/plan.md +38 -0
  182. package/src/templates/files/proposal.md +33 -0
  183. package/src/templates/files/reports/contract-test.md +40 -0
  184. package/src/templates/files/reports/e2e-test.md +30 -0
  185. package/src/templates/files/reports/integration-test.md +36 -0
  186. package/src/templates/files/reports/joint-test.md +58 -0
  187. package/src/templates/files/reports/perf.md +24 -0
  188. package/src/templates/files/reports/regression.md +20 -0
  189. package/src/templates/files/reports/remote-test.md +55 -0
  190. package/src/templates/files/reports/self-test.md +43 -0
  191. package/src/templates/files/reports/smoke-test.md +22 -0
  192. package/src/templates/files/reports/unit-test.md +36 -0
  193. package/src/templates/files/requirement.md +51 -0
  194. package/src/templates/files/review.md +38 -0
  195. package/src/templates/files/tests.md +36 -0
  196. package/src/templates/files/verify.md +32 -0
  197. package/src/templates/index.js +21 -0
  198. package/src/utils/log.js +37 -0
@@ -0,0 +1,197 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://devflow.dev/schemas/status-surface.schema.json",
4
+ "title": "devflow status JSON surface",
5
+ "description": "Machine-readable surface returned by devflow status --json for IDE/Web UI rendering.",
6
+ "type": "object",
7
+ "required": [
8
+ "type",
9
+ "slug",
10
+ "title",
11
+ "level",
12
+ "phase",
13
+ "source",
14
+ "phases",
15
+ "artifacts",
16
+ "apply",
17
+ "review",
18
+ "verify",
19
+ "riskSignals",
20
+ "workflow",
21
+ "pendingCheckpoint",
22
+ "checkpointConfirmationCard",
23
+ "primaryPanel",
24
+ "blockingReason",
25
+ "availableActions",
26
+ "nextAction"
27
+ ],
28
+ "properties": {
29
+ "type": { "const": "change_status_surface" },
30
+ "slug": { "type": "string" },
31
+ "title": { "type": "string" },
32
+ "level": { "type": ["string", "null"], "enum": ["L0", "L1", "L2", "L3", null] },
33
+ "phase": { "type": ["string", "null"] },
34
+ "source": { "type": ["object", "null"] },
35
+ "phases": {
36
+ "type": "object",
37
+ "required": ["current", "items", "summary"],
38
+ "properties": {
39
+ "current": { "type": ["object", "null"] },
40
+ "items": {
41
+ "type": "array",
42
+ "items": {
43
+ "type": "object",
44
+ "required": ["id", "status", "ts", "current"],
45
+ "properties": {
46
+ "id": { "type": "string" },
47
+ "status": { "type": "string" },
48
+ "ts": { "type": ["string", "null"] },
49
+ "current": { "type": "boolean" }
50
+ },
51
+ "additionalProperties": true
52
+ }
53
+ },
54
+ "summary": { "type": "object" }
55
+ },
56
+ "additionalProperties": true
57
+ },
58
+ "artifacts": {
59
+ "type": "object",
60
+ "required": ["core", "optional", "directories"],
61
+ "properties": {
62
+ "core": { "type": "array", "items": { "$ref": "#/definitions/artifact" } },
63
+ "optional": { "type": "array", "items": { "$ref": "#/definitions/artifact" } },
64
+ "directories": { "type": "object" }
65
+ },
66
+ "additionalProperties": true
67
+ },
68
+ "apply": {
69
+ "type": "object",
70
+ "required": ["status", "currentTask", "iterations", "tasks", "summary"],
71
+ "properties": {
72
+ "status": { "type": "string" },
73
+ "currentTask": { "type": ["string", "null"] },
74
+ "iterations": { "type": "integer" },
75
+ "tasks": { "type": "array" },
76
+ "summary": { "type": "object" }
77
+ },
78
+ "additionalProperties": true
79
+ },
80
+ "review": {
81
+ "type": "object",
82
+ "required": ["status", "maxRounds", "rounds", "latestRound", "mustTotal", "shouldTotal", "nitTotal"],
83
+ "properties": {
84
+ "status": { "type": "string" },
85
+ "maxRounds": { "type": "integer" },
86
+ "rounds": { "type": "array" },
87
+ "latestRound": { "type": ["object", "null"] },
88
+ "mustTotal": { "type": "integer" },
89
+ "shouldTotal": { "type": "integer" },
90
+ "nitTotal": { "type": "integer" }
91
+ },
92
+ "additionalProperties": true
93
+ },
94
+ "verify": {
95
+ "type": "object",
96
+ "required": ["status", "requiredReports", "presentReports", "missingReports", "reports"],
97
+ "properties": {
98
+ "status": { "type": "string" },
99
+ "requiredReports": { "type": "array", "items": { "type": "string" } },
100
+ "presentReports": { "type": "array", "items": { "type": "string" } },
101
+ "missingReports": { "type": "array", "items": { "type": "string" } },
102
+ "reports": { "type": "array" }
103
+ },
104
+ "additionalProperties": true
105
+ },
106
+ "riskSignals": {
107
+ "type": "object",
108
+ "required": ["items", "summary"],
109
+ "properties": {
110
+ "items": { "type": "array" },
111
+ "summary": { "type": "object" }
112
+ },
113
+ "additionalProperties": true
114
+ },
115
+ "workflow": { "type": ["object", "null"] },
116
+ "pendingCheckpoint": { "type": ["object", "null"] },
117
+ "checkpointConfirmationCard": { "type": ["object", "null"] },
118
+ "primaryPanel": {
119
+ "type": "object",
120
+ "required": ["type", "title", "status", "actionIds"],
121
+ "properties": {
122
+ "type": {
123
+ "type": "string",
124
+ "enum": [
125
+ "checkpoint",
126
+ "workflow_confirm",
127
+ "workflow_check",
128
+ "review_blocked",
129
+ "verify_start",
130
+ "current_step",
131
+ "verify_ready",
132
+ "apply_tasks",
133
+ "review_ready",
134
+ "phase_hint"
135
+ ]
136
+ },
137
+ "title": { "type": "string" },
138
+ "status": { "type": "string" },
139
+ "reasonCode": { "type": "string" },
140
+ "phase": { "type": ["string", "null"] },
141
+ "step": { "type": "string" },
142
+ "checkpointType": { "type": "string" },
143
+ "checkpointId": { "type": "string" },
144
+ "actionIds": { "type": "array", "items": { "type": "string" } }
145
+ },
146
+ "additionalProperties": true
147
+ },
148
+ "blockingReason": {
149
+ "oneOf": [
150
+ { "type": "null" },
151
+ {
152
+ "type": "object",
153
+ "required": ["code", "source", "severity", "message"],
154
+ "properties": {
155
+ "code": { "type": "string" },
156
+ "source": { "type": "string" },
157
+ "severity": { "type": "string", "enum": ["blocker", "warning"] },
158
+ "message": { "type": "string" }
159
+ },
160
+ "additionalProperties": true
161
+ }
162
+ ]
163
+ },
164
+ "availableActions": {
165
+ "type": "array",
166
+ "items": {
167
+ "type": "object",
168
+ "required": ["id", "label", "command", "kind", "primary"],
169
+ "properties": {
170
+ "id": { "type": "string" },
171
+ "label": { "type": "string" },
172
+ "command": { "type": ["string", "null"] },
173
+ "kind": { "type": "string" },
174
+ "primary": { "type": "boolean" },
175
+ "danger": { "type": "boolean" },
176
+ "requiresReason": { "type": "boolean" },
177
+ "description": { "type": "string" }
178
+ },
179
+ "additionalProperties": true
180
+ }
181
+ },
182
+ "nextAction": { "type": ["string", "null"] }
183
+ },
184
+ "additionalProperties": true,
185
+ "definitions": {
186
+ "artifact": {
187
+ "type": "object",
188
+ "required": ["name", "path", "exists"],
189
+ "properties": {
190
+ "name": { "type": "string" },
191
+ "path": { "type": "string" },
192
+ "exists": { "type": "boolean" }
193
+ },
194
+ "additionalProperties": true
195
+ }
196
+ }
197
+ }
@@ -0,0 +1,70 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://devflow.dev/schemas/workflow-confirmation-surface.schema.json",
4
+ "title": "devflow workflow confirmation surface",
5
+ "description": "Machine-readable surface returned by devflow flow card --json for workflow confirmation UI.",
6
+ "type": "object",
7
+ "required": [
8
+ "type",
9
+ "slug",
10
+ "baseRecipe",
11
+ "actions",
12
+ "ok",
13
+ "status",
14
+ "errors",
15
+ "warnings",
16
+ "nextAction"
17
+ ],
18
+ "properties": {
19
+ "type": { "const": "workflow_confirmation_surface" },
20
+ "slug": { "type": "string" },
21
+ "baseRecipe": { "type": ["object", "null"] },
22
+ "actions": { "$ref": "#/definitions/actionMap" },
23
+ "ok": { "type": "boolean" },
24
+ "status": { "type": ["string", "null"] },
25
+ "errors": { "type": "array" },
26
+ "warnings": { "type": "array" },
27
+ "confirmationCard": { "$ref": "#/definitions/confirmationCard" },
28
+ "nextAction": { "type": ["string", "null"] }
29
+ },
30
+ "additionalProperties": true,
31
+ "definitions": {
32
+ "actionMap": {
33
+ "type": "object",
34
+ "required": ["picker", "applySelection", "check", "confirm"],
35
+ "properties": {
36
+ "picker": { "type": "string" },
37
+ "applySelection": { "type": "string" },
38
+ "check": { "type": "string" },
39
+ "confirm": { "type": "string" }
40
+ },
41
+ "additionalProperties": true
42
+ },
43
+ "confirmationCard": {
44
+ "type": "object",
45
+ "required": ["type", "title", "question", "steps", "primaryAction", "secondaryActions"],
46
+ "properties": {
47
+ "type": { "const": "workflow_confirm" },
48
+ "title": { "type": "string" },
49
+ "question": { "type": "string" },
50
+ "steps": { "type": "array" },
51
+ "primaryAction": { "$ref": "#/definitions/cardAction" },
52
+ "secondaryActions": {
53
+ "type": "array",
54
+ "items": { "$ref": "#/definitions/cardAction" }
55
+ }
56
+ },
57
+ "additionalProperties": true
58
+ },
59
+ "cardAction": {
60
+ "type": "object",
61
+ "required": ["id", "label", "command"],
62
+ "properties": {
63
+ "id": { "type": "string" },
64
+ "label": { "type": "string" },
65
+ "command": { "type": "string" }
66
+ },
67
+ "additionalProperties": true
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,94 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://devflow.dev/schemas/workflow-picker.schema.json",
4
+ "title": "devflow workflow picker surface",
5
+ "description": "Machine-readable surface returned by devflow flow picker --json for linear grouped skill selection UI.",
6
+ "type": "object",
7
+ "required": [
8
+ "type",
9
+ "layout",
10
+ "baseRecipe",
11
+ "status",
12
+ "currentStep",
13
+ "groups",
14
+ "actions"
15
+ ],
16
+ "properties": {
17
+ "type": { "const": "workflow_picker_surface" },
18
+ "layout": { "const": "linear-grouped" },
19
+ "baseRecipe": { "type": ["object", "null"] },
20
+ "status": { "type": ["string", "null"] },
21
+ "currentStep": { "type": ["string", "null"] },
22
+ "groups": {
23
+ "type": "array",
24
+ "items": { "$ref": "#/definitions/group" }
25
+ },
26
+ "actions": { "$ref": "#/definitions/actionMap" }
27
+ },
28
+ "additionalProperties": true,
29
+ "definitions": {
30
+ "group": {
31
+ "type": "object",
32
+ "required": ["id", "label", "items"],
33
+ "properties": {
34
+ "id": { "type": "string" },
35
+ "label": { "type": "string" },
36
+ "items": {
37
+ "type": "array",
38
+ "items": { "$ref": "#/definitions/item" }
39
+ }
40
+ },
41
+ "additionalProperties": true
42
+ },
43
+ "item": {
44
+ "type": "object",
45
+ "required": [
46
+ "step",
47
+ "skill",
48
+ "label",
49
+ "group",
50
+ "selected",
51
+ "recommended",
52
+ "reason",
53
+ "required",
54
+ "optional",
55
+ "protected",
56
+ "locked",
57
+ "source",
58
+ "status",
59
+ "installed",
60
+ "command"
61
+ ],
62
+ "properties": {
63
+ "step": { "type": "string" },
64
+ "skill": { "type": "string" },
65
+ "label": { "type": "string" },
66
+ "group": { "type": "string" },
67
+ "selected": { "type": "boolean" },
68
+ "recommended": { "type": "boolean" },
69
+ "reason": { "type": ["string", "null"] },
70
+ "required": { "type": "boolean" },
71
+ "optional": { "type": "boolean" },
72
+ "protected": { "type": "boolean" },
73
+ "locked": { "type": "boolean" },
74
+ "source": { "type": ["string", "null"] },
75
+ "status": { "type": ["string", "null"] },
76
+ "installed": { "type": "boolean" },
77
+ "command": { "type": ["string", "null"] }
78
+ },
79
+ "additionalProperties": true
80
+ },
81
+ "actionMap": {
82
+ "type": "object",
83
+ "required": ["card", "check", "applySelection", "confirm", "suggest"],
84
+ "properties": {
85
+ "card": { "type": "string" },
86
+ "check": { "type": "string" },
87
+ "applySelection": { "type": "string" },
88
+ "confirm": { "type": "string" },
89
+ "suggest": { "type": "string" }
90
+ },
91
+ "additionalProperties": true
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env node
2
+ /* eslint-disable no-console */
3
+ 'use strict';
4
+
5
+ /**
6
+ * Auto-install devflow skills to user-wide IDE dirs after `npm i -g`.
7
+ *
8
+ * Behavior contract (intentionally conservative):
9
+ * - Only runs for global installs (`npm_config_global === 'true'`). Local
10
+ * `npm install` (whether in our own repo for devDeps, or as a transitive
11
+ * dependency of some other package) is filtered here and never reaches
12
+ * the install logic. This is the ONLY guard we need against "dev-on-self":
13
+ * when a developer runs `npm install` inside this repo, it isn't global,
14
+ * so we already skip. Conversely, `npm i -g .` or `npm i -g <pkg>` from
15
+ * inside this repo IS a deliberate global install — we should honour it.
16
+ * - Skips when CI=1 or DEVFLOW_SKIP_POSTINSTALL=1.
17
+ * - Installs one central skill copy under ~/.devflow/skills/devflow-kit, then
18
+ * links ~/.cursor, ~/.claude and ~/.agents to it.
19
+ * - Never fails the parent npm install — any error is logged as a warning.
20
+ *
21
+ * Manual recovery: `devflow skills install --scope=user`.
22
+ */
23
+
24
+ function bail(msg) {
25
+ if (msg) console.log(`[devflow] ${msg}`);
26
+ process.exit(0);
27
+ }
28
+
29
+ function warn(msg) {
30
+ console.warn(`[devflow] ${msg}`);
31
+ }
32
+
33
+ // 1. Opt-outs
34
+ if (process.env.DEVFLOW_SKIP_POSTINSTALL) bail('DEVFLOW_SKIP_POSTINSTALL set, skip skill auto-install');
35
+ if (process.env.CI === 'true' || process.env.CI === '1') bail('CI environment, skip skill auto-install');
36
+
37
+ // 2. Only for global installs
38
+ // npm sets npm_config_global=true under `-g`. pnpm/yarn classic also set this for `-g`.
39
+ // This single check handles all "dev-on-self" cases:
40
+ // - `cd devflow-kit && npm install` → unset, skip
41
+ // - `cd devflow-kit && npm i -g .` → true, install (intentional)
42
+ // - `cd devflow-kit && npm i -g @chen.../...` → true, install (intentional)
43
+ if (process.env.npm_config_global !== 'true') bail();
44
+
45
+ // 3. Lazy-require — keeps cold-path failures harmless
46
+ let skills;
47
+ try {
48
+ skills = require('../src/cli/commands/skills.js');
49
+ } catch (err) {
50
+ warn(`could not load skill installer (${err.message}); run "devflow skills install --scope=user" manually`);
51
+ process.exit(0);
52
+ }
53
+
54
+ // 4. Bootstrap helper for ~/.devflow/providers.json (loaded lazily; never
55
+ // fatal if it can't be required — older installs may not ship this file yet).
56
+ let userconfig;
57
+ try {
58
+ userconfig = require('../src/providers/userconfig.js');
59
+ } catch (err) {
60
+ warn(`could not load user-config helper (${err.message})`);
61
+ }
62
+
63
+ (async () => {
64
+ // 5. Always bootstrap ~/.devflow/providers.json — even if skills are
65
+ // already present, the config file is independent and may not exist yet
66
+ // (e.g., upgrading from <0.1.5).
67
+ if (userconfig) {
68
+ try {
69
+ const uc = await userconfig.ensureUserConfig();
70
+ if (uc.created.providers) {
71
+ console.log(`[devflow] created empty provider config: ${uc.file} (chmod 0600)`);
72
+ console.log('[devflow] add providers via: devflow provider add <name>');
73
+ }
74
+ if (uc.created.example) {
75
+ console.log(`[devflow] created provider example: ${uc.example}`);
76
+ console.log('[devflow] copy needed entries into providers.json; keep personal secrets in env vars.');
77
+ }
78
+ } catch (err) {
79
+ warn(`user config bootstrap failed: ${err.message}`);
80
+ }
81
+ }
82
+
83
+ // 6. Always reinstall/update skills on every global install.
84
+ // The user-wide path stores one central copy and links each IDE namespace
85
+ // to it, so repeated global installs act as an in-place upgrade.
86
+ let alreadyInstalled = false;
87
+ try { alreadyInstalled = skills.userSkillsInstalled(); } catch (_) { /* ignore */ }
88
+
89
+ const verb = alreadyInstalled ? 'updating' : 'installing';
90
+ console.log(`[devflow] ${verb} skills to ~/.devflow/skills/devflow-kit and linking IDE skill dirs …`);
91
+ try {
92
+ const dests = skills.USER_SCOPE_TARGETS.map((k) => ({ key: k, dest: skills.TARGET_MAP[k] }));
93
+ const out = await skills.installToDests(process.cwd(), dests, { quiet: true, linkMode: 'central' });
94
+ for (const s of out) console.log(`[devflow] ${s.count} skills → ${s.path}`);
95
+ console.log(`[devflow] skills ${verb} done.`);
96
+ if (!alreadyInstalled) console.log('[devflow] next: cd <your-repo> && devflow init');
97
+ } catch (err) {
98
+ warn(`skill auto-${verb} failed: ${err.message}`);
99
+ warn('install will continue; run "devflow skills install --scope=user" later');
100
+ }
101
+ })();