thatgfsj-code 0.7.6 → 0.7.8
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/dist/cmd/index.js +1 -1
- package/dist/prompts/index.d.ts +7 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +75 -25
- package/dist/prompts/index.js.map +1 -1
- package/dist/tui/components/Header.js +1 -1
- package/package.json +1 -1
- package/src/cmd/index.tsx +1 -1
- package/src/prompts/index.ts +82 -26
- package/src/tui/components/Header.tsx +1 -1
package/dist/cmd/index.js
CHANGED
|
@@ -24,7 +24,7 @@ process.on('unhandledRejection', (reason) => {
|
|
|
24
24
|
program
|
|
25
25
|
.name('gfcode')
|
|
26
26
|
.description('Thatgfsj Code - AI Coding Assistant')
|
|
27
|
-
.version('0.7.
|
|
27
|
+
.version('0.7.8')
|
|
28
28
|
.argument('[prompt]', 'Task to execute (omit to start interactive mode)')
|
|
29
29
|
.option('-m, --model <model>', 'Specify model')
|
|
30
30
|
.option('-i, --interactive', 'Force interactive mode')
|
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* System Prompt Builder - Dynamic prompt construction
|
|
3
|
-
* Migrated from old src/core/system-prompt.ts
|
|
4
3
|
*/
|
|
5
4
|
import type { Tool } from '../tools/types.js';
|
|
6
5
|
export interface SystemPromptConfig {
|
|
@@ -19,7 +18,14 @@ export declare class SystemPromptBuilder {
|
|
|
19
18
|
private buildToolInstructions;
|
|
20
19
|
private buildEnvironment;
|
|
21
20
|
private buildPermissionMode;
|
|
21
|
+
/**
|
|
22
|
+
* Read project instruction files (generic, works for any user)
|
|
23
|
+
*/
|
|
22
24
|
private buildProjectInstructions;
|
|
25
|
+
/**
|
|
26
|
+
* Auto-inject recent NWT history into system prompt
|
|
27
|
+
*/
|
|
28
|
+
private buildNwtHistory;
|
|
23
29
|
private buildSkills;
|
|
24
30
|
private buildDateInfo;
|
|
25
31
|
setTools(tools: Tool[]): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;IAC3C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAA+B;gBAEjC,MAAM,GAAE,kBAAuB;IAW3C,KAAK,IAAI,MAAM;IAcf,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,qBAAqB;IAc7B,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAqDhC;;OAEG;IACH,OAAO,CAAC,eAAe;IA+BvB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,aAAa;IAMrB,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI;IAC7B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IACzB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI;CACzD"}
|
package/dist/prompts/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* System Prompt Builder - Dynamic prompt construction
|
|
3
|
-
* Migrated from old src/core/system-prompt.ts
|
|
4
3
|
*/
|
|
5
|
-
import { readFileSync, existsSync } from 'fs';
|
|
4
|
+
import { readFileSync, existsSync, readdirSync } from 'fs';
|
|
6
5
|
import { join } from 'path';
|
|
7
6
|
export class SystemPromptBuilder {
|
|
8
7
|
config;
|
|
@@ -23,6 +22,7 @@ export class SystemPromptBuilder {
|
|
|
23
22
|
this.buildEnvironment(),
|
|
24
23
|
this.buildPermissionMode(),
|
|
25
24
|
this.buildProjectInstructions(),
|
|
25
|
+
this.buildNwtHistory(),
|
|
26
26
|
this.buildSkills(),
|
|
27
27
|
this.buildDateInfo(),
|
|
28
28
|
];
|
|
@@ -32,14 +32,15 @@ export class SystemPromptBuilder {
|
|
|
32
32
|
return [
|
|
33
33
|
'You are Thatgfsj Code, an interactive coding agent running in the user\'s terminal.',
|
|
34
34
|
'',
|
|
35
|
-
'You have access to tools (file operations, shell commands, git, search) that let you',
|
|
36
|
-
'read, write, and modify files
|
|
35
|
+
'You have access to tools (file operations, shell commands, git, search, nwt) that let you',
|
|
36
|
+
'read, write, and modify files, run commands, and track project evolution.',
|
|
37
37
|
'',
|
|
38
38
|
'When working on a task:',
|
|
39
39
|
'1. First understand what files are involved',
|
|
40
40
|
'2. Read necessary files to understand the codebase',
|
|
41
41
|
'3. Make changes using appropriate tools',
|
|
42
42
|
'4. Verify the changes work',
|
|
43
|
+
'5. Log important changes to NWT (nwt log)',
|
|
43
44
|
'',
|
|
44
45
|
'Be concise but thorough. Show your reasoning.',
|
|
45
46
|
'',
|
|
@@ -51,16 +52,15 @@ export class SystemPromptBuilder {
|
|
|
51
52
|
}
|
|
52
53
|
buildToolInstructions() {
|
|
53
54
|
const tools = this.config.tools;
|
|
54
|
-
if (tools.length === 0)
|
|
55
|
+
if (tools.length === 0)
|
|
55
56
|
return '## Tools\n\nNo tools are currently registered.';
|
|
56
|
-
}
|
|
57
57
|
const toolDescs = tools.map(t => {
|
|
58
58
|
const params = t.parameters
|
|
59
59
|
.map(p => ` - ${p.name} (${p.type}${p.required ? ', required' : ''}): ${p.description}`)
|
|
60
60
|
.join('\n');
|
|
61
61
|
return `### ${t.name}\n${t.description}\n\nParameters:\n${params}`;
|
|
62
62
|
}).join('\n\n');
|
|
63
|
-
return `## Tools\n\nYou have access to the following tools:\n\n${toolDescs}\n\nTo use a tool, respond with a tool call
|
|
63
|
+
return `## Tools\n\nYou have access to the following tools:\n\n${toolDescs}\n\nTo use a tool, respond with a tool call.`;
|
|
64
64
|
}
|
|
65
65
|
buildEnvironment() {
|
|
66
66
|
return `## Environment\n\nWorking directory: ${this.config.cwd}`;
|
|
@@ -74,37 +74,87 @@ export class SystemPromptBuilder {
|
|
|
74
74
|
};
|
|
75
75
|
return `## Permission Mode\n\nCurrent mode: ${mode}\n\n${explanations[mode] || ''}`;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Read project instruction files (generic, works for any user)
|
|
79
|
+
*/
|
|
77
80
|
buildProjectInstructions() {
|
|
78
81
|
if (!this.config.includeProjectMd)
|
|
79
82
|
return '';
|
|
80
83
|
const cwd = this.config.cwd;
|
|
81
84
|
const home = process.env.USERPROFILE || process.env.HOME || '';
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
join(cwd, '.Codex.md'),
|
|
88
|
-
join(cwd, 'CODEX.md'),
|
|
89
|
-
join(cwd, '.codex.md'),
|
|
90
|
-
join(home, '.claude', 'CLAUDE.md'),
|
|
91
|
-
join(home, '.claude', 'SKILLS.md'),
|
|
92
|
-
join(home, '.Codex', 'SKILLS.md'),
|
|
93
|
-
join(home, '.Codex', 'AGENTS.md'),
|
|
94
|
-
join(home, '.agents', 'AGENTS.md'),
|
|
85
|
+
// Project-level files (any project can have these)
|
|
86
|
+
const projectFiles = [
|
|
87
|
+
'CLAUDE.md', '.claude.md', 'AGENTS.md',
|
|
88
|
+
'Codex.md', '.Codex.md', 'CODEX.md', '.codex.md',
|
|
89
|
+
'CONVENTIONS.md', 'CONTRIBUTING.md',
|
|
95
90
|
];
|
|
91
|
+
// User-level files (in home directory)
|
|
92
|
+
const userDirs = ['.claude', '.Codex', '.agents'];
|
|
93
|
+
const userFiles = ['CLAUDE.md', 'SKILLS.md', 'AGENTS.md', 'CONVENTIONS.md'];
|
|
94
|
+
const paths = [];
|
|
95
|
+
// Project-level
|
|
96
|
+
for (const f of projectFiles) {
|
|
97
|
+
paths.push(join(cwd, f));
|
|
98
|
+
}
|
|
99
|
+
// User-level
|
|
100
|
+
for (const dir of userDirs) {
|
|
101
|
+
for (const f of userFiles) {
|
|
102
|
+
paths.push(join(home, dir, f));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const sections = [];
|
|
106
|
+
const MAX_LEN = 3000;
|
|
96
107
|
for (const path of paths) {
|
|
97
108
|
if (existsSync(path)) {
|
|
98
109
|
try {
|
|
99
|
-
|
|
100
|
-
|
|
110
|
+
let content = readFileSync(path, 'utf-8').trim();
|
|
111
|
+
if (content) {
|
|
112
|
+
const filename = path.split(/[/\\]/).pop();
|
|
113
|
+
if (content.length > MAX_LEN) {
|
|
114
|
+
content = content.slice(0, MAX_LEN) + '\n... (truncated)';
|
|
115
|
+
}
|
|
116
|
+
sections.push(`[${filename}]\n${content}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch { }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (sections.length === 0)
|
|
123
|
+
return '';
|
|
124
|
+
return `## User Configuration\n\n${sections.join('\n\n')}`;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Auto-inject recent NWT history into system prompt
|
|
128
|
+
*/
|
|
129
|
+
buildNwtHistory() {
|
|
130
|
+
try {
|
|
131
|
+
const nwtDir = join(this.config.cwd, '.nwt', 'events');
|
|
132
|
+
if (!existsSync(nwtDir))
|
|
133
|
+
return '';
|
|
134
|
+
const files = readdirSync(nwtDir)
|
|
135
|
+
.filter(f => f.endsWith('.json'))
|
|
136
|
+
.sort()
|
|
137
|
+
.slice(-10); // Last 10 events
|
|
138
|
+
if (files.length === 0)
|
|
139
|
+
return '';
|
|
140
|
+
const events = files.map(f => {
|
|
141
|
+
try {
|
|
142
|
+
const ev = JSON.parse(readFileSync(join(nwtDir, f), 'utf-8'));
|
|
143
|
+
const time = ev.timestamp?.split('T')[0] || '';
|
|
144
|
+
const files = ev.files?.length > 0 ? ` [${ev.files.join(', ')}]` : '';
|
|
145
|
+
return `- [${ev.id}] ${time} ${ev.task}: ${ev.summary}${files}`;
|
|
101
146
|
}
|
|
102
147
|
catch {
|
|
103
|
-
|
|
148
|
+
return null;
|
|
104
149
|
}
|
|
105
|
-
}
|
|
150
|
+
}).filter(Boolean);
|
|
151
|
+
if (events.length === 0)
|
|
152
|
+
return '';
|
|
153
|
+
return `## Project History (NWT)\n\nRecent evolution events:\n\n${events.join('\n')}`;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return '';
|
|
106
157
|
}
|
|
107
|
-
return '';
|
|
108
158
|
}
|
|
109
159
|
buildSkills() {
|
|
110
160
|
if (!this.config.skillsPrompt)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAA+B;IAE7C,YAAY,SAA6B,EAAE;QACzC,IAAI,CAAC,MAAM,GAAG;YACZ,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;YAChC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE;YACzB,gBA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{ jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Box, Text } from 'ink';
|
|
5
5
|
export const Header = React.memo(function Header({ provider, model }) {
|
|
6
|
-
return (_jsxs(Box, { flexDirection: "column", marginBottom: 0, children: [_jsxs(Box, { justifyContent: "space-between", width: "100%", children: [_jsxs(Box, { children: [_jsx(Text, { color: "#06B6D4", bold: true, children: " \u26A1 " }), _jsx(Text, { color: "#22D3EE", bold: true, children: "THATGFSJ CODE" }), _jsx(Text, { dimColor: true, children: " v0.7.
|
|
6
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 0, children: [_jsxs(Box, { justifyContent: "space-between", width: "100%", children: [_jsxs(Box, { children: [_jsx(Text, { color: "#06B6D4", bold: true, children: " \u26A1 " }), _jsx(Text, { color: "#22D3EE", bold: true, children: "THATGFSJ CODE" }), _jsx(Text, { dimColor: true, children: " v0.7.8" })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#06B6D4", bold: true, children: [" ", provider, " "] }), _jsx(Text, { dimColor: true, children: "/" }), _jsxs(Text, { color: "#22D3EE", children: [" ", model, " "] })] })] }), _jsx(Text, { color: "#374151", children: '─'.repeat(80) })] }));
|
|
7
7
|
});
|
|
8
8
|
//# sourceMappingURL=Header.js.map
|
package/package.json
CHANGED
package/src/cmd/index.tsx
CHANGED
|
@@ -28,7 +28,7 @@ process.on('unhandledRejection', (reason) => {
|
|
|
28
28
|
program
|
|
29
29
|
.name('gfcode')
|
|
30
30
|
.description('Thatgfsj Code - AI Coding Assistant')
|
|
31
|
-
.version('0.7.
|
|
31
|
+
.version('0.7.8')
|
|
32
32
|
.argument('[prompt]', 'Task to execute (omit to start interactive mode)')
|
|
33
33
|
.option('-m, --model <model>', 'Specify model')
|
|
34
34
|
.option('-i, --interactive', 'Force interactive mode')
|
package/src/prompts/index.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* System Prompt Builder - Dynamic prompt construction
|
|
3
|
-
* Migrated from old src/core/system-prompt.ts
|
|
4
3
|
*/
|
|
5
4
|
|
|
6
|
-
import { readFileSync, existsSync } from 'fs';
|
|
5
|
+
import { readFileSync, existsSync, readdirSync } from 'fs';
|
|
7
6
|
import { join } from 'path';
|
|
8
7
|
import type { Tool } from '../tools/types.js';
|
|
9
8
|
|
|
@@ -37,6 +36,7 @@ export class SystemPromptBuilder {
|
|
|
37
36
|
this.buildEnvironment(),
|
|
38
37
|
this.buildPermissionMode(),
|
|
39
38
|
this.buildProjectInstructions(),
|
|
39
|
+
this.buildNwtHistory(),
|
|
40
40
|
this.buildSkills(),
|
|
41
41
|
this.buildDateInfo(),
|
|
42
42
|
];
|
|
@@ -47,14 +47,15 @@ export class SystemPromptBuilder {
|
|
|
47
47
|
return [
|
|
48
48
|
'You are Thatgfsj Code, an interactive coding agent running in the user\'s terminal.',
|
|
49
49
|
'',
|
|
50
|
-
'You have access to tools (file operations, shell commands, git, search) that let you',
|
|
51
|
-
'read, write, and modify files
|
|
50
|
+
'You have access to tools (file operations, shell commands, git, search, nwt) that let you',
|
|
51
|
+
'read, write, and modify files, run commands, and track project evolution.',
|
|
52
52
|
'',
|
|
53
53
|
'When working on a task:',
|
|
54
54
|
'1. First understand what files are involved',
|
|
55
55
|
'2. Read necessary files to understand the codebase',
|
|
56
56
|
'3. Make changes using appropriate tools',
|
|
57
57
|
'4. Verify the changes work',
|
|
58
|
+
'5. Log important changes to NWT (nwt log)',
|
|
58
59
|
'',
|
|
59
60
|
'Be concise but thorough. Show your reasoning.',
|
|
60
61
|
'',
|
|
@@ -67,9 +68,7 @@ export class SystemPromptBuilder {
|
|
|
67
68
|
|
|
68
69
|
private buildToolInstructions(): string {
|
|
69
70
|
const tools = this.config.tools;
|
|
70
|
-
if (tools.length === 0)
|
|
71
|
-
return '## Tools\n\nNo tools are currently registered.';
|
|
72
|
-
}
|
|
71
|
+
if (tools.length === 0) return '## Tools\n\nNo tools are currently registered.';
|
|
73
72
|
|
|
74
73
|
const toolDescs = tools.map(t => {
|
|
75
74
|
const params = t.parameters
|
|
@@ -78,7 +77,7 @@ export class SystemPromptBuilder {
|
|
|
78
77
|
return `### ${t.name}\n${t.description}\n\nParameters:\n${params}`;
|
|
79
78
|
}).join('\n\n');
|
|
80
79
|
|
|
81
|
-
return `## Tools\n\nYou have access to the following tools:\n\n${toolDescs}\n\nTo use a tool, respond with a tool call
|
|
80
|
+
return `## Tools\n\nYou have access to the following tools:\n\n${toolDescs}\n\nTo use a tool, respond with a tool call.`;
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
private buildEnvironment(): string {
|
|
@@ -95,37 +94,94 @@ export class SystemPromptBuilder {
|
|
|
95
94
|
return `## Permission Mode\n\nCurrent mode: ${mode}\n\n${explanations[mode] || ''}`;
|
|
96
95
|
}
|
|
97
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Read project instruction files (generic, works for any user)
|
|
99
|
+
*/
|
|
98
100
|
private buildProjectInstructions(): string {
|
|
99
101
|
if (!this.config.includeProjectMd) return '';
|
|
100
102
|
|
|
101
103
|
const cwd = this.config.cwd;
|
|
102
104
|
const home = process.env.USERPROFILE || process.env.HOME || '';
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
join(cwd, 'CODEX.md'),
|
|
110
|
-
join(cwd, '.codex.md'),
|
|
111
|
-
join(home, '.claude', 'CLAUDE.md'),
|
|
112
|
-
join(home, '.claude', 'SKILLS.md'),
|
|
113
|
-
join(home, '.Codex', 'SKILLS.md'),
|
|
114
|
-
join(home, '.Codex', 'AGENTS.md'),
|
|
115
|
-
join(home, '.agents', 'AGENTS.md'),
|
|
105
|
+
|
|
106
|
+
// Project-level files (any project can have these)
|
|
107
|
+
const projectFiles = [
|
|
108
|
+
'CLAUDE.md', '.claude.md', 'AGENTS.md',
|
|
109
|
+
'Codex.md', '.Codex.md', 'CODEX.md', '.codex.md',
|
|
110
|
+
'CONVENTIONS.md', 'CONTRIBUTING.md',
|
|
116
111
|
];
|
|
117
112
|
|
|
113
|
+
// User-level files (in home directory)
|
|
114
|
+
const userDirs = ['.claude', '.Codex', '.agents'];
|
|
115
|
+
const userFiles = ['CLAUDE.md', 'SKILLS.md', 'AGENTS.md', 'CONVENTIONS.md'];
|
|
116
|
+
|
|
117
|
+
const paths: string[] = [];
|
|
118
|
+
|
|
119
|
+
// Project-level
|
|
120
|
+
for (const f of projectFiles) {
|
|
121
|
+
paths.push(join(cwd, f));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// User-level
|
|
125
|
+
for (const dir of userDirs) {
|
|
126
|
+
for (const f of userFiles) {
|
|
127
|
+
paths.push(join(home, dir, f));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const sections: string[] = [];
|
|
132
|
+
const MAX_LEN = 3000;
|
|
133
|
+
|
|
118
134
|
for (const path of paths) {
|
|
119
135
|
if (existsSync(path)) {
|
|
120
136
|
try {
|
|
121
|
-
|
|
122
|
-
|
|
137
|
+
let content = readFileSync(path, 'utf-8').trim();
|
|
138
|
+
if (content) {
|
|
139
|
+
const filename = path.split(/[/\\]/).pop();
|
|
140
|
+
if (content.length > MAX_LEN) {
|
|
141
|
+
content = content.slice(0, MAX_LEN) + '\n... (truncated)';
|
|
142
|
+
}
|
|
143
|
+
sections.push(`[${filename}]\n${content}`);
|
|
144
|
+
}
|
|
145
|
+
} catch {}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (sections.length === 0) return '';
|
|
150
|
+
return `## User Configuration\n\n${sections.join('\n\n')}`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Auto-inject recent NWT history into system prompt
|
|
155
|
+
*/
|
|
156
|
+
private buildNwtHistory(): string {
|
|
157
|
+
try {
|
|
158
|
+
const nwtDir = join(this.config.cwd, '.nwt', 'events');
|
|
159
|
+
if (!existsSync(nwtDir)) return '';
|
|
160
|
+
|
|
161
|
+
const files = readdirSync(nwtDir)
|
|
162
|
+
.filter(f => f.endsWith('.json'))
|
|
163
|
+
.sort()
|
|
164
|
+
.slice(-10); // Last 10 events
|
|
165
|
+
|
|
166
|
+
if (files.length === 0) return '';
|
|
167
|
+
|
|
168
|
+
const events = files.map(f => {
|
|
169
|
+
try {
|
|
170
|
+
const ev = JSON.parse(readFileSync(join(nwtDir, f), 'utf-8'));
|
|
171
|
+
const time = ev.timestamp?.split('T')[0] || '';
|
|
172
|
+
const files = ev.files?.length > 0 ? ` [${ev.files.join(', ')}]` : '';
|
|
173
|
+
return `- [${ev.id}] ${time} ${ev.task}: ${ev.summary}${files}`;
|
|
123
174
|
} catch {
|
|
124
|
-
|
|
175
|
+
return null;
|
|
125
176
|
}
|
|
126
|
-
}
|
|
177
|
+
}).filter(Boolean);
|
|
178
|
+
|
|
179
|
+
if (events.length === 0) return '';
|
|
180
|
+
|
|
181
|
+
return `## Project History (NWT)\n\nRecent evolution events:\n\n${events.join('\n')}`;
|
|
182
|
+
} catch {
|
|
183
|
+
return '';
|
|
127
184
|
}
|
|
128
|
-
return '';
|
|
129
185
|
}
|
|
130
186
|
|
|
131
187
|
private buildSkills(): string {
|
|
@@ -14,7 +14,7 @@ export const Header = React.memo(function Header({ provider, model }: Props) {
|
|
|
14
14
|
<Box>
|
|
15
15
|
<Text color="#06B6D4" bold> ⚡ </Text>
|
|
16
16
|
<Text color="#22D3EE" bold>THATGFSJ CODE</Text>
|
|
17
|
-
<Text dimColor> v0.7.
|
|
17
|
+
<Text dimColor> v0.7.8</Text>
|
|
18
18
|
</Box>
|
|
19
19
|
<Box>
|
|
20
20
|
<Text color="#06B6D4" bold> {provider} </Text>
|