Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Suggested prompts: "engineer", "architect" and "test" mean software only when qualified

Pixel (kwant bot)6861cfc30533
diff --git a/frontend/src/suggestedPrompts.ts b/frontend/src/suggestedPrompts.ts
index 6665a132..d5dc98fb 100644
--- a/frontend/src/suggestedPrompts.ts
+++ b/frontend/src/suggestedPrompts.ts
@@ -45,11 +45,11 @@ const ROLES: Role[] = [
},
{ match: /\b(life|career|executive|mindset) coach\b|\bcoach\b|\bmentor\b/i, asks: ['help me set goals for this month', "talk through a decision I'm stuck on"] },
{
- match: /\bdevops\b|\bsre\b|\b(cyber)?security (engineer|analyst|lead|specialist)\b|\bcybersecurity\b|\binfosec\b|\binfra(structure)?\b|\bsysadmin\b|\bplatform engineer(ing)?\b/i,
+ match: /\bdevops\b|\bsre\b|\bsite reliability\b|\bpenetration tester\b|\bpentester\b|\bethical hacker\b|\b(cyber)?security (engineer|analyst|lead|specialist)\b|\bcybersecurity\b|\binfosec\b|\binfra(structure)?\b|\bsysadmin\b|\bplatform engineer(ing)?\b/i,
asks: ["check my server's security", 'set up backups for my server'],
},
{
- match: /\bqa\b|\btest(er|ing)?\b|\bquality assurance\b|\brelease (engineer|manager)\b/i,
+ match: /\bqa\b|\bsdet\b|\bquality assurance\b|\btest (automation|engineer|lead|manager)\b|\btest(ers?|ing)\b|\brelease (engineer|manager)\b/i,
asks: ['write a test plan for the next release', 'find the riskiest part of this change'],
},
{
@@ -67,6 +67,14 @@ const ROLES: Role[] = [
asks: ['build a quick prototype', 'review my latest changes'],
generic: true,
},
+ {
+ match: /\b(sound|audio) (engineer|designer|technician|editor|producer)\b|\baudio\b|\bmusic(ian| producer)?\b|\bcomposer\b|\bdj\b|\bpodcast(er)?\b/i,
+ asks: ['pick background music for a story', 'suggest sound effects for a scene'],
+ },
+ {
+ match: /\blandscape (architect|designer|gardener)\b|\blandscap(er|ing)\b|\bgarden(er|ing)?\b|\bhorticultur/i,
+ asks: ['plan a small vegetable garden', 'suggest plants for a shady corner'],
+ },
{ match: /\bseo\b|\bkeywords?\b/i, asks: ['find keywords I could rank for', 'audit my homepage for SEO'] },
{ match: /\bmarketing\b|\bmarketer\b|\bgrowth\b|\bcampaigns?\b|\bsocial media\b|\bbrand\b/i, asks: ['draft a launch post', 'plan a two-week campaign'] },
{
@@ -94,6 +102,39 @@ const ROLES: Role[] = [
{ match: /\bphotograph|\billustrat|\bartist\b|\bgraphic design(er)?\b|\bcover design(er)?\b/i, asks: ['describe a cover image idea', 'critique this image'] },
];
+// Catch-all job words that say "software" only on their own ("Engineer", "Senior Developer") or
+// after a software word ("Web Developer", "Cloud Architect"). After any other word they name a
+// different trade: a Sound Engineer, a Landscape Architect, a Test Pilot's "test", a Taste Tester.
+const CATCH_ALL = /^(engineers?|developers?|devs?|architects?|testers?|testing|test (automation|engineer|lead|manager))$/i;
+const SOFTWARE_QUALIFIERS = new Set(
+ (
+ // seniority, and the words a persona puts before a job ("you are an engineer")
+ 'senior sr junior jr lead staff principal chief head founding associate intern freelance expert experienced skilled ' +
+ 'a an the as our your ' +
+ // software fields
+ 'software web mobile app apps ios android frontend front backend back end fullstack full stack cloud system systems ' +
+ 'solution solutions data ml ai learning platform devops game games embedded firmware api prompt qa manual beta ' +
+ // languages and frameworks
+ 'python javascript js typescript ts node react rust go golang java kotlin swift ruby rails php sql c c++ c# .net net'
+ ).split(' '),
+);
+
+/** False for a catch-all job word with a non-software word in front of it. */
+function qualifiedAsSoftware(text: string, start: number, matched: string): boolean {
+ if (!CATCH_ALL.test(matched)) return true;
+ const before = /([A-Za-z0-9+#.]+)[\s/-]+$/.exec(text.slice(0, start));
+ return !before || SOFTWARE_QUALIFIERS.has(before[1].toLowerCase());
+}
+
+/** The first match of a role's pattern that isn't a catch-all word in another trade. */
+function matchRole(role: Role, text: string): { start: number; end: number } | null {
+ const all = new RegExp(role.match.source, 'gi');
+ for (const m of text.matchAll(all)) {
+ if (qualifiedAsSoftware(text, m.index, m[0])) return { start: m.index, end: m.index + m[0].length };
+ }
+ return null;
+}
+
/**
* The role a piece of text names. A title is a noun phrase whose last word is the job
* ("Product Photographer" is a photographer), so the match ending latest wins, a longer phrase
@@ -104,9 +145,9 @@ function findRole(text: string | undefined, kind: 'title' | 'prose'): Role | nul
if (typeof text !== 'string' || !text.trim()) return null;
let best: { role: Role; start: number; end: number } | null = null;
for (const role of ROLES) {
- const m = role.match.exec(text);
+ const m = matchRole(role, text);
if (!m) continue;
- const hit = { role, start: m.index, end: m.index + m[0].length };
+ const hit = { role, ...m };
if (!best) {
best = hit;
continue;
diff --git a/frontend/tests/suggestedPrompts.test.mjs b/frontend/tests/suggestedPrompts.test.mjs
index 6d25a21d..79834766 100644
--- a/frontend/tests/suggestedPrompts.test.mjs
+++ b/frontend/tests/suggestedPrompts.test.mjs
@@ -162,3 +162,49 @@ test('a member or bot with a missing name or title is skipped, not a crash', ()
assert.deepEqual(suggestedPrompts({ kind: 'team', members: [{ title: 'Chef' }] }), []);
assert.deepEqual(suggestedPrompts({ kind: 'bot', bot: {} }), ['What can you help me with?']);
});
+
+test('"engineer", "architect" and "test" only mean software when nothing else or a software word qualifies them', () => {
+ const first = (title) => suggestedPrompts({ kind: 'bot', bot: { name: 'X', title } })[0];
+ // Rigel's second review: these got prototype, architecture and test-plan prompts.
+ assert.equal(first('Sound Engineer'), 'Pick background music for a story');
+ assert.equal(first('Landscape Architect'), 'Plan a small vegetable garden');
+ assert.equal(first('Interior Architect'), 'Suggest a layout for my living room');
+ for (const title of ['Test Pilot', 'Civil Engineer', 'Naval Architect', 'Flight Test Engineer', 'Taste Tester', 'Property Developer']) {
+ assert.equal(first(title), 'What can you help me with?', title);
+ }
+ // Software still reads as software, bare or qualified, in any case.
+ assert.equal(first('Software Architect'), 'Sketch the architecture for a new feature');
+ assert.equal(first('Cloud Architect'), 'Sketch the architecture for a new feature');
+ for (const title of ['Engineer', 'Senior Engineer', 'Web Developer', 'Full-Stack Developer', 'software engineer', 'iOS Developer']) {
+ assert.equal(first(title), 'Build a quick prototype', title);
+ }
+ for (const title of ['QA Engineer', 'Test Engineer', 'Software Tester', 'SDET']) {
+ assert.equal(first(title), 'Write a test plan for the next release', title);
+ }
+ assert.equal(first('Penetration Tester'), "Check my server's security");
+ // A persona is read the same way.
+ assert.equal(suggestedPrompts({ kind: 'bot', bot: { name: 'X', persona_prompt: 'A civil engineer who reviews bridges.' } })[0], 'What can you help me with?');
+ assert.equal(suggestedPrompts({ kind: 'bot', bot: { name: 'X', persona_prompt: 'You are an experienced software engineer.' } })[0], 'Build a quick prototype');
+});
+
+test('a storytelling team with a sound engineer gets no developer prompt, and an unmatched team gets the neutral opener', () => {
+ const story = suggestedPrompts({
+ kind: 'team',
+ lead: 'Tale',
+ purpose: 'Platform for Kids Storytelling',
+ members: [
+ { name: 'Tale', title: "Children's Book Author" },
+ { name: 'Audio', title: 'Sound Engineer' },
+ ],
+ });
+ assert.deepEqual(story, ['@Tale outline a blog post', '@Audio pick background music for a story', 'What can each of you help me with?']);
+ const civil = suggestedPrompts({
+ kind: 'team',
+ lead: 'Bridge',
+ members: [
+ { name: 'Bridge', title: 'Civil Engineer' },
+ { name: 'Pilot', title: 'Test Pilot' },
+ ],
+ });
+ assert.deepEqual(civil, ['@Bridge what should we tackle first?', 'What can each of you help me with?']);
+});