@howlil/ez-agents 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.md +845 -0
- package/README.zh-CN.md +702 -0
- package/agents/ez-codebase-mapper.md +770 -0
- package/agents/ez-debugger.md +1255 -0
- package/agents/ez-executor.md +487 -0
- package/agents/ez-integration-checker.md +443 -0
- package/agents/ez-nyquist-auditor.md +176 -0
- package/agents/ez-phase-researcher.md +553 -0
- package/agents/ez-plan-checker.md +706 -0
- package/agents/ez-planner.md +1307 -0
- package/agents/ez-project-researcher.md +629 -0
- package/agents/ez-research-synthesizer.md +247 -0
- package/agents/ez-roadmapper.md +650 -0
- package/agents/ez-ui-auditor.md +441 -0
- package/agents/ez-ui-checker.md +302 -0
- package/agents/ez-ui-researcher.md +355 -0
- package/agents/ez-verifier.md +579 -0
- package/bin/install.js +2862 -0
- package/bin/update.js +214 -0
- package/commands/ez/add-phase.md +43 -0
- package/commands/ez/add-tests.md +41 -0
- package/commands/ez/add-todo.md +47 -0
- package/commands/ez/audit-milestone.md +36 -0
- package/commands/ez/autonomous.md +41 -0
- package/commands/ez/check-todos.md +45 -0
- package/commands/ez/cleanup.md +18 -0
- package/commands/ez/complete-milestone.md +136 -0
- package/commands/ez/debug.md +168 -0
- package/commands/ez/discuss-phase.md +90 -0
- package/commands/ez/execute-phase.md +41 -0
- package/commands/ez/health.md +22 -0
- package/commands/ez/help.md +22 -0
- package/commands/ez/insert-phase.md +32 -0
- package/commands/ez/join-discord.md +18 -0
- package/commands/ez/list-phase-assumptions.md +46 -0
- package/commands/ez/map-codebase.md +71 -0
- package/commands/ez/new-milestone.md +44 -0
- package/commands/ez/new-project.md +42 -0
- package/commands/ez/pause-work.md +38 -0
- package/commands/ez/plan-milestone-gaps.md +34 -0
- package/commands/ez/plan-phase.md +45 -0
- package/commands/ez/progress.md +24 -0
- package/commands/ez/quick.md +45 -0
- package/commands/ez/reapply-patches.md +124 -0
- package/commands/ez/remove-phase.md +31 -0
- package/commands/ez/research-phase.md +190 -0
- package/commands/ez/resume-work.md +40 -0
- package/commands/ez/set-profile.md +34 -0
- package/commands/ez/settings.md +36 -0
- package/commands/ez/stats.md +18 -0
- package/commands/ez/ui-phase.md +34 -0
- package/commands/ez/ui-review.md +32 -0
- package/commands/ez/update.md +37 -0
- package/commands/ez/validate-phase.md +35 -0
- package/commands/ez/verify-work.md +38 -0
- package/get-shit-done/bin/ez-tools.cjs +598 -0
- package/get-shit-done/bin/lib/assistant-adapter.cjs +205 -0
- package/get-shit-done/bin/lib/audit-exec.cjs +150 -0
- package/get-shit-done/bin/lib/auth.cjs +175 -0
- package/get-shit-done/bin/lib/circuit-breaker.cjs +118 -0
- package/get-shit-done/bin/lib/commands.cjs +666 -0
- package/get-shit-done/bin/lib/config.cjs +183 -0
- package/get-shit-done/bin/lib/core.cjs +495 -0
- package/get-shit-done/bin/lib/file-lock.cjs +236 -0
- package/get-shit-done/bin/lib/frontmatter.cjs +299 -0
- package/get-shit-done/bin/lib/fs-utils.cjs +153 -0
- package/get-shit-done/bin/lib/git-utils.cjs +203 -0
- package/get-shit-done/bin/lib/health-check.cjs +163 -0
- package/get-shit-done/bin/lib/index.cjs +113 -0
- package/get-shit-done/bin/lib/init.cjs +710 -0
- package/get-shit-done/bin/lib/logger.cjs +117 -0
- package/get-shit-done/bin/lib/milestone.cjs +241 -0
- package/get-shit-done/bin/lib/model-provider.cjs +146 -0
- package/get-shit-done/bin/lib/phase.cjs +908 -0
- package/get-shit-done/bin/lib/retry.cjs +119 -0
- package/get-shit-done/bin/lib/roadmap.cjs +305 -0
- package/get-shit-done/bin/lib/safe-exec.cjs +128 -0
- package/get-shit-done/bin/lib/safe-path.cjs +130 -0
- package/get-shit-done/bin/lib/state.cjs +721 -0
- package/get-shit-done/bin/lib/temp-file.cjs +239 -0
- package/get-shit-done/bin/lib/template.cjs +222 -0
- package/get-shit-done/bin/lib/test-file-lock.cjs +112 -0
- package/get-shit-done/bin/lib/test-graceful.cjs +93 -0
- package/get-shit-done/bin/lib/test-logger.cjs +60 -0
- package/get-shit-done/bin/lib/test-safe-exec.cjs +38 -0
- package/get-shit-done/bin/lib/test-safe-path.cjs +33 -0
- package/get-shit-done/bin/lib/test-temp-file.cjs +125 -0
- package/get-shit-done/bin/lib/timeout-exec.cjs +62 -0
- package/get-shit-done/bin/lib/verify.cjs +820 -0
- package/get-shit-done/references/checkpoints.md +776 -0
- package/get-shit-done/references/continuation-format.md +249 -0
- package/get-shit-done/references/decimal-phase-calculation.md +65 -0
- package/get-shit-done/references/git-integration.md +248 -0
- package/get-shit-done/references/git-planning-commit.md +38 -0
- package/get-shit-done/references/model-profile-resolution.md +34 -0
- package/get-shit-done/references/model-profiles.md +93 -0
- package/get-shit-done/references/phase-argument-parsing.md +61 -0
- package/get-shit-done/references/planning-config.md +200 -0
- package/get-shit-done/references/questioning.md +162 -0
- package/get-shit-done/references/tdd.md +263 -0
- package/get-shit-done/references/ui-brand.md +160 -0
- package/get-shit-done/references/verification-patterns.md +612 -0
- package/get-shit-done/templates/DEBUG.md +164 -0
- package/get-shit-done/templates/UAT.md +247 -0
- package/get-shit-done/templates/UI-SPEC.md +100 -0
- package/get-shit-done/templates/VALIDATION.md +76 -0
- package/get-shit-done/templates/codebase/architecture.md +255 -0
- package/get-shit-done/templates/codebase/concerns.md +310 -0
- package/get-shit-done/templates/codebase/conventions.md +307 -0
- package/get-shit-done/templates/codebase/integrations.md +280 -0
- package/get-shit-done/templates/codebase/stack.md +186 -0
- package/get-shit-done/templates/codebase/structure.md +285 -0
- package/get-shit-done/templates/codebase/testing.md +480 -0
- package/get-shit-done/templates/config.json +37 -0
- package/get-shit-done/templates/context.md +352 -0
- package/get-shit-done/templates/continue-here.md +78 -0
- package/get-shit-done/templates/copilot-instructions.md +7 -0
- package/get-shit-done/templates/debug-subagent-prompt.md +91 -0
- package/get-shit-done/templates/discovery.md +146 -0
- package/get-shit-done/templates/milestone-archive.md +123 -0
- package/get-shit-done/templates/milestone.md +115 -0
- package/get-shit-done/templates/phase-prompt.md +610 -0
- package/get-shit-done/templates/planner-subagent-prompt.md +117 -0
- package/get-shit-done/templates/project.md +184 -0
- package/get-shit-done/templates/requirements.md +231 -0
- package/get-shit-done/templates/research-project/ARCHITECTURE.md +204 -0
- package/get-shit-done/templates/research-project/FEATURES.md +147 -0
- package/get-shit-done/templates/research-project/PITFALLS.md +200 -0
- package/get-shit-done/templates/research-project/STACK.md +120 -0
- package/get-shit-done/templates/research-project/SUMMARY.md +170 -0
- package/get-shit-done/templates/research.md +552 -0
- package/get-shit-done/templates/retrospective.md +54 -0
- package/get-shit-done/templates/roadmap.md +202 -0
- package/get-shit-done/templates/state.md +176 -0
- package/get-shit-done/templates/summary-complex.md +59 -0
- package/get-shit-done/templates/summary-minimal.md +41 -0
- package/get-shit-done/templates/summary-standard.md +48 -0
- package/get-shit-done/templates/summary.md +248 -0
- package/get-shit-done/templates/user-setup.md +311 -0
- package/get-shit-done/templates/verification-report.md +322 -0
- package/get-shit-done/workflows/add-phase.md +112 -0
- package/get-shit-done/workflows/add-tests.md +351 -0
- package/get-shit-done/workflows/add-todo.md +158 -0
- package/get-shit-done/workflows/audit-milestone.md +332 -0
- package/get-shit-done/workflows/autonomous.md +743 -0
- package/get-shit-done/workflows/check-todos.md +177 -0
- package/get-shit-done/workflows/cleanup.md +152 -0
- package/get-shit-done/workflows/complete-milestone.md +766 -0
- package/get-shit-done/workflows/diagnose-issues.md +219 -0
- package/get-shit-done/workflows/discovery-phase.md +289 -0
- package/get-shit-done/workflows/discuss-phase.md +762 -0
- package/get-shit-done/workflows/execute-phase.md +468 -0
- package/get-shit-done/workflows/execute-plan.md +483 -0
- package/get-shit-done/workflows/health.md +159 -0
- package/get-shit-done/workflows/help.md +492 -0
- package/get-shit-done/workflows/insert-phase.md +130 -0
- package/get-shit-done/workflows/list-phase-assumptions.md +178 -0
- package/get-shit-done/workflows/map-codebase.md +316 -0
- package/get-shit-done/workflows/new-milestone.md +384 -0
- package/get-shit-done/workflows/new-project.md +1111 -0
- package/get-shit-done/workflows/node-repair.md +92 -0
- package/get-shit-done/workflows/pause-work.md +122 -0
- package/get-shit-done/workflows/plan-milestone-gaps.md +274 -0
- package/get-shit-done/workflows/plan-phase.md +651 -0
- package/get-shit-done/workflows/progress.md +382 -0
- package/get-shit-done/workflows/quick.md +610 -0
- package/get-shit-done/workflows/remove-phase.md +155 -0
- package/get-shit-done/workflows/research-phase.md +74 -0
- package/get-shit-done/workflows/resume-project.md +307 -0
- package/get-shit-done/workflows/set-profile.md +81 -0
- package/get-shit-done/workflows/settings.md +242 -0
- package/get-shit-done/workflows/stats.md +57 -0
- package/get-shit-done/workflows/transition.md +544 -0
- package/get-shit-done/workflows/ui-phase.md +290 -0
- package/get-shit-done/workflows/ui-review.md +157 -0
- package/get-shit-done/workflows/update.md +320 -0
- package/get-shit-done/workflows/validate-phase.md +167 -0
- package/get-shit-done/workflows/verify-phase.md +243 -0
- package/get-shit-done/workflows/verify-work.md +584 -0
- package/package.json +55 -0
- package/scripts/build-hooks.js +43 -0
- package/scripts/run-tests.cjs +29 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* GSD Temp File — Secure temporary file handler
|
|
5
|
+
*
|
|
6
|
+
* Creates secure temp files with fs.mkdtemp(), automatic cleanup on exit,
|
|
7
|
+
* and path validation to prevent traversal attacks.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* const { createTempFile, cleanupAll } = require('./temp-file.cjs');
|
|
11
|
+
* const tempFile = await createTempFile('prefix-');
|
|
12
|
+
* // ... use temp file ...
|
|
13
|
+
* // Automatically cleaned up on process exit
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const os = require('os');
|
|
19
|
+
const crypto = require('crypto');
|
|
20
|
+
const Logger = require('./logger.cjs');
|
|
21
|
+
const logger = new Logger();
|
|
22
|
+
|
|
23
|
+
// Track all created temp resources for cleanup
|
|
24
|
+
const tempResources = new Set();
|
|
25
|
+
let cleanupRegistered = false;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generate a secure random suffix for temp names
|
|
29
|
+
* @returns {string} - Random hex string
|
|
30
|
+
*/
|
|
31
|
+
function generateSecureSuffix() {
|
|
32
|
+
return crypto.randomBytes(8).toString('hex');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Validate that a path is safe (no traversal attacks)
|
|
37
|
+
* @param {string} basePath - Base directory
|
|
38
|
+
* @param {string} targetPath - Target path to validate
|
|
39
|
+
* @returns {boolean} - True if safe
|
|
40
|
+
*/
|
|
41
|
+
function isPathSafe(basePath, targetPath) {
|
|
42
|
+
const resolvedBase = path.resolve(basePath);
|
|
43
|
+
const resolvedTarget = path.resolve(targetPath);
|
|
44
|
+
|
|
45
|
+
// Ensure target starts with base (is inside base)
|
|
46
|
+
const normalizedBase = resolvedBase + path.sep;
|
|
47
|
+
return resolvedTarget === resolvedBase ||
|
|
48
|
+
resolvedTarget.startsWith(normalizedBase);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Create a secure temporary directory
|
|
53
|
+
* @param {string} prefix - Prefix for temp directory name
|
|
54
|
+
* @param {string} customBase - Custom base directory (default: os.tmpdir())
|
|
55
|
+
* @returns {Promise<string>} - Path to created temp directory
|
|
56
|
+
*/
|
|
57
|
+
async function createTempDir(prefix = 'gsd-', customBase = null) {
|
|
58
|
+
const baseDir = customBase || os.tmpdir();
|
|
59
|
+
const tempPath = await fs.promises.mkdtemp(path.join(baseDir, prefix));
|
|
60
|
+
|
|
61
|
+
logger.debug(`Created temp directory: ${tempPath}`);
|
|
62
|
+
tempResources.add({ type: 'dir', path: tempPath });
|
|
63
|
+
|
|
64
|
+
registerCleanup();
|
|
65
|
+
|
|
66
|
+
return tempPath;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Create a secure temporary file
|
|
71
|
+
* @param {string} prefix - Prefix for temp file name
|
|
72
|
+
* @param {string} customBase - Custom base directory (default: os.tmpdir())
|
|
73
|
+
* @param {string} content - Optional initial content
|
|
74
|
+
* @returns {Promise<string>} - Path to created temp file
|
|
75
|
+
*/
|
|
76
|
+
async function createTempFile(prefix = 'gsd-', customBase = null, content = '') {
|
|
77
|
+
const baseDir = customBase || os.tmpdir();
|
|
78
|
+
const fileName = `${prefix}${generateSecureSuffix()}`;
|
|
79
|
+
const tempPath = path.join(baseDir, fileName);
|
|
80
|
+
|
|
81
|
+
await fs.promises.writeFile(tempPath, content, 'utf-8');
|
|
82
|
+
|
|
83
|
+
logger.debug(`Created temp file: ${tempPath}`);
|
|
84
|
+
tempResources.add({ type: 'file', path: tempPath });
|
|
85
|
+
|
|
86
|
+
registerCleanup();
|
|
87
|
+
|
|
88
|
+
return tempPath;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Write content to a temp file safely
|
|
93
|
+
* @param {string} tempPath - Path to temp file
|
|
94
|
+
* @param {string} content - Content to write
|
|
95
|
+
* @param {Object} options - Write options
|
|
96
|
+
*/
|
|
97
|
+
async function writeToTemp(tempPath, content, options = {}) {
|
|
98
|
+
const { validateBase = os.tmpdir() } = options;
|
|
99
|
+
|
|
100
|
+
if (!isPathSafe(validateBase, tempPath)) {
|
|
101
|
+
throw new Error(`Path traversal detected: ${tempPath}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
await fs.promises.writeFile(tempPath, content, 'utf-8');
|
|
105
|
+
logger.debug(`Written to temp file: ${tempPath}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Read content from a temp file safely
|
|
110
|
+
* @param {string} tempPath - Path to temp file
|
|
111
|
+
* @param {Object} options - Read options
|
|
112
|
+
* @returns {Promise<string>} - File content
|
|
113
|
+
*/
|
|
114
|
+
async function readFromTemp(tempPath, options = {}) {
|
|
115
|
+
const { validateBase = os.tmpdir() } = options;
|
|
116
|
+
|
|
117
|
+
if (!isPathSafe(validateBase, tempPath)) {
|
|
118
|
+
throw new Error(`Path traversal detected: ${tempPath}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const content = await fs.promises.readFile(tempPath, 'utf-8');
|
|
122
|
+
logger.debug(`Read from temp file: ${tempPath}`);
|
|
123
|
+
|
|
124
|
+
return content;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Clean up a specific temp resource
|
|
129
|
+
* @param {string} tempPath - Path to temp file or directory
|
|
130
|
+
*/
|
|
131
|
+
async function cleanupTemp(tempPath) {
|
|
132
|
+
const resolvedPath = path.resolve(tempPath);
|
|
133
|
+
|
|
134
|
+
for (const resource of tempResources) {
|
|
135
|
+
if (path.resolve(resource.path) === resolvedPath) {
|
|
136
|
+
try {
|
|
137
|
+
if (resource.type === 'dir') {
|
|
138
|
+
await fs.promises.rm(resolvedPath, { recursive: true, force: true });
|
|
139
|
+
logger.debug(`Cleaned up temp directory: ${resolvedPath}`);
|
|
140
|
+
} else {
|
|
141
|
+
await fs.promises.unlink(resolvedPath);
|
|
142
|
+
logger.debug(`Cleaned up temp file: ${resolvedPath}`);
|
|
143
|
+
}
|
|
144
|
+
tempResources.delete(resource);
|
|
145
|
+
} catch (err) {
|
|
146
|
+
logger.warn(`Failed to cleanup temp: ${resolvedPath}`, {
|
|
147
|
+
error: err.message
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Clean up all tracked temp resources
|
|
157
|
+
*/
|
|
158
|
+
async function cleanupAll() {
|
|
159
|
+
logger.info(`Cleaning up ${tempResources.size} temp resources...`);
|
|
160
|
+
|
|
161
|
+
const cleanupPromises = [];
|
|
162
|
+
for (const resource of tempResources) {
|
|
163
|
+
cleanupPromises.push(
|
|
164
|
+
cleanupTemp(resource.path).catch(err => {
|
|
165
|
+
logger.warn(`Cleanup failed for ${resource.path}: ${err.message}`);
|
|
166
|
+
})
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
await Promise.all(cleanupPromises);
|
|
171
|
+
logger.info('Temp cleanup complete');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Register cleanup handlers (called automatically)
|
|
176
|
+
*/
|
|
177
|
+
function registerCleanup() {
|
|
178
|
+
if (cleanupRegistered) return;
|
|
179
|
+
cleanupRegistered = true;
|
|
180
|
+
|
|
181
|
+
const cleanupHandler = async () => {
|
|
182
|
+
if (tempResources.size > 0) {
|
|
183
|
+
await cleanupAll();
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// Register for various exit scenarios
|
|
188
|
+
process.on('exit', () => {
|
|
189
|
+
// Synchronous cleanup for exit event
|
|
190
|
+
if (tempResources.size > 0) {
|
|
191
|
+
logger.debug('Synchronous temp cleanup on exit');
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
process.on('SIGINT', async () => {
|
|
196
|
+
await cleanupHandler();
|
|
197
|
+
process.exit(130);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
process.on('SIGTERM', async () => {
|
|
201
|
+
await cleanupHandler();
|
|
202
|
+
process.exit(143);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
process.on('beforeExit', async () => {
|
|
206
|
+
await cleanupHandler();
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Handle uncaught errors
|
|
210
|
+
process.on('uncaughtException', async (err) => {
|
|
211
|
+
logger.error('Uncaught exception, cleaning up temps...', {
|
|
212
|
+
error: err.message
|
|
213
|
+
});
|
|
214
|
+
await cleanupHandler();
|
|
215
|
+
process.exit(1);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
logger.debug('Temp cleanup handlers registered');
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Get list of tracked temp resources
|
|
223
|
+
* @returns {Array} - Array of {type, path} objects
|
|
224
|
+
*/
|
|
225
|
+
function getTrackedTemps() {
|
|
226
|
+
return Array.from(tempResources);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
module.exports = {
|
|
230
|
+
createTempDir,
|
|
231
|
+
createTempFile,
|
|
232
|
+
writeToTemp,
|
|
233
|
+
readFromTemp,
|
|
234
|
+
cleanupTemp,
|
|
235
|
+
cleanupAll,
|
|
236
|
+
getTrackedTemps,
|
|
237
|
+
isPathSafe,
|
|
238
|
+
generateSecureSuffix
|
|
239
|
+
};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template — Template selection and fill operations
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { normalizePhaseName, findPhaseInternal, generateSlugInternal, toPosixPath, output, error } = require('./core.cjs');
|
|
8
|
+
const { reconstructFrontmatter } = require('./frontmatter.cjs');
|
|
9
|
+
|
|
10
|
+
function cmdTemplateSelect(cwd, planPath, raw) {
|
|
11
|
+
if (!planPath) {
|
|
12
|
+
error('plan-path required');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const fullPath = path.join(cwd, planPath);
|
|
17
|
+
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
18
|
+
|
|
19
|
+
// Simple heuristics
|
|
20
|
+
const taskMatch = content.match(/###\s*Task\s*\d+/g) || [];
|
|
21
|
+
const taskCount = taskMatch.length;
|
|
22
|
+
|
|
23
|
+
const decisionMatch = content.match(/decision/gi) || [];
|
|
24
|
+
const hasDecisions = decisionMatch.length > 0;
|
|
25
|
+
|
|
26
|
+
// Count file mentions
|
|
27
|
+
const fileMentions = new Set();
|
|
28
|
+
const filePattern = /`([^`]+\.[a-zA-Z]+)`/g;
|
|
29
|
+
let m;
|
|
30
|
+
while ((m = filePattern.exec(content)) !== null) {
|
|
31
|
+
if (m[1].includes('/') && !m[1].startsWith('http')) {
|
|
32
|
+
fileMentions.add(m[1]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const fileCount = fileMentions.size;
|
|
36
|
+
|
|
37
|
+
let template = 'templates/summary-standard.md';
|
|
38
|
+
let type = 'standard';
|
|
39
|
+
|
|
40
|
+
if (taskCount <= 2 && fileCount <= 3 && !hasDecisions) {
|
|
41
|
+
template = 'templates/summary-minimal.md';
|
|
42
|
+
type = 'minimal';
|
|
43
|
+
} else if (hasDecisions || fileCount > 6 || taskCount > 5) {
|
|
44
|
+
template = 'templates/summary-complex.md';
|
|
45
|
+
type = 'complex';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const result = { template, type, taskCount, fileCount, hasDecisions };
|
|
49
|
+
output(result, raw, template);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
// Fallback to standard
|
|
52
|
+
output({ template: 'templates/summary-standard.md', type: 'standard', error: e.message }, raw, 'templates/summary-standard.md');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function cmdTemplateFill(cwd, templateType, options, raw) {
|
|
57
|
+
if (!templateType) { error('template type required: summary, plan, or verification'); }
|
|
58
|
+
if (!options.phase) { error('--phase required'); }
|
|
59
|
+
|
|
60
|
+
const phaseInfo = findPhaseInternal(cwd, options.phase);
|
|
61
|
+
if (!phaseInfo || !phaseInfo.found) { output({ error: 'Phase not found', phase: options.phase }, raw); return; }
|
|
62
|
+
|
|
63
|
+
const padded = normalizePhaseName(options.phase);
|
|
64
|
+
const today = new Date().toISOString().split('T')[0];
|
|
65
|
+
const phaseName = options.name || phaseInfo.phase_name || 'Unnamed';
|
|
66
|
+
const phaseSlug = phaseInfo.phase_slug || generateSlugInternal(phaseName);
|
|
67
|
+
const phaseId = `${padded}-${phaseSlug}`;
|
|
68
|
+
const planNum = (options.plan || '01').padStart(2, '0');
|
|
69
|
+
const fields = options.fields || {};
|
|
70
|
+
|
|
71
|
+
let frontmatter, body, fileName;
|
|
72
|
+
|
|
73
|
+
switch (templateType) {
|
|
74
|
+
case 'summary': {
|
|
75
|
+
frontmatter = {
|
|
76
|
+
phase: phaseId,
|
|
77
|
+
plan: planNum,
|
|
78
|
+
subsystem: '[primary category]',
|
|
79
|
+
tags: [],
|
|
80
|
+
provides: [],
|
|
81
|
+
affects: [],
|
|
82
|
+
'tech-stack': { added: [], patterns: [] },
|
|
83
|
+
'key-files': { created: [], modified: [] },
|
|
84
|
+
'key-decisions': [],
|
|
85
|
+
'patterns-established': [],
|
|
86
|
+
duration: '[X]min',
|
|
87
|
+
completed: today,
|
|
88
|
+
...fields,
|
|
89
|
+
};
|
|
90
|
+
body = [
|
|
91
|
+
`# Phase ${options.phase}: ${phaseName} Summary`,
|
|
92
|
+
'',
|
|
93
|
+
'**[Substantive one-liner describing outcome]**',
|
|
94
|
+
'',
|
|
95
|
+
'## Performance',
|
|
96
|
+
'- **Duration:** [time]',
|
|
97
|
+
'- **Tasks:** [count completed]',
|
|
98
|
+
'- **Files modified:** [count]',
|
|
99
|
+
'',
|
|
100
|
+
'## Accomplishments',
|
|
101
|
+
'- [Key outcome 1]',
|
|
102
|
+
'- [Key outcome 2]',
|
|
103
|
+
'',
|
|
104
|
+
'## Task Commits',
|
|
105
|
+
'1. **Task 1: [task name]** - `hash`',
|
|
106
|
+
'',
|
|
107
|
+
'## Files Created/Modified',
|
|
108
|
+
'- `path/to/file.ts` - What it does',
|
|
109
|
+
'',
|
|
110
|
+
'## Decisions & Deviations',
|
|
111
|
+
'[Key decisions or "None - followed plan as specified"]',
|
|
112
|
+
'',
|
|
113
|
+
'## Next Phase Readiness',
|
|
114
|
+
'[What\'s ready for next phase]',
|
|
115
|
+
].join('\n');
|
|
116
|
+
fileName = `${padded}-${planNum}-SUMMARY.md`;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
case 'plan': {
|
|
120
|
+
const planType = options.type || 'execute';
|
|
121
|
+
const wave = parseInt(options.wave) || 1;
|
|
122
|
+
frontmatter = {
|
|
123
|
+
phase: phaseId,
|
|
124
|
+
plan: planNum,
|
|
125
|
+
type: planType,
|
|
126
|
+
wave,
|
|
127
|
+
depends_on: [],
|
|
128
|
+
files_modified: [],
|
|
129
|
+
autonomous: true,
|
|
130
|
+
user_setup: [],
|
|
131
|
+
must_haves: { truths: [], artifacts: [], key_links: [] },
|
|
132
|
+
...fields,
|
|
133
|
+
};
|
|
134
|
+
body = [
|
|
135
|
+
`# Phase ${options.phase} Plan ${planNum}: [Title]`,
|
|
136
|
+
'',
|
|
137
|
+
'## Objective',
|
|
138
|
+
'- **What:** [What this plan builds]',
|
|
139
|
+
'- **Why:** [Why it matters for the phase goal]',
|
|
140
|
+
'- **Output:** [Concrete deliverable]',
|
|
141
|
+
'',
|
|
142
|
+
'## Context',
|
|
143
|
+
'@.planning/PROJECT.md',
|
|
144
|
+
'@.planning/ROADMAP.md',
|
|
145
|
+
'@.planning/STATE.md',
|
|
146
|
+
'',
|
|
147
|
+
'## Tasks',
|
|
148
|
+
'',
|
|
149
|
+
'<task type="code">',
|
|
150
|
+
' <name>[Task name]</name>',
|
|
151
|
+
' <files>[file paths]</files>',
|
|
152
|
+
' <action>[What to do]</action>',
|
|
153
|
+
' <verify>[How to verify]</verify>',
|
|
154
|
+
' <done>[Definition of done]</done>',
|
|
155
|
+
'</task>',
|
|
156
|
+
'',
|
|
157
|
+
'## Verification',
|
|
158
|
+
'[How to verify this plan achieved its objective]',
|
|
159
|
+
'',
|
|
160
|
+
'## Success Criteria',
|
|
161
|
+
'- [ ] [Criterion 1]',
|
|
162
|
+
'- [ ] [Criterion 2]',
|
|
163
|
+
].join('\n');
|
|
164
|
+
fileName = `${padded}-${planNum}-PLAN.md`;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case 'verification': {
|
|
168
|
+
frontmatter = {
|
|
169
|
+
phase: phaseId,
|
|
170
|
+
verified: new Date().toISOString(),
|
|
171
|
+
status: 'pending',
|
|
172
|
+
score: '0/0 must-haves verified',
|
|
173
|
+
...fields,
|
|
174
|
+
};
|
|
175
|
+
body = [
|
|
176
|
+
`# Phase ${options.phase}: ${phaseName} — Verification`,
|
|
177
|
+
'',
|
|
178
|
+
'## Observable Truths',
|
|
179
|
+
'| # | Truth | Status | Evidence |',
|
|
180
|
+
'|---|-------|--------|----------|',
|
|
181
|
+
'| 1 | [Truth] | pending | |',
|
|
182
|
+
'',
|
|
183
|
+
'## Required Artifacts',
|
|
184
|
+
'| Artifact | Expected | Status | Details |',
|
|
185
|
+
'|----------|----------|--------|---------|',
|
|
186
|
+
'| [path] | [what] | pending | |',
|
|
187
|
+
'',
|
|
188
|
+
'## Key Link Verification',
|
|
189
|
+
'| From | To | Via | Status | Details |',
|
|
190
|
+
'|------|----|----|--------|---------|',
|
|
191
|
+
'| [source] | [target] | [connection] | pending | |',
|
|
192
|
+
'',
|
|
193
|
+
'## Requirements Coverage',
|
|
194
|
+
'| Requirement | Status | Blocking Issue |',
|
|
195
|
+
'|-------------|--------|----------------|',
|
|
196
|
+
'| [req] | pending | |',
|
|
197
|
+
'',
|
|
198
|
+
'## Result',
|
|
199
|
+
'[Pending verification]',
|
|
200
|
+
].join('\n');
|
|
201
|
+
fileName = `${padded}-VERIFICATION.md`;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
default:
|
|
205
|
+
error(`Unknown template type: ${templateType}. Available: summary, plan, verification`);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const fullContent = `---\n${reconstructFrontmatter(frontmatter)}\n---\n\n${body}\n`;
|
|
210
|
+
const outPath = path.join(cwd, phaseInfo.directory, fileName);
|
|
211
|
+
|
|
212
|
+
if (fs.existsSync(outPath)) {
|
|
213
|
+
output({ error: 'File already exists', path: toPosixPath(path.relative(cwd, outPath)) }, raw);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
fs.writeFileSync(outPath, fullContent, 'utf-8');
|
|
218
|
+
const relPath = toPosixPath(path.relative(cwd, outPath));
|
|
219
|
+
output({ created: true, path: relPath, template: templateType }, raw, relPath);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
module.exports = { cmdTemplateSelect, cmdTemplateFill };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Test script for GSD File Lock
|
|
5
|
+
* Run: node get-shit-done/bin/lib/test-file-lock.cjs
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { withLock, isLocked, ifUnlocked } = require('./file-lock.cjs');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
const testFile = path.join(__dirname, 'test-lock-target.txt');
|
|
13
|
+
|
|
14
|
+
async function testBasicLock() {
|
|
15
|
+
console.log('\n=== Test 1: Basic Lock ===');
|
|
16
|
+
|
|
17
|
+
await withLock(testFile, async () => {
|
|
18
|
+
console.log('Lock acquired, writing to file...');
|
|
19
|
+
fs.writeFileSync(testFile, 'Test content', 'utf-8');
|
|
20
|
+
console.log('File written');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
console.log('Lock released');
|
|
24
|
+
console.log('File content:', fs.readFileSync(testFile, 'utf-8'));
|
|
25
|
+
console.log('✓ Basic lock test passed');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function testIsLocked() {
|
|
29
|
+
console.log('\n=== Test 2: Check Lock Status ===');
|
|
30
|
+
|
|
31
|
+
const beforeLock = await isLocked(testFile);
|
|
32
|
+
console.log('Locked before:', beforeLock);
|
|
33
|
+
|
|
34
|
+
const lockPromise = withLock(testFile, async () => {
|
|
35
|
+
console.log('Lock held for 1 second...');
|
|
36
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Wait for lock to be acquired
|
|
40
|
+
await new Promise(r => setTimeout(r, 100));
|
|
41
|
+
|
|
42
|
+
const duringLock = await isLocked(testFile);
|
|
43
|
+
console.log('Locked during:', duringLock);
|
|
44
|
+
|
|
45
|
+
await lockPromise;
|
|
46
|
+
|
|
47
|
+
await new Promise(r => setTimeout(r, 100));
|
|
48
|
+
const afterLock = await isLocked(testFile);
|
|
49
|
+
console.log('Locked after:', afterLock);
|
|
50
|
+
|
|
51
|
+
if (!beforeLock && duringLock && !afterLock) {
|
|
52
|
+
console.log('✓ Lock status test passed');
|
|
53
|
+
} else {
|
|
54
|
+
console.log('✗ Lock status test failed');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function testIfUnlocked() {
|
|
59
|
+
console.log('\n=== Test 3: If Unlocked Pattern ===');
|
|
60
|
+
|
|
61
|
+
// First call should succeed (file not locked)
|
|
62
|
+
const result1 = await ifUnlocked(testFile, async () => {
|
|
63
|
+
console.log('File was unlocked, writing...');
|
|
64
|
+
fs.writeFileSync(testFile, 'Written by ifUnlocked', 'utf-8');
|
|
65
|
+
return 'success';
|
|
66
|
+
}, 'fallback');
|
|
67
|
+
|
|
68
|
+
console.log('Result 1:', result1);
|
|
69
|
+
|
|
70
|
+
// Lock the file and try again
|
|
71
|
+
const lockPromise = withLock(testFile, async () => {
|
|
72
|
+
await new Promise(r => setTimeout(r, 500));
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await new Promise(r => setTimeout(r, 50));
|
|
76
|
+
|
|
77
|
+
const result2 = await ifUnlocked(testFile, async () => {
|
|
78
|
+
return 'should-not-reach';
|
|
79
|
+
}, 'fallback-value');
|
|
80
|
+
|
|
81
|
+
console.log('Result 2 (while locked):', result2);
|
|
82
|
+
|
|
83
|
+
await lockPromise;
|
|
84
|
+
|
|
85
|
+
if (result1 === 'success' && result2 === 'fallback-value') {
|
|
86
|
+
console.log('✓ IfUnlocked test passed');
|
|
87
|
+
} else {
|
|
88
|
+
console.log('✗ IfUnlocked test failed');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function runTests() {
|
|
93
|
+
try {
|
|
94
|
+
await testBasicLock();
|
|
95
|
+
await testIsLocked();
|
|
96
|
+
await testIfUnlocked();
|
|
97
|
+
|
|
98
|
+
console.log('\n' + '='.repeat(50));
|
|
99
|
+
console.log('File Lock test COMPLETE ✓');
|
|
100
|
+
console.log('='.repeat(50));
|
|
101
|
+
} catch (err) {
|
|
102
|
+
console.error('Test failed:', err);
|
|
103
|
+
process.exit(1);
|
|
104
|
+
} finally {
|
|
105
|
+
// Cleanup
|
|
106
|
+
if (fs.existsSync(testFile)) {
|
|
107
|
+
fs.unlinkSync(testFile);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
runTests();
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Test script for GSD Health Check and Timeout Exec
|
|
5
|
+
* Run: node get-shit-done/bin/lib/test-graceful.cjs
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const HealthCheck = require('./health-check.cjs');
|
|
9
|
+
const { execWithTimeout } = require('./timeout-exec.cjs');
|
|
10
|
+
|
|
11
|
+
console.log('='.repeat(50));
|
|
12
|
+
console.log('Testing GSD Graceful Degradation...');
|
|
13
|
+
console.log('='.repeat(50));
|
|
14
|
+
|
|
15
|
+
// Test 1: Health Check
|
|
16
|
+
console.log('\n--- Test 1: Health Check ---\n');
|
|
17
|
+
|
|
18
|
+
const health = new HealthCheck();
|
|
19
|
+
const result = health.runAll();
|
|
20
|
+
|
|
21
|
+
console.log('Health Status:', result.status.toUpperCase());
|
|
22
|
+
console.log('Node Version:', result.node_version);
|
|
23
|
+
console.log('Timestamp:', result.timestamp);
|
|
24
|
+
|
|
25
|
+
if (result.warnings.length > 0) {
|
|
26
|
+
console.log('\nWarnings:');
|
|
27
|
+
result.warnings.forEach(w => console.log(` ⚠ ${w}`));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (result.issues.length > 0) {
|
|
31
|
+
console.log('\nIssues:');
|
|
32
|
+
result.issues.forEach(i => console.log(` ✗ ${i}`));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.log('\nChecks:');
|
|
36
|
+
Object.entries(result.checks).forEach(([key, value]) => {
|
|
37
|
+
const icon = value ? '✓' : '✗';
|
|
38
|
+
console.log(` ${icon} ${key}: ${value ? 'pass' : 'fail'}`);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Test 2: Timeout Exec - Success case
|
|
42
|
+
console.log('\n--- Test 2: Timeout Exec (Success) ---\n');
|
|
43
|
+
|
|
44
|
+
(async () => {
|
|
45
|
+
try {
|
|
46
|
+
const output = await execWithTimeout('node', ['--version']);
|
|
47
|
+
console.log('Node version command:', output);
|
|
48
|
+
console.log('✓ Command executed successfully');
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.error('✗ Command failed:', err.message);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Test 3: Timeout Exec - With fallback
|
|
54
|
+
console.log('\n--- Test 3: Timeout Exec (With Fallback) ---\n');
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
// This should fail (nonexistent command) but return fallback
|
|
58
|
+
const output = await execWithTimeout('nonexistent-command', [], {
|
|
59
|
+
fallback: 'fallback-value'
|
|
60
|
+
});
|
|
61
|
+
console.log('Result with fallback:', output);
|
|
62
|
+
console.log('✓ Fallback returned successfully');
|
|
63
|
+
} catch (err) {
|
|
64
|
+
console.error('✗ Command failed without fallback:', err.message);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Test 4: Timeout Exec - Timeout scenario
|
|
68
|
+
console.log('\n--- Test 4: Timeout Exec (Timeout Test) ---\n');
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
// Create a script that takes too long
|
|
72
|
+
const { writeFileSync } = require('fs');
|
|
73
|
+
const { join } = require('path');
|
|
74
|
+
const tempScript = join(__dirname, 'temp-sleep.js');
|
|
75
|
+
writeFileSync(tempScript, 'setTimeout(() => console.log("done"), 3000);');
|
|
76
|
+
|
|
77
|
+
const output = await execWithTimeout('node', [tempScript], {
|
|
78
|
+
timeout: 1000,
|
|
79
|
+
fallback: 'timed-out-fallback'
|
|
80
|
+
});
|
|
81
|
+
console.log('Result after timeout:', output);
|
|
82
|
+
console.log('✓ Timeout handled with fallback');
|
|
83
|
+
|
|
84
|
+
// Cleanup
|
|
85
|
+
require('fs').unlinkSync(tempScript);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.error('Timeout test error:', err.message);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log('\n' + '='.repeat(50));
|
|
91
|
+
console.log('Graceful Degradation test COMPLETE ✓');
|
|
92
|
+
console.log('='.repeat(50));
|
|
93
|
+
})();
|