@jsleekr/graft 6.0.2 → 6.1.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.
@@ -41,9 +41,9 @@ export function generate(program, report, sourceFile, index, backend) {
41
41
  }
42
42
  }
43
43
  }
44
- // Orchestration
44
+ // Orchestration (separate file — does not overwrite CLAUDE.md)
45
45
  files.push({
46
- path: '.claude/CLAUDE.md',
46
+ path: '.claude/orchestration.md',
47
47
  content: be.generateOrchestration(ctx),
48
48
  });
49
49
  // Settings
package/dist/index.js CHANGED
@@ -182,18 +182,19 @@ graph ${safeName}(input: Input, output: Output, budget: 10k) {
182
182
  }
183
183
  `);
184
184
  }
185
- // Generate or append .claude/CLAUDE.md with .gft spec
185
+ // Generate .claude/ config files
186
186
  const claudeDir = path.join(dir, '.claude');
187
187
  fs.mkdirSync(claudeDir, { recursive: true });
188
188
  const { buildSystemPrompt } = await import('./generator.js');
189
189
  const gftSpec = buildSystemPrompt();
190
- const claudeMdPath = path.join(claudeDir, 'CLAUDE.md');
191
- const existingClaudeMd = fs.existsSync(claudeMdPath) ? fs.readFileSync(claudeMdPath, 'utf-8') : '';
192
- if (existingClaudeMd && existingClaudeMd.includes('graft compile')) {
193
- console.log(` .claude/CLAUDE.md already contains Graft config — skipped`);
194
- }
195
- else {
196
- const graftSection = `
190
+ // 1. Write .gft spec to a separate file (never overwritten by compile)
191
+ const specPath = path.join(claudeDir, 'graft-spec.md');
192
+ const specContent = `# Graft — .gft Language Reference
193
+
194
+ > Auto-generated by \`graft init\`. This file is the .gft syntax reference
195
+ > that Claude Code reads to understand the Graft language.
196
+ > Do NOT delete this file — \`graft compile\` does not touch it.
197
+
197
198
  ## Graft — Multi-Agent Pipelines
198
199
 
199
200
  This project uses **Graft** (.gft) for defining multi-agent pipelines.
@@ -223,15 +224,22 @@ graft watch <file.gft> # Watch and recompile on changes
223
224
 
224
225
  ${gftSpec}
225
226
  `;
226
- if (existingClaudeMd) {
227
- // Append Graft section to existing CLAUDE.md
228
- fs.writeFileSync(claudeMdPath, existingClaudeMd.trimEnd() + '\n\n' + graftSection.trim() + '\n');
229
- }
230
- else {
231
- // Create new CLAUDE.md with Graft header
232
- fs.writeFileSync(claudeMdPath, `# ${safeName}\n` + graftSection);
233
- }
234
- } // end else (not already configured)
227
+ fs.writeFileSync(specPath, specContent);
228
+ // 2. Add Graft reference to CLAUDE.md (short pointer, not the full spec)
229
+ const claudeMdPath = path.join(claudeDir, 'CLAUDE.md');
230
+ const existingClaudeMd = fs.existsSync(claudeMdPath) ? fs.readFileSync(claudeMdPath, 'utf-8') : '';
231
+ const graftReference = `## Graft
232
+
233
+ This project uses Graft for multi-agent pipelines. Read \`.claude/graft-spec.md\` for the full .gft syntax reference. Run \`graft compile <file.gft>\` to generate harness files.`;
234
+ if (existingClaudeMd && existingClaudeMd.includes('graft-spec.md')) {
235
+ console.log(` .claude/CLAUDE.md already references Graft skipped`);
236
+ }
237
+ else if (existingClaudeMd) {
238
+ fs.writeFileSync(claudeMdPath, existingClaudeMd.trimEnd() + '\n\n' + graftReference + '\n');
239
+ }
240
+ else {
241
+ fs.writeFileSync(claudeMdPath, `# ${safeName}\n\n` + graftReference + '\n');
242
+ }
235
243
  if (isExisting) {
236
244
  console.log(`\nGraft added to current project.`);
237
245
  console.log(` .claude/CLAUDE.md — Graft spec injected`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsleekr/graft",
3
- "version": "6.0.2",
3
+ "version": "6.1.0",
4
4
  "description": "Graft compiler — compile .gft graph DSL to Claude Code harness structures",
5
5
  "type": "module",
6
6
  "license": "MIT",