thatgfsj-code 0.6.0 → 0.7.0
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/app/index.d.ts +2 -0
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +10 -5
- package/dist/app/index.js.map +1 -1
- package/dist/cmd/index.js +1 -1
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +7 -0
- package/dist/prompts/index.js.map +1 -1
- package/dist/skills/brainstorming.d.ts +3 -0
- package/dist/skills/brainstorming.d.ts.map +1 -0
- package/dist/skills/brainstorming.js +42 -0
- package/dist/skills/brainstorming.js.map +1 -0
- package/dist/skills/code-review.d.ts +3 -0
- package/dist/skills/code-review.d.ts.map +1 -0
- package/dist/skills/code-review.js +44 -0
- package/dist/skills/code-review.js.map +1 -0
- package/dist/skills/executing-plans.d.ts +3 -0
- package/dist/skills/executing-plans.d.ts.map +1 -0
- package/dist/skills/executing-plans.js +26 -0
- package/dist/skills/executing-plans.js.map +1 -0
- package/dist/skills/frontend-design.d.ts +3 -0
- package/dist/skills/frontend-design.d.ts.map +1 -0
- package/dist/skills/frontend-design.js +34 -0
- package/dist/skills/frontend-design.js.map +1 -0
- package/dist/skills/git-workflow.d.ts +3 -0
- package/dist/skills/git-workflow.d.ts.map +1 -0
- package/dist/skills/git-workflow.js +35 -0
- package/dist/skills/git-workflow.js.map +1 -0
- package/dist/skills/improve-architecture.d.ts +3 -0
- package/dist/skills/improve-architecture.d.ts.map +1 -0
- package/dist/skills/improve-architecture.js +37 -0
- package/dist/skills/improve-architecture.js.map +1 -0
- package/dist/skills/index.d.ts +50 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +98 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/neuroweave.d.ts +3 -0
- package/dist/skills/neuroweave.d.ts.map +1 -0
- package/dist/skills/neuroweave.js +46 -0
- package/dist/skills/neuroweave.js.map +1 -0
- package/dist/skills/playwright.d.ts +3 -0
- package/dist/skills/playwright.d.ts.map +1 -0
- package/dist/skills/playwright.js +71 -0
- package/dist/skills/playwright.js.map +1 -0
- package/dist/skills/prototype.d.ts +3 -0
- package/dist/skills/prototype.d.ts.map +1 -0
- package/dist/skills/prototype.js +29 -0
- package/dist/skills/prototype.js.map +1 -0
- package/dist/skills/subagent.d.ts +3 -0
- package/dist/skills/subagent.d.ts.map +1 -0
- package/dist/skills/subagent.js +27 -0
- package/dist/skills/subagent.js.map +1 -0
- package/dist/skills/supabase.d.ts +3 -0
- package/dist/skills/supabase.d.ts.map +1 -0
- package/dist/skills/supabase.js +43 -0
- package/dist/skills/supabase.js.map +1 -0
- package/dist/skills/systematic-debugging.d.ts +3 -0
- package/dist/skills/systematic-debugging.d.ts.map +1 -0
- package/dist/skills/systematic-debugging.js +43 -0
- package/dist/skills/systematic-debugging.js.map +1 -0
- package/dist/skills/tdd.d.ts +3 -0
- package/dist/skills/tdd.d.ts.map +1 -0
- package/dist/skills/tdd.js +38 -0
- package/dist/skills/tdd.js.map +1 -0
- package/dist/skills/triage.d.ts +3 -0
- package/dist/skills/triage.d.ts.map +1 -0
- package/dist/skills/triage.js +34 -0
- package/dist/skills/triage.js.map +1 -0
- package/dist/skills/verification.d.ts +3 -0
- package/dist/skills/verification.d.ts.map +1 -0
- package/dist/skills/verification.js +30 -0
- package/dist/skills/verification.js.map +1 -0
- package/dist/skills/writing-plans.d.ts +3 -0
- package/dist/skills/writing-plans.d.ts.map +1 -0
- package/dist/skills/writing-plans.js +41 -0
- package/dist/skills/writing-plans.js.map +1 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +3 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/nwt.d.ts +70 -0
- package/dist/tools/nwt.d.ts.map +1 -0
- package/dist/tools/nwt.js +289 -0
- package/dist/tools/nwt.js.map +1 -0
- package/dist/tui/app.d.ts.map +1 -1
- package/dist/tui/app.js +6 -6
- package/dist/tui/app.js.map +1 -1
- package/dist/tui/components/ChatList.d.ts +4 -5
- package/dist/tui/components/ChatList.d.ts.map +1 -1
- package/dist/tui/components/ChatList.js +3 -3
- package/dist/tui/components/ChatList.js.map +1 -1
- package/dist/tui/components/ChatMessage.d.ts +2 -1
- package/dist/tui/components/ChatMessage.d.ts.map +1 -1
- package/dist/tui/components/ChatMessage.js +7 -7
- package/dist/tui/components/ChatMessage.js.map +1 -1
- package/dist/tui/components/Header.d.ts.map +1 -1
- package/dist/tui/components/Header.js +1 -1
- package/dist/tui/components/Header.js.map +1 -1
- package/dist/tui/components/StatusBar.d.ts +9 -0
- package/dist/tui/components/StatusBar.d.ts.map +1 -0
- package/dist/tui/components/StatusBar.js +8 -0
- package/dist/tui/components/StatusBar.js.map +1 -0
- package/dist/tui/components/Thinking.js +1 -1
- package/dist/tui/components/Thinking.js.map +1 -1
- package/dist/tui/components/ToolCall.d.ts +2 -1
- package/dist/tui/components/ToolCall.d.ts.map +1 -1
- package/dist/tui/components/ToolCall.js +29 -24
- package/dist/tui/components/ToolCall.js.map +1 -1
- package/dist/tui/components/UserInput.d.ts.map +1 -1
- package/dist/tui/components/UserInput.js +16 -22
- package/dist/tui/components/UserInput.js.map +1 -1
- package/dist/tui/hooks/useCommands.d.ts.map +1 -1
- package/dist/tui/hooks/useCommands.js +28 -1
- package/dist/tui/hooks/useCommands.js.map +1 -1
- package/package.json +1 -1
- package/src/app/index.ts +12 -6
- package/src/cmd/index.tsx +1 -1
- package/src/prompts/index.ts +8 -0
- package/src/skills/brainstorming.ts +43 -0
- package/src/skills/code-review.ts +45 -0
- package/src/skills/executing-plans.ts +27 -0
- package/src/skills/frontend-design.ts +35 -0
- package/src/skills/git-workflow.ts +36 -0
- package/src/skills/improve-architecture.ts +38 -0
- package/src/skills/index.ts +136 -0
- package/src/skills/neuroweave.ts +47 -0
- package/src/skills/playwright.ts +72 -0
- package/src/skills/prototype.ts +30 -0
- package/src/skills/subagent.ts +28 -0
- package/src/skills/supabase.ts +44 -0
- package/src/skills/systematic-debugging.ts +44 -0
- package/src/skills/tdd.ts +39 -0
- package/src/skills/triage.ts +35 -0
- package/src/skills/verification.ts +31 -0
- package/src/skills/writing-plans.ts +42 -0
- package/src/tools/index.ts +3 -0
- package/src/tools/nwt.ts +362 -0
- package/src/tui/app.tsx +9 -8
- package/src/tui/components/ChatList.tsx +6 -3
- package/src/tui/components/ChatMessage.tsx +15 -12
- package/src/tui/components/Header.tsx +13 -7
- package/src/tui/components/StatusBar.tsx +30 -0
- package/src/tui/components/Thinking.tsx +3 -3
- package/src/tui/components/ToolCall.tsx +34 -32
- package/src/tui/components/UserInput.tsx +22 -40
- package/src/tui/hooks/useCommands.ts +29 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skills Registry - Built-in skills for development workflows
|
|
3
|
+
* Inspired by skills.sh (obra/superpowers, mattpocock/skills, anthropics/skills)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface Skill {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
category: 'planning' | 'debugging' | 'testing' | 'architecture' | 'workflow' | 'browser' | 'review';
|
|
11
|
+
prompt: string;
|
|
12
|
+
autoActivate?: string[]; // Keywords that auto-activate this skill
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Import all skills
|
|
16
|
+
import { writingPlansSkill } from './writing-plans.js';
|
|
17
|
+
import { executingPlansSkill } from './executing-plans.js';
|
|
18
|
+
import { systematicDebuggingSkill } from './systematic-debugging.js';
|
|
19
|
+
import { brainstormingSkill } from './brainstorming.js';
|
|
20
|
+
import { tddSkill } from './tdd.js';
|
|
21
|
+
import { improveArchitectureSkill } from './improve-architecture.js';
|
|
22
|
+
import { verificationSkill } from './verification.js';
|
|
23
|
+
import { codeReviewSkill } from './code-review.js';
|
|
24
|
+
import { prototypeSkill } from './prototype.js';
|
|
25
|
+
import { triageSkill } from './triage.js';
|
|
26
|
+
import { gitWorkflowSkill } from './git-workflow.js';
|
|
27
|
+
import { subagentSkill } from './subagent.js';
|
|
28
|
+
import { playwrightSkill } from './playwright.js';
|
|
29
|
+
import { frontendDesignSkill } from './frontend-design.js';
|
|
30
|
+
import { supabaseSkill } from './supabase.js';
|
|
31
|
+
import { neuroweaveSkill } from './neuroweave.js';
|
|
32
|
+
|
|
33
|
+
// All built-in skills (16 total)
|
|
34
|
+
export const BUILTIN_SKILLS: Skill[] = [
|
|
35
|
+
writingPlansSkill,
|
|
36
|
+
executingPlansSkill,
|
|
37
|
+
systematicDebuggingSkill,
|
|
38
|
+
brainstormingSkill,
|
|
39
|
+
tddSkill,
|
|
40
|
+
improveArchitectureSkill,
|
|
41
|
+
verificationSkill,
|
|
42
|
+
codeReviewSkill,
|
|
43
|
+
prototypeSkill,
|
|
44
|
+
triageSkill,
|
|
45
|
+
gitWorkflowSkill,
|
|
46
|
+
subagentSkill,
|
|
47
|
+
playwrightSkill,
|
|
48
|
+
frontendDesignSkill,
|
|
49
|
+
supabaseSkill,
|
|
50
|
+
neuroweaveSkill,
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
// Skill registry
|
|
54
|
+
export class SkillRegistry {
|
|
55
|
+
private skills: Map<string, Skill> = new Map();
|
|
56
|
+
private activeSkills: Set<string> = new Set();
|
|
57
|
+
|
|
58
|
+
constructor() {
|
|
59
|
+
for (const skill of BUILTIN_SKILLS) {
|
|
60
|
+
this.skills.set(skill.id, skill);
|
|
61
|
+
}
|
|
62
|
+
// Default active skills
|
|
63
|
+
this.activeSkills.add('writing-plans');
|
|
64
|
+
this.activeSkills.add('systematic-debugging');
|
|
65
|
+
this.activeSkills.add('verification');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get(id: string): Skill | undefined {
|
|
69
|
+
return this.skills.get(id);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
list(): Skill[] {
|
|
73
|
+
return [...this.skills.values()];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
listActive(): Skill[] {
|
|
77
|
+
return [...this.activeSkills].map(id => this.skills.get(id)!).filter(Boolean);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
activate(id: string): boolean {
|
|
81
|
+
if (this.skills.has(id)) {
|
|
82
|
+
this.activeSkills.add(id);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
deactivate(id: string): boolean {
|
|
89
|
+
return this.activeSkills.delete(id);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
isActive(id: string): boolean {
|
|
93
|
+
return this.activeSkills.has(id);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Get all active skill prompts for system prompt injection
|
|
98
|
+
*/
|
|
99
|
+
getActivePrompts(): string {
|
|
100
|
+
const active = this.listActive();
|
|
101
|
+
if (active.length === 0) return '';
|
|
102
|
+
|
|
103
|
+
return active.map(s => `### Skill: ${s.name}\n${s.prompt}`).join('\n\n');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Auto-activate skills based on user input
|
|
108
|
+
*/
|
|
109
|
+
autoActivate(input: string): void {
|
|
110
|
+
const lower = input.toLowerCase();
|
|
111
|
+
for (const skill of this.skills.values()) {
|
|
112
|
+
if (skill.autoActivate?.some(kw => lower.includes(kw))) {
|
|
113
|
+
this.activeSkills.add(skill.id);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
writingPlansSkill,
|
|
121
|
+
executingPlansSkill,
|
|
122
|
+
systematicDebuggingSkill,
|
|
123
|
+
brainstormingSkill,
|
|
124
|
+
tddSkill,
|
|
125
|
+
improveArchitectureSkill,
|
|
126
|
+
verificationSkill,
|
|
127
|
+
codeReviewSkill,
|
|
128
|
+
prototypeSkill,
|
|
129
|
+
triageSkill,
|
|
130
|
+
gitWorkflowSkill,
|
|
131
|
+
subagentSkill,
|
|
132
|
+
playwrightSkill,
|
|
133
|
+
frontendDesignSkill,
|
|
134
|
+
supabaseSkill,
|
|
135
|
+
neuroweaveSkill,
|
|
136
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Skill } from './index.js';
|
|
2
|
+
|
|
3
|
+
export const neuroweaveSkill: Skill = {
|
|
4
|
+
id: 'neuroweave',
|
|
5
|
+
name: 'NeuroWeave Timeline',
|
|
6
|
+
description: 'Project evolution memory - track decisions, changes, and milestones',
|
|
7
|
+
category: 'workflow',
|
|
8
|
+
autoActivate: ['timeline', 'history', 'what changed', 'why was', 'track'],
|
|
9
|
+
prompt: `## NeuroWeave Timeline (NWT)
|
|
10
|
+
|
|
11
|
+
You have access to the NWT tool for tracking project evolution. Use it to:
|
|
12
|
+
|
|
13
|
+
### When to Log Events
|
|
14
|
+
- **After significant changes**: New features, refactors, bug fixes
|
|
15
|
+
- **When making decisions**: Architecture choices, library selection, design patterns
|
|
16
|
+
- **At milestones**: Feature complete, tests passing, deployment ready
|
|
17
|
+
|
|
18
|
+
### How to Log
|
|
19
|
+
\`\`\`
|
|
20
|
+
nwt log
|
|
21
|
+
task: "Add user authentication"
|
|
22
|
+
summary: "Implemented JWT-based auth with login/register endpoints"
|
|
23
|
+
reason: "Need user accounts for personalized features"
|
|
24
|
+
files: "src/auth.ts, src/routes/auth.ts"
|
|
25
|
+
tags: "feature, auth, api"
|
|
26
|
+
\`\`\`
|
|
27
|
+
|
|
28
|
+
### Tags Convention
|
|
29
|
+
- \`feature\` - New functionality
|
|
30
|
+
- \`fix\` - Bug fixes
|
|
31
|
+
- \`refactor\` - Code restructuring
|
|
32
|
+
- \`decision\` - Architecture/design decisions
|
|
33
|
+
- \`milestone\` - Project milestones
|
|
34
|
+
- \`config\` - Configuration changes
|
|
35
|
+
- \`docs\` - Documentation updates
|
|
36
|
+
|
|
37
|
+
### Auto-log Rule
|
|
38
|
+
After completing a multi-step task, automatically log it to NWT with:
|
|
39
|
+
- task: What was done (imperative)
|
|
40
|
+
- summary: How it was done
|
|
41
|
+
- reason: Why it was done
|
|
42
|
+
- files: What files changed
|
|
43
|
+
- tags: Category labels
|
|
44
|
+
|
|
45
|
+
### Archives
|
|
46
|
+
Events older than 30 days are automatically archived. Use \`nwt story\` to see the full project narrative.`,
|
|
47
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Skill } from './index.js';
|
|
2
|
+
|
|
3
|
+
export const playwrightSkill: Skill = {
|
|
4
|
+
id: 'playwright',
|
|
5
|
+
name: 'Playwright Browser Automation',
|
|
6
|
+
description: 'Automate browser tasks: testing, scraping, screenshots',
|
|
7
|
+
category: 'browser',
|
|
8
|
+
autoActivate: ['browser', 'screenshot', 'scrape', 'web', '网页', '浏览器', 'playwright', 'e2e'],
|
|
9
|
+
prompt: `## Playwright Browser Automation
|
|
10
|
+
|
|
11
|
+
You can use the shell tool to run Playwright commands for browser automation.
|
|
12
|
+
|
|
13
|
+
### Setup
|
|
14
|
+
\`\`\`bash
|
|
15
|
+
npm install playwright
|
|
16
|
+
npx playwright install chromium
|
|
17
|
+
\`\`\`
|
|
18
|
+
|
|
19
|
+
### Common Tasks
|
|
20
|
+
|
|
21
|
+
**Take a screenshot:**
|
|
22
|
+
\`\`\`bash
|
|
23
|
+
npx playwright screenshot https://example.com screenshot.png
|
|
24
|
+
\`\`\`
|
|
25
|
+
|
|
26
|
+
**Scrape page content:**
|
|
27
|
+
\`\`\`javascript
|
|
28
|
+
// save as scrape.js
|
|
29
|
+
const { chromium } = require('playwright');
|
|
30
|
+
(async () => {
|
|
31
|
+
const browser = await chromium.launch();
|
|
32
|
+
const page = await browser.newPage();
|
|
33
|
+
await page.goto('https://example.com');
|
|
34
|
+
const title = await page.title();
|
|
35
|
+
const text = await page.textContent('body');
|
|
36
|
+
console.log('Title:', title);
|
|
37
|
+
console.log('Content:', text.slice(0, 500));
|
|
38
|
+
await browser.close();
|
|
39
|
+
})();
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
**Fill and submit forms:**
|
|
43
|
+
\`\`\`javascript
|
|
44
|
+
await page.fill('#username', 'user');
|
|
45
|
+
await page.fill('#password', 'pass');
|
|
46
|
+
await page.click('button[type="submit"]');
|
|
47
|
+
\`\`\`
|
|
48
|
+
|
|
49
|
+
**Wait for dynamic content:**
|
|
50
|
+
\`\`\`javascript
|
|
51
|
+
await page.waitForSelector('.results');
|
|
52
|
+
await page.waitForLoadState('networkidle');
|
|
53
|
+
\`\`\`
|
|
54
|
+
|
|
55
|
+
**E2E Testing:**
|
|
56
|
+
\`\`\`javascript
|
|
57
|
+
const { test, expect } = require('@playwright/test');
|
|
58
|
+
test('login flow', async ({ page }) => {
|
|
59
|
+
await page.goto('/login');
|
|
60
|
+
await page.fill('#email', 'test@example.com');
|
|
61
|
+
await page.fill('#password', 'password');
|
|
62
|
+
await page.click('button[type="submit"]');
|
|
63
|
+
await expect(page).toHaveURL('/dashboard');
|
|
64
|
+
});
|
|
65
|
+
\`\`\`
|
|
66
|
+
|
|
67
|
+
### Best Practices
|
|
68
|
+
- Use \`waitForSelector\` before interacting with elements
|
|
69
|
+
- Use \`page.locator()\` for reliable element selection
|
|
70
|
+
- Take screenshots for visual verification
|
|
71
|
+
- Use \`--headed\` flag to watch: \`npx playwright test --headed\``,
|
|
72
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Skill } from './index.js';
|
|
2
|
+
|
|
3
|
+
export const prototypeSkill: Skill = {
|
|
4
|
+
id: 'prototype',
|
|
5
|
+
name: 'Rapid Prototyping',
|
|
6
|
+
description: 'Quick working prototypes before production code',
|
|
7
|
+
category: 'workflow',
|
|
8
|
+
autoActivate: ['prototype', '原型', '快速实现', 'quick', 'demo'],
|
|
9
|
+
prompt: `## Rapid Prototyping Mode
|
|
10
|
+
|
|
11
|
+
When the user wants to quickly try something:
|
|
12
|
+
|
|
13
|
+
### Principles
|
|
14
|
+
- **Working > Perfect** - Get something running first
|
|
15
|
+
- **Skip boilerplate** - Use minimal setup
|
|
16
|
+
- **Hardcode first** - Constants before config
|
|
17
|
+
- **Single file** - Don't split until needed
|
|
18
|
+
|
|
19
|
+
### Workflow
|
|
20
|
+
1. Create a single file with everything
|
|
21
|
+
2. Make it work end-to-end
|
|
22
|
+
3. Show the result
|
|
23
|
+
4. Ask: "Want me to refactor this into proper code?"
|
|
24
|
+
|
|
25
|
+
### When to Use
|
|
26
|
+
- Exploring a new API or library
|
|
27
|
+
- Testing a design idea
|
|
28
|
+
- Creating a quick demo
|
|
29
|
+
- Validating an approach`,
|
|
30
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Skill } from './index.js';
|
|
2
|
+
|
|
3
|
+
export const subagentSkill: Skill = {
|
|
4
|
+
id: 'subagent',
|
|
5
|
+
name: 'Subagent Delegation',
|
|
6
|
+
description: 'Break complex tasks into parallel subtasks',
|
|
7
|
+
category: 'workflow',
|
|
8
|
+
prompt: `## Task Decomposition
|
|
9
|
+
|
|
10
|
+
For complex tasks, think about what can be done in parallel:
|
|
11
|
+
|
|
12
|
+
### Parallel-izable Tasks
|
|
13
|
+
- Reading multiple independent files
|
|
14
|
+
- Running multiple independent commands
|
|
15
|
+
- Creating multiple independent files
|
|
16
|
+
- Testing multiple independent features
|
|
17
|
+
|
|
18
|
+
### Sequential Tasks (must be done in order)
|
|
19
|
+
- Build → Test → Deploy
|
|
20
|
+
- Read → Analyze → Write
|
|
21
|
+
- Design → Implement → Verify
|
|
22
|
+
|
|
23
|
+
### When Task is Complex
|
|
24
|
+
1. Identify independent subtasks
|
|
25
|
+
2. Execute them (in parallel if possible)
|
|
26
|
+
3. Combine results
|
|
27
|
+
4. Verify the whole`,
|
|
28
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Skill } from './index.js';
|
|
2
|
+
|
|
3
|
+
export const supabaseSkill: Skill = {
|
|
4
|
+
id: 'supabase',
|
|
5
|
+
name: 'Supabase Best Practices',
|
|
6
|
+
description: 'PostgreSQL and Supabase patterns for backend development',
|
|
7
|
+
category: 'architecture',
|
|
8
|
+
autoActivate: ['supabase', 'postgres', 'database', 'sql', '数据库'],
|
|
9
|
+
prompt: `## Supabase / PostgreSQL Best Practices
|
|
10
|
+
|
|
11
|
+
### Schema Design
|
|
12
|
+
- Use UUIDs for primary keys (\`gen_random_uuid()\`)
|
|
13
|
+
- Always add \`created_at\` and \`updated_at\` timestamps
|
|
14
|
+
- Use enums for fixed sets of values
|
|
15
|
+
- Normalize first, denormalize for performance
|
|
16
|
+
|
|
17
|
+
### Row Level Security (RLS)
|
|
18
|
+
- Always enable RLS on tables
|
|
19
|
+
- Write policies for each operation (SELECT, INSERT, UPDATE, DELETE)
|
|
20
|
+
- Use \`auth.uid()\` for user-specific access
|
|
21
|
+
- Test policies thoroughly
|
|
22
|
+
|
|
23
|
+
### Queries
|
|
24
|
+
- Use \`select()\` with specific columns, not \`select('*')\`
|
|
25
|
+
- Use \`maybeSingle()\` instead of \`single()\` when 0 rows is valid
|
|
26
|
+
- Use \`range()\` for pagination
|
|
27
|
+
- Index columns used in WHERE and JOIN
|
|
28
|
+
|
|
29
|
+
### Common Patterns
|
|
30
|
+
\`\`\`typescript
|
|
31
|
+
// Insert with returning
|
|
32
|
+
const { data, error } = await supabase
|
|
33
|
+
.from('posts')
|
|
34
|
+
.insert({ title, content, user_id: user.id })
|
|
35
|
+
.select()
|
|
36
|
+
.single();
|
|
37
|
+
|
|
38
|
+
// Realtime subscriptions
|
|
39
|
+
const channel = supabase
|
|
40
|
+
.channel('changes')
|
|
41
|
+
.on('postgres_changes', { event: '*', schema: 'public', table: 'messages' }, handleChange)
|
|
42
|
+
.subscribe();
|
|
43
|
+
\`\`\``,
|
|
44
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Skill } from './index.js';
|
|
2
|
+
|
|
3
|
+
export const systematicDebuggingSkill: Skill = {
|
|
4
|
+
id: 'systematic-debugging',
|
|
5
|
+
name: 'Systematic Debugging',
|
|
6
|
+
description: 'Structured approach to finding and fixing bugs',
|
|
7
|
+
category: 'debugging',
|
|
8
|
+
autoActivate: ['bug', 'error', 'fix', 'debug', '不工作', '报错', '出错', '问题'],
|
|
9
|
+
prompt: `## Debugging Protocol
|
|
10
|
+
|
|
11
|
+
When debugging an issue, follow this systematic approach:
|
|
12
|
+
|
|
13
|
+
### 1. Understand the Problem
|
|
14
|
+
- What is the expected behavior?
|
|
15
|
+
- What is the actual behavior?
|
|
16
|
+
- When does it happen? (always, sometimes, specific conditions)
|
|
17
|
+
- What changed recently?
|
|
18
|
+
|
|
19
|
+
### 2. Gather Evidence
|
|
20
|
+
- Read error messages carefully - they often tell you exactly what's wrong
|
|
21
|
+
- Check logs, console output, stack traces
|
|
22
|
+
- Reproduce the issue reliably before attempting fixes
|
|
23
|
+
|
|
24
|
+
### 3. Form Hypotheses
|
|
25
|
+
- List 2-3 possible causes, ranked by likelihood
|
|
26
|
+
- For each hypothesis: "If X is the cause, then Y should be true"
|
|
27
|
+
|
|
28
|
+
### 4. Test Hypotheses
|
|
29
|
+
- Test the most likely hypothesis first
|
|
30
|
+
- Use minimal changes to isolate the issue
|
|
31
|
+
- Add debug logging if needed
|
|
32
|
+
|
|
33
|
+
### 5. Fix and Verify
|
|
34
|
+
- Apply the minimal fix that addresses the root cause
|
|
35
|
+
- Verify the fix works
|
|
36
|
+
- Check for regressions
|
|
37
|
+
- Explain WHY the fix works
|
|
38
|
+
|
|
39
|
+
### Anti-patterns to Avoid
|
|
40
|
+
- Don't make random changes hoping something works
|
|
41
|
+
- Don't change multiple things at once
|
|
42
|
+
- Don't skip the "understand" phase
|
|
43
|
+
- Don't fix symptoms instead of root causes`,
|
|
44
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Skill } from './index.js';
|
|
2
|
+
|
|
3
|
+
export const tddSkill: Skill = {
|
|
4
|
+
id: 'tdd',
|
|
5
|
+
name: 'Test-Driven Development',
|
|
6
|
+
description: 'Write tests first, then implement to pass them',
|
|
7
|
+
category: 'testing',
|
|
8
|
+
autoActivate: ['test', '测试', 'tdd', '写测试', '单元测试'],
|
|
9
|
+
prompt: `## TDD Workflow
|
|
10
|
+
|
|
11
|
+
When implementing new features, follow the Red-Green-Refactor cycle:
|
|
12
|
+
|
|
13
|
+
### 1. Red - Write a Failing Test
|
|
14
|
+
- Write the test FIRST
|
|
15
|
+
- Run it and confirm it FAILS
|
|
16
|
+
- This proves the test is actually testing something
|
|
17
|
+
|
|
18
|
+
### 2. Green - Make It Pass
|
|
19
|
+
- Write the MINIMUM code to make the test pass
|
|
20
|
+
- Don't over-engineer
|
|
21
|
+
- Run the test and confirm it PASSES
|
|
22
|
+
|
|
23
|
+
### 3. Refactor - Clean Up
|
|
24
|
+
- Now that tests protect you, improve the code
|
|
25
|
+
- Run tests after each change to ensure nothing broke
|
|
26
|
+
|
|
27
|
+
### Test Naming
|
|
28
|
+
\`\`\`
|
|
29
|
+
describe('FeatureName', () => {
|
|
30
|
+
it('should do X when Y', () => { ... });
|
|
31
|
+
it('should handle edge case Z', () => { ... });
|
|
32
|
+
});
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
### Always Test
|
|
36
|
+
- Happy path (normal usage)
|
|
37
|
+
- Edge cases (empty input, null, boundary values)
|
|
38
|
+
- Error cases (invalid input, missing data)`,
|
|
39
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Skill } from './index.js';
|
|
2
|
+
|
|
3
|
+
export const triageSkill: Skill = {
|
|
4
|
+
id: 'triage',
|
|
5
|
+
name: 'Issue Triage',
|
|
6
|
+
description: 'Quickly diagnose and prioritize issues',
|
|
7
|
+
category: 'debugging',
|
|
8
|
+
autoActivate: ['issue', 'problem', 'not working', 'broken', '不工作', '挂了'],
|
|
9
|
+
prompt: `## Issue Triage
|
|
10
|
+
|
|
11
|
+
When something is broken, quickly assess:
|
|
12
|
+
|
|
13
|
+
### Severity Classification
|
|
14
|
+
- **P0 Critical**: System down, data loss, security breach
|
|
15
|
+
- **P1 High**: Major feature broken, no workaround
|
|
16
|
+
- **P2 Medium**: Feature degraded, workaround exists
|
|
17
|
+
- **P3 Low**: Minor issue, cosmetic, nice-to-have
|
|
18
|
+
|
|
19
|
+
### Quick Diagnosis
|
|
20
|
+
1. **What changed?** - Recent commits, deployments, config changes
|
|
21
|
+
2. **Who is affected?** - All users, some users, specific environment
|
|
22
|
+
3. **When did it start?** - Timeline of first occurrence
|
|
23
|
+
4. **What's the impact?** - Data loss, functionality, UX
|
|
24
|
+
|
|
25
|
+
### Triage Output
|
|
26
|
+
\`\`\`
|
|
27
|
+
## Triage: [Issue Title]
|
|
28
|
+
|
|
29
|
+
**Severity**: P1 High
|
|
30
|
+
**Impact**: [who/what is affected]
|
|
31
|
+
**Root Cause**: [best guess based on evidence]
|
|
32
|
+
**Suggested Fix**: [minimal fix approach]
|
|
33
|
+
**Workaround**: [if any]
|
|
34
|
+
\`\`\``,
|
|
35
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Skill } from './index.js';
|
|
2
|
+
|
|
3
|
+
export const verificationSkill: Skill = {
|
|
4
|
+
id: 'verification',
|
|
5
|
+
name: 'Verification Before Completion',
|
|
6
|
+
description: 'Always verify work before marking as done',
|
|
7
|
+
category: 'workflow',
|
|
8
|
+
prompt: `## Verification Protocol
|
|
9
|
+
|
|
10
|
+
Before saying "done", always verify:
|
|
11
|
+
|
|
12
|
+
### For Code Changes
|
|
13
|
+
1. **Read the file** - Confirm the change was actually saved
|
|
14
|
+
2. **Check syntax** - Make sure there are no syntax errors
|
|
15
|
+
3. **Run tests** - If tests exist, run them
|
|
16
|
+
4. **Check imports** - Verify all imports resolve
|
|
17
|
+
|
|
18
|
+
### For File Operations
|
|
19
|
+
1. **Verify file exists** - Check the file was created/modified
|
|
20
|
+
2. **Read it back** - Confirm the content is correct
|
|
21
|
+
3. **Check permissions** - Ensure the file is accessible
|
|
22
|
+
|
|
23
|
+
### For Commands
|
|
24
|
+
1. **Check exit code** - Was it 0?
|
|
25
|
+
2. **Read output** - Look for warnings or errors
|
|
26
|
+
3. **Verify side effects** - Did the command do what was expected?
|
|
27
|
+
|
|
28
|
+
### Never Say "Done" Without
|
|
29
|
+
- Seeing actual output confirming success
|
|
30
|
+
- Or running a verification command`,
|
|
31
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Skill } from './index.js';
|
|
2
|
+
|
|
3
|
+
export const writingPlansSkill: Skill = {
|
|
4
|
+
id: 'writing-plans',
|
|
5
|
+
name: 'Writing Plans',
|
|
6
|
+
description: 'Break down complex tasks into step-by-step execution plans',
|
|
7
|
+
category: 'planning',
|
|
8
|
+
autoActivate: ['plan', '怎么实现', '如何做', '方案', '设计', '架构'],
|
|
9
|
+
prompt: `## Planning Mode
|
|
10
|
+
|
|
11
|
+
When the user asks you to plan something or the task is complex:
|
|
12
|
+
|
|
13
|
+
1. **Understand the goal** - Clarify what the user wants to achieve
|
|
14
|
+
2. **Explore the codebase** - Read relevant files to understand context
|
|
15
|
+
3. **Break it down** - Create a numbered list of concrete steps
|
|
16
|
+
4. **Identify risks** - Note potential issues or blockers
|
|
17
|
+
5. **Estimate complexity** - Mark steps as simple/medium/complex
|
|
18
|
+
|
|
19
|
+
### Plan Format
|
|
20
|
+
\`\`\`
|
|
21
|
+
## Plan: [Task Description]
|
|
22
|
+
|
|
23
|
+
### Context
|
|
24
|
+
- What we know about the current state
|
|
25
|
+
- Files/modules involved
|
|
26
|
+
|
|
27
|
+
### Steps
|
|
28
|
+
1. [Step description] (simple/medium/complex)
|
|
29
|
+
2. [Step description]
|
|
30
|
+
- Sub-step if needed
|
|
31
|
+
3. [Step description]
|
|
32
|
+
|
|
33
|
+
### Risks
|
|
34
|
+
- [Potential issue and mitigation]
|
|
35
|
+
|
|
36
|
+
### Files to modify
|
|
37
|
+
- path/to/file1.ts - [what changes]
|
|
38
|
+
- path/to/file2.ts - [what changes]
|
|
39
|
+
\`\`\`
|
|
40
|
+
|
|
41
|
+
Always present the plan to the user before executing. Ask: "Should I proceed with this plan?"`,
|
|
42
|
+
};
|
package/src/tools/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { FileTool } from './file.js';
|
|
|
8
8
|
import { ShellTool } from './shell.js';
|
|
9
9
|
import { GitTool } from './git.js';
|
|
10
10
|
import { SearchTool } from './search.js';
|
|
11
|
+
import { NwtTool } from './nwt.js';
|
|
11
12
|
|
|
12
13
|
export class ToolRegistry {
|
|
13
14
|
private tools: Map<string, Tool> = new Map();
|
|
@@ -25,6 +26,7 @@ export class ToolRegistry {
|
|
|
25
26
|
this.register(new ShellTool());
|
|
26
27
|
this.register(new GitTool());
|
|
27
28
|
this.register(new SearchTool());
|
|
29
|
+
this.register(new NwtTool());
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
setContext(ctx: Partial<ToolContext>): void {
|
|
@@ -106,3 +108,4 @@ export { FileTool } from './file.js';
|
|
|
106
108
|
export { ShellTool } from './shell.js';
|
|
107
109
|
export { GitTool } from './git.js';
|
|
108
110
|
export { SearchTool } from './search.js';
|
|
111
|
+
export { NwtTool } from './nwt.js';
|