forge-dev-framework 1.0.1 → 1.2.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/.claude/commands/forge/README.md +281 -0
- package/.claude/commands/forge/add-phase.md +90 -0
- package/.claude/commands/forge/complete-milestone.md +130 -0
- package/.claude/commands/forge/config.md +115 -0
- package/.claude/commands/forge/convert.md +31 -0
- package/.claude/commands/forge/debug.md +31 -0
- package/.claude/commands/forge/discuss.md +78 -0
- package/.claude/commands/forge/execute.md +85 -0
- package/.claude/commands/forge/generate.md +21 -0
- package/.claude/commands/forge/help.md +18 -0
- package/.claude/commands/forge/init.md +21 -0
- package/.claude/commands/forge/insert-phase.md +99 -0
- package/.claude/commands/forge/new-milestone.md +114 -0
- package/.claude/commands/forge/new-project.md +24 -0
- package/.claude/commands/forge/pause-work.md +111 -0
- package/.claude/commands/forge/plan.md +129 -0
- package/.claude/commands/forge/quick.md +41 -0
- package/.claude/commands/forge/remove-phase.md +92 -0
- package/.claude/commands/forge/resume.md +22 -0
- package/.claude/commands/forge/status.md +87 -0
- package/.claude/commands/forge/team-add.md +24 -0
- package/.claude/commands/forge/team-create.md +22 -0
- package/.claude/commands/forge/team-remove.md +24 -0
- package/.claude/commands/forge/team-start.md +22 -0
- package/.claude/commands/forge/team-view.md +18 -0
- package/.claude/commands/forge/verify.md +95 -0
- package/.claude/hooks/forge-context-cleanup.cjs +79 -0
- package/.claude/hooks/forge-event-guard.cjs +36 -0
- package/.claude/hooks/forge-size-guard.cjs +55 -0
- package/.claude/rules/api-patterns.md +13 -98
- package/.claude/rules/context-efficiency.md +10 -0
- package/.claude/rules/security-baseline.md +18 -204
- package/.claude/rules/testing-standards.md +16 -177
- package/.claude/rules/ui-conventions.md +17 -142
- package/README.md +1 -0
- package/bin/forge.js +5 -3
- package/dist/bin/forge.js +5 -3
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +15 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/convert.d.ts +6 -0
- package/dist/commands/convert.d.ts.map +1 -0
- package/dist/commands/convert.js +132 -0
- package/dist/commands/convert.js.map +1 -0
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +3 -2
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/index.d.ts +4 -4
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +4 -4
- package/dist/commands/index.js.map +1 -1
- package/dist/generators/gsd-converter.d.ts +100 -0
- package/dist/generators/gsd-converter.d.ts.map +1 -0
- package/dist/generators/gsd-converter.js +335 -0
- package/dist/generators/gsd-converter.js.map +1 -0
- package/dist/templates/.claude/rules/api-patterns.md.template +212 -0
- package/dist/templates/.claude/rules/security-baseline.md.template +322 -0
- package/dist/templates/.claude/rules/testing-standards.md.template +280 -0
- package/dist/templates/.claude/rules/ui-conventions.md.template +264 -0
- package/dist/templates/.planning/forge.config.json.template +75 -0
- package/dist/templates/CLAUDE.md.template +161 -0
- package/dist/templates/PLAN.md.template +177 -0
- package/dist/templates/PROJECT.md.template +156 -0
- package/dist/templates/REQUIREMENTS.md.template +221 -0
- package/dist/templates/ROADMAP.md.template +130 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -2
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +5 -5
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +5 -5
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/template-client.d.ts.map +1 -1
- package/dist/utils/template-client.js +3 -2
- package/dist/utils/template-client.js.map +1 -1
- package/package.json +6 -4
- package/dist/git/__tests__/worktree.test.d.ts +0 -5
- package/dist/git/__tests__/worktree.test.d.ts.map +0 -1
- package/dist/git/__tests__/worktree.test.js +0 -121
- package/dist/git/__tests__/worktree.test.js.map +0 -1
- package/dist/git/codeowners.d.ts +0 -101
- package/dist/git/codeowners.d.ts.map +0 -1
- package/dist/git/codeowners.js +0 -216
- package/dist/git/codeowners.js.map +0 -1
- package/dist/git/commit.d.ts +0 -135
- package/dist/git/commit.d.ts.map +0 -1
- package/dist/git/commit.js +0 -223
- package/dist/git/commit.js.map +0 -1
- package/dist/git/hooks/commit-msg.d.ts +0 -8
- package/dist/git/hooks/commit-msg.d.ts.map +0 -1
- package/dist/git/hooks/commit-msg.js +0 -34
- package/dist/git/hooks/commit-msg.js.map +0 -1
- package/dist/git/hooks/pre-commit.d.ts +0 -8
- package/dist/git/hooks/pre-commit.d.ts.map +0 -1
- package/dist/git/hooks/pre-commit.js +0 -34
- package/dist/git/hooks/pre-commit.js.map +0 -1
- package/dist/git/pre-commit-hooks.d.ts +0 -117
- package/dist/git/pre-commit-hooks.d.ts.map +0 -1
- package/dist/git/pre-commit-hooks.js +0 -270
- package/dist/git/pre-commit-hooks.js.map +0 -1
- package/dist/git/wipe-protocol.d.ts +0 -281
- package/dist/git/wipe-protocol.d.ts.map +0 -1
- package/dist/git/wipe-protocol.js +0 -237
- package/dist/git/wipe-protocol.js.map +0 -1
- package/dist/git/worktree.d.ts +0 -69
- package/dist/git/worktree.d.ts.map +0 -1
- package/dist/git/worktree.js +0 -202
- package/dist/git/worktree.js.map +0 -1
package/dist/git/commit.js
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Atomic Commit Enforcement for FORGE
|
|
3
|
-
*
|
|
4
|
-
* Enforces conventional commit format with task ID in scope:
|
|
5
|
-
* type(scope): description
|
|
6
|
-
*
|
|
7
|
-
* Examples:
|
|
8
|
-
* - feat(api-003): implement session authentication
|
|
9
|
-
* - fix(ui-002): resolve login form validation bug
|
|
10
|
-
* - test(core-001): add database integration tests
|
|
11
|
-
* - docs(readme): update installation instructions
|
|
12
|
-
*
|
|
13
|
-
* Rules:
|
|
14
|
-
* - Every task = one commit
|
|
15
|
-
* - Commit message MUST include task ID in scope
|
|
16
|
-
* - Pre-commit hooks validate format
|
|
17
|
-
* - Reject commits that don't match pattern
|
|
18
|
-
*/
|
|
19
|
-
import { z } from "zod";
|
|
20
|
-
// Conventional commit types
|
|
21
|
-
export const CommitType = z.enum([
|
|
22
|
-
"feat",
|
|
23
|
-
"fix",
|
|
24
|
-
"docs",
|
|
25
|
-
"style",
|
|
26
|
-
"refactor",
|
|
27
|
-
"perf",
|
|
28
|
-
"test",
|
|
29
|
-
"chore",
|
|
30
|
-
"revert",
|
|
31
|
-
]);
|
|
32
|
-
// Commit message format: type(scope): description
|
|
33
|
-
// Scope MUST be a task ID (e.g., api-003, ui-002)
|
|
34
|
-
const COMMIT_PATTERN = /^([a-z]+)\(([a-z]+-[0-9]+)\):\s+(.+)$/;
|
|
35
|
-
export class CommitFormatError extends Error {
|
|
36
|
-
commitMessage;
|
|
37
|
-
constructor(message, commitMessage) {
|
|
38
|
-
super(message);
|
|
39
|
-
this.commitMessage = commitMessage;
|
|
40
|
-
this.name = "CommitFormatError";
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Parse a commit message into its components.
|
|
45
|
-
*
|
|
46
|
-
* @param message - The commit message to parse
|
|
47
|
-
* @returns Parsed commit components
|
|
48
|
-
* @throws CommitFormatError if format is invalid
|
|
49
|
-
*/
|
|
50
|
-
export function parseCommitMessage(message) {
|
|
51
|
-
const match = message.match(COMMIT_PATTERN);
|
|
52
|
-
if (!match) {
|
|
53
|
-
throw new CommitFormatError(`Commit message must follow format "type(scope): description". Got: "${message}"`, message);
|
|
54
|
-
}
|
|
55
|
-
const [, typeRaw, scope, description] = match;
|
|
56
|
-
// Validate commit type
|
|
57
|
-
const typeResult = CommitType.safeParse(typeRaw);
|
|
58
|
-
if (!typeResult.success) {
|
|
59
|
-
throw new CommitFormatError(`Invalid commit type "${typeRaw}". Must be one of: ${CommitType.options.join(", ")}`, message);
|
|
60
|
-
}
|
|
61
|
-
// Validate scope format (task ID: domain-number)
|
|
62
|
-
if (!/^[a-z]+-[0-9]+$/.test(scope)) {
|
|
63
|
-
throw new CommitFormatError(`Invalid scope "${scope}". Scope must be a task ID in format "domain-number" (e.g., api-003)`, message);
|
|
64
|
-
}
|
|
65
|
-
// Validate description is not empty
|
|
66
|
-
if (!description || description.trim().length === 0) {
|
|
67
|
-
throw new CommitFormatError(`Commit description cannot be empty`, message);
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
type: typeResult.data,
|
|
71
|
-
scope,
|
|
72
|
-
description,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Format a commit message from components.
|
|
77
|
-
*
|
|
78
|
-
* @param type - Commit type
|
|
79
|
-
* @param scope - Task ID (e.g., api-003)
|
|
80
|
-
* @param description - Commit description
|
|
81
|
-
* @returns Formatted commit message
|
|
82
|
-
*/
|
|
83
|
-
export function formatCommitMessage(type, scope, description) {
|
|
84
|
-
return `${type}(${scope}): ${description}`;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Validate a commit message against FORGE standards.
|
|
88
|
-
*
|
|
89
|
-
* @param message - The commit message to validate
|
|
90
|
-
* @returns True if valid
|
|
91
|
-
* @throws CommitFormatError if invalid
|
|
92
|
-
*/
|
|
93
|
-
export function validateCommitMessage(message) {
|
|
94
|
-
parseCommitMessage(message);
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Check if a commit message is for a specific task.
|
|
99
|
-
*
|
|
100
|
-
* @param message - The commit message
|
|
101
|
-
* @param taskId - The task ID to check
|
|
102
|
-
* @returns True if the commit is for the specified task
|
|
103
|
-
*/
|
|
104
|
-
export function isCommitForTask(message, taskId) {
|
|
105
|
-
try {
|
|
106
|
-
const parsed = parseCommitMessage(message);
|
|
107
|
-
return parsed.scope === taskId;
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Extract task ID from a commit message.
|
|
115
|
-
*
|
|
116
|
-
* @param message - The commit message
|
|
117
|
-
* @returns Task ID or null if format is invalid
|
|
118
|
-
*/
|
|
119
|
-
export function extractTaskId(message) {
|
|
120
|
-
try {
|
|
121
|
-
const parsed = parseCommitMessage(message);
|
|
122
|
-
return parsed.scope;
|
|
123
|
-
}
|
|
124
|
-
catch {
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Create a full commit message with optional body and footer.
|
|
130
|
-
*
|
|
131
|
-
* @param options - Commit message components
|
|
132
|
-
* @returns Formatted commit message
|
|
133
|
-
*/
|
|
134
|
-
export function createCommitMessage(options) {
|
|
135
|
-
const { type, taskId, description, body, footer } = options;
|
|
136
|
-
let message = formatCommitMessage(type, taskId, description);
|
|
137
|
-
if (body) {
|
|
138
|
-
message += `\n\n${body}`;
|
|
139
|
-
}
|
|
140
|
-
if (footer) {
|
|
141
|
-
message += `\n\n${footer}`;
|
|
142
|
-
}
|
|
143
|
-
return message;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Batch validate multiple commit messages.
|
|
147
|
-
*
|
|
148
|
-
* Useful for pre-commit hooks that check all staged commits.
|
|
149
|
-
*
|
|
150
|
-
* @param messages - Array of commit messages
|
|
151
|
-
* @returns Object with validation results
|
|
152
|
-
*/
|
|
153
|
-
export function validateCommitMessages(messages) {
|
|
154
|
-
const errors = [];
|
|
155
|
-
for (const message of messages) {
|
|
156
|
-
try {
|
|
157
|
-
validateCommitMessage(message);
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
if (error instanceof CommitFormatError) {
|
|
161
|
-
errors.push({
|
|
162
|
-
message,
|
|
163
|
-
error: error.message,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
valid: errors.length === 0,
|
|
170
|
-
errors,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Generate a commit message from task information.
|
|
175
|
-
*
|
|
176
|
-
* This is a helper for agents to generate properly formatted commits.
|
|
177
|
-
*
|
|
178
|
-
* @param taskId - The task ID
|
|
179
|
-
* @param taskTitle - The task title (will be converted to description)
|
|
180
|
-
* @param type - Commit type (defaults to "feat")
|
|
181
|
-
* @returns Formatted commit message
|
|
182
|
-
*/
|
|
183
|
-
export function generateCommitFromTask(taskId, taskTitle, type = "feat") {
|
|
184
|
-
// Convert task title to commit description
|
|
185
|
-
// Lowercase first letter if it's capitalized
|
|
186
|
-
const description = taskTitle.charAt(0).toLowerCase() + taskTitle.slice(1);
|
|
187
|
-
return formatCommitMessage(type, taskId, description);
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Validate a commit for pre-commit hook usage.
|
|
191
|
-
*
|
|
192
|
-
* This is the main entry point for pre-commit hooks.
|
|
193
|
-
*
|
|
194
|
-
* @param message - The commit message to validate
|
|
195
|
-
* @param expectedTaskId - Optional expected task ID
|
|
196
|
-
* @returns Validation result
|
|
197
|
-
*/
|
|
198
|
-
export function validateForPreCommit(message, expectedTaskId) {
|
|
199
|
-
const errors = [];
|
|
200
|
-
let taskId = null;
|
|
201
|
-
try {
|
|
202
|
-
const parsed = parseCommitMessage(message);
|
|
203
|
-
taskId = parsed.scope;
|
|
204
|
-
// If expected task ID is provided, check for match
|
|
205
|
-
if (expectedTaskId && parsed.scope !== expectedTaskId) {
|
|
206
|
-
errors.push(`Commit scope "${parsed.scope}" does not match expected task ID "${expectedTaskId}"`);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
if (error instanceof CommitFormatError) {
|
|
211
|
-
errors.push(error.message);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
errors.push("Unknown validation error");
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return {
|
|
218
|
-
isValid: errors.length === 0,
|
|
219
|
-
taskId,
|
|
220
|
-
errors,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
//# sourceMappingURL=commit.js.map
|
package/dist/git/commit.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commit.js","sourceRoot":"","sources":["../../src/git/commit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4BAA4B;AAC5B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC;IAC/B,MAAM;IACN,KAAK;IACL,MAAM;IACN,OAAO;IACP,UAAU;IACV,MAAM;IACN,MAAM;IACN,OAAO;IACP,QAAQ;CACT,CAAC,CAAC;AAIH,kDAAkD;AAClD,kDAAkD;AAClD,MAAM,cAAc,GAAG,uCAAuC,CAAC;AAE/D,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACG;IAA7C,YAAY,OAAe,EAAkB,aAAqB;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,kBAAa,GAAb,aAAa,CAAQ;QAEhE,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAWD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAE5C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,iBAAiB,CACzB,uEAAuE,OAAO,GAAG,EACjF,OAAO,CACR,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC;IAE9C,uBAAuB;IACvB,MAAM,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,iBAAiB,CACzB,wBAAwB,OAAO,sBAAsB,UAAU,CAAC,OAAO,C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AC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3E,OAAO,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACxD,CAAC;AAWD;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAe,EACf,cAAuB;IAEvB,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,MAAM,GAAkB,IAAI,CAAC;IAEjC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAEtB,mDAAmD;QACnD,IAAI,cAAc,IAAI,MAAM,CAAC,KAAK,KAAK,cAAc,EAAE,CAAC;YACtD,MAAM,CAAC,IAAI,CACT,iBAAiB,MAAM,CAAC,KAAK,sCAAsC,cAAc,GAAG,CACrF,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,iBAAiB,EAAE,CAAC;YACvC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC5B,MAAM;QACN,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commit-msg.d.ts","sourceRoot":"","sources":["../../../src/git/hooks/commit-msg.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Commit Message Hook Implementation
|
|
3
|
-
*
|
|
4
|
-
* This is the TypeScript file that the shell hook calls.
|
|
5
|
-
* It validates the commit message format.
|
|
6
|
-
*/
|
|
7
|
-
import { readFileSync } from "node:fs";
|
|
8
|
-
import { runCommitMsgValidation } from "../pre-commit-hooks.js";
|
|
9
|
-
async function main() {
|
|
10
|
-
// Get commit message from the temp file (git passes it as first arg)
|
|
11
|
-
const commitMsgFile = process.argv[2];
|
|
12
|
-
if (!commitMsgFile) {
|
|
13
|
-
console.error("Usage: commit-msg <commit-message-file>");
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
const commitMessage = readFileSync(commitMsgFile, "utf-8").trim();
|
|
17
|
-
// Validate commit message
|
|
18
|
-
const result = runCommitMsgValidation(commitMessage);
|
|
19
|
-
if (!result.isValid) {
|
|
20
|
-
console.error("❌ FORGE Commit Message Validation Failed:\n");
|
|
21
|
-
for (const error of result.errors) {
|
|
22
|
-
console.error(` - ${error}\n`);
|
|
23
|
-
}
|
|
24
|
-
console.error("Commit message must follow format: type(scope): description\n" +
|
|
25
|
-
"Example: feat(api-003): implement session authentication");
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
process.exit(0);
|
|
29
|
-
}
|
|
30
|
-
main().catch((error) => {
|
|
31
|
-
console.error("Commit-msg hook error:", error);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=commit-msg.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commit-msg.js","sourceRoot":"","sources":["../../../src/git/hooks/commit-msg.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,KAAK,UAAU,IAAI;IACjB,qEAAqE;IACrE,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEtC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,aAAa,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAElE,0BAA0B;IAC1B,MAAM,MAAM,GAAG,sBAAsB,CAAC,aAAa,CAAC,CAAC;IAErD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAC7D,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,CAAC,KAAK,CACX,+DAA+D;YAC7D,0DAA0D,CAC7D,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pre-commit.d.ts","sourceRoot":"","sources":["../../../src/git/hooks/pre-commit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pre-commit Hook Implementation
|
|
3
|
-
*
|
|
4
|
-
* This is the TypeScript file that the shell hook calls.
|
|
5
|
-
* It runs all pre-commit validations and blocks commits that fail.
|
|
6
|
-
*/
|
|
7
|
-
import { runPreCommitValidations, loadPreCommitContext, parseTaskIdFromBranch } from "../pre-commit-hooks.js";
|
|
8
|
-
async function main() {
|
|
9
|
-
// Get the task ID from the branch name
|
|
10
|
-
const taskId = await parseTaskIdFromBranch();
|
|
11
|
-
if (!taskId) {
|
|
12
|
-
// Not a FORGE branch, allow commit
|
|
13
|
-
process.exit(0);
|
|
14
|
-
}
|
|
15
|
-
// Load validation context from state
|
|
16
|
-
const context = await loadPreCommitContext(taskId);
|
|
17
|
-
// Run validations
|
|
18
|
-
const result = await runPreCommitValidations(context);
|
|
19
|
-
if (!result.isValid) {
|
|
20
|
-
console.error("❌ FORGE Pre-commit Validations Failed:\n");
|
|
21
|
-
for (const error of result.errors) {
|
|
22
|
-
console.error(` - ${error}\n`);
|
|
23
|
-
}
|
|
24
|
-
console.error("Commit blocked. Fix the issues and try again.");
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
console.log("✅ FORGE Pre-commit Validations Passed.");
|
|
28
|
-
process.exit(0);
|
|
29
|
-
}
|
|
30
|
-
main().catch((error) => {
|
|
31
|
-
console.error("Pre-commit hook error:", error);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=pre-commit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pre-commit.js","sourceRoot":"","sources":["../../../src/git/hooks/pre-commit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE9G,KAAK,UAAU,IAAI;IACjB,uCAAuC;IACvC,MAAM,MAAM,GAAG,MAAM,qBAAqB,EAAE,CAAC;IAE7C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,mCAAmC;QACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,qCAAqC;IACrC,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAEnD,kBAAkB;IAClB,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAEtD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1D,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;IACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pre-commit Hooks for FORGE
|
|
3
|
-
*
|
|
4
|
-
* Creates hooks to enforce:
|
|
5
|
-
* - Out-of-scope file detection (agent tried to write outside allowedPaths)
|
|
6
|
-
* - Commit message format validation
|
|
7
|
-
* - Test execution requirement (if tests defined for task)
|
|
8
|
-
* - Contract file validation (if contract referenced)
|
|
9
|
-
*
|
|
10
|
-
* These hooks are installed to .git/hooks/ and run before each commit.
|
|
11
|
-
*/
|
|
12
|
-
export interface PreCommitContext {
|
|
13
|
-
taskId?: string;
|
|
14
|
-
allowedPaths?: string[];
|
|
15
|
-
requiredTests?: string[];
|
|
16
|
-
requiredContracts?: string[];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Generate the pre-commit hook script.
|
|
20
|
-
*
|
|
21
|
-
* This shell script is installed to .git/hooks/pre-commit.
|
|
22
|
-
*/
|
|
23
|
-
export declare function generatePreCommitScript(): string;
|
|
24
|
-
/**
|
|
25
|
-
* Generate the commit-msg hook script.
|
|
26
|
-
*
|
|
27
|
-
* This shell script is installed to .git/hooks/commit-msg.
|
|
28
|
-
*/
|
|
29
|
-
export declare function generateCommitMsgScript(): string;
|
|
30
|
-
/**
|
|
31
|
-
* Install pre-commit hooks to the .git/hooks directory.
|
|
32
|
-
*
|
|
33
|
-
* @param basePath - Root of the FORGE project
|
|
34
|
-
*/
|
|
35
|
-
export declare function installHooks(basePath?: string): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Check if files are within allowed paths.
|
|
38
|
-
*
|
|
39
|
-
* @param files - Files to check
|
|
40
|
-
* @param allowedPaths - Allowed path patterns
|
|
41
|
-
* @returns Validation result
|
|
42
|
-
*/
|
|
43
|
-
export declare function checkFileScope(files: string[], allowedPaths: string[]): {
|
|
44
|
-
isValid: boolean;
|
|
45
|
-
outOfScopeFiles: string[];
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* Get staged files for a commit.
|
|
49
|
-
*
|
|
50
|
-
* @returns Array of staged file paths
|
|
51
|
-
*/
|
|
52
|
-
export declare function getStagedFiles(): Promise<string[]>;
|
|
53
|
-
/**
|
|
54
|
-
* Validate that required contracts exist and are valid.
|
|
55
|
-
*
|
|
56
|
-
* @param contracts - Contract file paths to validate
|
|
57
|
-
* @param basePath - Root of the FORGE project
|
|
58
|
-
* @returns Validation result
|
|
59
|
-
*/
|
|
60
|
-
export declare function validateContracts(contracts: string[], basePath?: string): Promise<{
|
|
61
|
-
isValid: boolean;
|
|
62
|
-
errors: string[];
|
|
63
|
-
}>;
|
|
64
|
-
/**
|
|
65
|
-
* Run tests and check if they pass.
|
|
66
|
-
*
|
|
67
|
-
* @param testCommands - Test commands to run (e.g., ["npm test -- --grep 'session auth'"])
|
|
68
|
-
* @returns Test result
|
|
69
|
-
*/
|
|
70
|
-
export declare function runRequiredTests(testCommands: string[]): Promise<{
|
|
71
|
-
passed: boolean;
|
|
72
|
-
output: string;
|
|
73
|
-
}>;
|
|
74
|
-
/**
|
|
75
|
-
* Run all pre-commit validations.
|
|
76
|
-
*
|
|
77
|
-
* This is the main entry point for the pre-commit hook.
|
|
78
|
-
*
|
|
79
|
-
* @param context - Pre-commit validation context
|
|
80
|
-
* @returns Validation result with errors
|
|
81
|
-
*/
|
|
82
|
-
export declare function runPreCommitValidations(context: PreCommitContext): Promise<{
|
|
83
|
-
isValid: boolean;
|
|
84
|
-
errors: string[];
|
|
85
|
-
}>;
|
|
86
|
-
/**
|
|
87
|
-
* Run commit message validation.
|
|
88
|
-
*
|
|
89
|
-
* This is the main entry point for the commit-msg hook.
|
|
90
|
-
*
|
|
91
|
-
* @param message - Commit message to validate
|
|
92
|
-
* @param expectedTaskId - Expected task ID (optional)
|
|
93
|
-
* @returns Validation result
|
|
94
|
-
*/
|
|
95
|
-
export declare function runCommitMsgValidation(message: string, expectedTaskId?: string): {
|
|
96
|
-
isValid: boolean;
|
|
97
|
-
errors: string[];
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Read pre-commit context from task state.
|
|
101
|
-
*
|
|
102
|
-
* This loads the validation rules from the FORGE state.
|
|
103
|
-
*
|
|
104
|
-
* @param taskId - Task ID to load context for
|
|
105
|
-
* @param basePath - Root of the FORGE project
|
|
106
|
-
* @returns Pre-commit context
|
|
107
|
-
*/
|
|
108
|
-
export declare function loadPreCommitContext(taskId: string, basePath?: string): Promise<PreCommitContext>;
|
|
109
|
-
/**
|
|
110
|
-
* Parse task ID from the current branch name.
|
|
111
|
-
*
|
|
112
|
-
* FORGE branches use format: forge/{taskId}
|
|
113
|
-
*
|
|
114
|
-
* @returns Task ID or null
|
|
115
|
-
*/
|
|
116
|
-
export declare function parseTaskIdFromBranch(): Promise<string | null>;
|
|
117
|
-
//# sourceMappingURL=pre-commit-hooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pre-commit-hooks.d.ts","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