Skip to content

Commit c9dc2c5

Browse files
Major codebase cleanup and refactoring (#9)
# TLDR; Large-scale cleanup: refactored providers, discovery modules, and tests for consistency, strict TypeScript compliance, and better code organization. # Details - **Refactored core providers** (`CommandTreeProvider`, `QuickTasksProvider`, `TagConfig`) — reduced complexity, improved functional style - **Reorganized semantic/db layer** — moved `db.ts` from `semantic/` to `db/`, added `lifecycle.ts`, removed unused embedding modules (`embedder.ts`, `embeddingPipeline.ts`, `similarity.ts`, `store.ts`, `types.ts`, `index.ts`) - **Added new discovery modules** — C# script (`csharp-script.ts`), F# script (`fsharp-script.ts`) discovery - **Extracted reusable code** — `powershellParser.ts`, `nodeFactory.ts`, `tagSync.ts`, `watchers.ts` - **Overhauled tests** — replaced fake/indirect tests with proper E2E tests, added unit tests (`discovery.unit.test.ts`, `modelSelection.unit.test.ts`, `taskRunner.unit.test.ts`, `treehierarchy.unit.test.ts`), removed Copilot-dependent and embedding tests - **CI improvements** — added format check, spell check, coverage threshold (90%), excluded Copilot-dependent tests - **Added docs** — split SPEC.md into focused doc files, added Rust LSP plan/spec - **Added Claude skills** — `ci-prep`, `fix-bug` for agent workflows - **ESLint/Prettier/tsconfig** tightened — stricter rules, consistent formatting - **Website** — minor content and config updates # How do the tests prove the change works - 65 unit tests pass covering tree hierarchy, model selection, task runner params, PowerShell parsing, and discovery logic - E2E tests cover all major user flows: discovery, execution, filtering, quick tasks, tagging, tree view, configuration, markdown, and AI summaries - CI enforces 90% coverage threshold on lines, functions, branches, and statements ---------
1 parent a2596a6 commit c9dc2c5

127 files changed

Lines changed: 11205 additions & 10582 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(git push:*)",
5+
"WebFetch(domain:code.visualstudio.com)",
6+
"mcp__too-many-cooks__lock",
7+
"Bash(npm run compile:*)",
8+
"Bash(node -e:*)",
9+
"Bash(npx tsc:*)",
10+
"Bash(npm run lint:*)",
11+
"mcp__too-many-cooks__message",
12+
"mcp__too-many-cooks__register",
13+
"Bash(git add:*)",
14+
"Bash(git commit:*)",
15+
"Bash(find /Users/christianfindlay/Documents/Code/tmc/too-many-cooks -name test*.sh -o -name *test.sh)",
16+
"mcp__too-many-cooks__plan",
17+
"Bash(npm ci:*)",
18+
"Bash(npm run:*)",
19+
"Bash(npx cspell:*)",
20+
"Bash(gh pr:*)",
21+
"Bash(gh run:*)"
22+
]
23+
},
24+
"autoMemoryEnabled": false
25+
}

.claude/skills/ci-prep/SKILL.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
name: ci-prep
3+
description: Prepare the codebase for CI. Reads the CI workflow, builds a checklist, then loops through format/lint/build/test/coverage until every single check passes. Use before submitting a PR or when the user wants to ensure CI will pass.
4+
argument-hint: "[optional focus area]"
5+
allowed-tools: Read, Grep, Glob, Edit, Write, Bash
6+
---
7+
8+
# CI Prep — Get the Codebase PR-Ready
9+
10+
You MUST NOT STOP until every check passes and coverage threshold is met.
11+
12+
## Step 1: Read the CI Pipeline and Build Your Checklist
13+
14+
Read the CI workflow file:
15+
16+
```bash
17+
cat .github/workflows/ci.yml
18+
```
19+
20+
Parse EVERY step in the workflow. Extract the exact commands CI runs. Build yourself a numbered checklist of every check you need to pass. This is YOUR checklist — derived from the actual CI config, not from assumptions. The CI pipeline changes over time so you MUST read it fresh and build your list from what you find.
21+
22+
## Step 2: Coordinate with Other Agents
23+
24+
You are likely working alongside other agents who are editing files concurrently. Before making changes:
25+
26+
1. Check TMC status and messages for active agents and locked files
27+
2. Do NOT edit files that are locked by other agents
28+
3. Lock files before editing them yourself
29+
4. Communicate what you are doing via TMC broadcasts
30+
5. After each fix cycle, check TMC again — another agent may have broken something
31+
32+
## Step 3: The Loop
33+
34+
Run through your checklist from Step 1 in order. For each check:
35+
36+
1. Run the exact command from CI
37+
2. If it passes, move to the next check
38+
3. If it fails, FIX IT. Do NOT suppress warnings, ignore errors, remove assertions, or lower thresholds. Fix the actual code.
39+
4. Re-run that check to confirm the fix works
40+
5. Move to the next check
41+
42+
When you reach the end of the checklist, GO BACK TO THE START AND RUN THE ENTIRE CHECKLIST AGAIN. Other agents are working concurrently and may have broken something you already fixed. A fix for one check may have broken an earlier check.
43+
44+
**Keep looping through the full checklist until you get a COMPLETE CLEAN RUN with ZERO failures from start to finish.** One clean pass is not enough if you fixed anything during that pass — you need a clean pass where NOTHING needed fixing.
45+
46+
Do NOT stop after one loop. Do NOT stop after two loops. Keep going until a full pass completes with every single check green on the first try.
47+
48+
## Step 4: Final Coordination
49+
50+
1. Broadcast on TMC that CI prep is complete and all checks pass
51+
2. Release any locks you hold
52+
3. Report the final status to the user with the output of each passing check
53+
54+
## Rules
55+
56+
- NEVER stop with failing checks. Loop until everything is green.
57+
- NEVER suppress lint warnings, skip tests, or lower coverage thresholds.
58+
- NEVER remove assertions to make tests pass.
59+
- Fix the CODE, not the checks.
60+
- If you are stuck on a failure after 3 attempts on the same issue, ask the user for help. Do NOT silently give up.
61+
- Always coordinate with other agents via TMC. Check for messages regularly.
62+
- Leave the codebase in a state that will pass CI on the first try.

.claude/skills/fix-bug/SKILL.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
name: fix-bug
3+
description: Fix a bug using test-driven development. Use when the user reports a bug, describes unexpected behavior, wants to fix a defect, or says something is broken. Enforces a strict test-first workflow where a failing test must be written and verified before any fix is attempted.
4+
argument-hint: "[bug description]"
5+
allowed-tools: Read, Grep, Glob, Edit, Write, Bash
6+
---
7+
8+
# Bug Fix Skill — Test-First Workflow
9+
10+
You MUST follow this exact workflow. Do NOT skip steps. Do NOT fix the bug before writing a failing test.
11+
12+
## Step 1: Understand the Bug
13+
14+
- Read the bug description: $ARGUMENTS
15+
- Investigate the codebase to understand the relevant code
16+
- Identify the root cause (or narrow down candidates)
17+
- Summarize your understanding of the bug to the user before proceeding
18+
19+
## Step 2: Write a Failing Test
20+
21+
- Write a test that **directly exercises the buggy behavior**
22+
- The test must assert the **correct/expected** behavior — so it FAILS against the current broken code
23+
- The test name should clearly describe the bug (e.g., `test_orange_color_not_applied_to_head`)
24+
- Use the project's existing test framework and conventions
25+
26+
## Step 3: Run the Test — Confirm It FAILS
27+
28+
- Run ONLY the new test (not the full suite)
29+
- **Verify the test FAILS** and that it fails **because of the bug**, not for some other reason (typo, import error, wrong selector, etc.)
30+
- If the test passes: your test does not capture the bug. Go back to Step 2
31+
- If the test fails for the wrong reason: fix the test, not the code. Go back to Step 2
32+
- **Repeat until the test fails specifically because of the bug**
33+
34+
## Step 4: Show Failure to User
35+
36+
- Show the user the test code and the failure output
37+
- Explicitly ask: "This test fails because of the bug. Can you confirm this captures the issue before I fix it?"
38+
- **STOP and WAIT for user acknowledgment before proceeding**
39+
- Do NOT continue to Step 5 until the user confirms
40+
41+
## Step 5: Fix the Bug
42+
43+
- Make the **minimum change** needed to fix the bug
44+
- Do not refactor, clean up, or "improve" surrounding code
45+
- Do not change the test
46+
47+
## Step 6: Run the Test — Confirm It PASSES
48+
49+
- Run the new test again
50+
- **Verify it PASSES**
51+
- If it fails: go back to Step 5 and adjust the fix
52+
- **Repeat until the test passes**
53+
54+
## Step 7: Run the Full Test Suite
55+
56+
- Run ALL tests to make sure nothing else broke
57+
- If other tests fail: fix the regression without breaking the new test
58+
- Report the final result to the user
59+
60+
## Rules
61+
62+
- NEVER fix the bug before the failing test is written and confirmed
63+
- NEVER skip asking the user to acknowledge the test failure
64+
- NEVER modify the test to make it pass — modify the source code
65+
- If you cannot write a test for the bug, explain why and ask the user how to proceed
66+
- Keep the fix minimal — one bug, one fix, one test

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717

1818
- run: npm ci
1919

20+
- name: Format check
21+
run: npm run format:check
22+
2023
- name: Lint
2124
run: npm run lint
2225

@@ -31,8 +34,11 @@ jobs:
3134
- name: Unit tests
3235
run: npm run test:unit
3336

34-
- name: E2E tests
35-
run: xvfb-run -a npm run test:e2e
37+
- name: E2E tests with coverage
38+
run: xvfb-run -a npx vscode-test --coverage --grep @exclude-ci --invert
39+
40+
- name: Coverage threshold (90%)
41+
run: npm run coverage:check
3642

3743
website:
3844
runs-on: ubuntu-latest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ src/test/fixtures/workspace/.vscode/tasktree.json
3232
website/_site/
3333

3434
.commandtree/
35+
36+
logs/

.mcp.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"mcpServers": {}
3+
}

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"singleQuote": false,
4+
"trailingComma": "es5",
5+
"tabWidth": 2,
6+
"printWidth": 120
7+
}

.vscode-test.mjs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,31 @@ cpSync('./src/test/fixtures/workspace', testWorkspace, { recursive: true });
1414
const userDataDir = resolve(__dirname, '.vscode-test/user-data');
1515

1616
export default defineConfig({
17-
files: ['out/test/e2e/**/*.test.js', 'out/test/providers/**/*.test.js'],
18-
version: 'stable',
19-
workspaceFolder: testWorkspace,
20-
extensionDevelopmentPath: './',
21-
mocha: {
22-
ui: 'tdd',
23-
timeout: 60000,
24-
color: true,
25-
slow: 10000
26-
},
27-
launchArgs: [
28-
'--disable-gpu',
29-
'--user-data-dir', userDataDir
30-
],
17+
tests: [{
18+
files: ['out/test/e2e/**/*.test.js', 'out/test/providers/**/*.test.js'],
19+
version: 'stable',
20+
workspaceFolder: testWorkspace,
21+
extensionDevelopmentPath: './',
22+
mocha: {
23+
ui: 'tdd',
24+
timeout: 60000,
25+
color: true,
26+
slow: 10000
27+
},
28+
launchArgs: [
29+
'--disable-gpu',
30+
'--user-data-dir', userDataDir
31+
]
32+
}],
3133
coverage: {
3234
include: ['out/**/*.js'],
33-
exclude: ['out/test/**/*.js'],
34-
reporter: ['text', 'lcov', 'html'],
35+
exclude: [
36+
'out/test/**/*.js',
37+
'out/semantic/summariser.js', // requires Copilot auth, not available in CI
38+
'out/semantic/summaryPipeline.js', // requires Copilot auth, not available in CI
39+
'out/semantic/vscodeAdapters.js', // requires Copilot auth, not available in CI
40+
],
41+
reporter: ['text', 'lcov', 'html', 'json-summary'],
3542
output: './coverage'
3643
}
3744
});

Agents.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ You are working with many other agents. Make sure there is effective cooperation
1111

1212
- **Zero duplication - TOP PRIORITY** - Always search for existing code before adding. Move; don't copy files. Add assertions to tests rather than duplicating tests. AIM FOR LESS CODE!
1313
- **No string literals** - Named constants only, and it ONE location
14+
- DO NOT USE GIT
1415
- **Functional style** - Prefer pure functions, avoid classes where possible
1516
- **No suppressing warnings** - Fix them properly
16-
- **No REGEX** It is absolutely ⛔️ illegal
17+
- **No REGEX** It is absolutely ⛔️ illegal, and no text matching in general
1718
- **Don't run long runnings tasks** like docker builds, tests. Ask the user to do it!!
1819
- **Expressions over assignments** - Prefer const and immutable patterns
1920
- **Named parameters** - Use object params for functions with 3+ args
@@ -23,6 +24,8 @@ You are working with many other agents. Make sure there is effective cooperation
2324

2425
### Typescript
2526
- **TypeScript strict mode** - No `any`, no implicit types, turn all lints up to error
27+
- **Regularly run the linter** - Fix lint errors IMMEDIATELY
28+
- **Decouple providers from the VSCODE SDK** - No vscode sdk use within the providers
2629
- **Ignoring lints = ⛔️ illegal** - Fix violations immediately
2730
- **No throwing** - Only return `Result<T,E>`
2831

@@ -36,7 +39,6 @@ You are working with many other agents. Make sure there is effective cooperation
3639

3740
#### Rules
3841
- **Prefer e2e tests over unit tests** - only unit tests for isolating bugs
39-
- DO NOT USE GIT
4042
- Separate e2e tests from unit tests by file. They should not be in the same file together.
4143
- Prefer adding assertions to existing tests rather than adding new tests
4244
- Test files in `src/test/suite/*.test.ts`
@@ -96,8 +98,21 @@ assert.ok(true, 'Command ran');
9698

9799
## Critical Docs
98100

101+
### Vscode SDK
99102
[VSCode Extension API](https://code.visualstudio.com/api/)
100-
[SCode Extension Testing API](https://code.visualstudio.com/api/extension-guides/testing)
103+
[VSCode Extension Testing API](https://code.visualstudio.com/api/extension-guides/testing)
104+
[VSCODE Language Model API](https://code.visualstudio.com/api/extension-guides/ai/language-model)
105+
[Language Model Tool API](https://code.visualstudio.com/api/extension-guides/ai/tools)
106+
[AI extensibility in VS Cod](https://code.visualstudio.com/api/extension-guides/ai/ai-extensibility-overview)
107+
[AI language models in VS Code](https://code.visualstudio.com/docs/copilot/customization/language-models)
108+
109+
### Website
110+
111+
https://developers.google.com/search/blog/2025/05/succeeding-in-ai-search
112+
https://developers.google.com/search/docs/fundamentals/seo-starter-guide
113+
114+
https://studiohawk.com.au/blog/how-to-optimise-ai-overviews/
115+
https://about.ads.microsoft.com/en/blog/post/october-2025/optimizing-your-content-for-inclusion-in-ai-search-answers
101116

102117
## Project Structure
103118

@@ -110,11 +125,25 @@ CommandTree/
110125
│ │ └── TagConfig.ts # Tag configuration from commandtree.json
111126
│ ├── discovery/
112127
│ │ ├── index.ts # Discovery orchestration
113-
│ │ ├── shell.ts # Shell script discovery
114-
│ │ ├── npm.ts # NPM script discovery
115-
│ │ ├── make.ts # Makefile target discovery
116-
│ │ ├── launch.ts # launch.json discovery
117-
│ │ └── tasks.ts # tasks.json discovery
128+
│ │ ├── shell.ts # Shell scripts (.sh, .bash, .zsh)
129+
│ │ ├── npm.ts # NPM scripts (package.json)
130+
│ │ ├── make.ts # Makefile targets
131+
│ │ ├── launch.ts # VS Code launch configs
132+
│ │ ├── tasks.ts # VS Code tasks
133+
│ │ ├── python.ts # Python scripts (.py)
134+
│ │ ├── powershell.ts # PowerShell scripts (.ps1)
135+
│ │ ├── gradle.ts # Gradle tasks
136+
│ │ ├── cargo.ts # Cargo (Rust) tasks
137+
│ │ ├── maven.ts # Maven goals (pom.xml)
138+
│ │ ├── ant.ts # Ant targets (build.xml)
139+
│ │ ├── just.ts # Just recipes (justfile)
140+
│ │ ├── taskfile.ts # Taskfile tasks (Taskfile.yml)
141+
│ │ ├── deno.ts # Deno tasks (deno.json)
142+
│ │ ├── rake.ts # Rake tasks (Rakefile)
143+
│ │ ├── composer.ts # Composer scripts (composer.json)
144+
│ │ ├── docker.ts # Docker Compose services
145+
│ │ ├── dotnet.ts # .NET projects (.csproj)
146+
│ │ └── markdown.ts # Markdown files (.md)
118147
│ ├── models/
119148
│ │ └── TaskItem.ts # Task data model and TreeItem
120149
│ ├── runners/

Claude.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ You are working with many other agents. Make sure there is effective cooperation
1414
- DO NOT USE GIT
1515
- **Functional style** - Prefer pure functions, avoid classes where possible
1616
- **No suppressing warnings** - Fix them properly
17-
- **No REGEX** It is absolutely ⛔️ illegal, and no text matching in general
18-
- **Don't run long runnings tasks** like docker builds, tests. Ask the user to do it!!
17+
- Text matching (including Regex) is illegal. Use a proper parser/treesitter. If text matching is absolutely necessary, prefer Regex
1918
- **Expressions over assignments** - Prefer const and immutable patterns
2019
- **Named parameters** - Use object params for functions with 3+ args
2120
- **Keep files under 450 LOC and functions under 20 LOC**
2221
- **No commented-out code** - Delete it
2322
- **No placeholders** - If incomplete, leave LOUD compilation error with TODO
2423

2524
### Typescript
25+
- **CENTRALIZE global state** Keep it in one type/file.
2626
- **TypeScript strict mode** - No `any`, no implicit types, turn all lints up to error
2727
- **Regularly run the linter** - Fix lint errors IMMEDIATELY
2828
- **Decouple providers from the VSCODE SDK** - No vscode sdk use within the providers
@@ -40,6 +40,8 @@ You are working with many other agents. Make sure there is effective cooperation
4040
#### Rules
4141
- **Prefer e2e tests over unit tests** - only unit tests for isolating bugs
4242
- Separate e2e tests from unit tests by file. They should not be in the same file together.
43+
- Tests must prove USER INTERACTIONS work
44+
- E2E tests should have multiple user interactions each and loads of assertions
4345
- Prefer adding assertions to existing tests rather than adding new tests
4446
- Test files in `src/test/suite/*.test.ts`
4547
- Run tests: `npm test`

0 commit comments

Comments
 (0)