@maccesar/titools 2.0.6 → 2.0.7
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/AGENTS-TEMPLATE.md +1 -1
- package/lib/utils.js +6 -16
- package/package.json +1 -1
package/AGENTS-TEMPLATE.md
CHANGED
package/lib/utils.js
CHANGED
|
@@ -125,21 +125,12 @@ export function addOrUpdateBlock(filePath) {
|
|
|
125
125
|
|
|
126
126
|
const block = createKnowledgeBlock();
|
|
127
127
|
|
|
128
|
-
// Regex to find
|
|
129
|
-
//
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const startIndex = match.index;
|
|
135
|
-
const matchText = match[0];
|
|
136
|
-
const endIndex = startIndex + matchText.length;
|
|
137
|
-
|
|
138
|
-
// Remove the entire block and handle trailing newlines
|
|
139
|
-
const afterBlock = content.substring(endIndex);
|
|
140
|
-
const trimmedAfter = afterBlock.replace(/^\n+/, '');
|
|
141
|
-
content = content.substring(0, startIndex) + '\n\n' + trimmedAfter;
|
|
142
|
-
}
|
|
128
|
+
// Regex to find ALL existing blocks (old versioned or new static)
|
|
129
|
+
// Global flag /g is CRITICAL here to remove every single occurrence
|
|
130
|
+
const globalBlockRegex = /<!-- TITANIUM-KNOWLEDGE-(v[\d.]+|START) -->[\s\S]*?<!-- (END-TITANIUM-KNOWLEDGE|TITANIUM-KNOWLEDGE-END) -->/g;
|
|
131
|
+
|
|
132
|
+
// Clean up all existing blocks to prevent accumulation
|
|
133
|
+
content = content.replace(globalBlockRegex, '').trim();
|
|
143
134
|
|
|
144
135
|
// Add new block at the end (preserve existing content)
|
|
145
136
|
content = content.trimEnd() + '\n\n' + block + '\n';
|
|
@@ -147,7 +138,6 @@ export function addOrUpdateBlock(filePath) {
|
|
|
147
138
|
writeFileSync(filePath, content, 'utf8');
|
|
148
139
|
return true;
|
|
149
140
|
}
|
|
150
|
-
|
|
151
141
|
/**
|
|
152
142
|
* Detect Titanium SDK version from tiapp.xml
|
|
153
143
|
* @param {string} projectDir - Path to project directory
|