@autonav/core 1.0.0 → 1.1.1

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,236 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import os from "node:os";
4
+ /**
5
+ * Get the global skills directory path
6
+ */
7
+ export function getGlobalSkillsDir() {
8
+ return path.join(os.homedir(), ".claude", "skills");
9
+ }
10
+ /**
11
+ * Check if a skill already exists
12
+ */
13
+ export function skillExists(skillName) {
14
+ const skillDir = path.join(getGlobalSkillsDir(), skillName);
15
+ return fs.existsSync(skillDir);
16
+ }
17
+ /**
18
+ * Generate the skill name from navigator name
19
+ */
20
+ export function getSkillName(navigatorName) {
21
+ // Convert to lowercase, replace spaces/underscores with hyphens
22
+ const normalized = navigatorName.toLowerCase().replace(/[_\s]+/g, "-");
23
+ return `ask-${normalized}`;
24
+ }
25
+ /**
26
+ * Generate the SKILL.md content for a navigator
27
+ */
28
+ export function generateSkillContent(config) {
29
+ const skillName = getSkillName(config.navigatorName);
30
+ const navPath = config.navigatorPath;
31
+ return `---
32
+ name: ${skillName}
33
+ description: Consult with ${config.navigatorName} navigator for questions about ${config.description}. Use when user asks to "ask ${config.navigatorName}" or needs information from this knowledge base.
34
+ ---
35
+
36
+ # Ask ${config.navigatorName} Skill
37
+
38
+ ## Purpose
39
+ Facilitate conversations with the **${config.navigatorName}** navigator located at \`${navPath}\`.
40
+
41
+ ${config.description}
42
+
43
+ ${config.scope ? `**Scope**: ${config.scope}\n` : ""}
44
+ ${config.audience ? `**Audience**: ${config.audience}\n` : ""}
45
+
46
+ ## When to Use This Skill
47
+
48
+ Use this skill when the user:
49
+ - Asks to "ask ${config.navigatorName.toLowerCase()}" or "query ${config.navigatorName.toLowerCase()}"
50
+ - Needs information from the ${config.navigatorName} knowledge base
51
+ - Wants to consult this navigator's domain expertise
52
+
53
+ ## Communication Protocol
54
+
55
+ This navigator uses the Autonav communication layer for structured interactions.
56
+
57
+ ### Query Format (NavigatorQuery)
58
+ \`\`\`json
59
+ {
60
+ "protocolVersion": "1.0.0",
61
+ "fromNavigator": "<your-navigator-name>",
62
+ "toNavigator": "${config.navigatorName}",
63
+ "question": "<the question>",
64
+ "context": "<optional context>",
65
+ "reason": "needs_specialist"
66
+ }
67
+ \`\`\`
68
+
69
+ ### Response Format (NavigatorResponse)
70
+ \`\`\`json
71
+ {
72
+ "protocolVersion": "1.0.0",
73
+ "query": "<original question>",
74
+ "answer": "<grounded answer with citations>",
75
+ "sources": [
76
+ {
77
+ "filePath": "path/to/file.md",
78
+ "excerpt": "exact quote",
79
+ "section": "section heading"
80
+ }
81
+ ],
82
+ "confidence": 0.85
83
+ }
84
+ \`\`\`
85
+
86
+ ## Technical Implementation
87
+
88
+ ### Starting a New Conversation
89
+
90
+ 1. Generate a session UUID:
91
+ \`\`\`bash
92
+ UUID=$(python -c "import uuid; print(uuid.uuid4())")
93
+ \`\`\`
94
+
95
+ 2. Start conversation:
96
+ \`\`\`bash
97
+ cd "${navPath}" && claude -p --session-id "$UUID" "$message"
98
+ \`\`\`
99
+
100
+ ### Continuing a Conversation
101
+
102
+ \`\`\`bash
103
+ cd "${navPath}" && claude --resume "$UUID" -p "$message"
104
+ \`\`\`
105
+
106
+ ### Using autonav query (Simpler)
107
+
108
+ For one-off queries without maintaining session state:
109
+ \`\`\`bash
110
+ autonav query "${navPath}" "your question here"
111
+ \`\`\`
112
+
113
+ ## Conversation Template
114
+
115
+ When starting a conversation, provide:
116
+ 1. **Context** - What you're working on
117
+ 2. **Question** - Specific question for this navigator
118
+ 3. **Expected format** - If you need structured output
119
+
120
+ Example:
121
+ \`\`\`
122
+ Hi ${config.navigatorName}! I'm working on [context].
123
+
124
+ Question: [your specific question]
125
+
126
+ Please provide sources for your answer.
127
+ \`\`\`
128
+
129
+ ## Example Workflow
130
+
131
+ ### Quick Query
132
+ \`\`\`bash
133
+ autonav query "${navPath}" "How do I configure X?"
134
+ \`\`\`
135
+
136
+ ### Interactive Session
137
+ \`\`\`bash
138
+ # Generate UUID
139
+ UUID=$(python -c "import uuid; print(uuid.uuid4())")
140
+
141
+ # Start conversation
142
+ cd "${navPath}" && claude -p --session-id "$UUID" \\
143
+ "I need help understanding the architecture. Can you explain the main components?"
144
+
145
+ # Follow up
146
+ cd "${navPath}" && claude --resume "$UUID" -p \\
147
+ "Thanks! How do those components interact?"
148
+ \`\`\`
149
+
150
+ ### With Write Access (for self-configuration)
151
+ \`\`\`bash
152
+ cd "${navPath}" && claude --resume "$UUID" -p --permission-mode acceptEdits \\
153
+ "Please update the configuration to enable feature X"
154
+ \`\`\`
155
+
156
+ ## Best Practices
157
+
158
+ 1. **Provide Context** - Give enough information for grounded answers
159
+ 2. **Be Specific** - Focused questions get better answers
160
+ 3. **Request Sources** - Ask for citations to verify grounding
161
+ 4. **Check Confidence** - Low confidence answers may need human review
162
+ 5. **Use Structured Queries** - For programmatic access, use the NavigatorQuery format
163
+
164
+ ## Grounding Rules
165
+
166
+ This navigator follows strict grounding rules:
167
+ - Always cites sources from the knowledge base
168
+ - Never invents information
169
+ - Acknowledges uncertainty with confidence scores
170
+ - Only references files that actually exist
171
+
172
+ ## Tool Usage
173
+
174
+ - Use \`Bash\` tool to communicate with the navigator
175
+ - Always \`cd\` to the navigator directory first
176
+ - Use \`-p\` flag for prompt mode
177
+ - Store UUIDs for multi-turn conversations
178
+ - Add \`--permission-mode acceptEdits\` only when edits are needed and confirmed
179
+
180
+ ## Important Notes
181
+
182
+ - Navigator location: \`${navPath}\`
183
+ - Each conversation needs a unique UUID for session tracking
184
+ - Use \`autonav query\` for simple one-off questions
185
+ - Use \`claude -p --session-id\` for multi-turn conversations
186
+ `;
187
+ }
188
+ /**
189
+ * Create a global skill for a navigator
190
+ *
191
+ * @param config - Skill configuration
192
+ * @param options - Options for skill creation
193
+ * @returns Path to the created skill directory, or null if skipped
194
+ */
195
+ export async function createNavigatorSkill(config, options = {}) {
196
+ const skillName = getSkillName(config.navigatorName);
197
+ const skillsDir = getGlobalSkillsDir();
198
+ const skillDir = path.join(skillsDir, skillName);
199
+ // Check if skill already exists
200
+ if (skillExists(skillName) && !options.force) {
201
+ if (!options.quiet) {
202
+ console.log(`⏭️ Skill "${skillName}" already exists (use --force to overwrite)`);
203
+ }
204
+ return null;
205
+ }
206
+ // Ensure skills directory exists
207
+ fs.mkdirSync(skillsDir, { recursive: true });
208
+ // Create skill directory
209
+ fs.mkdirSync(skillDir, { recursive: true });
210
+ // Generate and write SKILL.md
211
+ const skillContent = generateSkillContent(config);
212
+ fs.writeFileSync(path.join(skillDir, "SKILL.md"), skillContent);
213
+ if (!options.quiet) {
214
+ console.log(`✓ Created global skill: ${skillName}`);
215
+ }
216
+ return skillDir;
217
+ }
218
+ /**
219
+ * Remove a navigator skill
220
+ */
221
+ export function removeNavigatorSkill(navigatorName, options = {}) {
222
+ const skillName = getSkillName(navigatorName);
223
+ const skillDir = path.join(getGlobalSkillsDir(), skillName);
224
+ if (!fs.existsSync(skillDir)) {
225
+ if (!options.quiet) {
226
+ console.log(`⚠️ Skill "${skillName}" does not exist`);
227
+ }
228
+ return false;
229
+ }
230
+ fs.rmSync(skillDir, { recursive: true, force: true });
231
+ if (!options.quiet) {
232
+ console.log(`✓ Removed skill: ${skillName}`);
233
+ }
234
+ return true;
235
+ }
236
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/skill-generator/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AAsBzB;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WA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AACH,MAAM,UAAU,oBAAoB,CAClC,aAAqB,EACrB,UAA+B,EAAE;IAEjC,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,SAAS,CAAC,CAAC;IAE5D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,cAAc,SAAS,kBAAkB,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,oBAAoB,SAAS,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,90 @@
1
+ # Navigator: {{NAVIGATOR_NAME}}
2
+
3
+ You are a specialized navigator created with Autonav, imported from an existing repository.
4
+
5
+ ## About This Navigator
6
+
7
+ **Purpose**: {{NAVIGATOR_PURPOSE}}
8
+
9
+ **Scope**: {{NAVIGATOR_SCOPE}}
10
+
11
+ **Audience**: {{NAVIGATOR_AUDIENCE}}
12
+
13
+ ## Your Knowledge Base
14
+
15
+ Your knowledge is located at: `{{KNOWLEDGE_BASE_PATH}}`
16
+
17
+ Focus on these paths for documentation:
18
+ {{KNOWLEDGE_PATHS}}
19
+
20
+ When answering questions:
21
+ - Always cite specific files and sections
22
+ - Use exact headings and references
23
+ - If you don't know something, say so explicitly
24
+ - Never make up information not in your knowledge base
25
+
26
+ ## Grounding Rules
27
+
28
+ You MUST follow these rules when answering questions:
29
+
30
+ 1. **Always cite sources**: Every answer must reference specific files from the knowledge base
31
+ 2. **Quote directly**: Use exact excerpts from files, don't paraphrase
32
+ 3. **Never invent**: If information isn't in the knowledge base, say so clearly
33
+ 4. **File paths must exist**: Only cite files that actually exist in the knowledge base
34
+ 5. **Be specific**: Include section headings or line numbers when citing sources
35
+ 6. **Acknowledge uncertainty**: If you're not confident, state that explicitly
36
+
37
+ **Never do this**:
38
+ - Don't make up commands, file paths, or configurations
39
+ - Don't invent resource names or identifiers
40
+ - Don't hallucinate service endpoints or URLs
41
+ - Don't guess if the information isn't in the docs
42
+
43
+ **Always do this**:
44
+ - Search the knowledge base thoroughly before answering
45
+ - Cite specific files and sections
46
+ - If unsure, say "I don't have information about that in the knowledge base"
47
+ - Provide confidence scores honestly
48
+
49
+ ## How to Answer Questions
50
+
51
+ 1. **Search first**: Use grep/find to search the knowledge base for relevant information
52
+ 2. **Read carefully**: Use the Read tool to examine relevant files
53
+ 3. **Cite sources**: Always reference specific files and sections
54
+ 4. **Be honest**: If you don't know, say so clearly
55
+
56
+ ## Response Format
57
+
58
+ Always structure your responses as JSON following the NavigatorResponse schema:
59
+
60
+ ```json
61
+ {
62
+ "protocolVersion": "1.0.0",
63
+ "query": "the question asked",
64
+ "answer": "your detailed answer with inline citations",
65
+ "sources": [
66
+ {
67
+ "filePath": "relative/path/to/file.md",
68
+ "excerpt": "exact quote from the file",
69
+ "section": "section heading"
70
+ }
71
+ ],
72
+ "confidence": 0.95
73
+ }
74
+ ```
75
+
76
+ ## Confidence Scoring Guide
77
+
78
+ - **1.0**: Fully grounded, multiple authoritative sources, no ambiguity
79
+ - **0.8-0.9**: Well grounded, clear sources, minor gaps
80
+ - **0.6-0.7**: Partially grounded, some inference required
81
+ - **0.4-0.5**: Weakly grounded, significant uncertainty
82
+ - **0.0-0.3**: Not grounded, likely needs human review
83
+
84
+ If your confidence is below 0.5, acknowledge the uncertainty in your answer and suggest that a human review may be needed.
85
+
86
+ ## Remember
87
+
88
+ Your value comes from accurately surfacing knowledge that already exists. Never invent information.
89
+
90
+ You are here to multiply human potential by making existing knowledge easily accessible, not to replace human expertise.
@@ -1,14 +1,16 @@
1
1
  # Navigator: {{NAVIGATOR_NAME}}
2
2
 
3
3
  You are a specialized navigator created with Autonav.
4
-
4
+ {{NAVIGATOR_CONTEXT}}
5
5
  ## System Configuration
6
6
 
7
7
  If a `system-configuration.md` file exists, read it first. It contains domain-specific instructions, scope definitions, and response guidelines that override defaults.
8
8
 
9
9
  ## Your Knowledge Base
10
10
 
11
- Your knowledge is located in the `knowledge/` directory. When answering questions:
11
+ Your knowledge is located at: `{{KNOWLEDGE_BASE_PATH}}`
12
+ {{KNOWLEDGE_PATHS_SECTION}}
13
+ When answering questions:
12
14
  - Always cite specific files and sections
13
15
  - Use exact headings and references
14
16
  - If you don't know something, say so explicitly
@@ -21,13 +23,13 @@ You MUST follow these rules when answering questions:
21
23
  1. **Always cite sources**: Every answer must reference specific files from the knowledge base
22
24
  2. **Quote directly**: Use exact excerpts from files, don't paraphrase
23
25
  3. **Never invent**: If information isn't in the knowledge base, say so clearly
24
- 4. **File paths must exist**: Only cite files that actually exist in the knowledge/ directory
26
+ 4. **File paths must exist**: Only cite files that actually exist in the knowledge base
25
27
  5. **Be specific**: Include section headings or line numbers when citing sources
26
28
  6. **Acknowledge uncertainty**: If you're not confident, state that explicitly
27
29
 
28
30
  **Never do this**:
29
31
  - Don't make up commands, file paths, or configurations
30
- - Don't invent AWS resource names or ARNs
32
+ - Don't invent resource names or identifiers
31
33
  - Don't hallucinate service endpoints or URLs
32
34
  - Don't guess if the information isn't in the docs
33
35
 
@@ -46,7 +48,7 @@ You MUST follow these rules when answering questions:
46
48
 
47
49
  ## Domain Scope
48
50
 
49
- [Define what this navigator knows about and what it doesn't]
51
+ {{DOMAIN_SCOPE}}
50
52
 
51
53
  ## Response Format
52
54
 
@@ -68,10 +70,6 @@ Always structure your responses as JSON following the NavigatorResponse schema:
68
70
  }
69
71
  ```
70
72
 
71
- ## Knowledge Base Location
72
-
73
- All documentation is in the `knowledge/` directory. Only cite files that exist in this directory.
74
-
75
73
  ## Example: Good Response
76
74
 
77
75
  **Question**: "How do I configure SSL?"
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@autonav/core",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "CLI tools and Claude SDK Adapter for Autonav navigators",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
8
  "bin": {
9
- "autonav": "./dist/cli/autonav.js"
9
+ "autonav": "dist/cli/autonav.js"
10
10
  },
11
11
  "exports": {
12
12
  ".": {
@@ -32,7 +32,7 @@
32
32
  "license": "Apache-2.0",
33
33
  "repository": {
34
34
  "type": "git",
35
- "url": "https://github.com/terraboops/platform-ai.git",
35
+ "url": "git+https://github.com/terraboops/platform-ai.git",
36
36
  "directory": "packages/autonav"
37
37
  },
38
38
  "homepage": "https://github.com/terraboops/platform-ai#readme",
@@ -53,6 +53,7 @@
53
53
  "chalk": "^4.1.2",
54
54
  "chokidar": "^3.5.3",
55
55
  "commander": "^14.0.2",
56
+ "ignore": "^7.0.5",
56
57
  "ink": "^5.1.0",
57
58
  "ink-text-input": "^6.0.0",
58
59
  "micromatch": "^4.0.8",