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.
Files changed (109) hide show
  1. package/.claude/commands/forge/README.md +281 -0
  2. package/.claude/commands/forge/add-phase.md +90 -0
  3. package/.claude/commands/forge/complete-milestone.md +130 -0
  4. package/.claude/commands/forge/config.md +115 -0
  5. package/.claude/commands/forge/convert.md +31 -0
  6. package/.claude/commands/forge/debug.md +31 -0
  7. package/.claude/commands/forge/discuss.md +78 -0
  8. package/.claude/commands/forge/execute.md +85 -0
  9. package/.claude/commands/forge/generate.md +21 -0
  10. package/.claude/commands/forge/help.md +18 -0
  11. package/.claude/commands/forge/init.md +21 -0
  12. package/.claude/commands/forge/insert-phase.md +99 -0
  13. package/.claude/commands/forge/new-milestone.md +114 -0
  14. package/.claude/commands/forge/new-project.md +24 -0
  15. package/.claude/commands/forge/pause-work.md +111 -0
  16. package/.claude/commands/forge/plan.md +129 -0
  17. package/.claude/commands/forge/quick.md +41 -0
  18. package/.claude/commands/forge/remove-phase.md +92 -0
  19. package/.claude/commands/forge/resume.md +22 -0
  20. package/.claude/commands/forge/status.md +87 -0
  21. package/.claude/commands/forge/team-add.md +24 -0
  22. package/.claude/commands/forge/team-create.md +22 -0
  23. package/.claude/commands/forge/team-remove.md +24 -0
  24. package/.claude/commands/forge/team-start.md +22 -0
  25. package/.claude/commands/forge/team-view.md +18 -0
  26. package/.claude/commands/forge/verify.md +95 -0
  27. package/.claude/hooks/forge-context-cleanup.cjs +79 -0
  28. package/.claude/hooks/forge-event-guard.cjs +36 -0
  29. package/.claude/hooks/forge-size-guard.cjs +55 -0
  30. package/.claude/rules/api-patterns.md +13 -98
  31. package/.claude/rules/context-efficiency.md +10 -0
  32. package/.claude/rules/security-baseline.md +18 -204
  33. package/.claude/rules/testing-standards.md +16 -177
  34. package/.claude/rules/ui-conventions.md +17 -142
  35. package/README.md +1 -0
  36. package/bin/forge.js +5 -3
  37. package/dist/bin/forge.js +5 -3
  38. package/dist/cli/index.d.ts.map +1 -1
  39. package/dist/cli/index.js +15 -1
  40. package/dist/cli/index.js.map +1 -1
  41. package/dist/commands/convert.d.ts +6 -0
  42. package/dist/commands/convert.d.ts.map +1 -0
  43. package/dist/commands/convert.js +132 -0
  44. package/dist/commands/convert.js.map +1 -0
  45. package/dist/commands/generate.d.ts.map +1 -1
  46. package/dist/commands/generate.js +3 -2
  47. package/dist/commands/generate.js.map +1 -1
  48. package/dist/commands/index.d.ts +4 -4
  49. package/dist/commands/index.d.ts.map +1 -1
  50. package/dist/commands/index.js +4 -4
  51. package/dist/commands/index.js.map +1 -1
  52. package/dist/generators/gsd-converter.d.ts +100 -0
  53. package/dist/generators/gsd-converter.d.ts.map +1 -0
  54. package/dist/generators/gsd-converter.js +335 -0
  55. package/dist/generators/gsd-converter.js.map +1 -0
  56. package/dist/templates/.claude/rules/api-patterns.md.template +212 -0
  57. package/dist/templates/.claude/rules/security-baseline.md.template +322 -0
  58. package/dist/templates/.claude/rules/testing-standards.md.template +280 -0
  59. package/dist/templates/.claude/rules/ui-conventions.md.template +264 -0
  60. package/dist/templates/.planning/forge.config.json.template +75 -0
  61. package/dist/templates/CLAUDE.md.template +161 -0
  62. package/dist/templates/PLAN.md.template +177 -0
  63. package/dist/templates/PROJECT.md.template +156 -0
  64. package/dist/templates/REQUIREMENTS.md.template +221 -0
  65. package/dist/templates/ROADMAP.md.template +130 -0
  66. package/dist/types/index.d.ts +2 -2
  67. package/dist/types/index.d.ts.map +1 -1
  68. package/dist/types/index.js +2 -2
  69. package/dist/types/index.js.map +1 -1
  70. package/dist/utils/index.d.ts +5 -5
  71. package/dist/utils/index.d.ts.map +1 -1
  72. package/dist/utils/index.js +5 -5
  73. package/dist/utils/index.js.map +1 -1
  74. package/dist/utils/template-client.d.ts.map +1 -1
  75. package/dist/utils/template-client.js +3 -2
  76. package/dist/utils/template-client.js.map +1 -1
  77. package/package.json +6 -4
  78. package/dist/git/__tests__/worktree.test.d.ts +0 -5
  79. package/dist/git/__tests__/worktree.test.d.ts.map +0 -1
  80. package/dist/git/__tests__/worktree.test.js +0 -121
  81. package/dist/git/__tests__/worktree.test.js.map +0 -1
  82. package/dist/git/codeowners.d.ts +0 -101
  83. package/dist/git/codeowners.d.ts.map +0 -1
  84. package/dist/git/codeowners.js +0 -216
  85. package/dist/git/codeowners.js.map +0 -1
  86. package/dist/git/commit.d.ts +0 -135
  87. package/dist/git/commit.d.ts.map +0 -1
  88. package/dist/git/commit.js +0 -223
  89. package/dist/git/commit.js.map +0 -1
  90. package/dist/git/hooks/commit-msg.d.ts +0 -8
  91. package/dist/git/hooks/commit-msg.d.ts.map +0 -1
  92. package/dist/git/hooks/commit-msg.js +0 -34
  93. package/dist/git/hooks/commit-msg.js.map +0 -1
  94. package/dist/git/hooks/pre-commit.d.ts +0 -8
  95. package/dist/git/hooks/pre-commit.d.ts.map +0 -1
  96. package/dist/git/hooks/pre-commit.js +0 -34
  97. package/dist/git/hooks/pre-commit.js.map +0 -1
  98. package/dist/git/pre-commit-hooks.d.ts +0 -117
  99. package/dist/git/pre-commit-hooks.d.ts.map +0 -1
  100. package/dist/git/pre-commit-hooks.js +0 -270
  101. package/dist/git/pre-commit-hooks.js.map +0 -1
  102. package/dist/git/wipe-protocol.d.ts +0 -281
  103. package/dist/git/wipe-protocol.d.ts.map +0 -1
  104. package/dist/git/wipe-protocol.js +0 -237
  105. package/dist/git/wipe-protocol.js.map +0 -1
  106. package/dist/git/worktree.d.ts +0 -69
  107. package/dist/git/worktree.d.ts.map +0 -1
  108. package/dist/git/worktree.js +0 -202
  109. package/dist/git/worktree.js.map +0 -1
@@ -1,270 +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
- import { writeFile, mkdir } from "node:fs/promises";
13
- import { join } from "node:path";
14
- import { execa } from "execa";
15
- import { validateForPreCommit } from "./commit.js";
16
- /**
17
- * Generate the pre-commit hook script.
18
- *
19
- * This shell script is installed to .git/hooks/pre-commit.
20
- */
21
- export function generatePreCommitScript() {
22
- return `#!/bin/bash
23
- # FORGE Pre-commit Hook
24
- # Auto-generated by FORGE - DO NOT EDIT MANUALLY
25
-
26
- set -e
27
-
28
- # Get the root of the git repository
29
- REPO_ROOT=$(git rev-parse --show-toplevel)
30
-
31
- # Run the TypeScript pre-commit validator
32
- node "$REPO_ROOT/dist/git/hooks/pre-commit.js" "$@"
33
- `;
34
- }
35
- /**
36
- * Generate the commit-msg hook script.
37
- *
38
- * This shell script is installed to .git/hooks/commit-msg.
39
- */
40
- export function generateCommitMsgScript() {
41
- return `#!/bin/bash
42
- # FORGE Commit Message Hook
43
- # Auto-generated by FORGE - DO NOT EDIT MANUALLY
44
-
45
- set -e
46
-
47
- # Get the root of the git repository
48
- REPO_ROOT=$(git rev-parse --show-toplevel)
49
-
50
- # Run the TypeScript commit-msg validator
51
- node "$REPO_ROOT/dist/git/hooks/commit-msg.js" "$1"
52
- `;
53
- }
54
- /**
55
- * Install pre-commit hooks to the .git/hooks directory.
56
- *
57
- * @param basePath - Root of the FORGE project
58
- */
59
- export async function installHooks(basePath = "/home/parz/projects/forge") {
60
- const hooksDir = join(basePath, ".git", "hooks");
61
- // Ensure hooks directory exists
62
- await mkdir(hooksDir, { recursive: true });
63
- // Write pre-commit hook
64
- const preCommitPath = join(hooksDir, "pre-commit");
65
- await writeFile(preCommitPath, generatePreCommitScript(), { mode: 0o755 });
66
- // Write commit-msg hook
67
- const commitMsgPath = join(hooksDir, "commit-msg");
68
- await writeFile(commitMsgPath, generateCommitMsgScript(), { mode: 0o755 });
69
- console.log("FORGE pre-commit hooks installed.");
70
- }
71
- /**
72
- * Check if files are within allowed paths.
73
- *
74
- * @param files - Files to check
75
- * @param allowedPaths - Allowed path patterns
76
- * @returns Validation result
77
- */
78
- export function checkFileScope(files, allowedPaths) {
79
- const outOfScopeFiles = [];
80
- for (const file of files) {
81
- const isAllowed = allowedPaths.some((pattern) => {
82
- // Simple glob matching - converts gitignore-style patterns to regex
83
- const regexPattern = pattern
84
- .replace(/\*\*/g, ".*")
85
- .replace(/\*/g, "[^/]*")
86
- .replace(/\?/g, "[^/]");
87
- const regex = new RegExp(`^${regexPattern}`);
88
- return regex.test(file);
89
- });
90
- if (!isAllowed) {
91
- outOfScopeFiles.push(file);
92
- }
93
- }
94
- return {
95
- isValid: outOfScopeFiles.length === 0,
96
- outOfScopeFiles,
97
- };
98
- }
99
- /**
100
- * Get staged files for a commit.
101
- *
102
- * @returns Array of staged file paths
103
- */
104
- export async function getStagedFiles() {
105
- const { stdout } = await execa("git", ["diff", "--cached", "--name-only", "--diff-filter=ACM"]);
106
- return stdout.split("\n").filter((f) => f.length > 0);
107
- }
108
- /**
109
- * Validate that required contracts exist and are valid.
110
- *
111
- * @param contracts - Contract file paths to validate
112
- * @param basePath - Root of the FORGE project
113
- * @returns Validation result
114
- */
115
- export async function validateContracts(contracts, basePath = "/home/parz/projects/forge") {
116
- const errors = [];
117
- const { readFile } = await import("node:fs/promises");
118
- for (const contract of contracts) {
119
- const contractPath = join(basePath, contract);
120
- try {
121
- // Check if file exists
122
- await readFile(contractPath, "utf-8");
123
- // TODO: Add validation based on contract type
124
- // - OpenAPI validation for .yaml files
125
- // - TypeScript type checking for .d.ts files
126
- // - Zod schema validation
127
- }
128
- catch (error) {
129
- errors.push(`Contract file not found or invalid: ${contract}`);
130
- }
131
- }
132
- return {
133
- isValid: errors.length === 0,
134
- errors,
135
- };
136
- }
137
- /**
138
- * Run tests and check if they pass.
139
- *
140
- * @param testCommands - Test commands to run (e.g., ["npm test -- --grep 'session auth'"])
141
- * @returns Test result
142
- */
143
- export async function runRequiredTests(testCommands) {
144
- const results = [];
145
- for (const command of testCommands) {
146
- try {
147
- const { stdout, stderr } = await execa(command, { shell: true });
148
- results.push({ passed: true, output: stdout + stderr });
149
- }
150
- catch (error) {
151
- if (error instanceof Error) {
152
- results.push({ passed: false, output: error.message });
153
- }
154
- else {
155
- results.push({ passed: false, output: "Unknown error" });
156
- }
157
- }
158
- }
159
- const allPassed = results.every((r) => r.passed);
160
- const combinedOutput = results.map((r, i) => `Test ${i + 1}:\n${r.output}`).join("\n\n");
161
- return {
162
- passed: allPassed,
163
- output: combinedOutput,
164
- };
165
- }
166
- /**
167
- * Run all pre-commit validations.
168
- *
169
- * This is the main entry point for the pre-commit hook.
170
- *
171
- * @param context - Pre-commit validation context
172
- * @returns Validation result with errors
173
- */
174
- export async function runPreCommitValidations(context) {
175
- const errors = [];
176
- // 1. Get staged files
177
- const stagedFiles = await getStagedFiles();
178
- // 2. Check file scope (if allowedPaths provided)
179
- if (context.allowedPaths && context.allowedPaths.length > 0) {
180
- const scopeCheck = checkFileScope(stagedFiles, context.allowedPaths);
181
- if (!scopeCheck.isValid) {
182
- errors.push(`Out-of-scope files detected: ${scopeCheck.outOfScopeFiles.join(", ")}\n` +
183
- `Allowed paths: ${context.allowedPaths.join(", ")}`);
184
- }
185
- }
186
- // 3. Validate contracts (if required)
187
- if (context.requiredContracts && context.requiredContracts.length > 0) {
188
- const contractValidation = await validateContracts(context.requiredContracts);
189
- if (!contractValidation.isValid) {
190
- errors.push(...contractValidation.errors);
191
- }
192
- }
193
- // 4. Run required tests (if specified)
194
- if (context.requiredTests && context.requiredTests.length > 0) {
195
- const testResult = await runRequiredTests(context.requiredTests);
196
- if (!testResult.passed) {
197
- errors.push(`Required tests failed:\n${testResult.output}`);
198
- }
199
- }
200
- return {
201
- isValid: errors.length === 0,
202
- errors,
203
- };
204
- }
205
- /**
206
- * Run commit message validation.
207
- *
208
- * This is the main entry point for the commit-msg hook.
209
- *
210
- * @param message - Commit message to validate
211
- * @param expectedTaskId - Expected task ID (optional)
212
- * @returns Validation result
213
- */
214
- export function runCommitMsgValidation(message, expectedTaskId) {
215
- const result = validateForPreCommit(message, expectedTaskId);
216
- return {
217
- isValid: result.isValid,
218
- errors: result.errors,
219
- };
220
- }
221
- /**
222
- * Read pre-commit context from task state.
223
- *
224
- * This loads the validation rules from the FORGE state.
225
- *
226
- * @param taskId - Task ID to load context for
227
- * @param basePath - Root of the FORGE project
228
- * @returns Pre-commit context
229
- */
230
- export async function loadPreCommitContext(taskId, basePath = "/home/parz/projects/forge") {
231
- const { readFile } = await import("node:fs/promises");
232
- const statePath = join(basePath, "state", "STATE.json");
233
- try {
234
- const stateRaw = await readFile(statePath, "utf-8");
235
- const state = JSON.parse(stateRaw);
236
- const task = state.tasks.find((t) => t.id === taskId);
237
- if (!task) {
238
- throw new Error(`Task ${taskId} not found in STATE.json`);
239
- }
240
- return {
241
- taskId: task.id,
242
- allowedPaths: task.allowedPaths,
243
- requiredTests: task.verify,
244
- requiredContracts: task.contracts,
245
- };
246
- }
247
- catch (error) {
248
- // If state doesn't exist, return empty context
249
- return {};
250
- }
251
- }
252
- /**
253
- * Parse task ID from the current branch name.
254
- *
255
- * FORGE branches use format: forge/{taskId}
256
- *
257
- * @returns Task ID or null
258
- */
259
- export async function parseTaskIdFromBranch() {
260
- try {
261
- const { stdout } = await execa("git", ["branch", "--show-current"]);
262
- const branch = stdout.trim();
263
- const match = branch.match(/^forge\/(.+)$/);
264
- return match ? match[1] : null;
265
- }
266
- catch {
267
- return null;
268
- }
269
- }
270
- //# sourceMappingURL=pre-commit-hooks.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pre-commit-hooks.js","sourceRoot":"","sources":["../../src/git/pre-commit-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAS,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EA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,CAAC,MAAM;YAC1B,iBAAiB,EAAE,IAAI,CAAC,SAAS;SAClC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,+CAA+C;QAC/C,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;QACpE,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;QAE7B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC5C,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,281 +0,0 @@
1
- /**
2
- * The Wipe Protocol - Context Hygiene for FORGE
3
- *
4
- * Treats agent context as ephemeral, git as persistent.
5
- *
6
- * Lifecycle:
7
- * 1. Hydrate — Agent starts, reads CLAUDE.md + STATE.json + assigned task + contracts
8
- * 2. Execute — Agent writes code, runs tests within its domain
9
- * 3. Commit — Atomic git commit linked to task ID
10
- * 4. Terminate — Session ends, context wiped
11
- * 5. Reincarnate — Next task starts with fresh context, reads NEW git state
12
- */
13
- import { z } from "zod";
14
- export declare const TaskSchema: z.ZodObject<{
15
- id: z.ZodString;
16
- title: z.ZodString;
17
- ownerRole: z.ZodString;
18
- status: z.ZodEnum<["pending", "in_progress", "completed", "blocked"]>;
19
- deps: z.ZodArray<z.ZodString, "many">;
20
- allowedPaths: z.ZodArray<z.ZodString, "many">;
21
- acceptance: z.ZodArray<z.ZodString, "many">;
22
- verify: z.ZodArray<z.ZodString, "many">;
23
- commit: z.ZodNullable<z.ZodString>;
24
- requests: z.ZodArray<z.ZodString, "many">;
25
- priority: z.ZodNumber;
26
- }, "strip", z.ZodTypeAny, {
27
- status: "pending" | "in_progress" | "completed" | "blocked";
28
- allowedPaths: string[];
29
- commit: string | null;
30
- id: string;
31
- title: string;
32
- ownerRole: string;
33
- deps: string[];
34
- acceptance: string[];
35
- verify: string[];
36
- requests: string[];
37
- priority: number;
38
- }, {
39
- status: "pending" | "in_progress" | "completed" | "blocked";
40
- allowedPaths: string[];
41
- commit: string | null;
42
- id: string;
43
- title: string;
44
- ownerRole: string;
45
- deps: string[];
46
- acceptance: string[];
47
- verify: string[];
48
- requests: string[];
49
- priority: number;
50
- }>;
51
- export type Task = z.infer<typeof TaskSchema>;
52
- export declare const StateSchema: z.ZodObject<{
53
- project: z.ZodObject<{
54
- name: z.ZodString;
55
- status: z.ZodString;
56
- currentMilestone: z.ZodString;
57
- currentPhase: z.ZodNumber;
58
- }, "strip", z.ZodTypeAny, {
59
- status: string;
60
- name: string;
61
- currentMilestone: string;
62
- currentPhase: number;
63
- }, {
64
- status: string;
65
- name: string;
66
- currentMilestone: string;
67
- currentPhase: number;
68
- }>;
69
- tasks: z.ZodArray<z.ZodObject<{
70
- id: z.ZodString;
71
- title: z.ZodString;
72
- ownerRole: z.ZodString;
73
- status: z.ZodEnum<["pending", "in_progress", "completed", "blocked"]>;
74
- deps: z.ZodArray<z.ZodString, "many">;
75
- allowedPaths: z.ZodArray<z.ZodString, "many">;
76
- acceptance: z.ZodArray<z.ZodString, "many">;
77
- verify: z.ZodArray<z.ZodString, "many">;
78
- commit: z.ZodNullable<z.ZodString>;
79
- requests: z.ZodArray<z.ZodString, "many">;
80
- priority: z.ZodNumber;
81
- }, "strip", z.ZodTypeAny, {
82
- status: "pending" | "in_progress" | "completed" | "blocked";
83
- allowedPaths: string[];
84
- commit: string | null;
85
- id: string;
86
- title: string;
87
- ownerRole: string;
88
- deps: string[];
89
- acceptance: string[];
90
- verify: string[];
91
- requests: string[];
92
- priority: number;
93
- }, {
94
- status: "pending" | "in_progress" | "completed" | "blocked";
95
- allowedPaths: string[];
96
- commit: string | null;
97
- id: string;
98
- title: string;
99
- ownerRole: string;
100
- deps: string[];
101
- acceptance: string[];
102
- verify: string[];
103
- requests: string[];
104
- priority: number;
105
- }>, "many">;
106
- contracts: z.ZodArray<z.ZodObject<{
107
- id: z.ZodString;
108
- path: z.ZodString;
109
- version: z.ZodString;
110
- publishedBy: z.ZodString;
111
- consumers: z.ZodArray<z.ZodString, "many">;
112
- }, "strip", z.ZodTypeAny, {
113
- path: string;
114
- id: string;
115
- version: string;
116
- publishedBy: string;
117
- consumers: string[];
118
- }, {
119
- path: string;
120
- id: string;
121
- version: string;
122
- publishedBy: string;
123
- consumers: string[];
124
- }>, "many">;
125
- eventsPointer: z.ZodString;
126
- }, "strip", z.ZodTypeAny, {
127
- project: {
128
- status: string;
129
- name: string;
130
- currentMilestone: string;
131
- currentPhase: number;
132
- };
133
- tasks: {
134
- status: "pending" | "in_progress" | "completed" | "blocked";
135
- allowedPaths: string[];
136
- commit: string | null;
137
- id: string;
138
- title: string;
139
- ownerRole: string;
140
- deps: string[];
141
- acceptance: string[];
142
- verify: string[];
143
- requests: string[];
144
- priority: number;
145
- }[];
146
- contracts: {
147
- path: string;
148
- id: string;
149
- version: string;
150
- publishedBy: string;
151
- consumers: string[];
152
- }[];
153
- eventsPointer: string;
154
- }, {
155
- project: {
156
- status: string;
157
- name: string;
158
- currentMilestone: string;
159
- currentPhase: number;
160
- };
161
- tasks: {
162
- status: "pending" | "in_progress" | "completed" | "blocked";
163
- allowedPaths: string[];
164
- commit: string | null;
165
- id: string;
166
- title: string;
167
- ownerRole: string;
168
- deps: string[];
169
- acceptance: string[];
170
- verify: string[];
171
- requests: string[];
172
- priority: number;
173
- }[];
174
- contracts: {
175
- path: string;
176
- id: string;
177
- version: string;
178
- publishedBy: string;
179
- consumers: string[];
180
- }[];
181
- eventsPointer: string;
182
- }>;
183
- export type State = z.infer<typeof StateSchema>;
184
- export interface HydrateContext {
185
- claudeRules: string;
186
- state: State;
187
- task: Task;
188
- contracts: Map<string, string>;
189
- }
190
- /**
191
- * Phase 1: Hydrate
192
- *
193
- * Agent starts. Reads all necessary context from the repository.
194
- * This is the ONLY state the agent receives - no conversation history.
195
- *
196
- * @param taskId - The task ID to hydrate for
197
- * @param basePath - Root of the FORGE project
198
- * @returns Hydration context with all necessary artifacts
199
- */
200
- export declare function hydrate(taskId: string, basePath?: string): Promise<HydrateContext>;
201
- /**
202
- * Phase 2: Execute
203
- *
204
- * Agent writes code, runs tests within its domain.
205
- * This is where the actual work happens.
206
- *
207
- * Note: This function is a placeholder - the actual execution
208
- * is done by the agent teammate. We just provide the isolation
209
- * context (worktree) and validation (allowedPaths).
210
- *
211
- * @param taskId - The task ID being executed
212
- * @param basePath - Root of the FORGE project
213
- * @returns Path to the worktree for execution
214
- */
215
- export declare function execute(taskId: string, basePath?: string): Promise<string>;
216
- /**
217
- * Validate that files are within allowed paths for a task.
218
- *
219
- * Enforces the CODEOWNERS boundary - agents can only write
220
- * within their assigned domain.
221
- *
222
- * @param files - Files to validate
223
- * @param allowedPaths - Allowed path patterns
224
- * @throws Error if any file is out of scope
225
- */
226
- export declare function validateScope(files: string[], allowedPaths: string[]): void;
227
- /**
228
- * Phase 3: Commit
229
- *
230
- * Atomic git commit linked to task ID.
231
- * Every task MUST result in exactly one commit.
232
- *
233
- * Format: type(scope): description
234
- * Example: feat(api-003): implement session authentication
235
- *
236
- * @param taskId - The task ID
237
- * @param message - Commit message (will be formatted)
238
- * @param basePath - Root of the FORGE project
239
- * @returns The commit hash
240
- */
241
- export declare function commitTask(taskId: string, message: string, basePath?: string): Promise<string>;
242
- /**
243
- * Phase 4: Terminate
244
- *
245
- * Session ends. Context is wiped clean.
246
- * The agent's conversation history is discarded.
247
- *
248
- * Note: In Agent Teams, this happens naturally when the agent
249
- * exits. We just need to ensure the worktree is cleaned up.
250
- *
251
- * @param taskId - The task ID
252
- * @param keepWorktree - Whether to keep the worktree (for debugging)
253
- */
254
- export declare function terminate(taskId: string, keepWorktree?: boolean): Promise<void>;
255
- /**
256
- * Phase 5: Reincarnate
257
- *
258
- * Next task starts with fresh context, reading the NEW git state.
259
- *
260
- * This happens naturally when a new agent spawns - they start
261
- * with a fresh context window and hydrate() to read current state.
262
- *
263
- * @param nextTaskId - The next task ID to work on
264
- * @param basePath - Root of the FORGE project
265
- * @returns Hydration context for the next task
266
- */
267
- export declare function reincarnate(nextTaskId: string, basePath?: string): Promise<HydrateContext>;
268
- /**
269
- * Execute the full Wipe Protocol lifecycle for a task.
270
- *
271
- * This is the main entry point that orchestrates all phases.
272
- * Note that phases 2 (execute) and 4 (terminate) happen
273
- * externally - this just sets up and tears down.
274
- *
275
- * @param taskId - The task ID to execute
276
- * @param workCallback - Async function that does the actual work
277
- * @param basePath - Root of the FORGE project
278
- * @returns Commit hash from the completed task
279
- */
280
- export declare function runWipeProtocol(taskId: string, workCallback: (worktreePath: string) => Promise<string>, basePath?: string): Promise<string>;
281
- //# sourceMappingURL=wipe-protocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wipe-protocol.d.ts","sourceRoot":"","sources":["../../src/git/wipe-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYrB,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBtB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,CAAC,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