@maccesar/titools 2.0.5 → 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 +2 -1
- package/lib/config.js +2 -2
- package/lib/utils.js +12 -22
- package/package.json +1 -1
package/AGENTS-TEMPLATE.md
CHANGED
package/lib/config.js
CHANGED
|
@@ -20,8 +20,8 @@ try {
|
|
|
20
20
|
// Version management
|
|
21
21
|
export const PACKAGE_VERSION = packageVersion;
|
|
22
22
|
export const TITANIUM_KNOWLEDGE_VERSION = `v${PACKAGE_VERSION}`;
|
|
23
|
-
export const BLOCK_START =
|
|
24
|
-
export const BLOCK_END = '<!--
|
|
23
|
+
export const BLOCK_START = '<!-- TITANIUM-KNOWLEDGE-START -->';
|
|
24
|
+
export const BLOCK_END = '<!-- TITANIUM-KNOWLEDGE-END -->';
|
|
25
25
|
|
|
26
26
|
// Repository configuration
|
|
27
27
|
export const REPO_URL = 'https://github.com/macCesar/titools';
|
package/lib/utils.js
CHANGED
|
@@ -25,7 +25,8 @@ export function blockExists(filePath) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const content = readFileSync(filePath, 'utf8');
|
|
28
|
-
|
|
28
|
+
// Match both old versioned blocks and new static blocks
|
|
29
|
+
return /<!-- TITANIUM-KNOWLEDGE-(v[\d.]+|START) -->/.test(content);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
@@ -39,10 +40,8 @@ export function removeOldBlock(filePath) {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
const content = readFileSync(filePath, 'utf8');
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
'g'
|
|
45
|
-
);
|
|
43
|
+
// Regex to match any Titanium knowledge block (old or new)
|
|
44
|
+
const regex = /[\s\S]*?<!-- TITANIUM-KNOWLEDGE-(v[\d.]+|START) -->[\s\S]*?<!-- (END-TITANIUM-KNOWLEDGE|TITANIUM-KNOWLEDGE-END) -->[\s\S]*?\n*/g;
|
|
46
45
|
|
|
47
46
|
const newContent = content.replace(regex, '\n\n');
|
|
48
47
|
|
|
@@ -99,7 +98,7 @@ export function createKnowledgeBlock() {
|
|
|
99
98
|
const compressedIndex = buildKnowledgeIndex();
|
|
100
99
|
|
|
101
100
|
// Build the knowledge block using template literals
|
|
102
|
-
const
|
|
101
|
+
const blockHeader = `${BLOCK_START}\n<!-- Version: ${TITANIUM_KNOWLEDGE_VERSION} -->`;
|
|
103
102
|
const commentContent = `## Titanium SDK Knowledge Index
|
|
104
103
|
|
|
105
104
|
Generated by \`titools\` based on Vercel's research on AGENTS.md effectiveness.
|
|
@@ -109,7 +108,7 @@ Always consult the documentation files below rather than relying on training dat
|
|
|
109
108
|
|
|
110
109
|
This knowledge index is based on the latest Titanium SDK documentation.`;
|
|
111
110
|
|
|
112
|
-
return `\n\n${
|
|
111
|
+
return `\n\n${blockHeader}\n${commentContent}\n\n${compressedIndex}\n${BLOCK_END}\n`;
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
/**
|
|
@@ -126,20 +125,12 @@ export function addOrUpdateBlock(filePath) {
|
|
|
126
125
|
|
|
127
126
|
const block = createKnowledgeBlock();
|
|
128
127
|
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// Remove from start to end of block (including END marker and trailing newlines)
|
|
136
|
-
const afterBlock = content.substring(endIndex + BLOCK_END.length);
|
|
137
|
-
// Trim leading newlines from afterBlock
|
|
138
|
-
const trimmedAfter = afterBlock.replace(/^\n+/, '');
|
|
139
|
-
content = content.substring(0, startIndex) + '\n\n' + trimmedAfter;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
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
|