legacyver 2.1.3 → 2.1.5
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/.env +1 -0
- package/.env.example +17 -0
- package/.gitattributes +0 -0
- package/bin/legacyver.js +18 -2
- package/legacyver-docs/SUMMARY.md +1 -3
- package/legacyver-docs/components.md +31 -22
- package/legacyver-docs/index.md +5 -7
- package/package.json +3 -1
- package/src/api/auth.js +69 -0
- package/src/cli/commands/analyze.js +40 -9
- package/src/cli/commands/init.js +14 -7
- package/src/cli/commands/login.js +68 -0
- package/src/cli/commands/logout.js +22 -0
- package/src/cli/commands/providers.js +29 -11
- package/src/cli/ui.js +38 -0
- package/src/db/config.js +18 -0
- package/src/db/index.js +145 -0
- package/src/llm/free-model.js +12 -3
- package/src/llm/index.js +9 -6
- package/src/llm/providers/groq.js +4 -2
- package/src/llm/providers/kimi.js +86 -0
- package/src/llm/validator.js +1 -1
- package/src/utils/config.js +28 -2
- package/temp_credentials/README.md +61 -0
- package/temp_credentials/db-credentials.txt +6 -0
- package/temp_credentials/domain.txt +1 -0
- package/temp_credentials/kubeconfig.yaml +18 -0
- package/temp_credentials/kubernetes-credentials.txt +2 -0
- package/.agent/skills/openspec-apply-change/SKILL.md +0 -156
- package/.agent/skills/openspec-archive-change/SKILL.md +0 -114
- package/.agent/skills/openspec-bulk-archive-change/SKILL.md +0 -246
- package/.agent/skills/openspec-continue-change/SKILL.md +0 -118
- package/.agent/skills/openspec-explore/SKILL.md +0 -290
- package/.agent/skills/openspec-ff-change/SKILL.md +0 -101
- package/.agent/skills/openspec-new-change/SKILL.md +0 -74
- package/.agent/skills/openspec-onboard/SKILL.md +0 -529
- package/.agent/skills/openspec-sync-specs/SKILL.md +0 -138
- package/.agent/skills/openspec-verify-change/SKILL.md +0 -168
- package/.agent/workflows/opsx-apply.md +0 -149
- package/.agent/workflows/opsx-archive.md +0 -154
- package/.agent/workflows/opsx-bulk-archive.md +0 -239
- package/.agent/workflows/opsx-continue.md +0 -111
- package/.agent/workflows/opsx-explore.md +0 -171
- package/.agent/workflows/opsx-ff.md +0 -91
- package/.agent/workflows/opsx-new.md +0 -66
- package/.agent/workflows/opsx-onboard.md +0 -522
- package/.agent/workflows/opsx-sync.md +0 -131
- package/.agent/workflows/opsx-verify.md +0 -161
- package/.github/prompts/opsx-apply.prompt.md +0 -149
- package/.github/prompts/opsx-archive.prompt.md +0 -154
- package/.github/prompts/opsx-bulk-archive.prompt.md +0 -239
- package/.github/prompts/opsx-continue.prompt.md +0 -111
- package/.github/prompts/opsx-explore.prompt.md +0 -171
- package/.github/prompts/opsx-ff.prompt.md +0 -91
- package/.github/prompts/opsx-new.prompt.md +0 -66
- package/.github/prompts/opsx-onboard.prompt.md +0 -522
- package/.github/prompts/opsx-sync.prompt.md +0 -131
- package/.github/prompts/opsx-verify.prompt.md +0 -161
- package/.github/skills/openspec-apply-change/SKILL.md +0 -156
- package/.github/skills/openspec-archive-change/SKILL.md +0 -114
- package/.github/skills/openspec-bulk-archive-change/SKILL.md +0 -246
- package/.github/skills/openspec-continue-change/SKILL.md +0 -118
- package/.github/skills/openspec-explore/SKILL.md +0 -290
- package/.github/skills/openspec-ff-change/SKILL.md +0 -101
- package/.github/skills/openspec-new-change/SKILL.md +0 -74
- package/.github/skills/openspec-onboard/SKILL.md +0 -529
- package/.github/skills/openspec-sync-specs/SKILL.md +0 -138
- package/.github/skills/openspec-verify-change/SKILL.md +0 -168
- package/.legacyverignore.example +0 -43
- package/.legacyverrc +0 -7
- package/.opencode/command/opsx-apply.md +0 -149
- package/.opencode/command/opsx-archive.md +0 -154
- package/.opencode/command/opsx-bulk-archive.md +0 -239
- package/.opencode/command/opsx-continue.md +0 -111
- package/.opencode/command/opsx-explore.md +0 -171
- package/.opencode/command/opsx-ff.md +0 -91
- package/.opencode/command/opsx-new.md +0 -66
- package/.opencode/command/opsx-onboard.md +0 -522
- package/.opencode/command/opsx-sync.md +0 -131
- package/.opencode/command/opsx-verify.md +0 -161
- package/.opencode/skills/openspec-apply-change/SKILL.md +0 -156
- package/.opencode/skills/openspec-archive-change/SKILL.md +0 -114
- package/.opencode/skills/openspec-bulk-archive-change/SKILL.md +0 -246
- package/.opencode/skills/openspec-continue-change/SKILL.md +0 -118
- package/.opencode/skills/openspec-explore/SKILL.md +0 -290
- package/.opencode/skills/openspec-ff-change/SKILL.md +0 -101
- package/.opencode/skills/openspec-new-change/SKILL.md +0 -74
- package/.opencode/skills/openspec-onboard/SKILL.md +0 -529
- package/.opencode/skills/openspec-sync-specs/SKILL.md +0 -138
- package/.opencode/skills/openspec-verify-change/SKILL.md +0 -168
- package/legacyver-docs/config.md +0 -30
- package/legacyver-docs/errors.md +0 -74
- package/legacyver-docs/logger.md +0 -83
- package/nul +0 -2
package/src/db/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { Pool } = require('pg');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const dbConfig = require('./config');
|
|
6
|
+
const { loadSession } = require('../utils/config');
|
|
7
|
+
const logger = require('../utils/logger');
|
|
8
|
+
|
|
9
|
+
let _pool = null;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Lazy singleton pool — created on first use, ended after push.
|
|
13
|
+
*/
|
|
14
|
+
function getPool() {
|
|
15
|
+
if (!_pool) {
|
|
16
|
+
_pool = new Pool(dbConfig);
|
|
17
|
+
}
|
|
18
|
+
return _pool;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Find or create a repository for the given user + project path.
|
|
23
|
+
* @param {Pool} pool
|
|
24
|
+
* @param {string} userId UUID
|
|
25
|
+
* @param {string} projectPath absolute path of the analyzed directory
|
|
26
|
+
* @returns {Promise<string>} repository id (UUID)
|
|
27
|
+
*/
|
|
28
|
+
async function getOrCreateRepo(pool, userId, projectPath) {
|
|
29
|
+
const name = path.basename(projectPath);
|
|
30
|
+
const fullName = projectPath;
|
|
31
|
+
|
|
32
|
+
// Try find existing
|
|
33
|
+
const existing = await pool.query(
|
|
34
|
+
'SELECT id FROM repositories WHERE user_id = $1 AND full_name = $2',
|
|
35
|
+
[userId, fullName]
|
|
36
|
+
);
|
|
37
|
+
if (existing.rows.length > 0) {
|
|
38
|
+
return existing.rows[0].id;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Insert new
|
|
42
|
+
const inserted = await pool.query(
|
|
43
|
+
'INSERT INTO repositories (user_id, name, full_name) VALUES ($1, $2, $3) RETURNING id',
|
|
44
|
+
[userId, name, fullName]
|
|
45
|
+
);
|
|
46
|
+
return inserted.rows[0].id;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Find or create a documentation record for a repository.
|
|
51
|
+
* One documentation per repository (title = repo name).
|
|
52
|
+
* @param {Pool} pool
|
|
53
|
+
* @param {string} repositoryId UUID
|
|
54
|
+
* @param {string} repoName
|
|
55
|
+
* @returns {Promise<string>} documentation id (UUID)
|
|
56
|
+
*/
|
|
57
|
+
async function getOrCreateDocumentation(pool, repositoryId, repoName) {
|
|
58
|
+
const existing = await pool.query(
|
|
59
|
+
'SELECT id FROM documentations WHERE repository_id = $1',
|
|
60
|
+
[repositoryId]
|
|
61
|
+
);
|
|
62
|
+
if (existing.rows.length > 0) {
|
|
63
|
+
return existing.rows[0].id;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const inserted = await pool.query(
|
|
67
|
+
'INSERT INTO documentations (repository_id, title, description) VALUES ($1, $2, $3) RETURNING id',
|
|
68
|
+
[repositoryId, `${repoName} Documentation`, `Auto-generated documentation for ${repoName}`]
|
|
69
|
+
);
|
|
70
|
+
return inserted.rows[0].id;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Upsert documentation pages.
|
|
75
|
+
* Each fragment becomes a page; slug = file path, title = file name.
|
|
76
|
+
* Uses (documentation_id, slug) as the logical unique key.
|
|
77
|
+
* @param {Pool} pool
|
|
78
|
+
* @param {string} documentationId UUID
|
|
79
|
+
* @param {Array<{relativePath: string, content: string}>} fragments
|
|
80
|
+
* @returns {Promise<number>} count of upserted pages
|
|
81
|
+
*/
|
|
82
|
+
async function upsertPages(pool, documentationId, fragments) {
|
|
83
|
+
let count = 0;
|
|
84
|
+
for (let i = 0; i < fragments.length; i++) {
|
|
85
|
+
const frag = fragments[i];
|
|
86
|
+
const slug = frag.relativePath.replace(/\\/g, '/');
|
|
87
|
+
const title = path.basename(frag.relativePath);
|
|
88
|
+
|
|
89
|
+
// Check if page exists
|
|
90
|
+
const existing = await pool.query(
|
|
91
|
+
'SELECT id FROM documentation_pages WHERE documentation_id = $1 AND slug = $2',
|
|
92
|
+
[documentationId, slug]
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
if (existing.rows.length > 0) {
|
|
96
|
+
// Update existing
|
|
97
|
+
await pool.query(
|
|
98
|
+
'UPDATE documentation_pages SET content = $1, title = $2, page_order = $3, created_at = NOW() WHERE id = $4',
|
|
99
|
+
[frag.content, title, i + 1, existing.rows[0].id]
|
|
100
|
+
);
|
|
101
|
+
} else {
|
|
102
|
+
// Insert new
|
|
103
|
+
await pool.query(
|
|
104
|
+
'INSERT INTO documentation_pages (documentation_id, slug, title, content, page_order) VALUES ($1, $2, $3, $4, $5)',
|
|
105
|
+
[documentationId, slug, title, frag.content, i + 1]
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
count++;
|
|
109
|
+
}
|
|
110
|
+
return count;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Top-level push function. Called from analyze command.
|
|
115
|
+
* Short-circuits if user is not logged in.
|
|
116
|
+
* @param {Array<{relativePath: string, content: string}>} fragments
|
|
117
|
+
* @param {string} projectPath absolute path of the analyzed directory
|
|
118
|
+
* @param {object} [opts] optional overrides for testing
|
|
119
|
+
* @param {object} [opts.pool] pg Pool instance (skips singleton pool)
|
|
120
|
+
* @param {object} [opts.session] session object (skips loadSession)
|
|
121
|
+
* @returns {Promise<{skipped: boolean, pushed?: number}>}
|
|
122
|
+
*/
|
|
123
|
+
async function pushToDatabase(fragments, projectPath, opts) {
|
|
124
|
+
const session = (opts && opts.session) || loadSession();
|
|
125
|
+
if (!session.userId) {
|
|
126
|
+
return { skipped: true };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const ownPool = !(opts && opts.pool);
|
|
130
|
+
const pool = (opts && opts.pool) || getPool();
|
|
131
|
+
try {
|
|
132
|
+
const repoName = path.basename(projectPath);
|
|
133
|
+
const repoId = await getOrCreateRepo(pool, session.userId, projectPath);
|
|
134
|
+
const docId = await getOrCreateDocumentation(pool, repoId, repoName);
|
|
135
|
+
const pushed = await upsertPages(pool, docId, fragments);
|
|
136
|
+
return { skipped: false, pushed };
|
|
137
|
+
} finally {
|
|
138
|
+
if (ownPool) {
|
|
139
|
+
await pool.end().catch(() => {});
|
|
140
|
+
_pool = null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
module.exports = { getPool, getOrCreateRepo, getOrCreateDocumentation, upsertPages, pushToDatabase };
|
package/src/llm/free-model.js
CHANGED
|
@@ -9,10 +9,10 @@ const pc = require('picocolors');
|
|
|
9
9
|
* @returns {Object} mutated config
|
|
10
10
|
*/
|
|
11
11
|
function applyFreeModelPolicy(config) {
|
|
12
|
-
const provider = (config.provider || '
|
|
12
|
+
const provider = (config.provider || 'groq').toLowerCase();
|
|
13
13
|
|
|
14
|
-
// Ollama, Groq, and
|
|
15
|
-
if (provider === 'ollama' || provider === 'groq' || provider === 'gemini') {
|
|
14
|
+
// Ollama, Groq, Gemini, and Kimi are always free — skip openrouter-specific logic
|
|
15
|
+
if (provider === 'ollama' || provider === 'groq' || provider === 'gemini' || provider === 'kimi') {
|
|
16
16
|
config.isFreeModel = true;
|
|
17
17
|
config.skipCostEstimation = true;
|
|
18
18
|
if (provider === 'groq') {
|
|
@@ -33,6 +33,15 @@ function applyFreeModelPolicy(config) {
|
|
|
33
33
|
config.concurrency = 2;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
if (provider === 'kimi') {
|
|
37
|
+
console.log(pc.cyan('[info] Using Kimi (Moonshot AI) — free credits. Rate limit: 3 req/min'));
|
|
38
|
+
// Cap concurrency to 1 for Kimi (conservative rate limit)
|
|
39
|
+
const requested = parseInt(config.concurrency) || 1;
|
|
40
|
+
if (requested > 1) {
|
|
41
|
+
logger.warn(`Kimi free tier: capping concurrency from ${requested} to 1.`);
|
|
42
|
+
config.concurrency = 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
36
45
|
return config;
|
|
37
46
|
}
|
|
38
47
|
|
package/src/llm/index.js
CHANGED
|
@@ -4,24 +4,27 @@ const { OpenRouterProvider } = require('./providers/openrouter');
|
|
|
4
4
|
const { OllamaProvider } = require('./providers/ollama');
|
|
5
5
|
const { GroqProvider } = require('./providers/groq');
|
|
6
6
|
const { GeminiProvider } = require('./providers/gemini');
|
|
7
|
+
const { KimiProvider } = require('./providers/kimi');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Provider factory — returns the appropriate LLM adapter.
|
|
10
11
|
* @param {Object} config
|
|
11
|
-
* @returns {OpenRouterProvider|OllamaProvider|GroqProvider|GeminiProvider}
|
|
12
|
+
* @returns {OpenRouterProvider|OllamaProvider|GroqProvider|GeminiProvider|KimiProvider}
|
|
12
13
|
*/
|
|
13
14
|
function createProvider(config) {
|
|
14
|
-
const provider = (config.provider || '
|
|
15
|
+
const provider = (config.provider || 'groq').toLowerCase();
|
|
15
16
|
switch (provider) {
|
|
17
|
+
case 'openrouter':
|
|
18
|
+
return new OpenRouterProvider(config);
|
|
16
19
|
case 'ollama':
|
|
17
20
|
return new OllamaProvider(config);
|
|
18
|
-
case 'groq':
|
|
19
|
-
return new GroqProvider(config);
|
|
20
21
|
case 'gemini':
|
|
21
22
|
return new GeminiProvider(config);
|
|
22
|
-
case '
|
|
23
|
+
case 'kimi':
|
|
24
|
+
return new KimiProvider(config);
|
|
25
|
+
case 'groq':
|
|
23
26
|
default:
|
|
24
|
-
return new
|
|
27
|
+
return new GroqProvider(config);
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
|
|
@@ -4,10 +4,12 @@ const { NoApiKeyError } = require('../../utils/errors');
|
|
|
4
4
|
|
|
5
5
|
const GROQ_BASE = 'https://api.groq.com/openai/v1';
|
|
6
6
|
const DEFAULT_MODEL = 'llama-3.3-70b-versatile';
|
|
7
|
-
|
|
7
|
+
// Built-in shared key — lets users run legacyver out of the box without setup.
|
|
8
|
+
// Users can override with their own GROQ_API_KEY env var for higher rate limits.
|
|
9
|
+
const BUILT_IN_KEY = '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';
|
|
8
10
|
class GroqProvider {
|
|
9
11
|
constructor(config) {
|
|
10
|
-
this.apiKey = process.env.GROQ_API_KEY || config.groqApiKey;
|
|
12
|
+
this.apiKey = process.env.GROQ_API_KEY || config.groqApiKey || BUILT_IN_KEY;
|
|
11
13
|
if (!this.apiKey) throw new NoApiKeyError('groq');
|
|
12
14
|
this.model = config.model || DEFAULT_MODEL;
|
|
13
15
|
this.name = 'groq';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { NoApiKeyError } = require('../../utils/errors');
|
|
4
|
+
|
|
5
|
+
const KIMI_BASE = 'https://api.moonshot.cn/v1';
|
|
6
|
+
const DEFAULT_MODEL = 'moonshot-v1-8k';
|
|
7
|
+
|
|
8
|
+
class KimiProvider {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.apiKey = process.env.MOONSHOT_API_KEY || config.kimiApiKey;
|
|
11
|
+
if (!this.apiKey) throw new NoApiKeyError('kimi');
|
|
12
|
+
this.model = config.model || DEFAULT_MODEL;
|
|
13
|
+
this.name = 'kimi';
|
|
14
|
+
this.isFreeModel = true; // Kimi free credits on sign-up
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async complete(chunk) {
|
|
18
|
+
const body = {
|
|
19
|
+
model: this.model,
|
|
20
|
+
messages: [
|
|
21
|
+
{ role: 'system', content: chunk.systemPrompt },
|
|
22
|
+
{ role: 'user', content: chunk.userMessage },
|
|
23
|
+
],
|
|
24
|
+
temperature: 0.3,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let response;
|
|
28
|
+
try {
|
|
29
|
+
response = await fetch(`${KIMI_BASE}/chat/completions`, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(body),
|
|
36
|
+
});
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new Error(`Could not connect to Kimi (Moonshot) API: ${e.message}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (response.status === 429) {
|
|
42
|
+
const { RateLimitError } = require('../../utils/errors');
|
|
43
|
+
const headerVal = parseInt(response.headers.get('retry-after') || '0');
|
|
44
|
+
// Kimi rate limits are moderate; 10s minimum wait
|
|
45
|
+
const retryAfter = Math.max(headerVal * 1000, 10000);
|
|
46
|
+
const err = new RateLimitError('kimi', retryAfter);
|
|
47
|
+
try {
|
|
48
|
+
const text = await response.text();
|
|
49
|
+
const parsed = JSON.parse(text);
|
|
50
|
+
const detail = parsed.error && parsed.error.message ? parsed.error.message : text.substring(0, 200);
|
|
51
|
+
err.message = `Rate limit exceeded for provider "kimi": ${detail}`;
|
|
52
|
+
} catch (_) {
|
|
53
|
+
// keep default message
|
|
54
|
+
}
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (response.status === 401) {
|
|
59
|
+
const text = await response.text();
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Kimi API authentication failed (401). Check your MOONSHOT_API_KEY.\n` +
|
|
62
|
+
`Get a key at: https://platform.moonshot.cn/console/api-keys\n` +
|
|
63
|
+
`Detail: ${text.substring(0, 300)}`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
const text = await response.text();
|
|
69
|
+
throw new Error(`Kimi API error ${response.status}: ${text.substring(0, 500)}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const data = await response.json();
|
|
73
|
+
const content = (data.choices && data.choices[0] && data.choices[0].message && data.choices[0].message.content) || '';
|
|
74
|
+
const usage = data.usage || {};
|
|
75
|
+
const tokensUsed = {
|
|
76
|
+
input: usage.prompt_tokens || 0,
|
|
77
|
+
output: usage.completion_tokens || 0,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return { content, tokensUsed };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
estimateCost() { return 0; }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
module.exports = { KimiProvider };
|
package/src/llm/validator.js
CHANGED
|
@@ -40,7 +40,7 @@ function validateFragment(fragment, fileFacts) {
|
|
|
40
40
|
for (const exp of (fileFacts.exports || [])) knownIdentifiers.add(exp);
|
|
41
41
|
|
|
42
42
|
// Common words to skip (not identifiers)
|
|
43
|
-
const stopWords = new Set(['The', 'This', 'File', 'Function', 'Class', 'Method', 'Returns', 'Return', 'Parameter', 'Param', 'Import', 'Export', 'Overview', 'Usage', 'Example', 'Dependencies', 'Async', 'Static', 'Public', 'Private', 'Protected', 'Boolean', 'String', 'Number', 'Object', 'Array', 'Void', 'Null', 'Undefined', 'True', 'False', 'Error', 'Promise', 'Request', 'Response', 'Node', 'JavaScript', 'TypeScript', 'PHP', 'Python', 'Laravel', 'Express', 'Route', 'Controller', 'Model', 'Service', 'Repository', 'Middleware', 'Provider', 'Summary']);
|
|
43
|
+
const stopWords = new Set(['The', 'This', 'File', 'Function', 'Functions', 'Class', 'Method', 'Returns', 'Return', 'Parameter', 'Parameters', 'Param', 'Import', 'Export', 'Overview', 'Usage', 'Example', 'Dependencies', 'Dependency', 'Async', 'Static', 'Public', 'Private', 'Protected', 'Boolean', 'String', 'Number', 'Object', 'Array', 'Void', 'Null', 'Undefined', 'True', 'False', 'Error', 'Promise', 'Request', 'Response', 'Node', 'JavaScript', 'TypeScript', 'PHP', 'Python', 'Laravel', 'Express', 'Route', 'Controller', 'Model', 'Service', 'Repository', 'Middleware', 'Provider', 'Summary', 'None', 'Name', 'Description', 'Value', 'Type', 'Map', 'Set', 'Date', 'Creates', 'Create', 'Retrieves', 'Retrieve', 'Updates', 'Update', 'Deletes', 'Delete', 'Validates', 'Validate', 'Destroys', 'Destroy', 'Returns', 'Return', 'Gets', 'Get', 'Sets', 'Set', 'Checks', 'Check', 'Handles', 'Handle', 'Builds', 'Build', 'Loads', 'Load', 'Saves', 'Save', 'Sends', 'Send', 'Reads', 'Read', 'Writes', 'Write', 'Parses', 'Parse', 'Formats', 'Format', 'Converts', 'Convert', 'Generates', 'Generate', 'Initializes', 'Initialize', 'Registers', 'Register', 'Removes', 'Remove', 'Adds', 'Add', 'Lists', 'List', 'Fetches', 'Fetch', 'Renders', 'Render', 'Runs', 'Run', 'Starts', 'Start', 'Stops', 'Stop', 'Optional', 'Required', 'Default', 'Properties', 'Methods', 'Fields', 'Attributes', 'Throws', 'Emits', 'For', 'With', 'From', 'Into', 'Upon', 'When', 'After', 'Before', 'During', 'John', 'Jane', 'Doe', 'Example', 'New', 'Old', 'Current', 'Previous', 'Next', 'First', 'Last', 'All', 'Each', 'Every', 'Any', 'Given', 'Note', 'See', 'Also', 'More', 'Less', 'Here', 'There', 'Where', 'How', 'What', 'Which', 'Such', 'Like', 'Used', 'Uses', 'Using']);
|
|
44
44
|
|
|
45
45
|
const capitalizedIdentifiers = outputText.match(/\b([A-Z][a-zA-Z]{2,})\b/g) || [];
|
|
46
46
|
for (const identifier of capitalizedIdentifiers) {
|
package/src/utils/config.js
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const { cosmiconfigSync } = require('cosmiconfig');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Session file stores auth state across CLI invocations.
|
|
9
|
+
* Lives in ~/.legacyver/session.json (user-level, not project-level).
|
|
10
|
+
*/
|
|
11
|
+
const SESSION_DIR = path.join(require('os').homedir(), '.legacyver');
|
|
12
|
+
const SESSION_FILE = path.join(SESSION_DIR, 'session.json');
|
|
13
|
+
|
|
14
|
+
function loadSession() {
|
|
15
|
+
try {
|
|
16
|
+
return JSON.parse(fs.readFileSync(SESSION_FILE, 'utf8'));
|
|
17
|
+
} catch {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function saveSession(data) {
|
|
23
|
+
fs.mkdirSync(SESSION_DIR, { recursive: true });
|
|
24
|
+
fs.writeFileSync(SESSION_FILE, JSON.stringify(data, null, 2), 'utf8');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function clearSession() {
|
|
28
|
+
try { fs.unlinkSync(SESSION_FILE); } catch { /* ignore */ }
|
|
29
|
+
}
|
|
4
30
|
|
|
5
31
|
const explorer = cosmiconfigSync('legacyver', {
|
|
6
32
|
searchPlaces: [
|
|
@@ -33,7 +59,7 @@ function loadConfig(cliFlags = {}) {
|
|
|
33
59
|
}
|
|
34
60
|
|
|
35
61
|
const defaults = {
|
|
36
|
-
provider: '
|
|
62
|
+
provider: 'groq',
|
|
37
63
|
model: undefined,
|
|
38
64
|
format: 'markdown',
|
|
39
65
|
out: './legacyver-docs',
|
|
@@ -61,4 +87,4 @@ function loadConfig(cliFlags = {}) {
|
|
|
61
87
|
return { ...defaults, ...fileConfig, ...cleanCli };
|
|
62
88
|
}
|
|
63
89
|
|
|
64
|
-
module.exports = { loadConfig };
|
|
90
|
+
module.exports = { loadConfig, loadSession, saveSession, clearSession };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Team Infrastructure Usage Guide
|
|
2
|
+
|
|
3
|
+
Welcome to your team infrastructure folder! Here’s how to use the files provided:
|
|
4
|
+
|
|
5
|
+
## 1. `domain.txt`
|
|
6
|
+
|
|
7
|
+
- This file contains your public application domain in the format:
|
|
8
|
+
|
|
9
|
+
`https://<team-name>.hackathon.sev-2.com`
|
|
10
|
+
|
|
11
|
+
- This domain will be configured in the Kubernetes ingress, so your deployed app will be accessible at this address.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 2. `db-credentials.txt`
|
|
15
|
+
|
|
16
|
+
- This file contains your team's PostgreSQL database username, password, and database name.
|
|
17
|
+
- You can find it in your team folder: `db-credentials.txt`.
|
|
18
|
+
- Example content:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
rdms = "PostgreSQL"
|
|
22
|
+
host = "localhost"
|
|
23
|
+
port = 5432
|
|
24
|
+
username = "your_team_user"
|
|
25
|
+
password = "your_team_password"
|
|
26
|
+
database = "your_team_db"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- Use these credentials to connect your app or a database client to your team's schema.
|
|
30
|
+
|
|
31
|
+
## 3. `kubeconfig.yaml`
|
|
32
|
+
|
|
33
|
+
- This file allows you to connect to your team’s Kubernetes namespace/cluster.
|
|
34
|
+
- Usage example:
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
kubectl --kubeconfig=./kubeconfig.yaml -n <team-name> get pods
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- You can use this file with `kubectl` or any Kubernetes-compatible tool.
|
|
41
|
+
|
|
42
|
+
## Deployment Steps
|
|
43
|
+
|
|
44
|
+
1. Dockerize your app
|
|
45
|
+
2. Push your image to your container registry (e.g., Docker Hub).
|
|
46
|
+
3. Deploy your application as usual (e.g., with `kubectl apply -f ...`).
|
|
47
|
+
4. Ensure your app’s ingress resource uses the domain from `domain.txt`.
|
|
48
|
+
5. Access your app at the public URL after deployment.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
If you have questions, contact the hackathon team.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
## Useful Links
|
|
58
|
+
|
|
59
|
+
- [Kubernetes for Beginners (FreeCodeCamp)](https://www.freecodecamp.org/news/the-kubernetes-handbook/)
|
|
60
|
+
- [kubectl Cheat Sheet (Kubernetes Official)](https://kubernetes.io/docs/reference/kubectl/cheatsheet/)
|
|
61
|
+
- [Kubernetes Ingress Guide (Solo.io)](https://www.solo.io/topics/api-gateway/kubernetes-ingress)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
https://weci-holic.hackathon.sev-2.com
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: Config
|
|
3
|
+
clusters:
|
|
4
|
+
- name: local
|
|
5
|
+
cluster:
|
|
6
|
+
server: "https://103.185.52.45:6443"
|
|
7
|
+
certificate-authority-data: "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJkekNDQVIyZ0F3SUJBZ0lCQURBS0JnZ3Foa2pPUFFRREFqQWpNU0V3SHdZRFZRUUREQmhyTTNNdGMyVnkKZG1WeUxXTmhRREUzTnpFek9UQTRNRFF3SGhjTk1qWXdNakU0TURVd01EQTBXaGNOTXpZd01qRTJNRFV3TURBMApXakFqTVNFd0h3WURWUVFEREJock0zTXRjMlZ5ZG1WeUxXTmhRREUzTnpFek9UQTRNRFF3V1RBVEJnY3Foa2pPClBRSUJCZ2dxaGtqT1BRTUJCd05DQUFTckpZTUNCdG9kU2lGZ2k1bkJ0YnNRaE4wcTRnSmRJQ2lzeGRwN2FGR00KcTVaWk5iQXpLbjNrd05hU2JmZ2sxL2xUQWFIWnFSUlI0czdqaEFIclhUMjZvMEl3UURBT0JnTlZIUThCQWY4RQpCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVXdHdVk4YVZ2QzVURDZnaUdFQlNTCmRrK2loU2t3Q2dZSUtvWkl6ajBFQXdJRFNBQXdSUUlnYld1Y1NkQUVsZ3orcmp2Z1hrU0hXTTRSQnlrQVo4VjQKWDBlTjhYZzdJMmNDSVFDZWRtR2pVMzVQaUtheVFnQS9NWHJMd2ZyL1pBeUU3eUJzWHo2bGN5VFZKZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K"
|
|
8
|
+
contexts:
|
|
9
|
+
- name: weci-holic
|
|
10
|
+
context:
|
|
11
|
+
cluster: local
|
|
12
|
+
namespace: weci-holic
|
|
13
|
+
user: weci-holic-sa
|
|
14
|
+
current-context: weci-holic
|
|
15
|
+
users:
|
|
16
|
+
- name: weci-holic-sa
|
|
17
|
+
user:
|
|
18
|
+
token: eyJhbGciOiJSUzI1NiIsImtpZCI6IlFteFl2cGk1RkF5TEFkdDJYSC05UnVmUGJhYXJCU0pBNjNEcUZxcEtsdFUifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJ3ZWNpLWhvbGljIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6IndlY2ktaG9saWMtc2EtdG9rZW4iLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoid2VjaS1ob2xpYy1zYSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjhlNjY0ZmQyLWNkNTYtNGEyNi1iNjE5LWRjYzg1Y2Y2ZWFjMiIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDp3ZWNpLWhvbGljOndlY2ktaG9saWMtc2EifQ.jlBrE-ajb4CCj2244Kl-B-5jXikmNOh1kwbnMKttZFE8OJSi9xUEc1x6oQni1P83p5pkbqvreZpN8FtA-_YiMJpyMkjInWogfBc7TVvymJ0F0KQ-Ybxu2ibxkQvOOlNLuctCq4NbCm0oQaH3iBlvsFMpKuZJnogDwEbc6fompYrsxdXGh4F-zoh91mGiSsc7vyLfNJrKQvkivoOoaVwP2Y9xIZUnXMiTCExLUo1DthbRVN4PMPiCytJ6Tvg4LSMruu9-nW2be1hCgTV5IffB4hlhIgaWwCpBzygiWM4--Yg0tS-lejbquehDhVTWMkeOoZqzRKnMdU5iVyxBGB0pOA
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: openspec-apply-change
|
|
3
|
-
description: Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
|
|
4
|
-
license: MIT
|
|
5
|
-
compatibility: Requires openspec CLI.
|
|
6
|
-
metadata:
|
|
7
|
-
author: openspec
|
|
8
|
-
version: "1.0"
|
|
9
|
-
generatedBy: "1.1.1"
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
Implement tasks from an OpenSpec change.
|
|
13
|
-
|
|
14
|
-
**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
15
|
-
|
|
16
|
-
**Steps**
|
|
17
|
-
|
|
18
|
-
1. **Select the change**
|
|
19
|
-
|
|
20
|
-
If a name is provided, use it. Otherwise:
|
|
21
|
-
- Infer from conversation context if the user mentioned a change
|
|
22
|
-
- Auto-select if only one active change exists
|
|
23
|
-
- If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
|
|
24
|
-
|
|
25
|
-
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
|
|
26
|
-
|
|
27
|
-
2. **Check status to understand the schema**
|
|
28
|
-
```bash
|
|
29
|
-
openspec status --change "<name>" --json
|
|
30
|
-
```
|
|
31
|
-
Parse the JSON to understand:
|
|
32
|
-
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
|
33
|
-
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
|
|
34
|
-
|
|
35
|
-
3. **Get apply instructions**
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
openspec instructions apply --change "<name>" --json
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
This returns:
|
|
42
|
-
- Context file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
|
|
43
|
-
- Progress (total, complete, remaining)
|
|
44
|
-
- Task list with status
|
|
45
|
-
- Dynamic instruction based on current state
|
|
46
|
-
|
|
47
|
-
**Handle states:**
|
|
48
|
-
- If `state: "blocked"` (missing artifacts): show message, suggest using openspec-continue-change
|
|
49
|
-
- If `state: "all_done"`: congratulate, suggest archive
|
|
50
|
-
- Otherwise: proceed to implementation
|
|
51
|
-
|
|
52
|
-
4. **Read context files**
|
|
53
|
-
|
|
54
|
-
Read the files listed in `contextFiles` from the apply instructions output.
|
|
55
|
-
The files depend on the schema being used:
|
|
56
|
-
- **spec-driven**: proposal, specs, design, tasks
|
|
57
|
-
- Other schemas: follow the contextFiles from CLI output
|
|
58
|
-
|
|
59
|
-
5. **Show current progress**
|
|
60
|
-
|
|
61
|
-
Display:
|
|
62
|
-
- Schema being used
|
|
63
|
-
- Progress: "N/M tasks complete"
|
|
64
|
-
- Remaining tasks overview
|
|
65
|
-
- Dynamic instruction from CLI
|
|
66
|
-
|
|
67
|
-
6. **Implement tasks (loop until done or blocked)**
|
|
68
|
-
|
|
69
|
-
For each pending task:
|
|
70
|
-
- Show which task is being worked on
|
|
71
|
-
- Make the code changes required
|
|
72
|
-
- Keep changes minimal and focused
|
|
73
|
-
- Mark task complete in the tasks file: `- [ ]` → `- [x]`
|
|
74
|
-
- Continue to next task
|
|
75
|
-
|
|
76
|
-
**Pause if:**
|
|
77
|
-
- Task is unclear → ask for clarification
|
|
78
|
-
- Implementation reveals a design issue → suggest updating artifacts
|
|
79
|
-
- Error or blocker encountered → report and wait for guidance
|
|
80
|
-
- User interrupts
|
|
81
|
-
|
|
82
|
-
7. **On completion or pause, show status**
|
|
83
|
-
|
|
84
|
-
Display:
|
|
85
|
-
- Tasks completed this session
|
|
86
|
-
- Overall progress: "N/M tasks complete"
|
|
87
|
-
- If all done: suggest archive
|
|
88
|
-
- If paused: explain why and wait for guidance
|
|
89
|
-
|
|
90
|
-
**Output During Implementation**
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
## Implementing: <change-name> (schema: <schema-name>)
|
|
94
|
-
|
|
95
|
-
Working on task 3/7: <task description>
|
|
96
|
-
[...implementation happening...]
|
|
97
|
-
✓ Task complete
|
|
98
|
-
|
|
99
|
-
Working on task 4/7: <task description>
|
|
100
|
-
[...implementation happening...]
|
|
101
|
-
✓ Task complete
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
**Output On Completion**
|
|
105
|
-
|
|
106
|
-
```
|
|
107
|
-
## Implementation Complete
|
|
108
|
-
|
|
109
|
-
**Change:** <change-name>
|
|
110
|
-
**Schema:** <schema-name>
|
|
111
|
-
**Progress:** 7/7 tasks complete ✓
|
|
112
|
-
|
|
113
|
-
### Completed This Session
|
|
114
|
-
- [x] Task 1
|
|
115
|
-
- [x] Task 2
|
|
116
|
-
...
|
|
117
|
-
|
|
118
|
-
All tasks complete! Ready to archive this change.
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
**Output On Pause (Issue Encountered)**
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
## Implementation Paused
|
|
125
|
-
|
|
126
|
-
**Change:** <change-name>
|
|
127
|
-
**Schema:** <schema-name>
|
|
128
|
-
**Progress:** 4/7 tasks complete
|
|
129
|
-
|
|
130
|
-
### Issue Encountered
|
|
131
|
-
<description of the issue>
|
|
132
|
-
|
|
133
|
-
**Options:**
|
|
134
|
-
1. <option 1>
|
|
135
|
-
2. <option 2>
|
|
136
|
-
3. Other approach
|
|
137
|
-
|
|
138
|
-
What would you like to do?
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
**Guardrails**
|
|
142
|
-
- Keep going through tasks until done or blocked
|
|
143
|
-
- Always read context files before starting (from the apply instructions output)
|
|
144
|
-
- If task is ambiguous, pause and ask before implementing
|
|
145
|
-
- If implementation reveals issues, pause and suggest artifact updates
|
|
146
|
-
- Keep code changes minimal and scoped to each task
|
|
147
|
-
- Update task checkbox immediately after completing each task
|
|
148
|
-
- Pause on errors, blockers, or unclear requirements - don't guess
|
|
149
|
-
- Use contextFiles from CLI output, don't assume specific file names
|
|
150
|
-
|
|
151
|
-
**Fluid Workflow Integration**
|
|
152
|
-
|
|
153
|
-
This skill supports the "actions on a change" model:
|
|
154
|
-
|
|
155
|
-
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
|
|
156
|
-
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
|