create-snowline-agents 1.0.0

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.
@@ -0,0 +1,116 @@
1
+ ๏ปฟ# Project Rules (CBT Master - Snowline Agent Ecosystem)
2
+
3
+ - Before creating a new function, always define all variables that will be used first (to avoid *ReferenceError* or variables that have not been *destructured*).
4
+
5
+ ## ๐Ÿ›‘ THE Snowline Agent CORE DIRECTIVES (MANDATORY)
6
+ You (the AI Agent) are **STRICTLY FORBIDDEN** from using standard tools (such as \grep_search\, \cat\, \ls\, standard ESLint, or manually reading \package.json\) if there is a custom tool from the Snowline Agent ecosystem that can do it faster and save more tokens.
7
+
8
+ **You MUST ALWAYS use the following Python scripts according to the need:**
9
+
10
+ 1. **Starting a Session / Analyzing Project (Deep Analyzer)**
11
+ - DO NOT read \package.json\ manually.
12
+ - ALWAYS use: \python .agents/skills/deep_analyzer/analyzer.py\
13
+ 2. **Searching Code / Variables (Smart Search)**
14
+ - DO NOT use \grep_search\.
15
+ - ALWAYS use: \python .agents/skills/smart_search/code_finder.py <dir> <keyword>\
16
+ 3. **Massive Code Editing (Smart Replace)**
17
+ - For cross-file edits, use: \python .agents/skills/smart_replace/replace_text.py <dir> <search> <replace>\
18
+ 4. **Reading Large Files (Selective Reader)**
19
+ - DO NOT read files > 300 lines entirely at once.
20
+ - ALWAYS create a TOC first: \python .agents/skills/selective_reader/reader.py <file>\
21
+ 5. **Security & Bug Auditing (Project Guardian)**
22
+ - ALWAYS use: \python .agents/skills/project_guardian/guardian.py\
23
+ 6. **Finding Residues / Junk Files (Clean Sweeper)**
24
+ - ALWAYS use: \python .agents/skills/clean_sweeper/sweeper.py <dir>\
25
+ 7. **Extracting Project Info (Deep Analyzer)**
26
+ - ALWAYS use: \python .agents/skills/deep_analyzer/analyzer.py\
27
+ 8. **Debugging Crashes (Crash Decoder)**
28
+ - DO NOT read huge tracebacks. Save to \.txt\ and use: \python .agents/skills/crash_decoder/decoder.py <file>\
29
+ 9. **Creating New Files (Auto-Scaffolder)**
30
+ - ALWAYS generate boilerplate first: \python .agents/skills/auto_scaffolder/scaffolder.py <type> <name>\
31
+ 10. **Fixing Broken Imports (Smart Import Fixer)**
32
+ - ALWAYS use: \python .agents/skills/import_fixer/fixer.py <file> <import_string>\
33
+ 11. **Viewing Directory Trees (Smart Tree)**
34
+ - ALWAYS use: \python .agents/skills/smart_tree/scripts/tree_viewer.py <dir>\
35
+ 12. **Extracting Database Schema (DB Extractor)**
36
+ - ALWAYS use: \python .agents/skills/db_extractor/scripts/extractor.py <project_root_dir>\
37
+
38
+
39
+ ## ๐Ÿ“– Mandatory Reading Protocol (Selective Reader)
40
+
41
+ **Primary Rule**
42
+ Before reading the contents of ANY file (especially potentially large files like React components, utils, or files with complex logic), you MUST run the Selective File Reader to get the TOC (Table of Contents) FIRST, WITHOUT EXCEPTION and WITHOUT ASSUMPTION.
43
+
44
+ This applies even if:
45
+ - You feel the file is likely short or simple.
46
+ - You feel familiar with the pattern/structure of similar files from previous tasks.
47
+ - You are certain the file only contains a single function.
48
+
49
+ Assumptions like these MUST NOT be used as an excuse to skip Selective Reader. Run it first, then decide your next steps based on the actual TOC output โ€” not guesswork.
50
+
51
+ **The ONLY Permitted Exceptions**
52
+ You may skip Selective Reader ONLY if the following conditions are met:
53
+ 1. **Documented Technical Limitations**: Such as files with monolithic JSX components noted in the "Known Limitations" of the Selective Reader SKILL.md. In this case, you MUST still run Selective Reader first to view the TOC output. ONLY IF the TOC proves insufficiently detailed (as per the documented limitation) may you proceed to read manually with \ iew_file\ for the unreached sections.
54
+ 2. **Proven Small Files via TOC**: If Selective Reader has already been run and the TOC proves the file is indeed short (e.g., under 50 lines), you do not need to run it again for the SAME file in the SAME task.
55
+
56
+ These exceptions DO NOT serve as an excuse to skip at the beginning โ€” exceptions only apply AFTER Selective Reader has been run and proven insufficient or small.
57
+
58
+ **Strictly Forbidden**
59
+ - Skipping Selective Reader because you "can guess" the file contents based on filename, patterns, or past experience.
60
+ - Reading a file directly with \ iew_file\ without running Selective Reader first, unless you can prove Selective Reader was already run for that same file in the current task.
61
+
62
+ **When in Doubt**
63
+ If you are unsure whether a situation qualifies as a valid exception, ALWAYS run Selective Reader first. It is cheaper than reading the full file, carrying no significant risk if it turns out unnecessary.
64
+
65
+ ## Live Progress Tracker (PLAN.md)
66
+ - **MANDATORY**: For every significant task, you MUST maintain a \PLAN.md\ file in the root directory.
67
+ - **Execution Rules**:
68
+ 1. APPEND ONLY. Do not rewrite the whole file just to add a log entry.
69
+ 2. Write concise, bulleted logs, not paragraphs.
70
+ 3. **CRITICAL**: Before executing any command that MODIFIES files (like replace_text.py --apply), write your intended action in the "Waiting for User Approval" section and STOP for user approval.
71
+ 4. Once a task is fully completed, archive the file to \plan_archive/PLAN_<date>_<task_name>.md\.
72
+
73
+ ## ๐Ÿ—ฃ๏ธ Communication Efficiency
74
+
75
+ **Language Handling**
76
+ 1. The user writes instructions in Indonesian. If the instruction needs to be translated into English for technical purposes (English keyword-based search queries, variable/function names, commit messages, code comments, English documentation), perform the translation internally as part of your thought process โ€” do not call any external translation tools/APIs.
77
+ 2. Do not translate back to the user unless requested. Simply use the internal translation results for technical purposes, and always reply to the user in Indonesian.
78
+
79
+ **Reporting & Feedback Style**
80
+ The goal is to save tokens and speed up communication. Apply the following rules to every report/feedback to the user:
81
+
82
+ **Mandatory structure, in order:**
83
+ 1. What was done (1-2 sentences, without fluffy intros)
84
+ 2. Relevant proof/output (code snippets, terminal results, or concrete data โ€” not a narrative summary)
85
+ 3. Questions or next steps (if any, max 1-2 options)
86
+
87
+ **Prohibitions:**
88
+ - No fluffy or excessive opening sentences ("I would be happy to...", "This is a very good decision...")
89
+ - No excessive adjectives or self-praise regarding your own work ("extraordinary", "perfect", "professional", "sophisticated", "enterprise-grade", etc.)
90
+ - Do not repeat the contents of the code/output that has already been displayed as a separate narrative sentence.
91
+ - Do not explain things that were not asked, unless it is an important finding that carries risk (e.g., a new bug, potential data loss).
92
+
93
+ **Additional Guidelines:**
94
+ - Ideal length: routine reports (tool execution results, minor change confirmations) should be 3-6 lines. Reports for complex findings (bug investigations, multi-file analysis) can be longer, but must remain in the structured format above โ€” no free-form narratives.
95
+ - Emojis and decorative formatting: use sparingly as structure markers (โœ… โš ๏ธ ๐Ÿ›ก๏ธ), avoid using them as excessive decorations on every line.
96
+ - Mandatory Tool Usage: ALWAYS use the custom Python tools (Deep Analyzer, Smart Search, Selective Reader) located in \.agents/skills/\ for analyzing the project or finding code, rather than manual commands or blind reading.
97
+ ## ๐Ÿš€ Auto-Scaffolding for New Projects (Project Level)
98
+
99
+ When starting a session in any project, evaluate the completeness of the \.agents\ ecosystem. If the \.agents\ folder is missing or incomplete (e.g., missing \knowledge\ architecture, \AGENTS.md\ rules, or \PLAN.md\ tracker), you MUST propose to auto-generate the complete ecosystem for the user.
100
+
101
+ **The Complete Ecosystem Standard (Project Level):**
102
+ 1. **\AGENTS.md\**: Project-specific rules (copied from the global template) for local overrides.
103
+ 2. **\knowledge/\**: Architectural context generated by the Context Mapper tool.
104
+ 3. **\PLAN.md\**: Live progress tracker in the project root.
105
+ *(Note: \skills\ is no longer needed at the project level because it is installed globally).*
106
+
107
+ **Action Flow:**
108
+ 1. Check the project root for these 3 components.
109
+ 2. If any are missing, DO NOT ask via normal chat text. Instead, create an implementation_plan.md Artifact with RequestFeedback=true (this generates a clickable 'Proceed' button for the user).
110
+ 3. Include this exact summary in the artifact:
111
+ > [INFO] Dokumentasi ekosistem .agents di project ini belum lengkap. Klik 'Proceed' agar saya men-setup semuanya (Aturan Lokal, Peta Arsitektur, dan Tracker) sekarang.
112
+ 4. Once the user clicks Proceed, automatically create the folders, run Context Mapper to generate the knowledge files, and scaffold the \PLAN.md\ and \AGENTS.md\ files.
113
+ ## ๐Ÿง  Tech Lead Disciplines (Built-in)
114
+ To maintain high code quality while remaining effortless for the user, the agent automatically applies these disciplines:
115
+ 1. **Implicit Grilling (No Guesswork)**: For complex feature requests, do not blindly guess edge cases (e.g., timeouts, null states, missing data). Ask 1-2 highly targeted questions to clarify the boundaries before writing code. Keep it brief and easy to answer.
116
+ 2. **Diagnostic Discipline (No Blind Fixes)**: When asked to fix a bug, DO NOT immediately suggest code changes based on error logs alone. First, ensure there is a clear feedback loop (a way to reproduce the error locally). If the error cannot be reproduced or tested, verify the logic first or ask the user for a reproduction step before writing the fix.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Usman Aziz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # โ„๏ธ Snowline Agent Tools
2
+
3
+ ![Python](https://img.shields.io/badge/Python-3.x-blue.svg?logo=python&logoColor=white)
4
+ ![No Dependencies](https://img.shields.io/badge/Dependencies-Zero-brightgreen.svg)
5
+ ![License](https://img.shields.io/badge/License-MIT-green.svg)
6
+
7
+ ## ๐Ÿš€ Quick Install (Project-Level)
8
+ Make any project "AI-Ready" in seconds. Run one of these commands in your project's root folder to instantly install the Snowline Agent ecosystem. It will safely scaffold `.agents/skills`, `.agents/knowledge`, and your `PLAN.md` without affecting global system configs.
9
+
10
+ **Option 1: Using NPM (Cross-Platform)**
11
+ ```bash
12
+ npx create-snowline-agents
13
+ ```
14
+
15
+ **Option 2: Using PowerShell (Windows)**
16
+ ```powershell
17
+ irm https://raw.githubusercontent.com/UsmanAzizz/snowline-agent-tools/main/install.ps1 | iex
18
+ ```
19
+
20
+ **Option 3: Using Bash/cURL (Mac/Linux)**
21
+ ```bash
22
+ curl -sL https://raw.githubusercontent.com/UsmanAzizz/snowline-agent-tools/main/install.sh | bash
23
+ ```
24
+
25
+ ---
26
+
27
+ A collection of simple, portable, and lightweight Python scripts specifically designed to guide AI coding assistants (like Gemini, Claude, or Aider) working within a repository.
28
+
29
+ The main goal of this project is to **save LLM token usage** by preventing the AI from reading files blindly, as well as providing safety guardrails for automated file modifications.
30
+
31
+ ## ๐Ÿ›๏ธ Core Principles
32
+
33
+ 1. **Simple & Portable:** 100% pure Python (`os`, `re`, `json`). No `node_modules` required, no external executors like `ripgrep` needed. Just copy the scripts to your project and run them.
34
+ 2. **Token Efficient:** Terminal outputs are extremely concise. No useless long logs, only displaying crucial insights (`[FAIL]`, `[WARN]`) to prevent the AI from exhausting its context memory.
35
+ 3. **AI Prompt Bridge:** Each Python script doesn't just print data; it also returns a ready-to-use prompt sentence at the very last line, so users can instantly copy it to guide the AI.
36
+ 4. **Protection & Dry-Run:** Scripts that modify files MUST feature a dry-run preview mode by default and force the use of an `--apply` argument before actually altering files on disk.
37
+
38
+ ---
39
+
40
+ ## ๐Ÿ› ๏ธ The Arsenal (10 Core Tools)
41
+
42
+ The ecosystem is divided into three major categories: **Search & Modify**, **Audit & Analyze**, and **Workflow Helpers**.
43
+
44
+ ### Category 1: Search & Modify
45
+ *These tools replace standard IDE search and regex-replace functions with AI-optimized alternatives.*
46
+
47
+ #### 1. Smart Replace (`smart_replace/replace_text.py`)
48
+ - **Function:** High-speed find-and-replace using pure Python regex.
49
+ - **Why it's better:** It has built-in guardrails. By default, it runs a dry-run preview. It forces the user/AI to use the `--apply` flag to mutate files. When applying, it automatically creates backups in a `.backup_replace/` folder before overwriting, preventing catastrophic code loss.
50
+ - **Example Output:**
51
+ ```text
52
+ [DRY-RUN MODE]
53
+ File: src/components/Button.jsx
54
+ - old: console.log("debug");
55
+ + new: // console.log("debug");
56
+
57
+ [OK] Scan selesai (120 file dipindai). Menemukan 1 kecocokan.
58
+ ๐Ÿ’ก PROMPT UNTUK AI: "Berdasarkan hasil dry-run di atas, tolong jalankan ulang perintah tersebut dengan menambahkan flag --apply..."
59
+ ```
60
+
61
+ #### 2. Smart Search (`smart_search/code_finder.py`)
62
+ - **Function:** Context-aware code search.
63
+ - **Why it's better:** Instead of just returning a single line like `grep`, it returns a clean block of code (strictly limited to 5 lines of context) so the AI understands the implementation instantly.
64
+ - **Example Output:**
65
+ ```text
66
+ --- File: src/utils/api.js ---
67
+ 42: export const fetchUser = async (id) => {
68
+ 43: const response = await axios.get(`/users/${id}`);
69
+ 44: return response.data;
70
+ 45: }
71
+ ```
72
+
73
+ #### 3. Smart Import Fixer (`import_fixer/fixer.py`)
74
+ - **Function:** Automatically resolves broken relative imports.
75
+ - **Why it's better:** If a file is moved, relative imports (like `../../services/api.js`) break. This tool searches the entire project for the missing file, calculates the correct relative path, and patches the file automatically.
76
+
77
+ ### Category 2: Audit & Analyze
78
+ *These tools replace manual file reading and code reviews, saving massive amounts of AI tokens.*
79
+
80
+ #### 4. Project Guardian (`project_guardian/guardian.py`)
81
+ - **Function:** A holistic security and health auditor.
82
+ - **Why it's better:** Detects exposed credentials (passwords, API keys), validates `.gitignore` rules against active `.env` files, checks for broken relative imports, flags unused npm packages, and runs NPM auditโ€”all in one command.
83
+ - **Example Output:**
84
+ ```text
85
+ ๐Ÿ›ก๏ธ PROJECT GUARDIAN AUDITOR ๐Ÿ›ก๏ธ
86
+ --- MODULE 1: SECRET SCANNER ---
87
+ [FAIL] Potential credential leak in src/config/db.js line 12
88
+
89
+ --- MODULE 2: ENV & GITIGNORE VERIFIER ---
90
+ [FAIL] File .env.development is missing from .gitignore!
91
+ ```
92
+
93
+ #### 5. Clean Sweeper (`clean_sweeper/sweeper.py`)
94
+ - **Function:** A project health and tech-debt scanner.
95
+ - **Why it's better:** Finds leftover quarantine logs, temporary backup folders (like `AA/`, `old/`), massive commented-out code blocks, and `TODO/FIXME` tags.
96
+
97
+ #### 6. Deep Analyzer (`deep_analyzer/analyzer.py`)
98
+ - **Function:** The Project Profiler / X-Ray Scanner.
99
+ - **Why it's better:** Automatically extracts the tech stack, core dependencies, file statistics, and available testing/linting commands directly from `package.json` or config files.
100
+ - **Example Output:**
101
+ ```text
102
+ [OK] Tech Stack Detected: Node.js, Vite (React/Vue)
103
+ [INFO] Available npm/yarn Commands:
104
+ - npm run start
105
+ - npm run test
106
+ [INFO] Core Dependencies: 55 runtime, 9 dev
107
+ ```
108
+
109
+ #### 7. Selective Reader (`selective_reader/reader.py`)
110
+ - **Function:** Table of Contents (TOC) Extractor for large files.
111
+ - **Why it's better:** Uses Python regex heuristics to extract the skeleton (classes, functions, arrow functions) of JS/TS/Py files. Allows the AI to surgically read only the lines it needs.
112
+
113
+ #### 8. Context Mapper (`context_mapper/context_mapper.py`)
114
+ - **Function:** The Knowledge Catalog builder.
115
+ - **Why it's better:** Automatically generates `PROJECT_STRUCTURE.md` and `COMMON_PATTERNS.md` inside `.agents/knowledge/`. AI agents read these files first to instantly understand the project's architecture.
116
+
117
+ ### Category 3: Workflow Helpers
118
+ *These tools assist the AI when actively writing or debugging code.*
119
+
120
+ #### 9. Crash Decoder (`crash_decoder/decoder.py`)
121
+ - **Function:** The Error Trace Analyzer.
122
+ - **Why it's better:** Parses massive terminal crash logs, filters out irrelevant `node_modules` and internal node noise, and pinpoints the exact file and line in your source code that caused the crash.
123
+
124
+ #### 10. Auto-Scaffolder (`auto_scaffolder/scaffolder.py`)
125
+ - **Function:** The Pattern Generator.
126
+ - **Why it's better:** Instantly generates boilerplate files for React components or API routes following the project's standards, avoiding inconsistent manual coding.
127
+
128
+ ---
129
+
130
+ ## ๐Ÿš€ Installation & Usage
131
+
132
+ These tools are designed to run locally on your machine, callable by your AI agent or by yourself. **Python 3.x is the only requirement.**
133
+
134
+ ### Interactive Dashboard (For Humans)
135
+ For human users, the easiest way to use the ecosystem is via the central dashboard:
136
+ ```bash
137
+ python run_all.py
138
+ ```
139
+ This will launch a CLI menu where you can select and run any of the 10 tools interactively.
140
+
141
+ ### AI Agent Workflow (For AI)
142
+ Place these folders inside your project's workspace customizations directory (e.g., `.agents/skills/` at the root of your project).
143
+
144
+ Example commands your agent will run:
145
+ ```bash
146
+ # Analyze the project stack
147
+ python .agents/skills/deep_analyzer/analyzer.py
148
+
149
+ # Auto Scaffold a React Component
150
+ python .agents/skills/auto_scaffolder/scaffolder.py react "DataSiswa" "src/view/admin/data_siswa"
151
+
152
+ # Project Guardian (Silent Mode)
153
+ python .agents/skills/project_guardian/guardian.py --summary
154
+ ```
155
+
156
+ ## ๐Ÿค Compatibility
157
+ These tools were originally built and battle-tested within the Gemini (Antigravity IDE) ecosystem. However, they are highly portable and easily adaptable for **Claude Code**, **Aider**, or other CLI-based AI agents that support custom system prompts and bash execution.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: Auto-Scaffolder (Pattern Generator)
3
+ description: Use this skill to automatically generate boilerplate code for new React components or API routes perfectly matching the project's standards.
4
+ ---
5
+
6
+ ## Instructions for AI Agent
7
+
8
+ **When to use this skill:**
9
+ - When the user asks you to "create a new page", "make a new component", or "add a new API route".
10
+ - **NEVER use write_to_file to write a component from scratch manually.** Always generate the boilerplate first using this tool.
11
+
12
+ **Command to run:**
13
+ ```powershell
14
+ # For React Components
15
+ python .agents/skills/auto_scaffolder/scaffolder.py react "MyComponent" "src/view/admin/my_feature"
16
+
17
+ # For API Routes
18
+ python .agents/skills/auto_scaffolder/scaffolder.py api "my_route" "src/backend/routes"
19
+ ```
20
+
21
+ **Expected Behavior & Next Steps:**
22
+ 1. The tool will create the file instantly with proper imports and structure.
23
+ 2. Once generated, you can then use `replace_file_content` to inject the specific logic requested by the user into the generated boilerplate.
@@ -0,0 +1,115 @@
1
+ import os
2
+ import sys
3
+
4
+ if sys.stdout.encoding != 'utf-8':
5
+ sys.stdout.reconfigure(encoding='utf-8')
6
+
7
+ REACT_TEMPLATE = """import React, { useState, useEffect } from 'react';
8
+
9
+ const {name} = () => {
10
+ const [data, setData] = useState([]);
11
+ const [loading, setLoading] = useState(false);
12
+
13
+ useEffect(() => {
14
+ // Fetch data logic here
15
+ }, []);
16
+
17
+ return (
18
+ <div className="{name.lower()}-container">
19
+ <h2>{name} Component</h2>
20
+ {loading ? <p>Loading...</p> : <p>Content goes here.</p>}
21
+ </div>
22
+ );
23
+ };
24
+
25
+ export default {name};
26
+ """
27
+
28
+ API_TEMPLATE = """const express = require('express');
29
+ const router = express.Router();
30
+
31
+ // GET endpoint
32
+ router.get('/', async (req, res) => {
33
+ try {
34
+ // Logic here
35
+ res.status(200).json({ success: true, data: [] });
36
+ } catch (error) {
37
+ console.error(error);
38
+ res.status(500).json({ success: false, message: 'Server Error' });
39
+ }
40
+ });
41
+
42
+ // POST endpoint
43
+ router.post('/', async (req, res) => {
44
+ try {
45
+ // Logic here
46
+ res.status(201).json({ success: true, message: 'Created' });
47
+ } catch (error) {
48
+ console.error(error);
49
+ res.status(500).json({ success: false, message: 'Server Error' });
50
+ }
51
+ });
52
+
53
+ module.exports = router;
54
+ """
55
+
56
+ def generate_scaffold(file_type, name, target_dir, apply_mode):
57
+ print("๐Ÿ—๏ธ AUTO-SCAFFOLDER ๐Ÿ—๏ธ")
58
+ print("=" * 60)
59
+
60
+ if file_type.lower() not in ['react', 'api']:
61
+ print("[FAIL] Invalid type. Choose 'react' or 'api'.")
62
+ return
63
+
64
+ if not os.path.exists(target_dir) and apply_mode:
65
+ os.makedirs(target_dir, exist_ok=True)
66
+
67
+ if file_type.lower() == 'react':
68
+ filename = f"{name}.jsx"
69
+ content = REACT_TEMPLATE.replace("{name}", name).replace("{name.lower()}", name.lower())
70
+ else:
71
+ filename = f"{name.lower()}.js"
72
+ content = API_TEMPLATE
73
+
74
+ filepath = os.path.join(target_dir, filename)
75
+
76
+ if os.path.exists(filepath):
77
+ print(f"[FAIL] File {filename} already exists at {target_dir}!")
78
+ return
79
+
80
+ if not apply_mode:
81
+ print("[DRY-RUN MODE] Auto-Scaffolder Preview")
82
+ print("=" * 50)
83
+ print(f"Target File: {filepath}")
84
+ print("--- Content Preview ---")
85
+ print(content)
86
+ print("=" * 50)
87
+ print("\n๐Ÿ’ก PROMPT UNTUK AI (Copy-Paste ini):")
88
+ print(f'"Pratinjau berhasil. Silakan jalankan ulang perintah dengan tambahan flag --apply untuk membuat file {filename}."')
89
+ else:
90
+ try:
91
+ with open(filepath, 'w', encoding='utf-8') as f:
92
+ f.write(content)
93
+ print(f"[OK] Successfully generated {filename} at {target_dir}")
94
+ print("\n" + "=" * 60)
95
+ print("๐Ÿ’ก PROMPT UNTUK AI (Copy-Paste ini):")
96
+ print(f'"Berdasarkan hasil Auto-Scaffolder di atas, tolong gunakan tool replace_file_content untuk mulai mengisi logika yang sesungguhnya di dalam {filename}."')
97
+ except Exception as e:
98
+ print(f"[FAIL] Error generating file: {e}")
99
+
100
+ def main():
101
+ if len(sys.argv) < 3:
102
+ print("Usage: python scaffolder.py <react|api> <ComponentName> [target_dir] [--apply]")
103
+ sys.exit(1)
104
+
105
+ file_type = sys.argv[1]
106
+ name = sys.argv[2]
107
+
108
+ args = sys.argv[3:]
109
+ apply_mode = "--apply" in args
110
+ target_dir = args[0] if len(args) > 0 and args[0] != "--apply" else os.getcwd()
111
+
112
+ generate_scaffold(file_type, name, target_dir, apply_mode)
113
+
114
+ if __name__ == "__main__":
115
+ main()
package/bin/install.js ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { execSync } = require('child_process');
5
+
6
+ console.log('Installing Snowline Agent Ecosystem (Project-Level)...');
7
+
8
+ const projectRoot = process.cwd();
9
+ const agentsDir = path.join(projectRoot, '.agents');
10
+ const skillsDir = path.join(agentsDir, 'skills');
11
+ const knowledgeDir = path.join(agentsDir, 'knowledge');
12
+ const repoUrl = 'https://github.com/UsmanAzizz/snowline-agent-tools.git';
13
+ let isNewInstall = false;
14
+
15
+ // Ensure .agents and .agents/knowledge exist
16
+ if (!fs.existsSync(agentsDir)) {
17
+ fs.mkdirSync(agentsDir, { recursive: true });
18
+ }
19
+ if (!fs.existsSync(knowledgeDir)) {
20
+ fs.mkdirSync(knowledgeDir, { recursive: true });
21
+ }
22
+
23
+ // Scaffold skills
24
+ if (fs.existsSync(skillsDir)) {
25
+ console.log(`Found existing skills directory at ${skillsDir}`);
26
+ if (fs.existsSync(path.join(skillsDir, '.git'))) {
27
+ console.log('Pulling latest updates...');
28
+ try {
29
+ execSync('git pull origin main', { cwd: skillsDir, stdio: 'inherit' });
30
+ } catch (e) {
31
+ console.error('Failed to update repository.');
32
+ }
33
+ } else {
34
+ console.log('Existing skills directory is not a git repository. Skipping git pull.');
35
+ }
36
+ } else {
37
+ isNewInstall = true;
38
+ console.log(`Downloading Snowline Agent skills...`);
39
+ try {
40
+ execSync(`git clone ${repoUrl} "${skillsDir}"`, { stdio: 'inherit' });
41
+ } catch (e) {
42
+ console.error('Failed to clone repository. Make sure git is installed.');
43
+ process.exit(1);
44
+ }
45
+ }
46
+
47
+ // Copy AGENTS_TEMPLATE.md to AGENTS.md in the project root
48
+ const templatePath = path.join(skillsDir, 'AGENTS_TEMPLATE.md');
49
+ const localAgentsPath = path.join(agentsDir, 'AGENTS.md');
50
+
51
+ if (fs.existsSync(templatePath)) {
52
+ if (!fs.existsSync(localAgentsPath)) {
53
+ console.log('Creating Project AGENTS.md...');
54
+ fs.copyFileSync(templatePath, localAgentsPath);
55
+ console.log('Project AGENTS.md created successfully.');
56
+ } else {
57
+ console.log('Project AGENTS.md already exists. Skipping overwrite.');
58
+ }
59
+ }
60
+
61
+ // Scaffold PLAN.md in project root
62
+ const planPath = path.join(projectRoot, 'PLAN.md');
63
+ if (!fs.existsSync(planPath)) {
64
+ console.log('Creating PLAN.md...');
65
+ fs.writeFileSync(planPath, '# Project Plan / Task Tracker\n\n- [ ] Initial task\n', 'utf8');
66
+ }
67
+
68
+ if (isNewInstall) {
69
+ console.log('\nInstallation Complete!');
70
+ console.log('This project is now powered by the Snowline Agent Ecosystem.');
71
+ }
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: Project Health & Residue Sweeper
3
+ description: Use this skill when the user asks you to scan for project health, technical debt, or leftover residue files across a repository. It runs a Python script that deeply scans the project for unused DBs, temporary folders, TODO/FIXME tags, and large commented code blocks.
4
+ ---
5
+
6
+ ## Instructions for AI Agent
7
+
8
+ When the user asks you to "bersihkan project", "cari residu", or check the health/tech debt of a project, use this skill to run a sweeping analysis.
9
+
10
+ **Command to run:**
11
+ ```powershell
12
+ python .agents/skills/clean_sweeper/sweeper.py "<absolute_target_directory>"
13
+ ```
14
+ *(Make sure your current working directory `Cwd` is set to the root of the user's project when running this).*
15
+
16
+ **Expected Output:**
17
+ The script will output a Markdown-formatted report directly to stdout detailing suspect folders, stray leftover files, count of `TODO`/`FIXME` tags (with proper word boundaries), and large commented out code blocks.
18
+
19
+ ### ๐Ÿ›‘ CRITICAL BEHAVIORAL RULE (VETO PROTOCOL)
20
+ 1. **Never quarantine, move, or delete files automatically.** You MUST NOT assume a file is trash just because the script flagged it.
21
+ 2. Read the script output and present a clean summary to the user.
22
+ 3. Explicitly ask the user: *"Mana saja dari daftar ini yang boleh saya pindahkan ke karantina/hapus?"*
23
+ 4. Wait for the user's explicit confirmation (VETO) per item BEFORE executing any file modification or terminal `mv`/`rm` commands.
@@ -0,0 +1,98 @@
1
+ import os
2
+ import re
3
+ import sys
4
+
5
+ if sys.stdout.encoding != 'utf-8':
6
+ sys.stdout.reconfigure(encoding='utf-8')
7
+
8
+ MAX_FILE_SIZE = 500 * 1024 # 500 KB
9
+ ignore_dirs = {'node_modules', '.git', 'build', 'dist', 'uploads', 'public', '.vscode', '.history', 'quarantine', '.native_browser', '.exambro_android', '.plan', '.skills', '.backup_replace', '.agents'}
10
+
11
+ def sweep(target):
12
+ residue_files = []
13
+ todo_count = 0
14
+ comment_blocks = []
15
+ scanned_files = 0
16
+
17
+ for root, dirs, files in os.walk(target):
18
+ dirs[:] = [d for d in dirs if d not in ignore_dirs]
19
+
20
+ for d in dirs:
21
+ if d.lower() in ['aa', 'arsip', 'temp', 'backup', 'old', 'scratch']:
22
+ residue_files.append(os.path.join(root, d) + " [Suspected Backup/Temp Folder]")
23
+
24
+ for f in files:
25
+ filepath = os.path.join(root, f)
26
+ if os.path.getsize(filepath) > MAX_FILE_SIZE:
27
+ continue
28
+
29
+ scanned_files += 1
30
+ f_lower = f.lower()
31
+ if f_lower.endswith(('.bak', '.old', '.log', '.db', '.sqlite', '.tmp')) or 'copy' in f_lower:
32
+ if f_lower not in ['database.db'] and not f_lower.endswith('.test.js'):
33
+ residue_files.append(filepath + " [Suspected Leftover File]")
34
+
35
+ if f == 'database.db' and root == target:
36
+ residue_files.append(filepath + " [Local SQLite DB in MySQL project]")
37
+
38
+ if f_lower.endswith(('.js', '.jsx', '.php', '.html', '.py')):
39
+ try:
40
+ with open(filepath, 'r', encoding='utf-8') as file:
41
+ content = file.read()
42
+ todos = re.findall(r'(?i)\b(TODO|FIXME)\b', content)
43
+ todo_count += len(todos)
44
+
45
+ lines = content.split('\n')
46
+ consecutive_comments = 0
47
+ for i, line in enumerate(lines):
48
+ if line.strip().startswith(('//', '#')):
49
+ consecutive_comments += 1
50
+ else:
51
+ if consecutive_comments >= 7:
52
+ comment_blocks.append(f"{filepath} (Lines {i-consecutive_comments+1}-{i}): {consecutive_comments} consecutive commented lines")
53
+ consecutive_comments = 0
54
+ except Exception:
55
+ pass
56
+
57
+ return residue_files, todo_count, comment_blocks, scanned_files
58
+
59
+ def main():
60
+ if len(sys.argv) < 2:
61
+ print("[FAIL] Usage: python sweeper.py <target_directory>")
62
+ sys.exit(1)
63
+
64
+ target = sys.argv[1]
65
+ residue_files, todo_count, comment_blocks, scanned_files = sweep(target)
66
+
67
+ print("๐Ÿงน CLEAN SWEEPER REPORT")
68
+ print("=" * 50)
69
+
70
+ total_issues = 0
71
+ if residue_files:
72
+ for r in residue_files:
73
+ rel = os.path.relpath(r.split(" [")[0], target)
74
+ print(f"[FAIL] {rel} " + r[r.index('['):])
75
+ total_issues += 1
76
+
77
+ if todo_count > 0:
78
+ print(f"[WARN] Found {todo_count} TODO/FIXME tags in the code.")
79
+ total_issues += 1
80
+
81
+ if comment_blocks:
82
+ for c in comment_blocks:
83
+ path_part, desc = c.split(" (", 1)
84
+ rel = os.path.relpath(path_part, target)
85
+ print(f"[WARN] {rel} ({desc}")
86
+ total_issues += 1
87
+
88
+ print("\n" + "=" * 50)
89
+
90
+ if total_issues == 0:
91
+ print(f"[OK] Proyek bersih! {scanned_files} file dipindai tanpa ada temuan residu.")
92
+ else:
93
+ print(f"[OK] Selesai memindai {scanned_files} file.")
94
+ print("\n๐Ÿ’ก PROMPT UNTUK AI (Copy-Paste ini):")
95
+ print('"Berdasarkan laporan Clean Sweeper di atas, tolong periksa temuan [FAIL] dan hapus file yatim piatu tersebut. Untuk temuan [WARN], periksa apakah komentar raksasa itu bisa dihapus."')
96
+
97
+ if __name__ == "__main__":
98
+ main()
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: Context Mapper (Knowledge Builder)
3
+ description: Use this skill when entering a new project or when the user creates significant new architectural folders. It scans the project and generates a PROJECT_STRUCTURE.md and COMMON_PATTERNS.md in the .agents/knowledge/ folder to give you instant architectural context without wasting tokens on manual search.
4
+ ---
5
+
6
+ ## Instructions for AI Agent
7
+
8
+ **When to use this skill:**
9
+ - When you first join a project and need to understand its structure.
10
+ - When the user asks you to "map the context" or "build the knowledge catalog".
11
+ - When you or the user have added a massive new feature (e.g. adding a whole new `admin/` module) and the `PROJECT_STRUCTURE.md` needs to be updated.
12
+
13
+ **Command to run:**
14
+ ```powershell
15
+ python .agents/skills/context_mapper/context_mapper.py
16
+ ```
17
+
18
+ **Expected Behavior & Next Steps:**
19
+ 1. The script will output a success message indicating that the Knowledge Catalog has been built in `.agents/knowledge/`.
20
+ 2. As a mandatory follow-up, you MUST use the `view_file` tool to read `.agents/knowledge/PROJECT_STRUCTURE.md` and `.agents/knowledge/COMMON_PATTERNS.md` to update your mental model of the project.
21
+ 3. If the user asks you to document a new coding convention, you should use `replace_file_content` to append it to `COMMON_PATTERNS.md`.