snow-flow 9.0.6 → 9.0.9

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.
Files changed (40) hide show
  1. package/package.json +2 -1
  2. package/postinstall.cjs +65 -11
  3. package/bunfig.toml +0 -2
  4. package/script/postinstall.mjs +0 -135
  5. package/script/preinstall.mjs +0 -45
  6. package/snow-code-config.example.json +0 -39
  7. package/src/acp/README.md +0 -164
  8. package/src/agent/generate.txt +0 -75
  9. package/src/dag/README.md +0 -473
  10. package/src/session/prompt/anthropic-20250930.txt +0 -166
  11. package/src/session/prompt/anthropic.txt +0 -235
  12. package/src/session/prompt/anthropic_spoof.txt +0 -1
  13. package/src/session/prompt/beast.txt +0 -200
  14. package/src/session/prompt/build-switch.txt +0 -5
  15. package/src/session/prompt/codex.txt +0 -353
  16. package/src/session/prompt/copilot-gpt-5.txt +0 -143
  17. package/src/session/prompt/gemini.txt +0 -217
  18. package/src/session/prompt/initialize.txt +0 -8
  19. package/src/session/prompt/plan.txt +0 -8
  20. package/src/session/prompt/qwen.txt +0 -141
  21. package/src/session/prompt/summarize-turn.txt +0 -5
  22. package/src/session/prompt/summarize.txt +0 -10
  23. package/src/session/prompt/title.txt +0 -24
  24. package/src/tool/bash.txt +0 -121
  25. package/src/tool/edit.txt +0 -10
  26. package/src/tool/glob.txt +0 -6
  27. package/src/tool/grep.txt +0 -8
  28. package/src/tool/ls.txt +0 -1
  29. package/src/tool/lsp-diagnostics.txt +0 -1
  30. package/src/tool/lsp-hover.txt +0 -1
  31. package/src/tool/multiedit.txt +0 -41
  32. package/src/tool/patch.txt +0 -1
  33. package/src/tool/read.txt +0 -12
  34. package/src/tool/task.txt +0 -76
  35. package/src/tool/todoread.txt +0 -14
  36. package/src/tool/todowrite.txt +0 -167
  37. package/src/tool/webfetch.txt +0 -14
  38. package/src/tool/websearch.txt +0 -11
  39. package/src/tool/write.txt +0 -8
  40. package/test-codespace-detection.js +0 -51
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "9.0.6",
3
+ "version": "9.0.9",
4
4
  "name": "snow-flow",
5
5
  "description": "Snow-Flow - AI-powered ServiceNow development CLI with 410+ MCP tools",
6
6
  "type": "module",
@@ -79,6 +79,7 @@
79
79
  "@standard-schema/spec": "1.0.0",
80
80
  "@zip.js/zip.js": "2.7.62",
81
81
  "ai": "5.0.8",
82
+ "axios": "1.7.9",
82
83
  "chokidar": "4.0.3",
83
84
  "decimal.js": "10.5.0",
84
85
  "diff": "8.0.2",
package/postinstall.cjs CHANGED
@@ -13,6 +13,9 @@ const binaryName = platform === 'windows' ? 'snow-code.exe' : 'snow-code';
13
13
  const packageDir = __dirname;
14
14
  const binDir = path.join(packageDir, 'bin');
15
15
  const binaryPath = path.join(binDir, binaryName);
16
+ const distDir = path.join(packageDir, 'dist');
17
+ const mcpDir = path.join(distDir, 'mcp');
18
+ const mcpIndexPath = path.join(mcpDir, 'enterprise-proxy', 'index.js');
16
19
 
17
20
  // Get version from package.json
18
21
  function getVersion() {
@@ -95,16 +98,67 @@ async function downloadBinary() {
95
98
  }
96
99
  }
97
100
 
98
- // Only run if binary doesn't exist
99
- if (!fs.existsSync(binaryPath)) {
100
- downloadBinary().catch(err => {
101
- console.log(`Download failed: ${err.message}`);
102
- });
103
- } else {
104
- // Make sure it's executable
105
- if (platform !== 'windows') {
106
- try {
107
- fs.chmodSync(binaryPath, 0o755);
108
- } catch {}
101
+ async function downloadMcpServers() {
102
+ const version = getVersion();
103
+ if (!version) {
104
+ console.log('Could not determine version, skipping MCP download');
105
+ return false;
106
+ }
107
+
108
+ const tarballName = 'snow-flow-mcp.tar.gz';
109
+ const releaseUrl = `https://github.com/groeimetai/snow-flow/releases/download/v${version}/${tarballName}`;
110
+
111
+ console.log('Downloading MCP servers...');
112
+
113
+ try {
114
+ // Download the tarball
115
+ const tarballData = await download(releaseUrl);
116
+
117
+ // Create temp file
118
+ const tmpDir = os.tmpdir();
119
+ const tarballPath = path.join(tmpDir, tarballName);
120
+ fs.writeFileSync(tarballPath, tarballData);
121
+
122
+ // Ensure dist directory exists
123
+ if (!fs.existsSync(distDir)) {
124
+ fs.mkdirSync(distDir, { recursive: true });
125
+ }
126
+
127
+ // Extract MCP servers
128
+ console.log('Extracting MCP servers...');
129
+ execSync(`tar -xzf "${tarballPath}" -C "${distDir}"`, { stdio: 'pipe' });
130
+
131
+ // Clean up
132
+ fs.unlinkSync(tarballPath);
133
+
134
+ console.log('✅ MCP servers installed successfully!');
135
+ return true;
136
+ } catch (error) {
137
+ console.log(`Note: Could not download MCP servers (${error.message})`);
138
+ console.log('Enterprise features may not be available.');
139
+ return false;
140
+ }
141
+ }
142
+
143
+ async function main() {
144
+ // Download binary if needed
145
+ if (!fs.existsSync(binaryPath)) {
146
+ await downloadBinary();
147
+ } else {
148
+ // Make sure it's executable
149
+ if (platform !== 'windows') {
150
+ try {
151
+ fs.chmodSync(binaryPath, 0o755);
152
+ } catch {}
153
+ }
154
+ }
155
+
156
+ // Download MCP servers if needed
157
+ if (!fs.existsSync(mcpIndexPath)) {
158
+ await downloadMcpServers();
109
159
  }
110
160
  }
161
+
162
+ main().catch(err => {
163
+ console.log(`Postinstall failed: ${err.message}`);
164
+ });
package/bunfig.toml DELETED
@@ -1,2 +0,0 @@
1
- [test]
2
- preload = ["./test/preload.ts"]
@@ -1,135 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from "fs"
4
- import path from "path"
5
- import os from "os"
6
- import { fileURLToPath } from "url"
7
- import { createRequire } from "module"
8
-
9
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
10
- const require = createRequire(import.meta.url)
11
-
12
- function detectPlatformAndArch() {
13
- // Map platform names
14
- let platform
15
- switch (os.platform()) {
16
- case "darwin":
17
- platform = "darwin"
18
- break
19
- case "linux":
20
- platform = "linux"
21
- break
22
- case "win32":
23
- platform = "windows"
24
- break
25
- default:
26
- platform = os.platform()
27
- break
28
- }
29
-
30
- // Map architecture names
31
- let arch
32
- switch (os.arch()) {
33
- case "x64":
34
- arch = "x64"
35
- break
36
- case "arm64":
37
- arch = "arm64"
38
- break
39
- case "arm":
40
- arch = "arm"
41
- break
42
- default:
43
- arch = os.arch()
44
- break
45
- }
46
-
47
- return { platform, arch }
48
- }
49
-
50
- function findBinary() {
51
- const { platform, arch } = detectPlatformAndArch()
52
- const packageName = `@groeimetai/snow-flow-${platform}-${arch}`
53
- const binary = platform === "windows" ? "snow-code.exe" : "snow-code"
54
-
55
- try {
56
- // Use require.resolve to find the package
57
- const packageJsonPath = require.resolve(`${packageName}/package.json`)
58
- const packageDir = path.dirname(packageJsonPath)
59
- const binaryPath = path.join(packageDir, "bin", binary)
60
-
61
- if (!fs.existsSync(binaryPath)) {
62
- throw new Error(`Binary not found at ${binaryPath}`)
63
- }
64
-
65
- return binaryPath
66
- } catch (error) {
67
- throw new Error(`Could not find package ${packageName}: ${error.message}`)
68
- }
69
- }
70
-
71
- async function regenerateWindowsCmdWrappers() {
72
- console.log("Windows + npm detected: Forcing npm to rebuild bin links")
73
-
74
- try {
75
- const { execSync } = require("child_process")
76
- const pkgPath = path.join(__dirname, "..")
77
-
78
- // npm_config_global is string | undefined
79
- // if it exists, the value is true
80
- const isGlobal = process.env.npm_config_global === "true" || pkgPath.includes(path.join("npm", "node_modules"))
81
-
82
- // The npm rebuild command does 2 things - Execute lifecycle scripts and rebuild bin links
83
- // We want to skip lifecycle scripts to avoid infinite loops, so we use --ignore-scripts
84
- const cmd = `npm rebuild @groeimetai/snow-flow-snowcode --ignore-scripts${isGlobal ? " -g" : ""}`
85
- const opts = {
86
- stdio: "inherit",
87
- shell: true,
88
- ...(isGlobal ? {} : { cwd: path.join(pkgPath, "..", "..") }), // For local, run from project root
89
- }
90
-
91
- console.log(`Running: ${cmd}`)
92
- execSync(cmd, opts)
93
- console.log("Successfully rebuilt npm bin links")
94
- } catch (error) {
95
- console.error("Error rebuilding npm links:", error.message)
96
- console.error("npm rebuild failed. You may need to manually run: npm rebuild @groeimetai/snow-flow-snowcode --ignore-scripts")
97
- }
98
- }
99
-
100
- async function main() {
101
- try {
102
- if (os.platform() === "win32") {
103
- // NPM eg format - npm/11.4.2 node/v24.4.1 win32 x64
104
- // Bun eg format - bun/1.2.19 npm/? node/v24.3.0 win32 x64
105
- if (process.env.npm_config_user_agent.startsWith("npm")) {
106
- await regenerateWindowsCmdWrappers()
107
- } else {
108
- console.log("Windows detected but not npm, skipping postinstall")
109
- }
110
- return
111
- }
112
-
113
- const binaryPath = findBinary()
114
- const binScript = path.join(__dirname, "bin", "snow-code")
115
-
116
- // Remove existing bin script if it exists
117
- if (fs.existsSync(binScript)) {
118
- fs.unlinkSync(binScript)
119
- }
120
-
121
- // Create symlink to the actual binary
122
- fs.symlinkSync(binaryPath, binScript)
123
- console.log(`snow-code binary symlinked: ${binScript} -> ${binaryPath}`)
124
- } catch (error) {
125
- console.error("Failed to create snow-code binary symlink:", error.message)
126
- process.exit(1)
127
- }
128
- }
129
-
130
- try {
131
- main()
132
- } catch (error) {
133
- console.error("Postinstall script error:", error.message)
134
- process.exit(0)
135
- }
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from "fs"
4
- import path from "path"
5
- import os from "os"
6
- import { fileURLToPath } from "url"
7
-
8
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
-
10
- function main() {
11
- if (os.platform() !== "win32") {
12
- console.log("Non-Windows platform detected, skipping preinstall")
13
- return
14
- }
15
-
16
- console.log("Windows detected: Modifying package.json bin entry")
17
-
18
- // Read package.json
19
- const packageJsonPath = path.join(__dirname, "package.json")
20
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"))
21
-
22
- // Modify bin to point to .cmd file on Windows
23
- packageJson.bin = {
24
- "snow-code": "./bin/snowcode.cmd",
25
- "snowcode": "./bin/snowcode.cmd",
26
- }
27
-
28
- // Write it back
29
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
30
- console.log("Updated package.json bin to use snowcode.cmd")
31
-
32
- // Now you can also remove the Unix script if you want
33
- const unixScript = path.join(__dirname, "bin", "snow-code")
34
- if (fs.existsSync(unixScript)) {
35
- console.log("Removing Unix shell script")
36
- fs.unlinkSync(unixScript)
37
- }
38
- }
39
-
40
- try {
41
- main()
42
- } catch (error) {
43
- console.error("Preinstall script error:", error.message)
44
- process.exit(0)
45
- }
@@ -1,39 +0,0 @@
1
- {
2
- "$schema": "https://opencode.ai/config.json",
3
- "tui": {
4
- "scroll_speed": 5
5
- },
6
- "mcp": {
7
- "servicenow-unified": {
8
- "type": "local",
9
- "command": ["node", "dist/mcp/servicenow-mcp-unified/index.js"],
10
- "environment": {
11
- "SERVICENOW_INSTANCE_URL": "https://dev12345.service-now.com",
12
- "SERVICENOW_CLIENT_ID": "your-client-id-here",
13
- "SERVICENOW_CLIENT_SECRET": "your-client-secret-here",
14
- "SERVICENOW_USERNAME": "your-username-here",
15
- "SERVICENOW_PASSWORD": "your-password-here"
16
- },
17
- "enabled": true
18
- },
19
- "snow-flow-orchestration": {
20
- "type": "local",
21
- "command": ["node", "dist/mcp/snow-flow-mcp.js"],
22
- "environment": {
23
- "SNOW_FLOW_ENV": "production"
24
- },
25
- "enabled": true
26
- },
27
- "snow-flow-enterprise": {
28
- "type": "local",
29
- "command": ["node", "../snow-flow-enterprise/mcp-proxy/dist/enterprise-proxy.js"],
30
- "description": "Enterprise integrations - Jira, Azure DevOps, Confluence (local proxy to remote server)",
31
- "environment": {
32
- "SNOW_ENTERPRISE_URL": "https://enterprise.snow-flow.dev",
33
- "SNOW_LICENSE_KEY": ""
34
- },
35
- "enabled": false,
36
- "_comment": "Run 'snow-flow auth login' to configure and enable this server"
37
- }
38
- }
39
- }
package/src/acp/README.md DELETED
@@ -1,164 +0,0 @@
1
- # ACP (Agent Client Protocol) Implementation
2
-
3
- This directory contains a clean, protocol-compliant implementation of the [Agent Client Protocol](https://agentclientprotocol.com/) for snow-code.
4
-
5
- ## Architecture
6
-
7
- The implementation follows a clean separation of concerns:
8
-
9
- ### Core Components
10
-
11
- - **`agent.ts`** - Implements the `Agent` interface from `@agentclientprotocol/sdk`
12
- - Handles initialization and capability negotiation
13
- - Manages session lifecycle (`session/new`, `session/load`)
14
- - Processes prompts and returns responses
15
- - Properly implements ACP protocol v1
16
-
17
- - **`client.ts`** - Implements the `Client` interface for client-side capabilities
18
- - File operations (`readTextFile`, `writeTextFile`)
19
- - Permission requests (auto-approves for now)
20
- - Terminal support (stub implementation)
21
-
22
- - **`session.ts`** - Session state management
23
- - Creates and tracks ACP sessions
24
- - Maps ACP sessions to internal snow-code sessions
25
- - Maintains working directory context
26
- - Handles MCP server configurations
27
-
28
- - **`server.ts`** - ACP server startup and lifecycle
29
- - Sets up JSON-RPC over stdio using the official library
30
- - Manages graceful shutdown on SIGTERM/SIGINT
31
- - Provides Instance context for the agent
32
-
33
- - **`types.ts`** - Type definitions for internal use
34
-
35
- ## Usage
36
-
37
- ### Command Line
38
-
39
- ```bash
40
- # Start the ACP server in the current directory
41
- snow-code acp
42
-
43
- # Start in a specific directory
44
- snow-code acp --cwd /path/to/project
45
- ```
46
-
47
- ### Programmatic
48
-
49
- ```typescript
50
- import { ACPServer } from "./acp/server"
51
-
52
- await ACPServer.start()
53
- ```
54
-
55
- ### Integration with Zed
56
-
57
- Add to your Zed configuration (`~/.config/zed/settings.json`):
58
-
59
- ```json
60
- {
61
- "agent_servers": {
62
- "OpenCode": {
63
- "command": "snow-code",
64
- "args": ["acp"]
65
- }
66
- }
67
- }
68
- ```
69
-
70
- ## Protocol Compliance
71
-
72
- This implementation follows the ACP specification v1:
73
-
74
- ✅ **Initialization**
75
-
76
- - Proper `initialize` request/response with protocol version negotiation
77
- - Capability advertisement (`agentCapabilities`)
78
- - Authentication support (stub)
79
-
80
- ✅ **Session Management**
81
-
82
- - `session/new` - Create new conversation sessions
83
- - `session/load` - Resume existing sessions (basic support)
84
- - Working directory context (`cwd`)
85
- - MCP server configuration support
86
-
87
- ✅ **Prompting**
88
-
89
- - `session/prompt` - Process user messages
90
- - Content block handling (text, resources)
91
- - Response with stop reasons
92
-
93
- ✅ **Client Capabilities**
94
-
95
- - File read/write operations
96
- - Permission requests
97
- - Terminal support (stub for future)
98
-
99
- ## Current Limitations
100
-
101
- ### Not Yet Implemented
102
-
103
- 1. **Streaming Responses** - Currently returns complete responses instead of streaming via `session/update` notifications
104
- 2. **Tool Call Reporting** - Doesn't report tool execution progress
105
- 3. **Session Modes** - No mode switching support yet
106
- 4. **Authentication** - No actual auth implementation
107
- 5. **Terminal Support** - Placeholder only
108
- 6. **Session Persistence** - `session/load` doesn't restore actual conversation history
109
-
110
- ### Future Enhancements
111
-
112
- - **Real-time Streaming**: Implement `session/update` notifications for progressive responses
113
- - **Tool Call Visibility**: Report tool executions as they happen
114
- - **Session Persistence**: Save and restore full conversation history
115
- - **Mode Support**: Implement different operational modes (ask, code, etc.)
116
- - **Enhanced Permissions**: More sophisticated permission handling
117
- - **Terminal Integration**: Full terminal support via snow-code's bash tool
118
-
119
- ## Testing
120
-
121
- ```bash
122
- # Run ACP tests
123
- bun test test/acp.test.ts
124
-
125
- # Test manually with stdio
126
- echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1}}' | snow-code acp
127
- ```
128
-
129
- ## Design Decisions
130
-
131
- ### Why the Official Library?
132
-
133
- We use `@agentclientprotocol/sdk` instead of implementing JSON-RPC ourselves because:
134
-
135
- - Ensures protocol compliance
136
- - Handles edge cases and future protocol versions
137
- - Reduces maintenance burden
138
- - Works with other ACP clients automatically
139
-
140
- ### Clean Architecture
141
-
142
- Each component has a single responsibility:
143
-
144
- - **Agent** = Protocol interface
145
- - **Client** = Client-side operations
146
- - **Session** = State management
147
- - **Server** = Lifecycle and I/O
148
-
149
- This makes the codebase maintainable and testable.
150
-
151
- ### Mapping to Snow-Code
152
-
153
- ACP sessions map cleanly to snow-code's internal session model:
154
-
155
- - ACP `session/new` → creates internal Session
156
- - ACP `session/prompt` → uses SessionPrompt.prompt()
157
- - Working directory context preserved per-session
158
- - Tool execution uses existing ToolRegistry
159
-
160
- ## References
161
-
162
- - [ACP Specification](https://agentclientprotocol.com/)
163
- - [TypeScript Library](https://github.com/agentclientprotocol/typescript-sdk)
164
- - [Protocol Examples](https://github.com/agentclientprotocol/typescript-sdk/tree/main/src/examples)
@@ -1,75 +0,0 @@
1
- You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.
2
-
3
- **Important Context**: You may have access to project-specific instructions from CLAUDE.md files and other context that may include coding standards, project structure, and custom requirements. Consider this context when creating agents to ensure they align with the project's established patterns and practices.
4
-
5
- When a user describes what they want an agent to do, you will:
6
-
7
- 1. **Extract Core Intent**: Identify the fundamental purpose, key responsibilities, and success criteria for the agent. Look for both explicit requirements and implicit needs. Consider any project-specific context from CLAUDE.md files. For agents that are meant to review code, you should assume that the user is asking to review recently written code and not the whole codebase, unless the user has explicitly instructed you otherwise.
8
-
9
- 2. **Design Expert Persona**: Create a compelling expert identity that embodies deep domain knowledge relevant to the task. The persona should inspire confidence and guide the agent's decision-making approach.
10
-
11
- 3. **Architect Comprehensive Instructions**: Develop a system prompt that:
12
-
13
- - Establishes clear behavioral boundaries and operational parameters
14
- - Provides specific methodologies and best practices for task execution
15
- - Anticipates edge cases and provides guidance for handling them
16
- - Incorporates any specific requirements or preferences mentioned by the user
17
- - Defines output format expectations when relevant
18
- - Aligns with project-specific coding standards and patterns from CLAUDE.md
19
-
20
- 4. **Optimize for Performance**: Include:
21
-
22
- - Decision-making frameworks appropriate to the domain
23
- - Quality control mechanisms and self-verification steps
24
- - Efficient workflow patterns
25
- - Clear escalation or fallback strategies
26
-
27
- 5. **Create Identifier**: Design a concise, descriptive identifier that:
28
- - Uses lowercase letters, numbers, and hyphens only
29
- - Is typically 2-4 words joined by hyphens
30
- - Clearly indicates the agent's primary function
31
- - Is memorable and easy to type
32
- - Avoids generic terms like "helper" or "assistant"
33
-
34
- 6 **Example agent descriptions**:
35
-
36
- - in the 'whenToUse' field of the JSON object, you should include examples of when this agent should be used.
37
- - examples should be of the form:
38
- - <example>
39
- Context: The user is creating a code-review agent that should be called after a logical chunk of code is written.
40
- user: "Please write a function that checks if a number is prime"
41
- assistant: "Here is the relevant function: "
42
- <function call omitted for brevity only for this example>
43
- <commentary>
44
- Since the user is greeting, use the Task tool to launch the greeting-responder agent to respond with a friendly joke.
45
- </commentary>
46
- assistant: "Now let me use the code-reviewer agent to review the code"
47
- </example>
48
- - <example>
49
- Context: User is creating an agent to respond to the word "hello" with a friendly jok.
50
- user: "Hello"
51
- assistant: "I'm going to use the Task tool to launch the greeting-responder agent to respond with a friendly joke"
52
- <commentary>
53
- Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
54
- </commentary>
55
- </example>
56
- - If the user mentioned or implied that the agent should be used proactively, you should include examples of this.
57
- - NOTE: Ensure that in the examples, you are making the assistant use the Agent tool and not simply respond directly to the task.
58
-
59
- Your output must be a valid JSON object with exactly these fields:
60
- {
61
- "identifier": "A unique, descriptive identifier using lowercase letters, numbers, and hyphens (e.g., 'code-reviewer', 'api-docs-writer', 'test-generator')",
62
- "whenToUse": "A precise, actionable description starting with 'Use this agent when...' that clearly defines the triggering conditions and use cases. Ensure you include examples as described above.",
63
- "systemPrompt": "The complete system prompt that will govern the agent's behavior, written in second person ('You are...', 'You will...') and structured for maximum clarity and effectiveness"
64
- }
65
-
66
- Key principles for your system prompts:
67
-
68
- - Be specific rather than generic - avoid vague instructions
69
- - Include concrete examples when they would clarify behavior
70
- - Balance comprehensiveness with clarity - every instruction should add value
71
- - Ensure the agent has enough context to handle variations of the core task
72
- - Make the agent proactive in seeking clarification when needed
73
- - Build in quality assurance and self-correction mechanisms
74
-
75
- Remember: The agents you create should be autonomous experts capable of handling their designated tasks with minimal additional guidance. Your system prompts are their complete operational manual.