p-doom/crowd-code-dataset-0.2 huggingface dataset:
[tab] package.json (json)
{
  "name": "crowd-pilot",
  "displayName": "crowd-pilot-extension",
  "description": "Teaching language models to code like humans.",
  "publisher": "p(doom)",
  "version": "0.0.1",
  "engines": {
    "vscode": "^1.99.3"
  },
  "categories": [
    "Other"
  ],
  "activationEvents": [
    "onStartupFinished"
  ],
  "main": "./out/extension.js",
  "contributes": {
    "commands": [
      {
        "command": "crowd-pilot.hideUi",
        "title": "crowd-pilot: Hide Preview"
      },
      {
        "command": "crowd-pilot.sglangTest",
        "title": "crowd-pilot: Test SGLang"
      },
      {
        "command": "crowd-pilot.modelRun",
        "title": "crowd-pilot: Model Plan & Run"
      }
    ],
    "keybindings": [
      {
        "command": "crowd-pilot.modelRun",
        "key": "tab",
        "mac": "tab",
        "when": "editorTextFocus && crowdPilot.uiVisible"
      },
      {
        "command": "crowd-pilot.modelRun",
        "key": "tab",
        "mac": "tab",
        "when": "inQuickOpen && crowdPilot.uiVisible"
      },
      {
        "command": "crowd-pilot.hideUi",
        "key": "escape",
        "mac": "escape",
        "when": "crowdPilot.uiVisible"
      }
    ]
  },
  "scripts": {
    "vscode:prepublish": "npm run compile",
    "compile": "tsc -p ./",
    "watch": "tsc -watch -p ./",
    "pretest": "npm run compile && npm run lint",
    "lint": "eslint src",
    "test": "vscode-test"
  },
  "devDependencies": {
    "@types/vscode": "^1.105.0",
    "@types/mocha": "^10.0.10",
    "@types/node": "22.x",
    "@typescript-eslint/eslint-plugin": "^8.45.0",
    "@typescript-eslint/parser": "^8.45.0",
    "eslint": "^9.36.0",
    "typescript": "^5.9.3",
    "@vscode/test-cli": "^0.0.11",
    "@vscode/test-electron": "^2.5.2"
  }
}
[tab] vsc-extension-quickstart.md (markdown)
# Welcome to your VS Code Extension

## What's in the folder

* This folder contains all of the files necessary for your extension.
* `package.json` - this is the manifest file in which you declare your extension and command.
  * The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
* `src/extension.ts` - this is the main file where you will provide the implementation of your command.
  * The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
  * We pass the function containing the implementation of the command as the second parameter to `registerCommand`.

## Get up and running straight away

* Press `F5` to open a new window with your extension loaded.
* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`.
* Set breakpoints in your code inside `src/extension.ts` to debug your extension.
* Find output from your extension in the debug console.

## Make changes

* You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`.
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.

## Explore the API

* You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`.

## Run tests

* Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner)
* Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered.
* Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A`
* See the output of the test result in the Test Results view.
* Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder.
  * The provided test runner will only consider files matching the name pattern `**.test.ts`.
  * You can create folders inside the `test` folder to structure your tests any way you want.

## Go further

* [Follow UX guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) to create extensions that seamlessly integrate with VS Code's native interface and patterns.
* Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension).
* [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace.
* Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).
* Integrate to the [report issue](https://code.visualstudio.com/api/get-started/wrapping-up#issue-reporting) flow to get issue and feature requests reported by users.
[content] src/extension.ts (typescript)
function parseSinglePlannedAction(raw: string): PlannedAction | undefined {
	let text = raw.trim();
	text = text.replace(/^```(?:json)?\s*/i, '').replace(/```\s*$/i, '').trim();
	// Try parse as object first
	let parsed: unknown;
	try {
		parsed = JSON.parse(text);
	} catch {
		// If not directly parseable, try to extract first JSON object or array
		const objMatch = text.match(/\{[\s\S]*\}/);
		const arrMatch = text.match(/\[[\s\S]*\]/);
		const candidate = objMatch?.[0] ?? arrMatch?.[0];
		if (!candidate) { return undefined; }
		try {
			parsed = JSON.parse(candidate);
		} catch {
			return undefined;
		}
	}
	// If array, take first element
	if (Array.isArray(parsed)) {
		parsed = parsed[0];
	}
	if (!parsed || typeof parsed !== 'object' || typeof (parsed as any).kind !== 'string') {
		return undefined;
	}
	const item = parsed as any;
	switch (item.kind) {
		case 'showTextDocument':
			return { kind: 'showTextDocument' };
		case 'setSelections': {
			const selections = Array.isArray(item.selections) ? item.selections : [];
			const norm = selections.map((s: any) => ({
				start: Array.isArray(s?.start) && s.start.length === 2 ? [Number(s.start[0]) || 0, Number(s.start[1]) || 0] as [number, number] : [0, 0] as [number, number],
				end: Array.isArray(s?.end) && s.end.length === 2 ? [Number(s.end[0]) || 0, Number(s.end[1]) || 0] as [number, number] : [0, 0] as [number, number]
			}));
			return { kind: 'setSelections', selections: norm };
		}
		case 'editInsert': {
			const pos = Array.isArray(item.position) && item.position.length === 2 ? [Number(item.position[0]) || 0, Number(item.position[1]) || 0] as [number, number] : [0, 0] as [number, number];
			const textVal = typeof item.text === 'string' ? item.text : '';
			return { kind: 'editInsert', position: pos, text: textVal };
		}
		case 'editDelete': {
			const start = Array.isArray(item.range?.start) && item.range.start.length === 2 ? [Number(item.range.start[0]) || 0, Number(item.range.start[1]) || 0] as [number, number] : [0, 0] as [number, number];
			const end = Array.isArray(item.range?.end) && item.range.end.length === 2 ? [Number(item.range.end[0]) || 0, Number(item.range.end[1]) || 0] as [number, number] : [0, 0] as [number, number];
			return { kind: 'editDelete', range: { start, end } };
		}
		case 'editReplace': {
			const start = Array.isArray(item.range?.start) && item.range.start.length === 2 ? [Number(item.range.start[0]) || 0, Number(item.range.start[1]) || 0] as [number, number] : [0, 0] as [number, number];
			const end = Array.isArray(item.range?.end) && item.range.end.length === 2 ? [Number(item.range.end[0]) || 0, Number(item.range.end[1]) || 0] as [number, number] : [0, 0] as [number, number];
			const textVal = typeof item.text === 'string' ? item.text : '';
			return { kind: 'editReplace', range: { start, end }, text: textVal };
		}
		case 'terminalShow':
			return { kind: 'terminalShow' };
		case 'terminalSendText': {
			const textVal = typeof item.text === 'string' ? item.text : '';
			return { kind: 'terminalSendText', text: textVal };
		}
		default:
			return undefined;
	}
}
[content] src/extension.ts (typescript)

function parsePlannedActions(raw: string): PlannedAction | undefined {
	let text = raw.trim();
	text = text.replace(/^```(?:json)?\s*/i, '').replace(/```\s*$/i, '').trim();
	// Try parse as object first
	let parsed: unknown;
	try {
		parsed = JSON.parse(text);
	} catch {
		// If not directly parseable, try to extract first JSON object or array
		const objMatch = text.match(/\{[\s\S]*\}/);
		const arrMatch = text.match(/\[[\s\S]*\]/);
		const candidate = objMatch?.[0] ?? arrMatch?.[0];
		if (!candidate) { return undefined; }
		try {
			parsed = JSON.parse(candidate);
		} catch {
			return undefined;
		}
	}
	// If array, take first element
	if (Array.isArray(parsed)) {
		parsed = parsed[0];
	}
	if (!parsed || typeof parsed !== 'object' || typeof (parsed as any).kind !== 'string') {
		return undefined;
	}
	const item = parsed as any;
	switch (item.kind) {
		case 'showTextDocument':
			return { kind: 'showTextDocument' };
		case 'setSelections': {
			const selections = Array.isArray(item.selections) ? item.selections : [];
			const norm = selections.map((s: any) => ({
				start: Array.isArray(s?.start) && s.start.length === 2 ? [Number(s.start[0]) || 0, Number(s.start[1]) || 0] as [number, number] : [0, 0] as [number, number],
				end: Array.isArray(s?.end) && s.end.length === 2 ? [Number(s.end[0]) || 0, Number(s.end[1]) || 0] as [number, number] : [0, 0] as [number, number]
			}));
			return { kind: 'setSelections', selections: norm };
		}
		case 'editInsert': {
			const pos = Array.isArray(item.position) && item.position.length === 2 ? [Number(item.position[0]) || 0, Number(item.position[1]) || 0] as [number, number] : [0, 0] as [number, number];
			const textVal = typeof item.text === 'string' ? item.text : '';
			return { kind: 'editInsert', position: pos, text: textVal };
		}
		case 'editDelete': {
			const start = Array.isArray(item.range?.start) && item.range.start.length === 2 ? [Number(item.range.start[0]) || 0, Number(item.range.start[1]) || 0] as [number, number] : [0, 0] as [number, number];
			const end = Array.isArray(item.range?.end) && item.range.end.length === 2 ? [Number(item.range.end[0]) || 0, Number(item.range.end[1]) || 0] as [number, number] : [0, 0] as [number, number];
			return { kind: 'editDelete', range: { start, end } };
		}
		case 'editReplace': {
			const start = Array.isArray(item.range?.start) && item.range.start.length === 2 ? [Number(item.range.start[0]) || 0, Number(item.range.start[1]) || 0] as [number, number] : [0, 0] as [number, number];
			const end = Array.isArray(item.range?.end) && item.range.end.length === 2 ? [Number(item.range.end[0]) || 0, Number(item.range.end[1]) || 0] as [number, number] : [0, 0] as [number, number];
			const textVal = typeof item.text === 'string' ? item.text : '';
			return { kind: 'editReplace', range: { start, end }, text: textVal };
		}
		case 'terminalShow':
			return { kind: 'terminalShow' };
		case 'terminalSendText': {
			const textVal = typeof item.text === 'string' ? item.text : '';
			return { kind: 'terminalSendText', text: textVal };
		}
		default:
			return undefined;
	}
}
[content] src/extension.ts (typescript)
	// Only preview certain action kinds
	const next = (action.kind === 'editInsert' || action.kind === 'editDelete' || action.kind === 'editReplace' || action.kind === 'terminalSendText' || action.kind === 'setSelections') ? action : undefined;
[content] src/extension.ts (typescript)
	if (action.kind === 'showTextDocument') {
		await vscode.window.showTextDocument(doc);
		return;
	}
	if (action.kind === 'setSelections') {
		editor.selections = action.selections.map(s => new vscode.Selection(
			new vscode.Position(s.start[0], s.start[1]),
			new vscode.Position(s.end[0], s.end[1])
		));
		if (editor.selections.length > 0) {
			editor.revealRange(editor.selections[0], vscode.TextEditorRevealType.InCenterIfOutsideViewport);
		}
		return;
	}
	if (action.kind === 'editInsert') {
		await editor.edit((e: vscode.TextEditorEdit) => e.insert(new vscode.Position(action.position[0], action.position[1]), action.text));
		return;
	}
	if (action.kind === 'editDelete') {
		const range = new vscode.Range(
			new vscode.Position(action.range.start[0], action.range.start[1]),
			new vscode.Position(action.range.end[0], action.range.end[1])
		);
		await editor.edit((e: vscode.TextEditorEdit) => e.delete(range));
		return;
	}
	if (action.kind === 'editReplace') {
		const range = new vscode.Range(
			new vscode.Position(action.range.start[0], action.range.start[1]),
			new vscode.Position(action.range.end[0], action.range.end[1])
		);
		await editor.edit((e: vscode.TextEditorEdit) => e.replace(range, action.text));
		return;
	}
	if (action.kind === 'terminalShow') {
		term.show();
		return;
	}
	if (action.kind === 'terminalSendText') {
		term.sendText(action.text);
		return;
[content] src/extension.ts (typescript)
	// Only preview the next text edit action (insert/delete/replace/terminalSendText/setSelections)
	const next = plan.find(a => a.kind === 'editInsert' || a.kind === 'editDelete' || a.kind === 'editReplace' || a.kind === 'terminalSendText' || a.kind === 'setSelections');
[content] src/extension.ts (typescript)
	for (const action of plan) {
		if (action.kind === 'showTextDocument') {
			await vscode.window.showTextDocument(doc);
			continue;
		}
		if (action.kind === 'setSelections') {
			editor.selections = action.selections.map(s => new vscode.Selection(
				new vscode.Position(s.start[0], s.start[1]),
				new vscode.Position(s.end[0], s.end[1])
			));
			if (editor.selections.length > 0) {
				editor.revealRange(editor.selections[0], vscode.TextEditorRevealType.InCenterIfOutsideViewport);
			}
			continue;
		}
		if (action.kind === 'editInsert') {
			await editor.edit((e: vscode.TextEditorEdit) => e.insert(new vscode.Position(action.position[0], action.position[1]), action.text));
			continue;
		}
		if (action.kind === 'editDelete') {
			const range = new vscode.Range(
				new vscode.Position(action.range.start[0], action.range.start[1]),
				new vscode.Position(action.range.end[0], action.range.end[1])
			);
			await editor.edit((e: vscode.TextEditorEdit) => e.delete(range));
			continue;
		}
		if (action.kind === 'editReplace') {
			const range = new vscode.Range(
				new vscode.Position(action.range.start[0], action.range.start[1]),
				new vscode.Position(action.range.end[0], action.range.end[1])
			);
			await editor.edit((e: vscode.TextEditorEdit) => e.replace(range, action.text));
			continue;
		}
		if (action.kind === 'terminalShow') {
			term.show();
			continue;
		}
		if (action.kind === 'terminalSendText') {
			term.sendText(action.text);
			continue;
		}