@walwal-harness/cli 5.5.1 → 5.5.2

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 (2) hide show
  1. package/bin/init.js +24 -13
  2. package/package.json +1 -1
package/bin/init.js CHANGED
@@ -101,27 +101,38 @@ function scaffoldHarness() {
101
101
  ensureDir(path.join(HARNESS_DIR, 'archive'));
102
102
  ensureDir(path.join(HARNESS_DIR, 'gotchas'));
103
103
 
104
- // Copy gotchas — ALWAYS overwrite system templates, preserve user custom entries
104
+ // Copy gotchas — preserve any existing file that has accumulated entries.
105
+ // Dispatcher appends `### [G-NNN] ...` entries directly; we must NEVER overwrite
106
+ // a file that has such entries, or user learning history is lost.
105
107
  const gotchasSrc = path.join(PKG_ROOT, 'gotchas');
106
108
  if (fs.existsSync(gotchasSrc)) {
107
- const CUSTOM_MARKER = '## Custom Gotchas';
109
+ const ENTRY_PATTERN = /^### \[G-\d+\]/m; // Gotcha entry heading
110
+ const CUSTOM_MARKER = '## Custom Gotchas'; // Legacy marker still supported
108
111
  const files = fs.readdirSync(gotchasSrc);
109
112
  for (const file of files) {
110
113
  const destPath = path.join(HARNESS_DIR, 'gotchas', file);
111
114
  const srcPath = path.join(gotchasSrc, file);
112
- if (fileExists(destPath) && file.endsWith('.md')) {
113
- // Preserve user-added custom section
114
- const existing = fs.readFileSync(destPath, 'utf8');
115
- const customIdx = existing.indexOf(CUSTOM_MARKER);
116
- const userCustom = customIdx !== -1 ? existing.substring(customIdx) : '';
117
- let newContent = fs.readFileSync(srcPath, 'utf8');
118
- if (userCustom) {
119
- newContent = newContent.trimEnd() + '\n\n' + userCustom;
120
- }
121
- fs.writeFileSync(destPath, newContent);
122
- } else {
115
+ if (!fileExists(destPath)) {
123
116
  copyFile(srcPath, destPath);
117
+ continue;
124
118
  }
119
+ if (!file.endsWith('.md')) continue;
120
+
121
+ const existing = fs.readFileSync(destPath, 'utf8');
122
+ const hasEntries = ENTRY_PATTERN.test(existing);
123
+ const hasCustomSection = existing.indexOf(CUSTOM_MARKER) !== -1;
124
+
125
+ if (hasEntries || hasCustomSection) {
126
+ // User has accumulated data — DO NOT overwrite. Skip silently.
127
+ // README.md is the only exception (system doc, regenerated below).
128
+ if (file === 'README.md') {
129
+ copyFile(srcPath, destPath);
130
+ }
131
+ continue;
132
+ }
133
+
134
+ // File exists but is just the scaffold template — safe to refresh
135
+ copyFile(srcPath, destPath);
125
136
  }
126
137
  }
127
138
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@walwal-harness/cli",
3
- "version": "5.5.1",
3
+ "version": "5.5.2",
4
4
  "description": "Production harness for AI agent engineering — Solo/Team mode, Planner, Generator(BE/FE), Evaluator chain (Code-Quality → Functional → Visual), optional Brainstormer. Supports React, Next.js, and Flutter FE stacks.",
5
5
  "bin": {
6
6
  "walwal-harness": "bin/init.js"