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.
- package/LICENSE +21 -0
- package/README.ja-JP.md +834 -0
- package/README.ko-KR.md +823 -0
- package/README.md +1006 -0
- package/README.pt-BR.md +452 -0
- package/README.zh-CN.md +800 -0
- package/agents/cap-brainstormer.md +154 -0
- package/agents/cap-debugger.md +221 -0
- package/agents/cap-prototyper.md +170 -0
- package/agents/cap-reviewer.md +230 -0
- package/agents/cap-tester.md +193 -0
- package/bin/install.js +5002 -0
- package/cap/bin/gsd-tools.cjs +1141 -0
- package/cap/bin/lib/arc-scanner.cjs +341 -0
- package/cap/bin/lib/cap-feature-map.cjs +506 -0
- package/cap/bin/lib/cap-session.cjs +191 -0
- package/cap/bin/lib/cap-stack-docs.cjs +598 -0
- package/cap/bin/lib/cap-tag-scanner.cjs +458 -0
- package/cap/bin/lib/commands.cjs +959 -0
- package/cap/bin/lib/config.cjs +466 -0
- package/cap/bin/lib/convention-reader.cjs +180 -0
- package/cap/bin/lib/core.cjs +1230 -0
- package/cap/bin/lib/feature-aggregator.cjs +422 -0
- package/cap/bin/lib/frontmatter.cjs +336 -0
- package/cap/bin/lib/init.cjs +1442 -0
- package/cap/bin/lib/manifest-generator.cjs +381 -0
- package/cap/bin/lib/milestone.cjs +252 -0
- package/cap/bin/lib/model-profiles.cjs +68 -0
- package/cap/bin/lib/monorepo-context.cjs +224 -0
- package/cap/bin/lib/monorepo-migrator.cjs +507 -0
- package/cap/bin/lib/phase.cjs +888 -0
- package/cap/bin/lib/profile-output.cjs +952 -0
- package/cap/bin/lib/profile-pipeline.cjs +539 -0
- package/cap/bin/lib/roadmap.cjs +329 -0
- package/cap/bin/lib/security.cjs +382 -0
- package/cap/bin/lib/session-manager.cjs +290 -0
- package/cap/bin/lib/skeleton-generator.cjs +177 -0
- package/cap/bin/lib/state.cjs +1031 -0
- package/cap/bin/lib/template.cjs +222 -0
- package/cap/bin/lib/test-detector.cjs +61 -0
- package/cap/bin/lib/uat.cjs +282 -0
- package/cap/bin/lib/verify.cjs +888 -0
- package/cap/bin/lib/workspace-detector.cjs +369 -0
- package/cap/bin/lib/workstream.cjs +491 -0
- package/cap/commands/gsd/workstreams.md +63 -0
- package/cap/references/arc-standard.md +315 -0
- package/cap/references/cap-agent-architecture.md +102 -0
- package/cap/references/cap-gitignore-template +9 -0
- package/cap/references/cap-zero-deps.md +158 -0
- package/cap/references/checkpoints.md +778 -0
- package/cap/references/continuation-format.md +249 -0
- package/cap/references/decimal-phase-calculation.md +64 -0
- package/cap/references/feature-map-template.md +25 -0
- package/cap/references/git-integration.md +295 -0
- package/cap/references/git-planning-commit.md +38 -0
- package/cap/references/model-profile-resolution.md +36 -0
- package/cap/references/model-profiles.md +139 -0
- package/cap/references/phase-argument-parsing.md +61 -0
- package/cap/references/planning-config.md +202 -0
- package/cap/references/questioning.md +162 -0
- package/cap/references/session-template.json +8 -0
- package/cap/references/tdd.md +263 -0
- package/cap/references/ui-brand.md +160 -0
- package/cap/references/user-profiling.md +681 -0
- package/cap/references/verification-patterns.md +612 -0
- package/cap/references/workstream-flag.md +58 -0
- package/cap/templates/DEBUG.md +164 -0
- package/cap/templates/UAT.md +265 -0
- package/cap/templates/UI-SPEC.md +100 -0
- package/cap/templates/VALIDATION.md +76 -0
- package/cap/templates/claude-md.md +122 -0
- package/cap/templates/codebase/architecture.md +255 -0
- package/cap/templates/codebase/concerns.md +310 -0
- package/cap/templates/codebase/conventions.md +307 -0
- package/cap/templates/codebase/integrations.md +280 -0
- package/cap/templates/codebase/stack.md +186 -0
- package/cap/templates/codebase/structure.md +285 -0
- package/cap/templates/codebase/testing.md +480 -0
- package/cap/templates/config.json +44 -0
- package/cap/templates/context.md +352 -0
- package/cap/templates/continue-here.md +78 -0
- package/cap/templates/copilot-instructions.md +7 -0
- package/cap/templates/debug-subagent-prompt.md +91 -0
- package/cap/templates/dev-preferences.md +21 -0
- package/cap/templates/discovery.md +146 -0
- package/cap/templates/discussion-log.md +63 -0
- package/cap/templates/milestone-archive.md +123 -0
- package/cap/templates/milestone.md +115 -0
- package/cap/templates/phase-prompt.md +610 -0
- package/cap/templates/planner-subagent-prompt.md +117 -0
- package/cap/templates/project.md +186 -0
- package/cap/templates/requirements.md +231 -0
- package/cap/templates/research-project/ARCHITECTURE.md +204 -0
- package/cap/templates/research-project/FEATURES.md +147 -0
- package/cap/templates/research-project/PITFALLS.md +200 -0
- package/cap/templates/research-project/STACK.md +120 -0
- package/cap/templates/research-project/SUMMARY.md +170 -0
- package/cap/templates/research.md +552 -0
- package/cap/templates/retrospective.md +54 -0
- package/cap/templates/roadmap.md +202 -0
- package/cap/templates/state.md +176 -0
- package/cap/templates/summary-complex.md +59 -0
- package/cap/templates/summary-minimal.md +41 -0
- package/cap/templates/summary-standard.md +48 -0
- package/cap/templates/summary.md +248 -0
- package/cap/templates/user-profile.md +146 -0
- package/cap/templates/user-setup.md +311 -0
- package/cap/templates/verification-report.md +322 -0
- package/cap/workflows/add-phase.md +112 -0
- package/cap/workflows/add-tests.md +351 -0
- package/cap/workflows/add-todo.md +158 -0
- package/cap/workflows/audit-milestone.md +340 -0
- package/cap/workflows/audit-uat.md +109 -0
- package/cap/workflows/autonomous.md +891 -0
- package/cap/workflows/check-todos.md +177 -0
- package/cap/workflows/cleanup.md +152 -0
- package/cap/workflows/complete-milestone.md +767 -0
- package/cap/workflows/diagnose-issues.md +231 -0
- package/cap/workflows/discovery-phase.md +289 -0
- package/cap/workflows/discuss-phase-assumptions.md +653 -0
- package/cap/workflows/discuss-phase.md +1049 -0
- package/cap/workflows/do.md +104 -0
- package/cap/workflows/execute-phase.md +846 -0
- package/cap/workflows/execute-plan.md +514 -0
- package/cap/workflows/fast.md +105 -0
- package/cap/workflows/forensics.md +265 -0
- package/cap/workflows/health.md +181 -0
- package/cap/workflows/help.md +660 -0
- package/cap/workflows/insert-phase.md +130 -0
- package/cap/workflows/list-phase-assumptions.md +178 -0
- package/cap/workflows/list-workspaces.md +56 -0
- package/cap/workflows/manager.md +362 -0
- package/cap/workflows/map-codebase.md +377 -0
- package/cap/workflows/milestone-summary.md +223 -0
- package/cap/workflows/new-milestone.md +486 -0
- package/cap/workflows/new-project.md +1250 -0
- package/cap/workflows/new-workspace.md +237 -0
- package/cap/workflows/next.md +97 -0
- package/cap/workflows/node-repair.md +92 -0
- package/cap/workflows/note.md +156 -0
- package/cap/workflows/pause-work.md +176 -0
- package/cap/workflows/plan-milestone-gaps.md +273 -0
- package/cap/workflows/plan-phase.md +859 -0
- package/cap/workflows/plant-seed.md +169 -0
- package/cap/workflows/pr-branch.md +129 -0
- package/cap/workflows/profile-user.md +450 -0
- package/cap/workflows/progress.md +507 -0
- package/cap/workflows/quick.md +757 -0
- package/cap/workflows/remove-phase.md +155 -0
- package/cap/workflows/remove-workspace.md +90 -0
- package/cap/workflows/research-phase.md +82 -0
- package/cap/workflows/resume-project.md +326 -0
- package/cap/workflows/review.md +228 -0
- package/cap/workflows/session-report.md +146 -0
- package/cap/workflows/settings.md +283 -0
- package/cap/workflows/ship.md +228 -0
- package/cap/workflows/stats.md +60 -0
- package/cap/workflows/transition.md +671 -0
- package/cap/workflows/ui-phase.md +302 -0
- package/cap/workflows/ui-review.md +165 -0
- package/cap/workflows/update.md +323 -0
- package/cap/workflows/validate-phase.md +174 -0
- package/cap/workflows/verify-phase.md +254 -0
- package/cap/workflows/verify-work.md +637 -0
- package/commands/cap/annotate.md +165 -0
- package/commands/cap/brainstorm.md +238 -0
- package/commands/cap/debug.md +297 -0
- package/commands/cap/init.md +262 -0
- package/commands/cap/iterate.md +234 -0
- package/commands/cap/prototype.md +281 -0
- package/commands/cap/refresh-docs.md +37 -0
- package/commands/cap/review.md +272 -0
- package/commands/cap/scan.md +249 -0
- package/commands/cap/start.md +234 -0
- package/commands/cap/status.md +189 -0
- package/commands/cap/test.md +250 -0
- package/hooks/dist/gsd-check-update.js +114 -0
- package/hooks/dist/gsd-context-monitor.js +156 -0
- package/hooks/dist/gsd-prompt-guard.js +96 -0
- package/hooks/dist/gsd-statusline.js +119 -0
- package/hooks/dist/gsd-workflow-guard.js +94 -0
- package/package.json +51 -0
- package/scripts/base64-scan.sh +262 -0
- package/scripts/build-hooks.js +82 -0
- package/scripts/cap-removal-checklist.md +202 -0
- package/scripts/prompt-injection-scan.sh +198 -0
- package/scripts/run-tests.cjs +29 -0
- package/scripts/secret-scan.sh +227 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// @gsd-context Monorepo context resolver -- assembles per-app planning paths and agent context for scoped operations
|
|
2
|
+
// @gsd-decision Separate module from workspace-detector to keep detection (read-only) separate from planning structure (write operations)
|
|
3
|
+
// @gsd-constraint Zero external dependencies -- uses only Node.js built-ins (fs, path)
|
|
4
|
+
// @gsd-ref(ref:AC-3) Each scoped app gets its own .planning/ directory with independent CODE-INVENTORY.md, PRD.md, and FEATURES.md
|
|
5
|
+
// @gsd-ref(ref:AC-7) Root .planning/ holds global decisions; app .planning/ holds app-specific work
|
|
6
|
+
// @gsd-pattern Two-level planning: root .planning/ for global context, app-path/.planning/ for scoped work
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const fs = require('node:fs');
|
|
11
|
+
const path = require('node:path');
|
|
12
|
+
|
|
13
|
+
// @gsd-api resolveAppPlanningDir(rootPath, appRelativePath) -- returns absolute path to app-scoped .planning/ directory
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {Object} MonorepoContext
|
|
17
|
+
* @property {string} rootPlanningDir - Absolute path to root .planning/
|
|
18
|
+
* @property {string} appPlanningDir - Absolute path to app-scoped .planning/
|
|
19
|
+
* @property {string} appRoot - Absolute path to the scoped app directory
|
|
20
|
+
* @property {string} appName - Name of the scoped app
|
|
21
|
+
* @property {string[]} manifestPaths - Paths to relevant package manifests for this app
|
|
22
|
+
* @property {Object} globalContext - Parsed global planning docs (lightweight refs)
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the .planning/ directory for an app-scoped operation.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} rootPath - Monorepo root
|
|
29
|
+
* @param {string} appRelativePath - Relative path to the app (e.g., 'apps/dashboard')
|
|
30
|
+
* @returns {string} Absolute path to app .planning/ directory
|
|
31
|
+
*/
|
|
32
|
+
function resolveAppPlanningDir(rootPath, appRelativePath) {
|
|
33
|
+
return path.join(rootPath, appRelativePath, '.planning');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Initialize the per-app .planning/ directory structure.
|
|
38
|
+
* Creates the directory and placeholder files mirroring root .planning/.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} rootPath - Monorepo root
|
|
41
|
+
* @param {string} appRelativePath - Relative path to the app
|
|
42
|
+
* @param {Object} [options]
|
|
43
|
+
* @param {string} [options.appName] - Display name for headers
|
|
44
|
+
* @returns {string} Path to created .planning/ directory
|
|
45
|
+
*/
|
|
46
|
+
function initAppPlanning(rootPath, appRelativePath, options) {
|
|
47
|
+
options = options || {};
|
|
48
|
+
const appPlanningDir = resolveAppPlanningDir(rootPath, appRelativePath);
|
|
49
|
+
const appName = options.appName || path.basename(appRelativePath);
|
|
50
|
+
|
|
51
|
+
fs.mkdirSync(appPlanningDir, { recursive: true });
|
|
52
|
+
fs.mkdirSync(path.join(appPlanningDir, 'prototype'), { recursive: true });
|
|
53
|
+
|
|
54
|
+
// @gsd-decision Create stub PRD.md and FEATURES.md in app .planning/ -- agents expect these files to exist
|
|
55
|
+
const prdPath = path.join(appPlanningDir, 'PRD.md');
|
|
56
|
+
if (!fs.existsSync(prdPath)) {
|
|
57
|
+
fs.writeFileSync(prdPath, `# ${appName} -- PRD\n\nApp-scoped PRD. Generated by monorepo-init.\n`, 'utf-8');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const featuresPath = path.join(appPlanningDir, 'FEATURES.md');
|
|
61
|
+
if (!fs.existsSync(featuresPath)) {
|
|
62
|
+
fs.writeFileSync(featuresPath, `# ${appName} -- Feature Map\n\nAuto-generated. Run extract-plan --app ${appRelativePath} to populate.\n`, 'utf-8');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Create prototype/CODE-INVENTORY.md stub
|
|
66
|
+
const codeInventoryPath = path.join(appPlanningDir, 'prototype', 'CODE-INVENTORY.md');
|
|
67
|
+
if (!fs.existsSync(codeInventoryPath)) {
|
|
68
|
+
fs.writeFileSync(codeInventoryPath, `# CODE-INVENTORY.md\n\nRun /gsd:extract-plan --app ${appRelativePath} to populate.\n`, 'utf-8');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return appPlanningDir;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Build the full MonorepoContext for an app-scoped operation.
|
|
76
|
+
* This is the primary function agents consume to get focused context.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} rootPath - Monorepo root
|
|
79
|
+
* @param {string} appRelativePath - Relative path to app
|
|
80
|
+
* @param {Object} [options]
|
|
81
|
+
* @param {string} [options.appName] - App display name
|
|
82
|
+
* @param {string[]} [options.appDependencies] - Package names this app depends on
|
|
83
|
+
* @returns {MonorepoContext}
|
|
84
|
+
*/
|
|
85
|
+
// @gsd-api buildMonorepoContext(rootPath, appRelativePath, options) -- returns MonorepoContext with local + global planning refs
|
|
86
|
+
function buildMonorepoContext(rootPath, appRelativePath, options) {
|
|
87
|
+
options = options || {};
|
|
88
|
+
const appAbsPath = path.join(rootPath, appRelativePath);
|
|
89
|
+
const appPlanningDir = resolveAppPlanningDir(rootPath, appRelativePath);
|
|
90
|
+
const rootPlanningDir = path.join(rootPath, '.planning');
|
|
91
|
+
const manifestsDir = path.join(rootPlanningDir, 'manifests');
|
|
92
|
+
|
|
93
|
+
const manifestPaths = resolveRelevantManifests(manifestsDir, appAbsPath, options.appDependencies || []);
|
|
94
|
+
|
|
95
|
+
// @gsd-decision Load global context lazily -- only read file headers, not full content, to minimize token usage
|
|
96
|
+
const globalContext = loadGlobalContextRefs(rootPlanningDir);
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
rootPlanningDir,
|
|
100
|
+
appPlanningDir,
|
|
101
|
+
appRoot: appAbsPath,
|
|
102
|
+
appName: options.appName || path.basename(appRelativePath),
|
|
103
|
+
manifestPaths,
|
|
104
|
+
globalContext,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Find package manifests relevant to a specific app based on its dependencies.
|
|
110
|
+
*
|
|
111
|
+
* @param {string} manifestsDir - Path to .planning/manifests/
|
|
112
|
+
* @param {string} appAbsPath - Absolute path to the app
|
|
113
|
+
* @param {string[]} knownDeps - Package names from workspace detection
|
|
114
|
+
* @returns {string[]} Paths to relevant manifest .md files
|
|
115
|
+
*/
|
|
116
|
+
function resolveRelevantManifests(manifestsDir, appAbsPath, knownDeps) {
|
|
117
|
+
// @gsd-risk If app package.json is missing or malformed, no manifests are resolved -- agent gets no package context
|
|
118
|
+
const manifestPaths = [];
|
|
119
|
+
|
|
120
|
+
if (!fs.existsSync(manifestsDir)) return manifestPaths;
|
|
121
|
+
|
|
122
|
+
// Read app's package.json for its dependencies
|
|
123
|
+
const appPkgPath = path.join(appAbsPath, 'package.json');
|
|
124
|
+
let appDeps = [...knownDeps];
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
const appPkg = JSON.parse(fs.readFileSync(appPkgPath, 'utf-8'));
|
|
128
|
+
const allDeps = { ...(appPkg.dependencies || {}), ...(appPkg.devDependencies || {}) };
|
|
129
|
+
for (const [name, version] of Object.entries(allDeps)) {
|
|
130
|
+
if (typeof version === 'string' && version.startsWith('workspace:')) {
|
|
131
|
+
if (!appDeps.includes(name)) appDeps.push(name);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} catch {
|
|
135
|
+
// No package.json or malformed -- use knownDeps only
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Match dependency names to manifest files
|
|
139
|
+
try {
|
|
140
|
+
const manifestFiles = fs.readdirSync(manifestsDir).filter(f => f.endsWith('.md'));
|
|
141
|
+
for (const file of manifestFiles) {
|
|
142
|
+
const baseName = file.replace('.md', '').replace(/__/g, '/');
|
|
143
|
+
// Check if any app dependency matches this manifest (with or without @ prefix)
|
|
144
|
+
const matches = appDeps.some(dep => {
|
|
145
|
+
const depNorm = dep.replace(/^@/, '');
|
|
146
|
+
return baseName === depNorm || baseName === dep;
|
|
147
|
+
});
|
|
148
|
+
if (matches) {
|
|
149
|
+
manifestPaths.push(path.join(manifestsDir, file));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} catch {
|
|
153
|
+
// manifestsDir not readable
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return manifestPaths;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Load lightweight references from global .planning/ docs.
|
|
161
|
+
* Reads only headers and first paragraphs to minimize context size.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} rootPlanningDir - Path to root .planning/
|
|
164
|
+
* @returns {Object} Global context references
|
|
165
|
+
*/
|
|
166
|
+
function loadGlobalContextRefs(rootPlanningDir) {
|
|
167
|
+
const refs = {
|
|
168
|
+
hasProject: false,
|
|
169
|
+
hasRoadmap: false,
|
|
170
|
+
hasRequirements: false,
|
|
171
|
+
projectSummary: null,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const projectPath = path.join(rootPlanningDir, 'PROJECT.md');
|
|
175
|
+
if (fs.existsSync(projectPath)) {
|
|
176
|
+
refs.hasProject = true;
|
|
177
|
+
try {
|
|
178
|
+
const content = fs.readFileSync(projectPath, 'utf-8');
|
|
179
|
+
// Extract first 5 lines as summary
|
|
180
|
+
refs.projectSummary = content.split('\n').slice(0, 5).join('\n');
|
|
181
|
+
} catch {
|
|
182
|
+
// Ignore
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
refs.hasRoadmap = fs.existsSync(path.join(rootPlanningDir, 'ROADMAP.md'));
|
|
187
|
+
refs.hasRequirements = fs.existsSync(path.join(rootPlanningDir, 'REQUIREMENTS.md'));
|
|
188
|
+
|
|
189
|
+
return refs;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Modify extract-tags scan path to scope to an app directory.
|
|
194
|
+
* Used by the --app flag in gsd-tools.cjs extract-tags case.
|
|
195
|
+
*
|
|
196
|
+
* @param {string} rootPath - Monorepo root
|
|
197
|
+
* @param {string} appRelativePath - App-scoped path
|
|
198
|
+
* @param {Object} originalOpts - Original extract-tags options
|
|
199
|
+
* @returns {Object} Modified options with scoped targetPath and outputFile
|
|
200
|
+
*/
|
|
201
|
+
// @gsd-api scopeExtractTags(rootPath, appRelativePath, originalOpts) -- returns modified options for app-scoped tag extraction
|
|
202
|
+
function scopeExtractTags(rootPath, appRelativePath, originalOpts) {
|
|
203
|
+
const appAbsPath = path.join(rootPath, appRelativePath);
|
|
204
|
+
const appPlanningDir = resolveAppPlanningDir(rootPath, appRelativePath);
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
...originalOpts,
|
|
208
|
+
// Override target path to scan only the app directory
|
|
209
|
+
targetPath: appAbsPath,
|
|
210
|
+
// Write output to app-scoped .planning/prototype/
|
|
211
|
+
outputFile: originalOpts.outputFile
|
|
212
|
+
? path.join(appPlanningDir, 'prototype', path.basename(originalOpts.outputFile))
|
|
213
|
+
: originalOpts.outputFile,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
module.exports = {
|
|
218
|
+
resolveAppPlanningDir,
|
|
219
|
+
initAppPlanning,
|
|
220
|
+
buildMonorepoContext,
|
|
221
|
+
resolveRelevantManifests,
|
|
222
|
+
loadGlobalContextRefs,
|
|
223
|
+
scopeExtractTags,
|
|
224
|
+
};
|