spequi 0.1.4 → 0.1.6

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.
@@ -19,7 +19,7 @@ On Windows, use the host filesystem tools to check for the launcher, then run No
19
19
 
20
20
  On attachment, report the agent host's actual MCP connection metadata when the host exposes it. Write a small JSON file under `.spequi` with `sessionId` (a stable random identifier for this attachment) and `mcps: { supported: true, connections: [{ name: "Display name", status: "connected" }] }`. Allowed statuses are connected, disconnected, unavailable and unknown. Include display names and status only; never copy credentials, URLs, environment variables or transport configuration. A configured server or a tool catalog alone does not prove connection health. If authoritative discovery is unavailable, use `mcps: { supported: false, connections: [] }`.
21
21
 
22
- Run `node .spequi/cli.mjs agent report --file <report.json> --name "Spequi Agent"` from the project root. Use the same name for `agent next`, and pass `--session-id <returned-id>` when polling to bind heartbeats to this attachment. The returned sessionId identifies the report; retain it for this attachment. Refresh reports at least every five minutes and when connections change. Do not invent connections or probe unrelated services to fill this list. Heartbeats still come from next/log/input; a report is not a substitute for serving the queue. Missing or expired reports display unknown in the UI.
22
+ Run `node .spequi/cli.mjs agent report --file <report.json> --name "<cli-name>"` from the project root. Replace `<cli-name>` with the actual host name, such as `Codex`, `Claude Code`, or `GigaCode CLI`; this name also identifies the CLI in usage analytics. Use the same name for `agent next`, and pass `--session-id <returned-id>` when polling to bind heartbeats to this attachment. The returned sessionId identifies the report; retain it for this attachment. Refresh reports at least every five minutes and when connections change. Do not invent connections or probe unrelated services to fill this list. Heartbeats still come from next/log/input; a report is not a substitute for serving the queue. Missing or expired reports display unknown in the UI.
23
23
 
24
24
  ## Agent loop
25
25
 
package/src/analytics.mjs CHANGED
@@ -5,11 +5,21 @@ import { execFile } from 'node:child_process';
5
5
  import { promisify } from 'node:util';
6
6
  import { readJSON, writeJSON, runtime, withLock } from './files.mjs';
7
7
 
8
- const endpoint = 'https://data.rahulnjs.com/api/spequi/sub/events';
8
+ const endpoints = ['https://data.rahulnjs.com/api/spequi/sub/events', 'https://sber.eval.best/spequi/event'];
9
9
  const projects = new Map();
10
10
  const diffFailures = new Set();
11
11
  const run = promisify(execFile);
12
12
 
13
+ async function deliverEvent(body) {
14
+ for (const endpoint of endpoints) {
15
+ try {
16
+ const response = await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body, signal: AbortSignal.timeout(5000) });
17
+ void response.body?.cancel().catch(() => {});
18
+ if (response.ok) return;
19
+ } catch {}
20
+ }
21
+ }
22
+
13
23
  export async function trackDiffFailure(root, previewId, reason) {
14
24
  const key = `${root}:${previewId}:${reason}`;
15
25
  if (diffFailures.has(key)) return;
@@ -58,8 +68,10 @@ export async function trackEvent(root, event, properties = {}) {
58
68
  });
59
69
  if (!firstUse) return;
60
70
  }
61
- const payload = { event, user_id: metadata.user_id, project_name: path.basename(root), git_user_name: metadata.git_user_name, occurred_at, ...properties };
62
- // Finish local bookkeeping before returning; network delivery is one non-blocking attempt.
63
- void fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload), signal: AbortSignal.timeout(5000) }).then(response => response.body?.cancel()).catch(() => {});
71
+ const agent = await readJSON(runtime(root, 'agent.json')).catch(() => null);
72
+ const cli_name = agent?.agent && agent.agent !== 'Spequi Agent' ? agent.agent : null;
73
+ const payload = { event, user_id: metadata.user_id, project_name: path.basename(root), git_user_name: metadata.git_user_name, cli_name, occurred_at, ...properties };
74
+ // Finish local bookkeeping before returning; delivery tries the fallback only if the primary fails.
75
+ void deliverEvent(JSON.stringify(payload));
64
76
  } catch {}
65
77
  }
package/src/server.mjs CHANGED
@@ -104,6 +104,7 @@ export async function startServer({ root = process.cwd(), port, quiet = false, r
104
104
  return;
105
105
  }
106
106
  if (request.method === 'GET') {
107
+ if (['/docs', '/docs/'].includes(url.pathname)) return send(response, 200, await fs.readFile(path.join(publicDir, 'index.html')), 'text/html; charset=utf-8');
107
108
  if (url.pathname === '/' && url.searchParams.get('view') === 'lifecycle') {
108
109
  url.searchParams.set('view', 'studio');
109
110
  return send(response, 302, '', undefined, { Location: url.pathname + url.search });
package/src/views.mjs CHANGED
@@ -41,7 +41,7 @@ function link(label, params, className = '', extra = '') { return `<a href="${e(
41
41
  function badge(label, type = '') { return `<span class="badge ${type}">${e(label)}</span>`; }
42
42
  function progressBar(progress) { return `<span class="progress-track" aria-label="${progress.done} of ${progress.total} tasks complete"><span style="width:${progress.total ? Math.round(progress.done / progress.total * 100) : 0}%"></span></span>`; }
43
43
  export function shell(content, data, csrf, params = {}) {
44
- return `<!doctype html><html lang="en" data-theme="enterprise"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="csrf-token" content="${csrf}"><title>${e(data.name)} · Spequi</title><link rel="icon" href="/favicon.svg" type="image/svg+xml"><script src="/assets/app.js" defer></script><script src="/assets/review.js" defer></script><script src="/assets/workflow.js" defer></script><script src="/assets/studio.js" defer></script><script src="/assets/session.js" defer></script><script src="/assets/requests.js" defer></script><link rel="stylesheet" href="/assets/fonts.css"><link rel="stylesheet" href="/assets/app.css"><link rel="stylesheet" href="/assets/diff.css"><link rel="stylesheet" href="/assets/review.css"><link rel="stylesheet" href="/assets/studio.css"></head><body><a class="skip-link" href="#document">Skip to document</a><header class="topbar"><div class="topbar-start"><div class="brand">${icon('layers')}<span>Spequi</span><span class="local-pill">LOCAL</span></div></div><div class="topbar-end"><button type="button" class="button requests-toggle" data-requests-toggle aria-controls="requests-panel" aria-expanded="false"><span class="requests-icon" aria-hidden="true">${icon('clock')}<span class="requests-attention" data-request-count hidden></span></span>Requests</button><button type="button" id="agent-indicator" class="session-indicator" data-session-toggle aria-expanded="false" aria-controls="agent-connections"><span class="session-agent-icon" aria-hidden="true">${icon('agent')}<i></i></span><span data-session-label>Checking agent</span><span class="session-chevron" aria-hidden="true">${icon('chevron')}</span></button><button type="button" class="session-mcp-button" aria-label="MCP connections" data-session-toggle aria-expanded="false" aria-controls="mcp-connections">${icon('plug')}<span id="mcp-count">MCPs</span></button><button type="button" id="theme-toggle" class="theme-toggle" aria-label="Switch to dark mode" title="Switch to dark mode"><span class="theme-icon-dark">${icon('moon')}</span><span class="theme-icon-light">${icon('sun')}</span></button></div></header><aside id="agent-connections" class="session-panel agent-panel" aria-label="Agent connection" hidden><header><h2>Agent</h2><button type="button" class="icon-button" data-session-close aria-label="Close agent details">${icon('close')}</button></header><div class="agent-summary"><span class="agent-avatar" aria-hidden="true">${icon('agent')}</span><div class="agent-identity"><strong id="session-agent-name">Spequi Agent</strong><p id="session-agent-caption">Checking connection</p></div><span id="session-state" class="agent-state-badge">Checking</span></div><dl class="agent-facts"><div><dt>Last seen</dt><dd><time id="session-last-seen">Not yet</time></dd></div><div><dt>Queue</dt><dd id="session-queue-state">Checking</dd></div></dl><section class="agent-current" data-session-current aria-label="Current request" hidden><div><strong id="session-current-change"></strong><span id="session-current-state"></span></div><p id="session-current-hint"></p></section><section id="session-recovery" class="agent-guidance" aria-label="Next step" hidden><p id="session-recovery-message"></p><p id="session-recovery-detail" hidden></p></section><footer class="agent-panel-actions"><button type="button" class="button" data-session-refresh>Refresh status</button><button type="button" class="text-button" data-session-open-requests>View requests ${icon('arrow')}</button></footer><p data-session-check-result role="status" aria-live="polite" aria-atomic="true"></p></aside><aside id="mcp-connections" class="session-panel mcp-panel" aria-label="MCP connections" hidden><header><div><h2>MCP connections</h2><span id="mcp-panel-state" class="mcp-panel-state">Not reported</span></div><button type="button" class="icon-button" data-session-close aria-label="Close MCP connections">${icon('close')}</button></header><div class="mcp-panel-body"><p id="mcp-report-summary" hidden></p><div class="mcp-empty" data-mcp-empty><span class="mcp-empty-icon" aria-hidden="true">${icon('plug')}</span><div><h3 id="mcp-empty-title">Waiting for connection details</h3><p id="mcp-empty-description">Your agent hasn’t shared its MCP connections yet.</p></div></div><ul id="session-mcps"></ul></div><footer class="mcp-panel-footer"><button type="button" class="text-button" data-mcp-refresh>Refresh status</button><time id="mcp-report-date">Not reported yet</time></footer></aside><aside id="requests-panel" class="requests-panel" aria-label="Requests" hidden><header><h2>Requests</h2><div class="requests-tools"><select data-request-filter aria-label="Filter requests"><option value="inbox" selected>Inbox</option><option value="all">All history</option><option value="active">Active history</option><option value="completed">Completed</option><option value="failed">Failed</option><option value="cancelled">Cancelled</option></select><button type="button" class="icon-button" data-requests-close aria-label="Close requests">${icon('close')}</button></div></header><div data-requests-feedback role="status" aria-live="polite"></div><div data-request-list></div><footer hidden><span data-request-pagination></span><nav data-request-pages aria-label="Request pages" hidden><button class="icon-button" type="button" data-request-page="previous" aria-label="Previous page" title="Previous page">${icon('chevron')}</button><button class="icon-button" type="button" data-request-page="next" aria-label="Next page" title="Next page">${icon('chevron')}</button></nav></footer></aside><dialog id="request-delete-dialog" aria-labelledby="request-delete-title" aria-describedby="request-delete-description request-delete-retention"><form method="dialog"><h2 id="request-delete-title">Delete this request?</h2><p id="request-delete-description">Remove it from request history.</p><label><input type="checkbox" name="reviewData" checked> Also delete its saved preview and that preview’s comments and exports</label><p id="request-delete-retention">Project files, OpenSpec documents, and applied-file backups are kept.</p><div class="dialog-actions"><button value="cancel" class="button">Keep request</button><button value="confirm" class="button danger-solid">Delete request</button></div></form></dialog><dialog id="draft-delete-dialog" aria-labelledby="draft-delete-title" aria-describedby="draft-delete-description draft-delete-retention"><form method="dialog"><h2 id="draft-delete-title">Delete this draft?</h2><p id="draft-delete-description">The saved idea will be removed.</p><label data-delete-plan-choice><input type="checkbox" name="deletePlan"> Also delete the planning files generated from this draft</label><p id="draft-delete-retention">Cancel active requests before deleting. Application source files are kept.</p><div class="dialog-actions"><button value="cancel" class="button">Keep draft</button><button value="confirm" class="button danger-solid">Delete draft</button></div></form></dialog>${content}<div id="toast" role="status" aria-live="polite" aria-atomic="true"></div><dialog id="apply-dialog"><form method="dialog"><h2>Apply this preview?</h2><p>The reviewed files will be written to your project. If any affected file has changed since the preview, the whole operation will stop.</p><div class="dialog-actions"><button value="cancel">Keep reviewing</button><button value="confirm" class="button primary">Apply reviewed files</button></div></form></dialog></body></html>`;
44
+ return `<!doctype html><html lang="en" data-theme="enterprise"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="csrf-token" content="${csrf}"><title>${e(data.name)} · Spequi</title><link rel="icon" href="/favicon.svg" type="image/svg+xml"><script src="/assets/app.js" defer></script><script src="/assets/review.js" defer></script><script src="/assets/workflow.js" defer></script><script src="/assets/studio.js" defer></script><script src="/assets/session.js" defer></script><script src="/assets/requests.js" defer></script><link rel="stylesheet" href="/assets/fonts.css"><link rel="stylesheet" href="/assets/app.css"><link rel="stylesheet" href="/assets/diff.css"><link rel="stylesheet" href="/assets/review.css"><link rel="stylesheet" href="/assets/studio.css"></head><body><a class="skip-link" href="#document">Skip to document</a><header class="topbar"><div class="topbar-start"><div class="brand">${icon('layers')}<span>Spequi</span><span class="local-pill">LOCAL</span></div></div><div class="topbar-end"><a class="tool-docs-link" href="/docs" target="_blank" rel="noopener noreferrer" aria-label="Spequi docs and landing page (opens in a new tab)" title="Docs and getting started">${icon('book')}<span>Docs</span></a><button type="button" class="button requests-toggle" data-requests-toggle aria-controls="requests-panel" aria-expanded="false"><span class="requests-icon" aria-hidden="true">${icon('clock')}<span class="requests-attention" data-request-count hidden></span></span>Requests</button><button type="button" id="agent-indicator" class="session-indicator" data-session-toggle aria-expanded="false" aria-controls="agent-connections"><span class="session-agent-icon" aria-hidden="true">${icon('agent')}<i></i></span><span data-session-label>Checking agent</span><span class="session-chevron" aria-hidden="true">${icon('chevron')}</span></button><button type="button" class="session-mcp-button" aria-label="MCP connections" data-session-toggle aria-expanded="false" aria-controls="mcp-connections">${icon('plug')}<span id="mcp-count">MCPs</span></button><button type="button" id="theme-toggle" class="theme-toggle" aria-label="Switch to dark mode" title="Switch to dark mode"><span class="theme-icon-dark">${icon('moon')}</span><span class="theme-icon-light">${icon('sun')}</span></button></div></header><aside id="agent-connections" class="session-panel agent-panel" aria-label="Agent connection" hidden><header><h2>Agent</h2><button type="button" class="icon-button" data-session-close aria-label="Close agent details">${icon('close')}</button></header><div class="agent-summary"><span class="agent-avatar" aria-hidden="true">${icon('agent')}</span><div class="agent-identity"><strong id="session-agent-name">Spequi Agent</strong><p id="session-agent-caption">Checking connection</p></div><span id="session-state" class="agent-state-badge">Checking</span></div><dl class="agent-facts"><div><dt>Last seen</dt><dd><time id="session-last-seen">Not yet</time></dd></div><div><dt>Queue</dt><dd id="session-queue-state">Checking</dd></div></dl><section class="agent-current" data-session-current aria-label="Current request" hidden><div><strong id="session-current-change"></strong><span id="session-current-state"></span></div><p id="session-current-hint"></p></section><section id="session-recovery" class="agent-guidance" aria-label="Next step" hidden><p id="session-recovery-message"></p><p id="session-recovery-detail" hidden></p></section><footer class="agent-panel-actions"><button type="button" class="button" data-session-refresh>Refresh status</button><button type="button" class="text-button" data-session-open-requests>View requests ${icon('arrow')}</button></footer><p data-session-check-result role="status" aria-live="polite" aria-atomic="true"></p></aside><aside id="mcp-connections" class="session-panel mcp-panel" aria-label="MCP connections" hidden><header><div><h2>MCP connections</h2><span id="mcp-panel-state" class="mcp-panel-state">Not reported</span></div><button type="button" class="icon-button" data-session-close aria-label="Close MCP connections">${icon('close')}</button></header><div class="mcp-panel-body"><p id="mcp-report-summary" hidden></p><div class="mcp-empty" data-mcp-empty><span class="mcp-empty-icon" aria-hidden="true">${icon('plug')}</span><div><h3 id="mcp-empty-title">Waiting for connection details</h3><p id="mcp-empty-description">Your agent hasn’t shared its MCP connections yet.</p></div></div><ul id="session-mcps"></ul></div><footer class="mcp-panel-footer"><button type="button" class="text-button" data-mcp-refresh>Refresh status</button><time id="mcp-report-date">Not reported yet</time></footer></aside><aside id="requests-panel" class="requests-panel" aria-label="Requests" hidden><header><h2>Requests</h2><div class="requests-tools"><select data-request-filter aria-label="Filter requests"><option value="inbox" selected>Inbox</option><option value="all">All history</option><option value="active">Active history</option><option value="completed">Completed</option><option value="failed">Failed</option><option value="cancelled">Cancelled</option></select><button type="button" class="icon-button" data-requests-close aria-label="Close requests">${icon('close')}</button></div></header><div data-requests-feedback role="status" aria-live="polite"></div><div data-request-list></div><footer hidden><span data-request-pagination></span><nav data-request-pages aria-label="Request pages" hidden><button class="icon-button" type="button" data-request-page="previous" aria-label="Previous page" title="Previous page">${icon('chevron')}</button><button class="icon-button" type="button" data-request-page="next" aria-label="Next page" title="Next page">${icon('chevron')}</button></nav></footer></aside><dialog id="request-delete-dialog" aria-labelledby="request-delete-title" aria-describedby="request-delete-description request-delete-retention"><form method="dialog"><h2 id="request-delete-title">Delete this request?</h2><p id="request-delete-description">Remove it from request history.</p><label><input type="checkbox" name="reviewData" checked> Also delete its saved preview and that preview’s comments and exports</label><p id="request-delete-retention">Project files, OpenSpec documents, and applied-file backups are kept.</p><div class="dialog-actions"><button value="cancel" class="button">Keep request</button><button value="confirm" class="button danger-solid">Delete request</button></div></form></dialog><dialog id="draft-delete-dialog" aria-labelledby="draft-delete-title" aria-describedby="draft-delete-description draft-delete-retention"><form method="dialog"><h2 id="draft-delete-title">Delete this draft?</h2><p id="draft-delete-description">The saved idea will be removed.</p><label data-delete-plan-choice><input type="checkbox" name="deletePlan"> Also delete the planning files generated from this draft</label><p id="draft-delete-retention">Cancel active requests before deleting. Application source files are kept.</p><div class="dialog-actions"><button value="cancel" class="button">Keep draft</button><button value="confirm" class="button danger-solid">Delete draft</button></div></form></dialog>${content}<div id="toast" role="status" aria-live="polite" aria-atomic="true"></div><dialog id="apply-dialog"><form method="dialog"><h2>Apply this preview?</h2><p>The reviewed files will be written to your project. If any affected file has changed since the preview, the whole operation will stop.</p><div class="dialog-actions"><button value="cancel">Keep reviewing</button><button value="confirm" class="button primary">Apply reviewed files</button></div></form></dialog></body></html>`;
45
45
  }
46
46
  export async function workspace({ root, data, params, jobs, agent, drafts = [], getReadiness, compact = true }) {
47
47
  if (params.view === 'studio' && params.draft && !params.creation && !params.change) {