code-as-plan 2.0.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 (188) hide show
  1. package/LICENSE +21 -0
  2. package/README.ja-JP.md +834 -0
  3. package/README.ko-KR.md +823 -0
  4. package/README.md +1006 -0
  5. package/README.pt-BR.md +452 -0
  6. package/README.zh-CN.md +800 -0
  7. package/agents/cap-brainstormer.md +154 -0
  8. package/agents/cap-debugger.md +221 -0
  9. package/agents/cap-prototyper.md +170 -0
  10. package/agents/cap-reviewer.md +230 -0
  11. package/agents/cap-tester.md +193 -0
  12. package/bin/install.js +5002 -0
  13. package/cap/bin/gsd-tools.cjs +1141 -0
  14. package/cap/bin/lib/arc-scanner.cjs +341 -0
  15. package/cap/bin/lib/cap-feature-map.cjs +506 -0
  16. package/cap/bin/lib/cap-session.cjs +191 -0
  17. package/cap/bin/lib/cap-stack-docs.cjs +598 -0
  18. package/cap/bin/lib/cap-tag-scanner.cjs +458 -0
  19. package/cap/bin/lib/commands.cjs +959 -0
  20. package/cap/bin/lib/config.cjs +466 -0
  21. package/cap/bin/lib/convention-reader.cjs +180 -0
  22. package/cap/bin/lib/core.cjs +1230 -0
  23. package/cap/bin/lib/feature-aggregator.cjs +422 -0
  24. package/cap/bin/lib/frontmatter.cjs +336 -0
  25. package/cap/bin/lib/init.cjs +1442 -0
  26. package/cap/bin/lib/manifest-generator.cjs +381 -0
  27. package/cap/bin/lib/milestone.cjs +252 -0
  28. package/cap/bin/lib/model-profiles.cjs +68 -0
  29. package/cap/bin/lib/monorepo-context.cjs +224 -0
  30. package/cap/bin/lib/monorepo-migrator.cjs +507 -0
  31. package/cap/bin/lib/phase.cjs +888 -0
  32. package/cap/bin/lib/profile-output.cjs +952 -0
  33. package/cap/bin/lib/profile-pipeline.cjs +539 -0
  34. package/cap/bin/lib/roadmap.cjs +329 -0
  35. package/cap/bin/lib/security.cjs +382 -0
  36. package/cap/bin/lib/session-manager.cjs +290 -0
  37. package/cap/bin/lib/skeleton-generator.cjs +177 -0
  38. package/cap/bin/lib/state.cjs +1031 -0
  39. package/cap/bin/lib/template.cjs +222 -0
  40. package/cap/bin/lib/test-detector.cjs +61 -0
  41. package/cap/bin/lib/uat.cjs +282 -0
  42. package/cap/bin/lib/verify.cjs +888 -0
  43. package/cap/bin/lib/workspace-detector.cjs +369 -0
  44. package/cap/bin/lib/workstream.cjs +491 -0
  45. package/cap/commands/gsd/workstreams.md +63 -0
  46. package/cap/references/arc-standard.md +315 -0
  47. package/cap/references/cap-agent-architecture.md +102 -0
  48. package/cap/references/cap-gitignore-template +9 -0
  49. package/cap/references/cap-zero-deps.md +158 -0
  50. package/cap/references/checkpoints.md +778 -0
  51. package/cap/references/continuation-format.md +249 -0
  52. package/cap/references/decimal-phase-calculation.md +64 -0
  53. package/cap/references/feature-map-template.md +25 -0
  54. package/cap/references/git-integration.md +295 -0
  55. package/cap/references/git-planning-commit.md +38 -0
  56. package/cap/references/model-profile-resolution.md +36 -0
  57. package/cap/references/model-profiles.md +139 -0
  58. package/cap/references/phase-argument-parsing.md +61 -0
  59. package/cap/references/planning-config.md +202 -0
  60. package/cap/references/questioning.md +162 -0
  61. package/cap/references/session-template.json +8 -0
  62. package/cap/references/tdd.md +263 -0
  63. package/cap/references/ui-brand.md +160 -0
  64. package/cap/references/user-profiling.md +681 -0
  65. package/cap/references/verification-patterns.md +612 -0
  66. package/cap/references/workstream-flag.md +58 -0
  67. package/cap/templates/DEBUG.md +164 -0
  68. package/cap/templates/UAT.md +265 -0
  69. package/cap/templates/UI-SPEC.md +100 -0
  70. package/cap/templates/VALIDATION.md +76 -0
  71. package/cap/templates/claude-md.md +122 -0
  72. package/cap/templates/codebase/architecture.md +255 -0
  73. package/cap/templates/codebase/concerns.md +310 -0
  74. package/cap/templates/codebase/conventions.md +307 -0
  75. package/cap/templates/codebase/integrations.md +280 -0
  76. package/cap/templates/codebase/stack.md +186 -0
  77. package/cap/templates/codebase/structure.md +285 -0
  78. package/cap/templates/codebase/testing.md +480 -0
  79. package/cap/templates/config.json +44 -0
  80. package/cap/templates/context.md +352 -0
  81. package/cap/templates/continue-here.md +78 -0
  82. package/cap/templates/copilot-instructions.md +7 -0
  83. package/cap/templates/debug-subagent-prompt.md +91 -0
  84. package/cap/templates/dev-preferences.md +21 -0
  85. package/cap/templates/discovery.md +146 -0
  86. package/cap/templates/discussion-log.md +63 -0
  87. package/cap/templates/milestone-archive.md +123 -0
  88. package/cap/templates/milestone.md +115 -0
  89. package/cap/templates/phase-prompt.md +610 -0
  90. package/cap/templates/planner-subagent-prompt.md +117 -0
  91. package/cap/templates/project.md +186 -0
  92. package/cap/templates/requirements.md +231 -0
  93. package/cap/templates/research-project/ARCHITECTURE.md +204 -0
  94. package/cap/templates/research-project/FEATURES.md +147 -0
  95. package/cap/templates/research-project/PITFALLS.md +200 -0
  96. package/cap/templates/research-project/STACK.md +120 -0
  97. package/cap/templates/research-project/SUMMARY.md +170 -0
  98. package/cap/templates/research.md +552 -0
  99. package/cap/templates/retrospective.md +54 -0
  100. package/cap/templates/roadmap.md +202 -0
  101. package/cap/templates/state.md +176 -0
  102. package/cap/templates/summary-complex.md +59 -0
  103. package/cap/templates/summary-minimal.md +41 -0
  104. package/cap/templates/summary-standard.md +48 -0
  105. package/cap/templates/summary.md +248 -0
  106. package/cap/templates/user-profile.md +146 -0
  107. package/cap/templates/user-setup.md +311 -0
  108. package/cap/templates/verification-report.md +322 -0
  109. package/cap/workflows/add-phase.md +112 -0
  110. package/cap/workflows/add-tests.md +351 -0
  111. package/cap/workflows/add-todo.md +158 -0
  112. package/cap/workflows/audit-milestone.md +340 -0
  113. package/cap/workflows/audit-uat.md +109 -0
  114. package/cap/workflows/autonomous.md +891 -0
  115. package/cap/workflows/check-todos.md +177 -0
  116. package/cap/workflows/cleanup.md +152 -0
  117. package/cap/workflows/complete-milestone.md +767 -0
  118. package/cap/workflows/diagnose-issues.md +231 -0
  119. package/cap/workflows/discovery-phase.md +289 -0
  120. package/cap/workflows/discuss-phase-assumptions.md +653 -0
  121. package/cap/workflows/discuss-phase.md +1049 -0
  122. package/cap/workflows/do.md +104 -0
  123. package/cap/workflows/execute-phase.md +846 -0
  124. package/cap/workflows/execute-plan.md +514 -0
  125. package/cap/workflows/fast.md +105 -0
  126. package/cap/workflows/forensics.md +265 -0
  127. package/cap/workflows/health.md +181 -0
  128. package/cap/workflows/help.md +660 -0
  129. package/cap/workflows/insert-phase.md +130 -0
  130. package/cap/workflows/list-phase-assumptions.md +178 -0
  131. package/cap/workflows/list-workspaces.md +56 -0
  132. package/cap/workflows/manager.md +362 -0
  133. package/cap/workflows/map-codebase.md +377 -0
  134. package/cap/workflows/milestone-summary.md +223 -0
  135. package/cap/workflows/new-milestone.md +486 -0
  136. package/cap/workflows/new-project.md +1250 -0
  137. package/cap/workflows/new-workspace.md +237 -0
  138. package/cap/workflows/next.md +97 -0
  139. package/cap/workflows/node-repair.md +92 -0
  140. package/cap/workflows/note.md +156 -0
  141. package/cap/workflows/pause-work.md +176 -0
  142. package/cap/workflows/plan-milestone-gaps.md +273 -0
  143. package/cap/workflows/plan-phase.md +859 -0
  144. package/cap/workflows/plant-seed.md +169 -0
  145. package/cap/workflows/pr-branch.md +129 -0
  146. package/cap/workflows/profile-user.md +450 -0
  147. package/cap/workflows/progress.md +507 -0
  148. package/cap/workflows/quick.md +757 -0
  149. package/cap/workflows/remove-phase.md +155 -0
  150. package/cap/workflows/remove-workspace.md +90 -0
  151. package/cap/workflows/research-phase.md +82 -0
  152. package/cap/workflows/resume-project.md +326 -0
  153. package/cap/workflows/review.md +228 -0
  154. package/cap/workflows/session-report.md +146 -0
  155. package/cap/workflows/settings.md +283 -0
  156. package/cap/workflows/ship.md +228 -0
  157. package/cap/workflows/stats.md +60 -0
  158. package/cap/workflows/transition.md +671 -0
  159. package/cap/workflows/ui-phase.md +302 -0
  160. package/cap/workflows/ui-review.md +165 -0
  161. package/cap/workflows/update.md +323 -0
  162. package/cap/workflows/validate-phase.md +174 -0
  163. package/cap/workflows/verify-phase.md +254 -0
  164. package/cap/workflows/verify-work.md +637 -0
  165. package/commands/cap/annotate.md +165 -0
  166. package/commands/cap/brainstorm.md +238 -0
  167. package/commands/cap/debug.md +297 -0
  168. package/commands/cap/init.md +262 -0
  169. package/commands/cap/iterate.md +234 -0
  170. package/commands/cap/prototype.md +281 -0
  171. package/commands/cap/refresh-docs.md +37 -0
  172. package/commands/cap/review.md +272 -0
  173. package/commands/cap/scan.md +249 -0
  174. package/commands/cap/start.md +234 -0
  175. package/commands/cap/status.md +189 -0
  176. package/commands/cap/test.md +250 -0
  177. package/hooks/dist/gsd-check-update.js +114 -0
  178. package/hooks/dist/gsd-context-monitor.js +156 -0
  179. package/hooks/dist/gsd-prompt-guard.js +96 -0
  180. package/hooks/dist/gsd-statusline.js +119 -0
  181. package/hooks/dist/gsd-workflow-guard.js +94 -0
  182. package/package.json +51 -0
  183. package/scripts/base64-scan.sh +262 -0
  184. package/scripts/build-hooks.js +82 -0
  185. package/scripts/cap-removal-checklist.md +202 -0
  186. package/scripts/prompt-injection-scan.sh +198 -0
  187. package/scripts/run-tests.cjs +29 -0
  188. package/scripts/secret-scan.sh +227 -0
@@ -0,0 +1,177 @@
1
+ // @gsd-context(phase:11) Skeleton generator -- produces directory tree and file list for architecture mode confirmation gate
2
+ // @gsd-decision This is a utility that generates the PLAN (tree display), not the files themselves. The agent creates files via Write tool after user confirms the plan.
3
+ // @gsd-ref(ref:ARCH-01) Supports skeleton generation with folder structure, config, and typed interfaces
4
+ // @gsd-ref(ref:ARCH-04) Generates preview for confirmation gate -- no files written until approved
5
+
6
+ 'use strict';
7
+
8
+ const path = require('node:path');
9
+
10
+ // @gsd-api generateSkeletonPlan(conventions, modules) -- returns SkeletonPlan with tree string and file list
11
+ // @gsd-pattern Skeleton plans are data structures, not side-effectful -- file writing is done by the agent after user approval
12
+
13
+ /**
14
+ * @typedef {Object} SkeletonFile
15
+ * @property {string} relativePath - path relative to project root
16
+ * @property {'config'|'interface'|'barrel'|'stub'|'entry'} type - file category
17
+ * @property {string} purpose - one-line description for the tree display
18
+ */
19
+
20
+ /**
21
+ * @typedef {Object} SkeletonPlan
22
+ * @property {string} tree - formatted directory tree string for display
23
+ * @property {SkeletonFile[]} files - ordered list of files to create
24
+ * @property {number} dirCount - number of directories in the skeleton
25
+ * @property {number} configCount - number of config files
26
+ * @property {number} interfaceCount - number of interface/type files
27
+ * @property {number} boundaryCount - number of module boundary (barrel) files
28
+ */
29
+
30
+ /**
31
+ * Generates a skeleton plan from discovered conventions and a list of module names.
32
+ *
33
+ * @param {import('./convention-reader.cjs').ConventionReport} conventions
34
+ * @param {string[]} moduleNames - names of top-level modules to create (e.g., ['tasks', 'users', 'database'])
35
+ * @returns {SkeletonPlan}
36
+ */
37
+ function generateSkeletonPlan(conventions, moduleNames) {
38
+ // @gsd-todo(ref:AC-1) Implement skeleton plan generation that produces folder structure, config files, and typed interfaces based on discovered conventions
39
+ // @gsd-constraint Generated skeleton must contain zero feature implementation code -- only structure and interfaces
40
+
41
+ const files = [];
42
+ const isEsm = conventions.moduleType === 'esm';
43
+
44
+ // @gsd-decision Config files are generated first in the plan because they define project-wide conventions that module files depend on
45
+ files.push({
46
+ relativePath: 'package.json',
47
+ type: 'config',
48
+ purpose: 'Project manifest matching existing conventions',
49
+ });
50
+
51
+ if (conventions.pathAliases && Object.keys(conventions.pathAliases).length > 0) {
52
+ files.push({
53
+ relativePath: 'tsconfig.json',
54
+ type: 'config',
55
+ purpose: 'TypeScript config preserving existing path aliases',
56
+ });
57
+ }
58
+
59
+ // @gsd-decision Entry point is src/index with extension matching module type (.mjs for ESM, .cjs for CJS, .js as default)
60
+ const ext = isEsm ? '.js' : '.cjs';
61
+ files.push({
62
+ relativePath: `src/index${ext}`,
63
+ type: 'entry',
64
+ purpose: 'Main entry point -- re-exports all module boundaries',
65
+ });
66
+
67
+ // Shared types
68
+ files.push({
69
+ relativePath: `src/types/index${ext}`,
70
+ type: 'interface',
71
+ purpose: 'Shared type definitions used across module boundaries',
72
+ });
73
+
74
+ // @gsd-pattern Each module gets exactly three files: barrel (index), types, and a single stub
75
+ // @gsd-decision Three-file module template keeps boundaries consistent and predictable across the codebase
76
+ for (const moduleName of moduleNames) {
77
+ // @gsd-context Module naming follows discovered convention (kebab-case, camelCase, etc.)
78
+ const dirName = applyNamingConvention(moduleName, conventions.namingConvention);
79
+
80
+ files.push({
81
+ relativePath: `src/${dirName}/index${ext}`,
82
+ type: 'barrel',
83
+ purpose: `${moduleName} module boundary -- barrel export`,
84
+ });
85
+
86
+ files.push({
87
+ relativePath: `src/${dirName}/types${ext}`,
88
+ type: 'interface',
89
+ purpose: `${moduleName} type definitions -- public API surface`,
90
+ });
91
+
92
+ files.push({
93
+ relativePath: `src/${dirName}/stub${ext}`,
94
+ type: 'stub',
95
+ purpose: `${moduleName} implementation stub -- throws NotImplemented`,
96
+ });
97
+ }
98
+
99
+ // Test structure
100
+ // @gsd-decision Test directory structure matches discovered convention -- colocated or separate
101
+ if (conventions.testPattern === 'separate-dir') {
102
+ files.push({
103
+ relativePath: 'tests/.gitkeep',
104
+ type: 'config',
105
+ purpose: 'Test directory placeholder matching existing test structure',
106
+ });
107
+ }
108
+
109
+ const plan = {
110
+ tree: buildTreeString(files),
111
+ files,
112
+ dirCount: countUniqueDirectories(files),
113
+ configCount: files.filter(f => f.type === 'config').length,
114
+ interfaceCount: files.filter(f => f.type === 'interface').length,
115
+ boundaryCount: files.filter(f => f.type === 'barrel').length,
116
+ };
117
+
118
+ return plan;
119
+ }
120
+
121
+ /**
122
+ * Applies the detected naming convention to a module name.
123
+ * @param {string} name - module name in plain form (e.g., 'user auth')
124
+ * @param {string} convention - detected convention
125
+ * @returns {string}
126
+ */
127
+ function applyNamingConvention(name, convention) {
128
+ // @gsd-todo Implement naming convention transformations (kebab-case, camelCase, PascalCase, snake_case)
129
+ const normalized = name.toLowerCase().replace(/\s+/g, '-');
130
+ switch (convention) {
131
+ case 'kebab-case':
132
+ return normalized;
133
+ case 'camelCase':
134
+ return normalized.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
135
+ case 'PascalCase':
136
+ return normalized.replace(/(^|-)([a-z])/g, (_, _sep, c) => c.toUpperCase());
137
+ case 'snake_case':
138
+ return normalized.replace(/-/g, '_');
139
+ default:
140
+ return normalized;
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Builds a formatted directory tree string from a list of files.
146
+ * @param {SkeletonFile[]} files
147
+ * @returns {string}
148
+ */
149
+ function buildTreeString(files) {
150
+ // @gsd-todo Implement tree string builder with proper indentation and box-drawing characters
151
+ // Stub: returns a simple flat listing
152
+ const lines = ['project-root/'];
153
+ for (const file of files) {
154
+ const depth = file.relativePath.split('/').length - 1;
155
+ const indent = ' '.repeat(depth + 1);
156
+ const basename = path.basename(file.relativePath);
157
+ lines.push(`${indent}${basename} -- ${file.purpose}`);
158
+ }
159
+ return lines.join('\n');
160
+ }
161
+
162
+ /**
163
+ * Counts unique directories from file paths.
164
+ * @param {SkeletonFile[]} files
165
+ * @returns {number}
166
+ */
167
+ function countUniqueDirectories(files) {
168
+ const dirs = new Set();
169
+ for (const file of files) {
170
+ const dir = path.dirname(file.relativePath);
171
+ if (dir !== '.') dirs.add(dir);
172
+ }
173
+ return dirs.size;
174
+ }
175
+
176
+ // @gsd-api Exports: generateSkeletonPlan, applyNamingConvention (for testing)
177
+ module.exports = { generateSkeletonPlan, applyNamingConvention, buildTreeString };