@ghl-ai/aw 0.1.39-beta.16 → 0.1.39-beta.17
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/integrate.mjs +8 -72
- package/package.json +1 -1
package/integrate.mjs
CHANGED
|
@@ -194,99 +194,35 @@ function findFiles(dir, typeName) {
|
|
|
194
194
|
return results;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
/**
|
|
198
|
-
* Read consumer config to decide whether to write managed sections into
|
|
199
|
-
* the repo's AGENTS.md / CLAUDE.md.
|
|
200
|
-
*
|
|
201
|
-
* Default behaviour: do NOT touch repo-local AGENTS.md/CLAUDE.md. The same
|
|
202
|
-
* AW Router Bridge + Platform Rules content is already injected into the
|
|
203
|
-
* GLOBAL files (~/.claude/CLAUDE.md and ~/.codex/AGENTS.md) by aw init,
|
|
204
|
-
* and Claude/Codex always read those. Modifying the repo file is invasive
|
|
205
|
-
* and bloats it with content that's already loaded globally.
|
|
206
|
-
*
|
|
207
|
-
* Repos that DO want managed sections in their repo file (e.g. for editors
|
|
208
|
-
* that don't read the global files, or to share AW context with collaborators
|
|
209
|
-
* who haven't run aw init) can opt in via .aw/config.json:
|
|
210
|
-
*
|
|
211
|
-
* { "writeRepoInstructionFiles": true }
|
|
212
|
-
*
|
|
213
|
-
* Existing repo files with managed sections are STRIPPED on next aw init
|
|
214
|
-
* (so users see the managed content go away — clean migration). Repos with
|
|
215
|
-
* the opt-in flag get them updated as before.
|
|
216
|
-
*/
|
|
217
|
-
function shouldWriteRepoInstructionFiles(cwd) {
|
|
218
|
-
const configPath = join(cwd, '.aw', 'config.json');
|
|
219
|
-
if (!existsSync(configPath)) return false;
|
|
220
|
-
try {
|
|
221
|
-
const config = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
222
|
-
return config.writeRepoInstructionFiles === true;
|
|
223
|
-
} catch {
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
197
|
/**
|
|
229
198
|
* Refresh rules sections in any existing AGENTS.md/CLAUDE.md at the repo
|
|
230
199
|
* root.
|
|
231
200
|
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
201
|
+
* Repo instruction files are user-owned. aw init no longer creates or updates
|
|
202
|
+
* managed sections in repo-local AGENTS.md / CLAUDE.md.
|
|
234
203
|
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
204
|
+
* The only repo-file behavior left is cleanup: if a repo still contains old
|
|
205
|
+
* aw-managed sections from prior versions, strip those sections while leaving
|
|
206
|
+
* the user's own content intact.
|
|
238
207
|
*/
|
|
239
208
|
export function copyInstructions(cwd, tempDir, namespace) {
|
|
240
209
|
const rulesSections = renderRules(cwd);
|
|
241
|
-
const writeManaged = shouldWriteRepoInstructionFiles(cwd);
|
|
242
210
|
const createdFiles = [];
|
|
243
211
|
|
|
244
212
|
for (const file of ['AGENTS.md', 'CLAUDE.md']) {
|
|
245
213
|
const dest = join(cwd, file);
|
|
246
214
|
if (existsSync(dest)) {
|
|
247
215
|
const existing = readFileSync(dest, 'utf8');
|
|
248
|
-
const updated =
|
|
249
|
-
? applyManagedInstructionSections(existing, file, rulesSections, { includeBridge: false })
|
|
250
|
-
: applyManagedInstructionSections(existing, file, {}, { includeBridge: false });
|
|
216
|
+
const updated = applyManagedInstructionSections(existing, file, {}, { includeBridge: false });
|
|
251
217
|
|
|
252
218
|
if (updated !== existing) {
|
|
253
219
|
writeFileSync(dest, updated);
|
|
254
|
-
|
|
255
|
-
fmt.logSuccess(`Updated ${file}`);
|
|
256
|
-
} else {
|
|
257
|
-
fmt.logStep(`Stripped aw-managed sections from ${file} (now in ~/.claude/CLAUDE.md / ~/.codex/AGENTS.md)`);
|
|
258
|
-
}
|
|
220
|
+
fmt.logStep(`Stripped aw-managed sections from ${file} (now in ~/.claude/CLAUDE.md / ~/.codex/AGENTS.md)`);
|
|
259
221
|
}
|
|
260
222
|
continue;
|
|
261
223
|
}
|
|
262
224
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
// Only CREATE a repo AGENTS.md if writeRepoInstructionFiles is opted in.
|
|
266
|
-
// Without the opt-in, repo files are user-owned and aw init never creates them.
|
|
267
|
-
if (!writeManaged) continue;
|
|
268
|
-
|
|
269
|
-
if (tempDir) {
|
|
270
|
-
const src = join(tempDir, '.aw_registry', file);
|
|
271
|
-
if (existsSync(src)) {
|
|
272
|
-
let content = readFileSync(src, 'utf8');
|
|
273
|
-
if (namespace) {
|
|
274
|
-
content = content.replace(/\{\{TEAM\}\}/g, namespace);
|
|
275
|
-
}
|
|
276
|
-
content = applyManagedInstructionSections(content, file, rulesSections, { includeBridge: false });
|
|
277
|
-
writeFileSync(dest, content);
|
|
278
|
-
fmt.logSuccess(`Created ${file}`);
|
|
279
|
-
createdFiles.push(dest);
|
|
280
|
-
continue;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const content = generateAgentsMd(cwd, namespace, rulesSections);
|
|
285
|
-
if (content) {
|
|
286
|
-
writeFileSync(dest, applyManagedInstructionSections(content, file, rulesSections, { includeBridge: false }));
|
|
287
|
-
fmt.logSuccess(`Created ${file}`);
|
|
288
|
-
createdFiles.push(dest);
|
|
289
|
-
}
|
|
225
|
+
// Never create repo instruction files anymore.
|
|
290
226
|
}
|
|
291
227
|
return createdFiles;
|
|
292
228
|
}
|