Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ jobs:
- run: npm run check
- run: npm test
- run: npm run package:vsix -- "$RUNNER_TEMP/agentextension.vsix"
- name: Test the packaged extension
run: |
unzip -q "$RUNNER_TEMP/agentextension.vsix" -d "$RUNNER_TEMP/agentextension-package"
AGENTEXTENSION_TEST_PACKAGED_PATH="$RUNNER_TEMP/agentextension-package/extension" node --test test/managed-vsix.test.js
59 changes: 35 additions & 24 deletions README.md

Large diffs are not rendered by default.

17 changes: 3 additions & 14 deletions media/panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ section { display: grid; gap: 8px; min-width: 0; }
.hint:empty { display: none; }

.panel { display: flex; flex-direction: column; height: 100%; }
.toolbar, .run-status, .workspace, .composer-area { flex: none; }
.toolbar, .run-status, .composer-area { flex: none; }
.toolbar {
display: flex;
align-items: center;
Expand All @@ -39,18 +39,7 @@ section { display: grid; gap: 8px; min-width: 0; }
.phase[data-phase="idle"], .phase[data-phase="cancelled"] { color: var(--muted); }
.phase[data-phase="running"] { color: var(--vscode-progressBar-background); }
.phase[data-phase="error"] { color: var(--vscode-errorForeground); }
#workspace-toggle span { display: inline-block; }
#workspace-toggle[aria-expanded="true"] span { transform: rotate(180deg); }
.workspace {
display: grid;
gap: 12px;
max-height: 42%;
overflow: auto;
padding: 12px;
border-bottom: 1px solid var(--line);
background: var(--vscode-editorWidget-background, var(--surface));
}
.workspace section + section { padding-top: 10px; border-top: 1px solid var(--line); }
#more-actions { min-width: 28px; font-size: 16px; line-height: 1; }
.run-status {
max-height: 20%;
overflow: auto;
Expand Down Expand Up @@ -129,6 +118,7 @@ textarea::placeholder { color: var(--vscode-input-placeholderForeground); }
gap: 5px 8px;
}
.composer-actions { padding: 4px 5px 5px; }
#slash-picker { min-width: 26px; }
.run-actions { margin-left: auto; }
.composer-meta { font-size: .88em; }
#model-settings { min-width: 0; max-width: 100%; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
Expand All @@ -150,7 +140,6 @@ textarea::placeholder { color: var(--vscode-input-placeholderForeground); }
box-shadow: 0 2px 8px var(--vscode-widget-shadow);
}
.context-options button { text-align: left; }
.context-options p { padding: 4px 7px; }

button, .quiet {
cursor: pointer;
Expand Down
67 changes: 31 additions & 36 deletions media/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,16 @@ const send = (type, fields = {}) => vscode.postMessage({ type, ...fields });

const prompt = byId('prompt');
const form = byId('form');
const workspace = byId('workspace');
const workspaceToggle = byId('workspace-toggle');
const contextMenu = byId('add-context');
const stream = byId('stream');
const phaseLabels = { idle: 'Ready', running: 'Running', question: 'Answer needed', plan: 'Plan to review',
review: 'Changes to review', ready: 'Ready to apply', done: 'Complete', applied: 'Applied', error: 'Error', cancelled: 'Cancelled' };

function showWorkspace(open) {
workspace.hidden = !open;
workspaceToggle.setAttribute('aria-expanded', String(open));
}

workspaceToggle.addEventListener('click', () => showWorkspace(workspace.hidden));
document.addEventListener('keydown', event => {
if (event.key !== 'Escape') return;
if (contextMenu.open) {
contextMenu.open = false;
contextMenu.querySelector('summary').focus();
} else if (!workspace.hidden) {
showWorkspace(false);
workspaceToggle.focus();
}
});
document.addEventListener('click', event => {
Expand Down Expand Up @@ -58,20 +47,34 @@ byId('attach-symbol').addEventListener('click', () => {
prompt.value = vscode.getState()?.prompt ?? '';
prompt.addEventListener('input', () => vscode.setState({ prompt: prompt.value }));
prompt.addEventListener('keydown', event => {
if (event.key !== 'Enter' || event.shiftKey || event.isComposing || event.keyCode === 229) return;
if (event.isComposing || event.keyCode === 229) return;
if (event.key === '/' && !prompt.value && !event.metaKey && !event.ctrlKey && !event.altKey && !byId('slash-picker').disabled) {
event.preventDefault();
if (!event.repeat) send('slash-commands');
return;
}
if (event.key !== 'Enter' || event.shiftKey) return;
event.preventDefault();
if (!event.repeat && !byId('run').disabled) form.requestSubmit(byId('run'));
});
form.addEventListener('submit', event => {
event.preventDefault();
if (!prompt.value.trim() || byId('run').disabled) return;
showWorkspace(false);
contextMenu.open = false;
send('run', { prompt: prompt.value, planFirst: event.submitter?.id === 'plan-first' });
});
for (const id of ['cancel', 'session', 'approve-plan', 'continue', 'apply', 'check-accepted', 'undo', 'select-skills', 'revoke', 'memory', 'connectors', 'connector-token', 'plugins', 'import-plugin', 'plugin-workflow', 'browser-access', 'computer-access', 'stop-surfaces', 'run-report', 'schedules', 'scheduled-questions', 'policy', 'instructions', 'export-audit', 'resume-run', 'review-conflicts', 'discard-checkpoint', 'review-git', 'model-settings']) {
for (const id of ['cancel', 'session', 'approve-plan', 'continue', 'apply', 'check-accepted', 'undo', 'revoke', 'stop-surfaces', 'scheduled-questions', 'resume-run', 'review-conflicts', 'discard-checkpoint', 'model-settings', 'more-actions']) {
byId(id).addEventListener('click', () => send(id));
}
for (const id of ['select-skills', 'instructions']) {
byId(id).addEventListener('click', () => {
contextMenu.open = false;
send(id);
});
}
byId('tool-picker').addEventListener('click', () => send('tools'));
byId('slash-picker').addEventListener('click', () => send('slash-commands'));
byId('setup-model').addEventListener('click', () => send('model-settings'));

function element(tag, text, className) {
const node = document.createElement(tag);
Expand Down Expand Up @@ -253,30 +256,22 @@ window.addEventListener('message', ({ data }) => {
lastPhase = state.phase;
lastRequest = state.request;
const busy = ['running', 'plan', 'review', 'question'].includes(state.phase);
const canRun = !busy && state.phase !== 'ready' && !state.applying && !state.scheduledRunning;
byId('surface-scope').textContent = state.surfaceScope || 'Browser and computer access off.';
byId('browser-access').disabled = byId('computer-access').disabled = busy || state.phase === 'ready' || state.applying;
const canRun = !busy && state.phase !== 'ready' && !state.applying && !state.scheduledRunning && !state.configuringModel;
byId('stop-surfaces').hidden = !state.surfacesActive && !state.surfaceScope;
byId('run-report').disabled = state.applying;
byId('review-git').disabled = busy || state.phase === 'ready' || state.applying || Boolean(state.scheduledRunning);
byId('schedule-summary').textContent = state.scheduleSummary || 'No scheduled reports.';
const pendingQuestions = state.pendingScheduleQuestions ?? 0;
byId('scheduled-question-inbox').hidden = !pendingQuestions;
byId('scheduled-question-summary').textContent = `${pendingQuestions} scheduled question${pendingQuestions === 1 ? '' : 's'} waiting.`;
byId('scheduled-questions').disabled = !canRun;
byId('policy-summary').textContent = state.policySummary || 'Every protected action asks first.';
byId('memory-summary').textContent = state.memorySummary || '';
byId('instruction-summary').textContent = state.instructionSummary || 'No instruction profiles in use.';
byId('instructions').disabled = busy || state.phase === 'ready' || state.applying;
byId('schedules').disabled = state.applying || Boolean(state.scheduledRunning);
for (const id of ['tool-picker', 'slash-picker', 'instructions', 'select-skills']) byId(id).disabled = !canRun;
byId('surface-activity').hidden = !state.surfaceEvents?.length;
byId('surface-events').replaceChildren(...(state.surfaceEvents ?? []).map(event => element('li', `${event.kind} · ${event.status}`)));
byId('welcome').hidden = state.phase !== 'idle' || Boolean(state.checkpoint || state.scheduledRunning);
byId('activity').hidden = !state.request && !state.text;
byId('request-card').hidden = !state.request;
if (requestChanged) byId('request').textContent = state.request ?? '';
const setupNeeded = state.phase === 'idle' && !state.model;
byId('welcome-hint').textContent = setupNeeded ? 'Configure a TrueForge model below to start your first run.'
byId('welcome-title').textContent = setupNeeded ? 'Connect a model to get started' : 'What would you like to change?';
byId('welcome-hint').textContent = setupNeeded ? 'Use an API key, a local model, or an existing TrueForge server.'
: 'Describe a task below. You can review the proposed edits before applying them.';
byId('phase').textContent = state.scheduledRunning ? 'Scheduled report' : setupNeeded ? 'Setup needed' : phaseLabels[state.phase] ?? state.phase;
byId('phase').dataset.phase = state.phase;
Expand All @@ -286,14 +281,20 @@ window.addEventListener('message', ({ data }) => {
if (status.textContent !== (state.status ?? '')) status.textContent = state.status ?? '';
byId('usage').hidden = !state.usage;
byId('usage').textContent = state.usage ? `Usage: ${state.usage} · Estimated cost ${state.usageCost ?? 'Unreported'}` : '';
byId('run').disabled = byId('plan-first').disabled = !canRun;
byId('run').disabled = byId('plan-first').disabled = !canRun || !state.model;
byId('cancel').hidden = !busy && state.phase !== 'ready' && !state.scheduledRunning;
byId('cancel').textContent = state.validatingApply ? 'Cancel validation'
: state.checkingAccepted ? 'Cancel check' : state.phase === 'ready' ? 'Discard draft' : 'Cancel run';
byId('run').hidden = byId('plan-first').hidden = !byId('cancel').hidden;
byId('run').hidden = byId('plan-first').hidden = !byId('cancel').hidden || !state.model;
const setupModel = byId('setup-model');
setupModel.hidden = Boolean(state.model) || !byId('cancel').hidden;
setupModel.disabled = !canRun;
setupModel.textContent = state.configuringModel ? 'Connecting…' : 'Connect model';
const modelSettings = byId('model-settings');
modelSettings.textContent = state.model || 'Configure model';
modelSettings.title = state.model ? `Model settings · ${state.model}` : 'Open model settings';
modelSettings.hidden = !state.model;
modelSettings.disabled = busy || state.applying || Boolean(state.scheduledRunning || state.configuringModel);
modelSettings.textContent = state.configuringModel ? 'Connecting…' : state.model || 'Connect model';
modelSettings.title = state.model ? `Change model · ${state.model}` : 'Connect a model';
modelSettings.setAttribute('aria-label', modelSettings.title);
byId('session').hidden = !state.session;
byId('history').hidden = !state.undo;
Expand All @@ -302,12 +303,6 @@ window.addEventListener('message', ({ data }) => {
const response = byId('response');
const responseChanged = response.textContent !== state.text;
if (responseChanged) response.textContent = state.text;
byId('select-skills').disabled = busy || state.phase === 'ready' || state.applying;
for (const id of ['memory', 'connectors', 'connector-token', 'plugins', 'import-plugin', 'plugin-workflow']) byId(id).disabled = busy || state.phase === 'ready' || state.applying;
byId('plugin-summary').textContent = state.plugins?.length
? `Enabled plugins: ${state.plugins.map(plugin => `${plugin.id} ${plugin.version} · ${plugin.digest.slice(0, 12)}`).join(', ')}` : 'No plugins enabled.';
byId('connector-summary').textContent = state.connectors?.length ? `Enabled connectors: ${state.connectors.join(', ')}` : 'No connectors enabled.';
byId('skill-summary').textContent = state.skills?.length ? `Selected skills: ${state.skills.join(', ')}` : 'No skills selected.';
byId('revoke').hidden = !busy || state.permissions?.closed;
byId('safety-actions').hidden = byId('revoke').hidden && byId('stop-surfaces').hidden;
byId('permissions').hidden = !state.permissions;
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "agentextension",
"displayName": "AgentExtension",
"description": "Reviewable coding changes in VS Code, powered by local TrueForge.",
"version": "0.6.1",
"version": "0.7.0",
"publisher": "LiteralKrishu",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -37,6 +37,22 @@
"command": "agentextension.open",
"title": "AgentExtension: Open Agent Panel"
},
{
"command": "agentextension.configureModel",
"title": "AgentExtension: Connect Model"
},
{
"command": "agentextension.tools",
"title": "AgentExtension: Configure Tools"
},
{
"command": "agentextension.slashCommands",
"title": "AgentExtension: Show Slash Commands"
},
{
"command": "agentextension.managePlugins",
"title": "AgentExtension: Manage Plugins"
},
{
"command": "agentextension.reviewGit",
"title": "AgentExtension: Review Working-Tree Changes"
Expand Down Expand Up @@ -292,7 +308,7 @@
"default": [],
"maxItems": 7,
"scope": "machine",
"description": "Approved local folders containing plugin directories with plugin.json. Installation does not enable a plugin. Review its version, content digest and capabilities in Manage plugins."
"description": "Approved local folders containing plugin directories with plugin.json. Review and enable a plugin's version, content digest, and capabilities under Tools → Plugins."
},
"agentextension.browserOrigins": {
"type": "array",
Expand Down
10 changes: 9 additions & 1 deletion plugins/fix-team/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
"schemaVersion": 1,
"id": "fix-team",
"publisher": "LiteralKrishu",
"version": "1.0.0",
"version": "1.1.0",
"description": "Diagnose a failed check and draft a contained fix for parent review.",
"skills": ["fix-workflow"],
"workers": ["test-diagnosis", "edit-proposal"],
"workflows": [
{
"id": "fix-check",
"title": "Diagnose and fix a failing check",
"prompt": "Investigate the failing check I describe. Use the diagnosis and edit-proposal workers when applicable. Propose the smallest fix and show the draft and verification for review.",
"planFirst": true
}
],
"roles": [
{
"name": "docs-check",
Expand Down
9 changes: 8 additions & 1 deletion plugins/review-team/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
"schemaVersion": 1,
"id": "review-team",
"publisher": "LiteralKrishu",
"version": "1.0.0",
"version": "1.1.0",
"description": "Research relevant repository excerpts and review a draft with bounded, read-only workers.",
"skills": ["review-workflow"],
"workers": ["repository-research", "diff-review"],
"workflows": [
{
"id": "research",
"title": "Research a repository question",
"prompt": "Use the repository research worker to investigate my question. Cite file paths and line numbers and identify any gaps in the evidence. Do not change files."
}
],
"connectors": [],
"capabilities": ["skill.read", "worker.research", "worker.review"]
}
38 changes: 35 additions & 3 deletions scripts/package-vsix.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@ const manifest = require('../package.json');
const root = path.resolve(__dirname, '..');
const runtimeDependencies = ['@truefoundry/trueforge-sdk', 'playwright-core'];
const main = './src/extension.bundle.cjs';
const target = `${process.platform}-${process.arch}`;

async function stageRuntime(staging) {
if (!require('node:module').registerHooks) throw new Error('Build the VSIX with Node.js 22.15 or later.');
const server = path.join(root, 'trueforge', 'server');
const npm = process.env.npm_execpath;
if (!npm) throw new Error('Run npm run package:vsix to build the VSIX.');
// The locked packages include SQLite prebuilds. A package build needs no compiler for the server.
execFileSync(process.execPath, [npm, 'ci', '--omit=dev', '--ignore-scripts', '--no-audit', '--no-fund'], {
cwd: server, stdio: 'inherit',
});
const runtime = path.join(staging, 'trueforge', 'runtime');
await fs.mkdir(runtime, { recursive: true });
const node = path.join(runtime, process.platform === 'win32' ? 'node.exe' : 'node');
const bin = path.dirname(process.execPath);
const license = [path.join(bin, '..', 'LICENSE'), path.join(bin, 'LICENSE')].find(existsSync);
if (!license) throw new Error('Build with an official Node.js distribution that includes its LICENSE file.');
await Promise.all([
fs.copyFile(process.execPath, node),
fs.copyFile(license, path.join(runtime, 'NODE-LICENSE')),
fs.copyFile(path.join(server, 'launch.cjs'), path.join(runtime, 'launch.cjs')),
fs.cp(path.join(server, 'node_modules'), path.join(runtime, 'node_modules'), {
recursive: true,
filter: source => !source.endsWith('.map') && path.basename(source) !== '.bin'
&& source !== path.join(server, 'node_modules', '@truefoundry', 'trueforge', 'dist', '_frontend'),
}),
]);
await fs.chmod(node, 0o755);
execFileSync(node, ['-e', 'new (require("better-sqlite3"))(":memory:").close()'], { cwd: runtime });
}

// The macOS helper is never committed. Each package compiles it from native/desktop.swift so the shipped
// binary always matches reviewed source. Elsewhere the package omits it and native app access is unavailable.
Expand All @@ -27,10 +57,12 @@ async function packageExtension(output) {
const withHelper = buildHelper();
const staging = await fs.mkdtemp(path.join(await fs.realpath(os.tmpdir()), 'agentextension-vsix-'));
try {
const assets = ['.vscodeignore', 'LICENSE', 'README.md', 'docs', 'media', 'native', 'plugins', 'skills', 'trueforge',
const assets = ['.vscodeignore', 'LICENSE', 'README.md', 'docs', 'media', 'native', 'plugins', 'skills',
'trueforge/agent.json', 'trueforge/model.example.json',
'src/retrieval.js', 'src/context.js', ...runtimeDependencies.map(name => `node_modules/${name}`)];
await Promise.all(assets.map(file => fs.cp(path.join(root, file), path.join(staging, file), { recursive: true,
filter: source => source !== helper || (withHelper && existsSync(helper)) })));
await stageRuntime(staging);
const packaged = { ...manifest, main,
dependencies: Object.fromEntries(runtimeDependencies.map(name => [name, manifest.dependencies[name]])) };
delete packaged.devDependencies;
Expand All @@ -49,13 +81,13 @@ async function packageExtension(output) {
// VS Code supplies its API. Retrieval starts a worker from its own file.
external: ['vscode', './retrieval', ...runtimeDependencies],
});
await createVSIX({ cwd: staging, packagePath: output });
await createVSIX({ cwd: staging, packagePath: output, target });
} finally {
await fs.rm(staging, { recursive: true, force: true });
}
}

const output = path.resolve(process.argv[2] ?? `${manifest.name}-${manifest.version}.vsix`);
const output = path.resolve(process.argv[2] ?? `${manifest.name}-${manifest.version}-${target}.vsix`);
packageExtension(output).catch(error => {
console.error(error.message);
process.exitCode = 1;
Expand Down
Loading
Loading