@maccesar/titools 2.0.5 → 2.0.6
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 +20 -20
- 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,19 +125,20 @@ export function addOrUpdateBlock(filePath) {
|
|
|
126
125
|
|
|
127
126
|
const block = createKnowledgeBlock();
|
|
128
127
|
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
128
|
+
// Regex to find any existing block (old versioned or new static)
|
|
129
|
+
// Group 1 matches the version/START, Group 2 matches the END marker
|
|
130
|
+
const blockRegex = /<!-- TITANIUM-KNOWLEDGE-(v[\d.]+|START) -->[\s\S]*?<!-- (END-TITANIUM-KNOWLEDGE|TITANIUM-KNOWLEDGE-END) -->/;
|
|
131
|
+
const match = content.match(blockRegex);
|
|
132
|
+
|
|
133
|
+
if (match) {
|
|
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
142
|
}
|
|
143
143
|
|
|
144
144
|
// Add new block at the end (preserve existing content)
|