@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.
@@ -101,7 +101,8 @@ The generated file contains:
101
101
  Example output:
102
102
 
103
103
  ```html
104
- <!-- TITANIUM-KNOWLEDGE-v2.0.5 -->
104
+ <!-- TITANIUM-KNOWLEDGE-START -->
105
+ <!-- Version: v2.0.6 -->
105
106
  <!--
106
107
  Titanium SDK Knowledge Index
107
108
  Generated by titools -->
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 = `<!-- TITANIUM-KNOWLEDGE-${TITANIUM_KNOWLEDGE_VERSION} -->`;
24
- export const BLOCK_END = '<!-- END-TITANIUM-KNOWLEDGE -->';
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
- return content.includes(BLOCK_START);
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
- const regex = new RegExp(
43
- `[\\s\\S]*?${BLOCK_START}[\\s\\S]*?${BLOCK_END}[\\s\\S]*?\\n*`,
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 blockStart = `<!-- TITANIUM-KNOWLEDGE-${TITANIUM_KNOWLEDGE_VERSION} -->`;
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${blockStart}\n${commentContent}\n\n${compressedIndex}\n<!-- END-TITANIUM-KNOWLEDGE -->\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
- // Remove existing block if present (only the block, not the content before/after)
130
- if (content.includes(BLOCK_START)) {
131
- const startIndex = content.indexOf(BLOCK_START);
132
- if (startIndex !== -1) {
133
- const endIndex = content.indexOf(BLOCK_END, startIndex);
134
- if (endIndex !== -1) {
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
- }
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maccesar/titools",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Titanium SDK skills and agents for AI coding assistants (Claude Code, Gemini CLI, Codex CLI)",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",