@algochad/archcoder 2.0.2
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.
- package/README.md +113 -0
- package/bin/cli-entry.js +55 -0
- package/bin/cli-output.js +145 -0
- package/bin/cli.js +5108 -0
- package/bin/cli.test.js +56 -0
- package/dist/apple-touch-icon-120x120.png +0 -0
- package/dist/apple-touch-icon-152x152.png +0 -0
- package/dist/apple-touch-icon-167x167.png +0 -0
- package/dist/apple-touch-icon-180x180.png +0 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/apple-touch-icon.svg +67 -0
- package/dist/assets/MultiRunWindow-BZp3MjJP.js +1 -0
- package/dist/assets/SettingsWindow-DoGYXpX7.js +1 -0
- package/dist/assets/TerminalView-BN7BR5Ff.js +3 -0
- package/dist/assets/TimelineDialog-ZQ33oVQR.js +1 -0
- package/dist/assets/ToolOutputDialog-Blv3pnug.js +16 -0
- package/dist/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/dist/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/dist/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/dist/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/dist/assets/index-CtCEGYrr.css +1 -0
- package/dist/assets/index-o_d2wtWC.js +48 -0
- package/dist/assets/main-5QGBtzdq.css +1 -0
- package/dist/assets/main-B6oiMU86.js +8033 -0
- package/dist/assets/vendor--DbVqbJpV.css +1 -0
- package/dist/assets/vendor-.bun-HTKwyaEM.js +10086 -0
- package/dist/assets/wasm-CG6Dc4jp.js +1 -0
- package/dist/assets/worker-bqd4RMrj.js +155 -0
- package/dist/favicon-16.png +0 -0
- package/dist/favicon-32.png +0 -0
- package/dist/favicon.png +0 -0
- package/dist/favicon.svg +67 -0
- package/dist/index.html +533 -0
- package/dist/logo-dark-192x192.png +0 -0
- package/dist/logo-dark-512x512.svg +16 -0
- package/dist/logo-light-192x192.png +0 -0
- package/dist/logo-light-512x512.svg +16 -0
- package/dist/pwa-192.png +0 -0
- package/dist/pwa-512.png +0 -0
- package/dist/pwa-maskable-192.png +0 -0
- package/dist/pwa-maskable-512.png +0 -0
- package/dist/site.webmanifest +22 -0
- package/dist/sw.js +1 -0
- package/package.json +107 -0
- package/public/apple-touch-icon-120x120.png +0 -0
- package/public/apple-touch-icon-152x152.png +0 -0
- package/public/apple-touch-icon-167x167.png +0 -0
- package/public/apple-touch-icon-180x180.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/apple-touch-icon.svg +67 -0
- package/public/favicon-16.png +0 -0
- package/public/favicon-32.png +0 -0
- package/public/favicon.png +0 -0
- package/public/favicon.svg +67 -0
- package/public/logo-dark-192x192.png +0 -0
- package/public/logo-dark-512x512.svg +16 -0
- package/public/logo-light-192x192.png +0 -0
- package/public/logo-light-512x512.svg +16 -0
- package/public/pwa-192.png +0 -0
- package/public/pwa-512.png +0 -0
- package/public/pwa-maskable-192.png +0 -0
- package/public/pwa-maskable-512.png +0 -0
- package/public/site.webmanifest +22 -0
- package/server/TERMINAL_INPUT_WS_PROTOCOL.md +44 -0
- package/server/index.d.ts +37 -0
- package/server/index.js +14694 -0
- package/server/lib/cloudflare-tunnel.js +650 -0
- package/server/lib/git/DOCUMENTATION.md +146 -0
- package/server/lib/git/credentials.js +74 -0
- package/server/lib/git/identity-storage.js +110 -0
- package/server/lib/git/index.js +6 -0
- package/server/lib/git/service.js +3117 -0
- package/server/lib/github/DOCUMENTATION.md +170 -0
- package/server/lib/github/auth.js +307 -0
- package/server/lib/github/device-flow.js +50 -0
- package/server/lib/github/index.js +24 -0
- package/server/lib/github/octokit.js +10 -0
- package/server/lib/github/pr-status.js +478 -0
- package/server/lib/github/repo/index.js +55 -0
- package/server/lib/installer/desktop.js +289 -0
- package/server/lib/installer/download.js +208 -0
- package/server/lib/installer/index.js +45 -0
- package/server/lib/installer/platform.js +100 -0
- package/server/lib/notifications/DOCUMENTATION.md +61 -0
- package/server/lib/notifications/index.js +1 -0
- package/server/lib/notifications/message.js +49 -0
- package/server/lib/notifications/message.test.js +59 -0
- package/server/lib/opencode/DOCUMENTATION.md +59 -0
- package/server/lib/opencode/agents.js +634 -0
- package/server/lib/opencode/auth.js +81 -0
- package/server/lib/opencode/commands.js +339 -0
- package/server/lib/opencode/index.js +66 -0
- package/server/lib/opencode/mcp.js +206 -0
- package/server/lib/opencode/providers.js +96 -0
- package/server/lib/opencode/shared.js +527 -0
- package/server/lib/opencode/skills.js +480 -0
- package/server/lib/opencode/tunnel-auth.js +591 -0
- package/server/lib/opencode/ui-auth.js +510 -0
- package/server/lib/package-manager.js +505 -0
- package/server/lib/quota/DOCUMENTATION.md +55 -0
- package/server/lib/quota/index.js +24 -0
- package/server/lib/quota/providers/claude.js +107 -0
- package/server/lib/quota/providers/codex.js +113 -0
- package/server/lib/quota/providers/copilot.js +165 -0
- package/server/lib/quota/providers/google/api.js +92 -0
- package/server/lib/quota/providers/google/auth.js +108 -0
- package/server/lib/quota/providers/google/index.js +124 -0
- package/server/lib/quota/providers/google/transforms.js +109 -0
- package/server/lib/quota/providers/index.js +152 -0
- package/server/lib/quota/providers/interface.js +55 -0
- package/server/lib/quota/providers/kimi.js +108 -0
- package/server/lib/quota/providers/minimax-cn-coding-plan.js +15 -0
- package/server/lib/quota/providers/minimax-coding-plan.js +15 -0
- package/server/lib/quota/providers/minimax-shared.js +136 -0
- package/server/lib/quota/providers/nanogpt.js +124 -0
- package/server/lib/quota/providers/ollama-cloud.js +112 -0
- package/server/lib/quota/providers/openai.js +91 -0
- package/server/lib/quota/providers/openrouter.js +92 -0
- package/server/lib/quota/providers/zai.js +91 -0
- package/server/lib/quota/utils/auth.js +46 -0
- package/server/lib/quota/utils/formatters.js +76 -0
- package/server/lib/quota/utils/index.js +10 -0
- package/server/lib/quota/utils/transformers.js +55 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +178 -0
- package/server/lib/skills-catalog/cache.js +32 -0
- package/server/lib/skills-catalog/clawdhub/api.js +158 -0
- package/server/lib/skills-catalog/clawdhub/index.js +30 -0
- package/server/lib/skills-catalog/clawdhub/install.js +238 -0
- package/server/lib/skills-catalog/clawdhub/scan.js +113 -0
- package/server/lib/skills-catalog/curated-sources.js +21 -0
- package/server/lib/skills-catalog/git.js +77 -0
- package/server/lib/skills-catalog/index.js +42 -0
- package/server/lib/skills-catalog/install.js +294 -0
- package/server/lib/skills-catalog/scan.js +221 -0
- package/server/lib/skills-catalog/source.js +85 -0
- package/server/lib/terminal/DOCUMENTATION.md +114 -0
- package/server/lib/terminal/index.js +12 -0
- package/server/lib/terminal/input-ws-protocol.js +66 -0
- package/server/lib/terminal/input-ws-protocol.test.js +138 -0
- package/server/lib/tts/DOCUMENTATION.md +134 -0
- package/server/lib/tts/index.js +16 -0
- package/server/lib/tts/service.js +162 -0
- package/server/lib/tts/summarization.js +171 -0
- package/server/lib/tunnels/index.js +166 -0
- package/server/lib/tunnels/providers/cloudflare.js +260 -0
- package/server/lib/tunnels/registry.js +51 -0
- package/server/lib/tunnels/types.js +219 -0
- package/server/lib/utils/lru.js +107 -0
- package/server/lib/utils/sse.js +121 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const DEFAULT_NOTIFICATION_MESSAGE_MAX_LENGTH = 250;
|
|
2
|
+
const DEFAULT_NOTIFICATION_SUMMARY_THRESHOLD = 200;
|
|
3
|
+
const DEFAULT_NOTIFICATION_SUMMARY_LENGTH = 100;
|
|
4
|
+
|
|
5
|
+
const resolvePositiveNumber = (value, fallback) => {
|
|
6
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) {
|
|
7
|
+
return fallback;
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const truncateNotificationText = (text, maxLength = DEFAULT_NOTIFICATION_MESSAGE_MAX_LENGTH) => {
|
|
13
|
+
if (typeof text !== 'string') {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const safeMaxLength = resolvePositiveNumber(maxLength, DEFAULT_NOTIFICATION_MESSAGE_MAX_LENGTH);
|
|
18
|
+
if (text.length <= safeMaxLength) {
|
|
19
|
+
return text;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return `${text.slice(0, safeMaxLength)}...`;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const prepareNotificationLastMessage = async ({ message, settings, summarize }) => {
|
|
26
|
+
const originalMessage = typeof message === 'string' ? message : '';
|
|
27
|
+
if (!originalMessage) {
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const shouldSummarize = settings?.summarizeLastMessage === true && typeof summarize === 'function';
|
|
32
|
+
const summaryThreshold = resolvePositiveNumber(settings?.summaryThreshold, DEFAULT_NOTIFICATION_SUMMARY_THRESHOLD);
|
|
33
|
+
const summaryLength = resolvePositiveNumber(settings?.summaryLength, DEFAULT_NOTIFICATION_SUMMARY_LENGTH);
|
|
34
|
+
const maxLastMessageLength = resolvePositiveNumber(settings?.maxLastMessageLength, DEFAULT_NOTIFICATION_MESSAGE_MAX_LENGTH);
|
|
35
|
+
|
|
36
|
+
let messageForNotification = originalMessage;
|
|
37
|
+
if (shouldSummarize && originalMessage.length > summaryThreshold) {
|
|
38
|
+
try {
|
|
39
|
+
const summary = await summarize(originalMessage, summaryLength);
|
|
40
|
+
if (typeof summary === 'string' && summary.trim().length > 0) {
|
|
41
|
+
messageForNotification = summary;
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
messageForNotification = originalMessage;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return truncateNotificationText(messageForNotification, maxLastMessageLength);
|
|
49
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { prepareNotificationLastMessage, truncateNotificationText } from './message.js';
|
|
4
|
+
|
|
5
|
+
describe('notification message helpers', () => {
|
|
6
|
+
it('truncates oversized notification text', () => {
|
|
7
|
+
expect(truncateNotificationText('abcdef', 3)).toBe('abc...');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('falls back to original message when summarization fails', async () => {
|
|
11
|
+
const message = '0123456789';
|
|
12
|
+
const summarize = async () => {
|
|
13
|
+
throw new Error('summarization failed');
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const result = await prepareNotificationLastMessage({
|
|
17
|
+
message,
|
|
18
|
+
summarize,
|
|
19
|
+
settings: {
|
|
20
|
+
summarizeLastMessage: true,
|
|
21
|
+
summaryThreshold: 5,
|
|
22
|
+
summaryLength: 3,
|
|
23
|
+
maxLastMessageLength: 4,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
expect(result).toBe('0123...');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('falls back to original message when summary is empty', async () => {
|
|
31
|
+
const result = await prepareNotificationLastMessage({
|
|
32
|
+
message: '0123456789',
|
|
33
|
+
summarize: async () => ' ',
|
|
34
|
+
settings: {
|
|
35
|
+
summarizeLastMessage: true,
|
|
36
|
+
summaryThreshold: 5,
|
|
37
|
+
summaryLength: 3,
|
|
38
|
+
maxLastMessageLength: 4,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
expect(result).toBe('0123...');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('uses summary when summarization succeeds', async () => {
|
|
46
|
+
const result = await prepareNotificationLastMessage({
|
|
47
|
+
message: '0123456789',
|
|
48
|
+
summarize: async () => 'short summary',
|
|
49
|
+
settings: {
|
|
50
|
+
summarizeLastMessage: true,
|
|
51
|
+
summaryThreshold: 5,
|
|
52
|
+
summaryLength: 3,
|
|
53
|
+
maxLastMessageLength: 100,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(result).toBe('short summary');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# OpenCode Module Documentation
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
This module provides OpenCode server integration utilities for the web server runtime, including configuration management, provider authentication, and UI authentication with rate limiting.
|
|
5
|
+
|
|
6
|
+
## Entrypoints and structure
|
|
7
|
+
- `packages/web/server/lib/opencode/index.js`: public entrypoint (currently baseline placeholder).
|
|
8
|
+
- `packages/web/server/lib/opencode/auth.js`: provider authentication file operations.
|
|
9
|
+
- `packages/web/server/lib/opencode/shared.js`: shared utilities for config, markdown, skills, and git helpers.
|
|
10
|
+
- `packages/web/server/lib/opencode/ui-auth.js`: UI session authentication with rate limiting.
|
|
11
|
+
|
|
12
|
+
## Public exports (auth.js)
|
|
13
|
+
- `readAuthFile()`: Reads and parses `~/.local/share/opencode/auth.json`.
|
|
14
|
+
- `writeAuthFile(auth)`: Writes auth file with automatic backup.
|
|
15
|
+
- `removeProviderAuth(providerId)`: Removes a provider's auth entry.
|
|
16
|
+
- `getProviderAuth(providerId)`: Returns auth for a specific provider or null.
|
|
17
|
+
- `listProviderAuths()`: Returns list of provider IDs with configured auth.
|
|
18
|
+
- `AUTH_FILE`: Auth file path constant.
|
|
19
|
+
- `OPENCODE_DATA_DIR`: OpenCode data directory path constant.
|
|
20
|
+
|
|
21
|
+
## Public exports (shared.js)
|
|
22
|
+
- `OPENCODE_CONFIG_DIR`, `AGENT_DIR`, `COMMAND_DIR`, `SKILL_DIR`, `CONFIG_FILE`, `CUSTOM_CONFIG_FILE`: Path constants.
|
|
23
|
+
- `AGENT_SCOPE`, `COMMAND_SCOPE`, `SKILL_SCOPE`: Scope constants with USER and PROJECT values.
|
|
24
|
+
- `ensureDirs()`: Creates required OpenCode directories.
|
|
25
|
+
- `parseMdFile(filePath)`, `writeMdFile(filePath, frontmatter, body)`: Markdown file operations with YAML frontmatter.
|
|
26
|
+
- `getConfigPaths(workingDirectory)`, `readConfigLayers(workingDirectory)`, `readConfig(workingDirectory)`: Config file operations with layer merging (user, project, custom).
|
|
27
|
+
- `writeConfig(config, filePath)`: Writes config with automatic backup.
|
|
28
|
+
- `getJsonEntrySource(layers, sectionKey, entryName)`: Resolves which config layer provides an entry.
|
|
29
|
+
- `getJsonWriteTarget(layers, preferredScope)`: Determines write target for config updates.
|
|
30
|
+
- `getAncestors(startDir, stopDir)`, `findWorktreeRoot(startDir)`: Git worktree helpers.
|
|
31
|
+
- `isPromptFileReference(value)`, `resolvePromptFilePath(reference)`, `writePromptFile(filePath, content)`: Prompt file reference handling.
|
|
32
|
+
- `walkSkillMdFiles(rootDir)`: Recursively finds all SKILL.md files.
|
|
33
|
+
- `addSkillFromMdFile(skillsMap, skillMdPath, scope, source)`: Parses and indexes a skill file.
|
|
34
|
+
- `resolveSkillSearchDirectories(workingDirectory)`: Returns skill search path order (config, project, home, custom).
|
|
35
|
+
- `listSkillSupportingFiles(skillDir)`, `readSkillSupportingFile(skillDir, relativePath)`, `writeSkillSupportingFile(skillDir, relativePath, content)`, `deleteSkillSupportingFile(skillDir, relativePath)`: Skill supporting file management.
|
|
36
|
+
|
|
37
|
+
## Public exports (ui-auth.js)
|
|
38
|
+
- `createUiAuth({ password, cookieName, sessionTtlMs })`: Creates UI auth instance with methods:
|
|
39
|
+
- `enabled`: Boolean indicating if auth is configured.
|
|
40
|
+
- `requireAuth(req, res, next)`: Express middleware to enforce authentication.
|
|
41
|
+
- `handleSessionStatus(req, res)`: Returns authentication status.
|
|
42
|
+
- `handleSessionCreate(req, res)`: Handles login with rate limiting.
|
|
43
|
+
- `ensureSessionToken(req, res)`: Returns or creates session token.
|
|
44
|
+
- `dispose()`: Cleans up timers and state.
|
|
45
|
+
|
|
46
|
+
## Storage and configuration
|
|
47
|
+
- Provider auth: `~/.local/share/opencode/auth.json`.
|
|
48
|
+
- User config: `~/.config/opencode/opencode.json`.
|
|
49
|
+
- Project config: `<workingDirectory>/.opencode/opencode.json` or `opencode.json`.
|
|
50
|
+
- Custom config: `OPENCODE_CONFIG` env var path.
|
|
51
|
+
- Rate limit config: `OPENCHAMBER_RATE_LIMIT_MAX_ATTEMPTS`, `OPENCHAMBER_RATE_LIMIT_NO_IP_MAX_ATTEMPTS` env vars.
|
|
52
|
+
|
|
53
|
+
## Notes for contributors
|
|
54
|
+
- This module serves as foundation for OpenCode-related server utilities.
|
|
55
|
+
- Index.js is currently a baseline placeholder; direct imports use submodule paths.
|
|
56
|
+
- All file writes include automatic backup before modification.
|
|
57
|
+
- Config merging follows priority: custom > project > user.
|
|
58
|
+
- UI auth uses scrypt for password hashing with constant-time comparison.
|
|
59
|
+
- Tunnel auth treats `host.docker.internal` as local-only when the socket remote IP is private/loopback.
|