spec-first-copilot 0.5.0-beta.12 → 0.5.0-beta.14
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/lib/init.js +7 -17
- package/lib/update.js +2 -37
- package/package.json +1 -1
- package/templates/.github/skills/sf-load/SKILL.md +23 -1
- package/templates/_gitignore +35 -0
package/lib/init.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const { execSync } = require('child_process');
|
|
4
3
|
|
|
5
4
|
const PLACEHOLDER = '{{PROJECT_NAME}}';
|
|
6
5
|
|
|
@@ -8,7 +7,9 @@ function copyDir(src, dest, replacements) {
|
|
|
8
7
|
fs.mkdirSync(dest, { recursive: true });
|
|
9
8
|
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
10
9
|
const srcPath = path.join(src, entry.name);
|
|
11
|
-
|
|
10
|
+
// Rename _gitignore → .gitignore (npm strips .gitignore from packages)
|
|
11
|
+
const destName = entry.name === '_gitignore' ? '.gitignore' : entry.name;
|
|
12
|
+
const destPath = path.join(dest, destName);
|
|
12
13
|
if (entry.isDirectory()) {
|
|
13
14
|
copyDir(srcPath, destPath, replacements);
|
|
14
15
|
} else {
|
|
@@ -24,7 +25,7 @@ function copyFile(src, dest, replacements) {
|
|
|
24
25
|
const textExtensions = ['.md', '.yaml', '.yml', '.json', '.js', '.ts', '.gitignore', '.gitkeep', ''];
|
|
25
26
|
const ext = path.extname(src).toLowerCase();
|
|
26
27
|
const basename = path.basename(src);
|
|
27
|
-
const isText = textExtensions.includes(ext) || basename.startsWith('.');
|
|
28
|
+
const isText = textExtensions.includes(ext) || basename.startsWith('.') || basename === '_gitignore';
|
|
28
29
|
|
|
29
30
|
if (isText) {
|
|
30
31
|
let content = fs.readFileSync(src, 'utf-8');
|
|
@@ -47,23 +48,12 @@ function init({ name, templatesDir, targetDir }) {
|
|
|
47
48
|
copyDir(templatesDir, dest, replacements);
|
|
48
49
|
patchProjectName(dest, name);
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
execSync('git init', { cwd: dest, stdio: 'pipe' });
|
|
52
|
-
execSync('git add -A', { cwd: dest, stdio: 'pipe' });
|
|
53
|
-
execSync(`git commit -m "chore: init project ${name} via spec-first-workflow"`, {
|
|
54
|
-
cwd: dest,
|
|
55
|
-
stdio: 'pipe',
|
|
56
|
-
});
|
|
57
|
-
console.log('Git initialized with initial commit.');
|
|
58
|
-
} catch {
|
|
59
|
-
console.log('Git init skipped (git not available or error).');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
console.log(`\nDone! Project "${name}" is ready.`);
|
|
51
|
+
console.log(`Done! Project "${name}" is ready.`);
|
|
63
52
|
console.log('\nNext steps:');
|
|
64
53
|
console.log(` 1. cd ${name}`);
|
|
65
54
|
console.log(' 2. Create a folder in workspace/Input/ with your project files (e.g. workspace/Input/my_app/)');
|
|
66
|
-
console.log(' 3.
|
|
55
|
+
console.log(' 3. Copy sfw.config.yml.example to sfw.config.yml and configure your backend');
|
|
56
|
+
console.log(' 4. Run /sf-new-project <folder-name> to start the pipeline');
|
|
67
57
|
console.log('');
|
|
68
58
|
}
|
|
69
59
|
|
package/lib/update.js
CHANGED
|
@@ -37,9 +37,6 @@ function update({ templatesDir, targetDir, force }) {
|
|
|
37
37
|
const stats = { added: [], updated: [], skipped: 0 };
|
|
38
38
|
syncDir(templatesDir, dest, force, stats, dest);
|
|
39
39
|
|
|
40
|
-
// Auto-configure .gitignore based on sfw.config.yml (before printing results)
|
|
41
|
-
adjustGitignore(dest, stats);
|
|
42
|
-
|
|
43
40
|
console.log('');
|
|
44
41
|
if (stats.added.length > 0) {
|
|
45
42
|
console.log(`Added (${stats.added.length}):`);
|
|
@@ -62,7 +59,8 @@ function syncDir(src, dest, force, stats, root) {
|
|
|
62
59
|
fs.mkdirSync(dest, { recursive: true });
|
|
63
60
|
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
64
61
|
const srcPath = path.join(src, entry.name);
|
|
65
|
-
const
|
|
62
|
+
const destName = entry.name === '_gitignore' ? '.gitignore' : entry.name;
|
|
63
|
+
const destPath = path.join(dest, destName);
|
|
66
64
|
if (entry.isDirectory()) {
|
|
67
65
|
syncDir(srcPath, destPath, force, stats, root);
|
|
68
66
|
} else {
|
|
@@ -131,37 +129,4 @@ function isFrameworkPath(rel) {
|
|
|
131
129
|
return false;
|
|
132
130
|
}
|
|
133
131
|
|
|
134
|
-
const WORKSPACE_IGNORE_MARKER = '# SFW: workspace ignored (external backend detected)';
|
|
135
|
-
const WORKSPACE_IGNORE_BLOCK = `
|
|
136
|
-
${WORKSPACE_IGNORE_MARKER}
|
|
137
|
-
# Content lives in the external backend (Confluence, etc.) — local is just cache
|
|
138
|
-
workspace/Output/**
|
|
139
|
-
!workspace/Output/.gitkeep
|
|
140
|
-
`;
|
|
141
|
-
|
|
142
|
-
function adjustGitignore(dest, stats) {
|
|
143
|
-
const configPath = path.join(dest, 'sfw.config.yml');
|
|
144
|
-
const gitignorePath = path.join(dest, '.gitignore');
|
|
145
|
-
|
|
146
|
-
if (!fs.existsSync(configPath) || !fs.existsSync(gitignorePath)) return;
|
|
147
|
-
|
|
148
|
-
const config = fs.readFileSync(configPath, 'utf-8');
|
|
149
|
-
const gitignore = fs.readFileSync(gitignorePath, 'utf-8');
|
|
150
|
-
|
|
151
|
-
const inputMatch = config.match(/^\s*adapter:\s*(\S+)/m);
|
|
152
|
-
const inputAdapter = inputMatch ? inputMatch[1] : 'filesystem';
|
|
153
|
-
const isExternal = inputAdapter !== 'filesystem';
|
|
154
|
-
|
|
155
|
-
const alreadyHasBlock = gitignore.includes(WORKSPACE_IGNORE_MARKER);
|
|
156
|
-
|
|
157
|
-
if (isExternal && !alreadyHasBlock) {
|
|
158
|
-
fs.appendFileSync(gitignorePath, WORKSPACE_IGNORE_BLOCK);
|
|
159
|
-
stats.updated.push('.gitignore (workspace ignored — external backend)');
|
|
160
|
-
} else if (!isExternal && alreadyHasBlock) {
|
|
161
|
-
const cleaned = gitignore.split(WORKSPACE_IGNORE_MARKER)[0].trimEnd() + '\n';
|
|
162
|
-
fs.writeFileSync(gitignorePath, cleaned, 'utf-8');
|
|
163
|
-
stats.updated.push('.gitignore (workspace restored — local mode)');
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
132
|
module.exports = { update };
|
package/package.json
CHANGED
|
@@ -156,7 +156,29 @@ Formato append-only:
|
|
|
156
156
|
- Se não existia no log → status `NOVO`
|
|
157
157
|
- Arquivo que existia no log mas sumiu do backend → status `REMOVIDO` (log only, não deleta local)
|
|
158
158
|
|
|
159
|
-
### 5.
|
|
159
|
+
### 5. Ajustar `.gitignore` conforme o adapter
|
|
160
|
+
|
|
161
|
+
Se o adapter NÃO é `filesystem` (ou seja, é um backend externo como Confluence):
|
|
162
|
+
- Verificar se `.gitignore` contém o bloco `# SFW: workspace ignored`
|
|
163
|
+
- Se NÃO contém, **adicionar** ao final do `.gitignore`:
|
|
164
|
+
```
|
|
165
|
+
# SFW: workspace ignored (external backend detected)
|
|
166
|
+
# Content lives in the external backend (Confluence, etc.) — local is just cache
|
|
167
|
+
workspace/Output/**
|
|
168
|
+
!workspace/Output/.gitkeep
|
|
169
|
+
```
|
|
170
|
+
- Informar ao usuário: "workspace/Output/ adicionado ao .gitignore (conteúdo vive no {adapter})"
|
|
171
|
+
|
|
172
|
+
Se o adapter É `filesystem`:
|
|
173
|
+
- Se `.gitignore` contém o bloco `# SFW: workspace ignored`, **removê-lo**
|
|
174
|
+
- Informar ao usuário: "workspace/Output/ removido do .gitignore (modo local)"
|
|
175
|
+
|
|
176
|
+
Isso garante que:
|
|
177
|
+
- Projetos com Confluence não commitam cache local
|
|
178
|
+
- Projetos que mudam de Confluence → filesystem voltam a rastrear
|
|
179
|
+
- A lógica roda no momento certo (após configurar `sfw.config.yml`, não no `init`)
|
|
180
|
+
|
|
181
|
+
### 6. Informar o usuário
|
|
160
182
|
|
|
161
183
|
```
|
|
162
184
|
Insumos carregados em workspace/Input/{nome}/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Insumos brutos do usuário — conteúdo nunca vai pro repositório
|
|
2
|
+
# A pasta workspace/Input/ existe no repo (via .gitkeep), mas seu conteúdo é ignorado
|
|
3
|
+
workspace/Input/**
|
|
4
|
+
!workspace/Input/.gitkeep
|
|
5
|
+
!workspace/Input/**/.gitkeep
|
|
6
|
+
|
|
7
|
+
# Memory pessoal (opcional — commit napkin.md se quiser compartilhar com o time)
|
|
8
|
+
# .ai/memory/napkin.md
|
|
9
|
+
|
|
10
|
+
# Repositórios de serviços (clonados/criados pelo workflow — cada um tem seu próprio .git)
|
|
11
|
+
projetos/
|
|
12
|
+
|
|
13
|
+
# MCP config — contém credenciais hardcoded (Confluence token, etc.)
|
|
14
|
+
.mcp.json
|
|
15
|
+
|
|
16
|
+
# Logs internos do workflow (append-only, gerados pelos commands)
|
|
17
|
+
.ai/load-log.md
|
|
18
|
+
.ai/publish-log.md
|
|
19
|
+
|
|
20
|
+
# IDEs
|
|
21
|
+
.vscode/
|
|
22
|
+
.idea/
|
|
23
|
+
|
|
24
|
+
# OS
|
|
25
|
+
.DS_Store
|
|
26
|
+
Thumbs.db
|
|
27
|
+
|
|
28
|
+
# Node
|
|
29
|
+
node_modules/
|
|
30
|
+
dist/
|
|
31
|
+
|
|
32
|
+
# Env
|
|
33
|
+
.env
|
|
34
|
+
.env.*
|
|
35
|
+
!.env.example
|