rrce-workflow 0.1.4 → 0.1.6
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/agent-core/prompts/documentation.md +15 -3
- package/agent-core/prompts/executor.md +23 -3
- package/agent-core/prompts/init.md +8 -3
- package/agent-core/prompts/planning_orchestrator.md +18 -3
- package/agent-core/prompts/research_discussion.md +5 -3
- package/agent-core/prompts/sync.md +12 -3
- package/agent-core/templates/documentation_output.md +2 -2
- package/agent-core/templates/executor_output.md +2 -2
- package/agent-core/templates/init_output.md +2 -2
- package/agent-core/templates/planning_output.md +2 -2
- package/agent-core/templates/research_output.md +2 -2
- package/package.json +1 -1
- package/src/commands/wizard/index.ts +114 -0
- package/src/commands/wizard/link-flow.ts +102 -0
- package/src/commands/wizard/setup-flow.ts +354 -0
- package/src/commands/wizard/sync-flow.ts +92 -0
- package/src/commands/wizard/update-flow.ts +128 -0
- package/src/commands/wizard/utils.ts +38 -0
- package/src/commands/wizard/vscode.ts +66 -0
- package/src/index.ts +1 -1
- package/src/lib/paths.ts +105 -0
- package/src/types/prompt.ts +3 -2
- package/src/commands/wizard.ts +0 -380
|
@@ -20,8 +20,20 @@ auto-identity:
|
|
|
20
20
|
|
|
21
21
|
You are the Documentation Lead for the project. Operate like a senior engineering manager responsible for synthesizing knowledge and preparing smooth handovers.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
**
|
|
23
|
+
Pipeline Position
|
|
24
|
+
- **Optional**: Documentation can be run at any point, but is most valuable after Execution.
|
|
25
|
+
- **Best After**: Executor phase complete (if documenting a specific task).
|
|
26
|
+
- **Standalone**: Can also run independently to document general knowledge, architecture, or runbooks.
|
|
27
|
+
|
|
28
|
+
Prerequisites (RECOMMENDED)
|
|
29
|
+
If a `TASK_SLUG` is provided:
|
|
30
|
+
1. **Execution Complete** (recommended): Check `{{RRCE_DATA}}/tasks/{{TASK_SLUG}}/meta.json` for `agents.executor.status === 'complete'`.
|
|
31
|
+
- If not complete, inform user: "Execution is not complete for this task. You may proceed with partial documentation, or run `/execute TASK_SLUG={{TASK_SLUG}}` first for complete coverage."
|
|
32
|
+
|
|
33
|
+
2. **Project Context Exists**: Check `{{RRCE_DATA}}/knowledge/project-context.md` exists.
|
|
34
|
+
- If missing, recommend: "Consider running `/init` first to establish project context for better documentation."
|
|
35
|
+
|
|
36
|
+
Documentation can proceed even if prerequisites are not fully met, but output quality may be limited.
|
|
25
37
|
|
|
26
38
|
Mission
|
|
27
39
|
- Translate the implemented work and accumulated context into durable documentation.
|
|
@@ -44,7 +56,7 @@ Path Resolution
|
|
|
44
56
|
- Secondary (auto-synced): `~/.rrce-workflow/workspaces/<workspace-name>/`
|
|
45
57
|
- When writing, always write to `{{RRCE_DATA}}` - the system ensures both locations stay in sync
|
|
46
58
|
- Data path: `{{RRCE_DATA}}` (resolves to primary storage based on mode)
|
|
47
|
-
- Global home: `{{RRCE_HOME}}` (
|
|
59
|
+
- Global home: `{{RRCE_HOME}}` (default: `~/.rrce-workflow`, customizable via `storage.globalPath` in config)
|
|
48
60
|
- Workspace root: `{{WORKSPACE_ROOT}}` (auto-detected or via `$RRCE_WORKSPACE`)
|
|
49
61
|
- Workspace name: `{{WORKSPACE_NAME}}` (from config or directory name)
|
|
50
62
|
|
|
@@ -16,8 +16,28 @@ auto-identity:
|
|
|
16
16
|
|
|
17
17
|
You are the Executor for the project. Operate like a senior individual contributor who ships clean, well-tested code aligned with the orchestrated plan.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
**
|
|
19
|
+
Pipeline Position
|
|
20
|
+
- **Requires**: Planning phase must be complete before execution can begin.
|
|
21
|
+
- **Next Step**: After execution is complete, optionally hand off to `/docs` (Documentation agent).
|
|
22
|
+
|
|
23
|
+
Prerequisites (STRICT)
|
|
24
|
+
Before proceeding, verify ALL of the following:
|
|
25
|
+
|
|
26
|
+
1. **Planning Complete**: Check `{{RRCE_DATA}}/tasks/{{TASK_SLUG}}/meta.json` exists and `agents.planning.status` is `complete`.
|
|
27
|
+
- If meta.json doesn't exist, **STOP** and prompt user:
|
|
28
|
+
> "Task not found. Please run `/research TASK_SLUG={{TASK_SLUG}}` to start a new task."
|
|
29
|
+
- If planning status is not `complete`, **STOP** and prompt user:
|
|
30
|
+
> "Planning phase is not complete for this task. Please run `/plan TASK_SLUG={{TASK_SLUG}}` first."
|
|
31
|
+
|
|
32
|
+
2. **Plan Artifact Exists**: Check that the plan file at `{{RRCE_DATA}}/tasks/{{TASK_SLUG}}/planning/{{TASK_SLUG}}-plan.md` exists.
|
|
33
|
+
- If missing, **STOP** and prompt user:
|
|
34
|
+
> "Plan artifact not found. Please run `/plan TASK_SLUG={{TASK_SLUG}}` first."
|
|
35
|
+
|
|
36
|
+
3. **Project Context Exists**: Check `{{RRCE_DATA}}/knowledge/project-context.md` exists.
|
|
37
|
+
- If missing, **STOP** and prompt user:
|
|
38
|
+
> "Project context not found. Please run `/init` first to establish project context."
|
|
39
|
+
|
|
40
|
+
Do not proceed with execution until all prerequisites are satisfied.
|
|
21
41
|
|
|
22
42
|
Mission
|
|
23
43
|
- Implement the scoped work, keeping quality high and feedback loops short.
|
|
@@ -40,7 +60,7 @@ Path Resolution
|
|
|
40
60
|
- Secondary (auto-synced): `~/.rrce-workflow/workspaces/<workspace-name>/`
|
|
41
61
|
- When writing, always write to `{{RRCE_DATA}}` - the system ensures both locations stay in sync
|
|
42
62
|
- Data path: `{{RRCE_DATA}}` (resolves to primary storage based on mode)
|
|
43
|
-
- Global home: `{{RRCE_HOME}}` (
|
|
63
|
+
- Global home: `{{RRCE_HOME}}` (default: `~/.rrce-workflow`, customizable via `storage.globalPath` in config)
|
|
44
64
|
- Workspace root: `{{WORKSPACE_ROOT}}` (auto-detected or via `$RRCE_WORKSPACE`)
|
|
45
65
|
- Workspace name: `{{WORKSPACE_NAME}}` (from config or directory name)
|
|
46
66
|
|
|
@@ -15,6 +15,11 @@ auto-identity:
|
|
|
15
15
|
|
|
16
16
|
You are the Project Initializer for RRCE-Workflow. Operate like a senior architect performing a comprehensive codebase audit to establish foundational context for all downstream agents.
|
|
17
17
|
|
|
18
|
+
Pipeline Position
|
|
19
|
+
- **Entry Point**: Init can be run at any time to establish or update project context.
|
|
20
|
+
- **Correlation**: Init and Planning work together to maintain project context. Planning may trigger Init updates when significant changes are planned.
|
|
21
|
+
- **Foundation**: All other agents (Research, Executor, Documentation, Sync) rely on the `project-context.md` created by Init.
|
|
22
|
+
|
|
18
23
|
Mission
|
|
19
24
|
- Analyze the workspace to extract tech stack, architecture patterns, coding conventions, and project structure.
|
|
20
25
|
- Produce a durable project context file that informs all future agent interactions.
|
|
@@ -30,14 +35,14 @@ Non-Negotiables
|
|
|
30
35
|
|
|
31
36
|
Path Resolution
|
|
32
37
|
- Storage mode: Determined by `.rrce-workflow.yaml` → global config → default (`global`)
|
|
33
|
-
- `global`: Data stored in
|
|
38
|
+
- `global`: Data stored in `{{RRCE_HOME}}/workspaces/<workspace-name>/`
|
|
34
39
|
- `workspace`: Data stored in `<workspace>/.rrce-workflow/`
|
|
35
40
|
- `both`: **Dual storage** - data stored in BOTH locations simultaneously
|
|
36
41
|
- Primary (for reads): `<workspace>/.rrce-workflow/`
|
|
37
|
-
- Secondary (auto-synced):
|
|
42
|
+
- Secondary (auto-synced): `{{RRCE_HOME}}/workspaces/<workspace-name>/`
|
|
38
43
|
- When writing, always write to `{{RRCE_DATA}}` - the system ensures both locations stay in sync
|
|
39
44
|
- Data path: `{{RRCE_DATA}}` (resolves to primary storage based on mode)
|
|
40
|
-
- Global home: `{{RRCE_HOME}}` (
|
|
45
|
+
- Global home: `{{RRCE_HOME}}` (default: `~/.rrce-workflow`, can be customized via `storage.globalPath` in `.rrce-workflow.yaml`)
|
|
41
46
|
- Workspace root: `{{WORKSPACE_ROOT}}` (auto-detected or via `$RRCE_WORKSPACE`)
|
|
42
47
|
- Workspace name: `{{WORKSPACE_NAME}}` (from config or directory name)
|
|
43
48
|
|
|
@@ -13,8 +13,23 @@ auto-identity:
|
|
|
13
13
|
|
|
14
14
|
You are the Planning & Task Orchestrator for the project. Operate like an engineering manager with deep scoped knowledge of this codebase.
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
**
|
|
16
|
+
Pipeline Position
|
|
17
|
+
- **Requires**: Research phase must be complete before planning can begin.
|
|
18
|
+
- **Correlation**: Planning works with Init to maintain project context. If planning reveals significant architectural changes, recommend running `/init` to update project context.
|
|
19
|
+
- **Next Step**: After planning is complete, hand off to `/execute` (Executor agent).
|
|
20
|
+
|
|
21
|
+
Prerequisites (STRICT)
|
|
22
|
+
Before proceeding, verify ALL of the following:
|
|
23
|
+
|
|
24
|
+
1. **Research Complete**: Check `{{RRCE_DATA}}/tasks/{{TASK_SLUG}}/meta.json` exists and `agents.research.status` is `complete`.
|
|
25
|
+
- If meta.json doesn't exist or research status is not `complete`, **STOP** and prompt user:
|
|
26
|
+
> "Research phase is not complete for this task. Please run `/research TASK_SLUG={{TASK_SLUG}}` first."
|
|
27
|
+
|
|
28
|
+
2. **Project Context Exists**: Check `{{RRCE_DATA}}/knowledge/project-context.md` exists.
|
|
29
|
+
- If missing, **STOP** and prompt user:
|
|
30
|
+
> "Project context not found. Please run `/init` first to establish project context."
|
|
31
|
+
|
|
32
|
+
Do not proceed with planning until both prerequisites are satisfied.
|
|
18
33
|
|
|
19
34
|
Mission
|
|
20
35
|
- Convert the Research brief into a concrete, prioritized plan that the Executor can follow with minimal ambiguity.
|
|
@@ -37,7 +52,7 @@ Path Resolution
|
|
|
37
52
|
- Secondary (auto-synced): `~/.rrce-workflow/workspaces/<workspace-name>/`
|
|
38
53
|
- When writing, always write to `{{RRCE_DATA}}` - the system ensures both locations stay in sync
|
|
39
54
|
- Data path: `{{RRCE_DATA}}` (resolves to primary storage based on mode)
|
|
40
|
-
- Global home: `{{RRCE_HOME}}` (
|
|
55
|
+
- Global home: `{{RRCE_HOME}}` (default: `~/.rrce-workflow`, customizable via `storage.globalPath` in config)
|
|
41
56
|
- Workspace root: `{{WORKSPACE_ROOT}}` (auto-detected or via `$RRCE_WORKSPACE`)
|
|
42
57
|
- Workspace name: `{{WORKSPACE_NAME}}` (from config or directory name)
|
|
43
58
|
|
|
@@ -20,8 +20,10 @@ auto-identity:
|
|
|
20
20
|
|
|
21
21
|
You are the Research & Discussion Lead for the project. Operate like a staff-level tech lead who owns broad project awareness.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
Pipeline Position
|
|
24
|
+
- **Entry Point**: Research can be the first agent invoked for a new task.
|
|
25
|
+
- **Recommendation**: If `{{RRCE_DATA}}/knowledge/project-context.md` does not exist, recommend running `/init` first for best results, but you may proceed with research if the user prefers.
|
|
26
|
+
- **Next Step**: After research is complete, hand off to `/plan` (Planning agent).
|
|
25
27
|
|
|
26
28
|
Mission
|
|
27
29
|
- Challenge and refine the incoming request until intent, constraints, and success criteria are explicit.
|
|
@@ -44,7 +46,7 @@ Path Resolution
|
|
|
44
46
|
- Secondary (auto-synced): `~/.rrce-workflow/workspaces/<workspace-name>/`
|
|
45
47
|
- When writing, always write to `{{RRCE_DATA}}` - the system ensures both locations stay in sync
|
|
46
48
|
- Data path: `{{RRCE_DATA}}` (resolves to primary storage based on mode)
|
|
47
|
-
- Global home: `{{RRCE_HOME}}` (
|
|
49
|
+
- Global home: `{{RRCE_HOME}}` (default: `~/.rrce-workflow`, customizable via `storage.globalPath` in config)
|
|
48
50
|
- Workspace root: `{{WORKSPACE_ROOT}}` (auto-detected or via `$RRCE_WORKSPACE`)
|
|
49
51
|
- Workspace name: `{{WORKSPACE_NAME}}` (from config or directory name)
|
|
50
52
|
|
|
@@ -14,8 +14,17 @@ auto-identity:
|
|
|
14
14
|
|
|
15
15
|
You are the Knowledge Sync Lead. Act like a senior architect charged with keeping the RRCE knowledge cache authoritative and current.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
Pipeline Position
|
|
18
|
+
- **Maintenance Agent**: Sync runs periodically or after significant codebase changes to keep knowledge current.
|
|
19
|
+
- **Requires**: Init must have been run at least once (project-context.md must exist).
|
|
20
|
+
- **Triggers Init**: If sync detects major structural changes, recommend running `/init` to update project context.
|
|
21
|
+
|
|
22
|
+
Prerequisites (STRICT)
|
|
23
|
+
1. **Project Context Exists**: Check `{{RRCE_DATA}}/knowledge/project-context.md` exists.
|
|
24
|
+
- If missing, **STOP** and prompt user:
|
|
25
|
+
> "Project context not found. Please run `/init` first to establish project context before syncing."
|
|
26
|
+
|
|
27
|
+
Do not proceed with sync until the prerequisite is satisfied.
|
|
19
28
|
|
|
20
29
|
Mission
|
|
21
30
|
- Inspect the live codebase to understand the present implementation and its recent changes.
|
|
@@ -37,7 +46,7 @@ Path Resolution
|
|
|
37
46
|
- Secondary (auto-synced): `~/.rrce-workflow/workspaces/<workspace-name>/`
|
|
38
47
|
- When writing, always write to `{{RRCE_DATA}}` - the system ensures both locations stay in sync
|
|
39
48
|
- Data path: `{{RRCE_DATA}}` (resolves to primary storage based on mode)
|
|
40
|
-
- Global home: `{{RRCE_HOME}}` (
|
|
49
|
+
- Global home: `{{RRCE_HOME}}` (default: `~/.rrce-workflow`, customizable via `storage.globalPath` in config)
|
|
41
50
|
- Workspace root: `{{WORKSPACE_ROOT}}` (auto-detected or via `$RRCE_WORKSPACE`)
|
|
42
51
|
- Workspace name: `{{WORKSPACE_NAME}}` (from config or directory name)
|
|
43
52
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
RRCE Template Variables:
|
|
3
3
|
- {{RRCE_DATA}}: Primary storage path (resolves based on storage mode in .rrce-workflow.yaml)
|
|
4
|
-
- global:
|
|
4
|
+
- global: {{RRCE_HOME}}/workspaces/<workspace-name>/
|
|
5
5
|
- workspace: <workspace>/.rrce-workflow/
|
|
6
6
|
- both: <workspace>/.rrce-workflow/ (primary, auto-synced to global)
|
|
7
|
-
- {{RRCE_HOME}}:
|
|
7
|
+
- {{RRCE_HOME}}: Global home (default: ~/.rrce-workflow, customizable via storage.globalPath in config)
|
|
8
8
|
- {{WORKSPACE_ROOT}}: Workspace root directory
|
|
9
9
|
- {{WORKSPACE_NAME}}: Workspace name from config or directory name
|
|
10
10
|
-->
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
RRCE Template Variables:
|
|
3
3
|
- {{RRCE_DATA}}: Primary storage path (resolves based on storage mode in .rrce-workflow.yaml)
|
|
4
|
-
- global:
|
|
4
|
+
- global: {{RRCE_HOME}}/workspaces/<workspace-name>/
|
|
5
5
|
- workspace: <workspace>/.rrce-workflow/
|
|
6
6
|
- both: <workspace>/.rrce-workflow/ (primary, auto-synced to global)
|
|
7
|
-
- {{RRCE_HOME}}:
|
|
7
|
+
- {{RRCE_HOME}}: Global home (default: ~/.rrce-workflow, customizable via storage.globalPath in config)
|
|
8
8
|
- {{WORKSPACE_ROOT}}: Workspace root directory
|
|
9
9
|
- {{WORKSPACE_NAME}}: Workspace name from config or directory name
|
|
10
10
|
-->
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
RRCE Template Variables:
|
|
3
3
|
- {{RRCE_DATA}}: Primary storage path (resolves based on storage mode in .rrce-workflow.yaml)
|
|
4
|
-
- global:
|
|
4
|
+
- global: {{RRCE_HOME}}/workspaces/<workspace-name>/
|
|
5
5
|
- workspace: <workspace>/.rrce-workflow/
|
|
6
6
|
- both: <workspace>/.rrce-workflow/ (primary, auto-synced to global)
|
|
7
|
-
- {{RRCE_HOME}}:
|
|
7
|
+
- {{RRCE_HOME}}: Global home (default: ~/.rrce-workflow, customizable via storage.globalPath in config)
|
|
8
8
|
- {{WORKSPACE_ROOT}}: Workspace root directory
|
|
9
9
|
- {{WORKSPACE_NAME}}: Workspace name from config or directory name
|
|
10
10
|
-->
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
RRCE Template Variables:
|
|
3
3
|
- {{RRCE_DATA}}: Primary storage path (resolves based on storage mode in .rrce-workflow.yaml)
|
|
4
|
-
- global:
|
|
4
|
+
- global: {{RRCE_HOME}}/workspaces/<workspace-name>/
|
|
5
5
|
- workspace: <workspace>/.rrce-workflow/
|
|
6
6
|
- both: <workspace>/.rrce-workflow/ (primary, auto-synced to global)
|
|
7
|
-
- {{RRCE_HOME}}:
|
|
7
|
+
- {{RRCE_HOME}}: Global home (default: ~/.rrce-workflow, customizable via storage.globalPath in config)
|
|
8
8
|
- {{WORKSPACE_ROOT}}: Workspace root directory
|
|
9
9
|
- {{WORKSPACE_NAME}}: Workspace name from config or directory name
|
|
10
10
|
-->
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
RRCE Template Variables:
|
|
3
3
|
- {{RRCE_DATA}}: Primary storage path (resolves based on storage mode in .rrce-workflow.yaml)
|
|
4
|
-
- global:
|
|
4
|
+
- global: {{RRCE_HOME}}/workspaces/<workspace-name>/
|
|
5
5
|
- workspace: <workspace>/.rrce-workflow/
|
|
6
6
|
- both: <workspace>/.rrce-workflow/ (primary, auto-synced to global)
|
|
7
|
-
- {{RRCE_HOME}}:
|
|
7
|
+
- {{RRCE_HOME}}: Global home (default: ~/.rrce-workflow, customizable via storage.globalPath in config)
|
|
8
8
|
- {{WORKSPACE_ROOT}}: Workspace root directory
|
|
9
9
|
- {{WORKSPACE_NAME}}: Workspace name from config or directory name
|
|
10
10
|
-->
|
package/package.json
CHANGED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { intro, select, spinner, note, outro, cancel, isCancel } from '@clack/prompts';
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { getGitUser } from '../../lib/git';
|
|
6
|
+
import {
|
|
7
|
+
detectWorkspaceRoot,
|
|
8
|
+
getWorkspaceName,
|
|
9
|
+
listGlobalProjects,
|
|
10
|
+
getLocalWorkspacePath
|
|
11
|
+
} from '../../lib/paths';
|
|
12
|
+
|
|
13
|
+
// Import flows
|
|
14
|
+
import { runSetupFlow } from './setup-flow';
|
|
15
|
+
import { runLinkProjectsFlow } from './link-flow';
|
|
16
|
+
import { runSyncToGlobalFlow } from './sync-flow';
|
|
17
|
+
import { runUpdateFlow } from './update-flow';
|
|
18
|
+
|
|
19
|
+
export async function runWizard() {
|
|
20
|
+
intro(pc.cyan(pc.inverse(' RRCE-Workflow Setup ')));
|
|
21
|
+
|
|
22
|
+
const s = spinner();
|
|
23
|
+
s.start('Detecting environment');
|
|
24
|
+
|
|
25
|
+
const workspacePath = detectWorkspaceRoot();
|
|
26
|
+
const workspaceName = getWorkspaceName(workspacePath);
|
|
27
|
+
const gitUser = getGitUser();
|
|
28
|
+
|
|
29
|
+
await new Promise(r => setTimeout(r, 800)); // Dramatic pause
|
|
30
|
+
s.stop('Environment detected');
|
|
31
|
+
|
|
32
|
+
note(
|
|
33
|
+
`Git User: ${pc.bold(gitUser || '(not found)')}
|
|
34
|
+
Workspace: ${pc.bold(workspaceName)}`,
|
|
35
|
+
'Context'
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Check for existing projects in global storage
|
|
39
|
+
const existingProjects = listGlobalProjects(workspaceName);
|
|
40
|
+
|
|
41
|
+
// Check if already configured
|
|
42
|
+
const configFilePath = path.join(workspacePath, '.rrce-workflow.yaml');
|
|
43
|
+
const isAlreadyConfigured = fs.existsSync(configFilePath);
|
|
44
|
+
|
|
45
|
+
// Check current storage mode from config
|
|
46
|
+
let currentStorageMode: string | null = null;
|
|
47
|
+
if (isAlreadyConfigured) {
|
|
48
|
+
try {
|
|
49
|
+
const configContent = fs.readFileSync(configFilePath, 'utf-8');
|
|
50
|
+
const modeMatch = configContent.match(/mode:\s*(global|workspace|both)/);
|
|
51
|
+
currentStorageMode = modeMatch?.[1] ?? null;
|
|
52
|
+
} catch {
|
|
53
|
+
// Ignore parse errors
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Check if workspace has local data that could be synced
|
|
58
|
+
const localDataPath = getLocalWorkspacePath(workspacePath);
|
|
59
|
+
const hasLocalData = fs.existsSync(localDataPath);
|
|
60
|
+
|
|
61
|
+
// If already configured, show menu
|
|
62
|
+
if (isAlreadyConfigured) {
|
|
63
|
+
const menuOptions: { value: string; label: string; hint?: string }[] = [];
|
|
64
|
+
|
|
65
|
+
// Add link option if other projects exist
|
|
66
|
+
if (existingProjects.length > 0) {
|
|
67
|
+
menuOptions.push({
|
|
68
|
+
value: 'link',
|
|
69
|
+
label: 'Link other project knowledge',
|
|
70
|
+
hint: `${existingProjects.length} projects available`
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Add sync to global option if using workspace-only mode
|
|
75
|
+
if (currentStorageMode === 'workspace' && hasLocalData) {
|
|
76
|
+
menuOptions.push({
|
|
77
|
+
value: 'sync-global',
|
|
78
|
+
label: 'Sync to global storage',
|
|
79
|
+
hint: 'Share knowledge with other projects'
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
menuOptions.push({ value: 'update', label: 'Update from package', hint: 'Get latest prompts & templates' });
|
|
84
|
+
menuOptions.push({ value: 'exit', label: 'Exit' });
|
|
85
|
+
|
|
86
|
+
const action = await select({
|
|
87
|
+
message: 'This workspace is already configured. What would you like to do?',
|
|
88
|
+
options: menuOptions,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
if (isCancel(action) || action === 'exit') {
|
|
92
|
+
outro('Exited.');
|
|
93
|
+
process.exit(0);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (action === 'link') {
|
|
97
|
+
await runLinkProjectsFlow(workspacePath, workspaceName, existingProjects);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (action === 'sync-global') {
|
|
102
|
+
await runSyncToGlobalFlow(workspacePath, workspaceName);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (action === 'update') {
|
|
107
|
+
await runUpdateFlow(workspacePath, workspaceName, currentStorageMode);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Run full setup flow for new workspaces
|
|
113
|
+
await runSetupFlow(workspacePath, workspaceName, existingProjects);
|
|
114
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { multiselect, spinner, note, outro, cancel, isCancel } from '@clack/prompts';
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import { listGlobalProjects, getEffectiveRRCEHome } from '../../lib/paths';
|
|
6
|
+
import { generateVSCodeWorkspace } from './vscode';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Run the link-only flow for adding other project knowledge to an existing workspace
|
|
10
|
+
*/
|
|
11
|
+
export async function runLinkProjectsFlow(
|
|
12
|
+
workspacePath: string,
|
|
13
|
+
workspaceName: string,
|
|
14
|
+
existingProjects?: string[]
|
|
15
|
+
) {
|
|
16
|
+
// Get projects if not provided
|
|
17
|
+
const projects = existingProjects ?? listGlobalProjects(workspaceName);
|
|
18
|
+
|
|
19
|
+
if (projects.length === 0) {
|
|
20
|
+
outro(pc.yellow('No other projects found in global storage.'));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const customGlobalPath = getEffectiveRRCEHome(workspacePath);
|
|
25
|
+
|
|
26
|
+
const linkedProjects = await multiselect({
|
|
27
|
+
message: 'Select projects to link:',
|
|
28
|
+
options: projects.map(name => ({
|
|
29
|
+
value: name,
|
|
30
|
+
label: name,
|
|
31
|
+
hint: `${customGlobalPath}/workspaces/${name}/knowledge`
|
|
32
|
+
})),
|
|
33
|
+
required: true,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (isCancel(linkedProjects)) {
|
|
37
|
+
cancel('Cancelled.');
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const selectedProjects = linkedProjects as string[];
|
|
42
|
+
|
|
43
|
+
if (selectedProjects.length === 0) {
|
|
44
|
+
outro('No projects selected.');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const s = spinner();
|
|
49
|
+
s.start('Linking projects');
|
|
50
|
+
|
|
51
|
+
// Update .rrce-workflow.yaml with linked projects
|
|
52
|
+
const configFilePath = path.join(workspacePath, '.rrce-workflow.yaml');
|
|
53
|
+
let configContent = fs.readFileSync(configFilePath, 'utf-8');
|
|
54
|
+
|
|
55
|
+
// Check if linked_projects section exists
|
|
56
|
+
if (configContent.includes('linked_projects:')) {
|
|
57
|
+
// Append to existing section - find and update
|
|
58
|
+
const lines = configContent.split('\n');
|
|
59
|
+
const linkedIndex = lines.findIndex(l => l.trim() === 'linked_projects:');
|
|
60
|
+
if (linkedIndex !== -1) {
|
|
61
|
+
// Find where to insert new projects (after existing ones)
|
|
62
|
+
let insertIndex = linkedIndex + 1;
|
|
63
|
+
while (insertIndex < lines.length && lines[insertIndex]?.startsWith(' - ')) {
|
|
64
|
+
insertIndex++;
|
|
65
|
+
}
|
|
66
|
+
// Add new projects that aren't already there
|
|
67
|
+
for (const name of selectedProjects) {
|
|
68
|
+
if (!configContent.includes(` - ${name}`)) {
|
|
69
|
+
lines.splice(insertIndex, 0, ` - ${name}`);
|
|
70
|
+
insertIndex++;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
configContent = lines.join('\n');
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
// Add new linked_projects section
|
|
77
|
+
configContent += `\nlinked_projects:\n`;
|
|
78
|
+
selectedProjects.forEach(name => {
|
|
79
|
+
configContent += ` - ${name}\n`;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fs.writeFileSync(configFilePath, configContent);
|
|
84
|
+
|
|
85
|
+
// Update VSCode workspace file
|
|
86
|
+
generateVSCodeWorkspace(workspacePath, workspaceName, selectedProjects, customGlobalPath);
|
|
87
|
+
|
|
88
|
+
s.stop('Projects linked');
|
|
89
|
+
|
|
90
|
+
// Show summary
|
|
91
|
+
const workspaceFile = `${workspaceName}.code-workspace`;
|
|
92
|
+
const summary = [
|
|
93
|
+
`Linked projects:`,
|
|
94
|
+
...selectedProjects.map(p => ` ✓ ${p}`),
|
|
95
|
+
``,
|
|
96
|
+
`Workspace file: ${pc.cyan(workspaceFile)}`,
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
note(summary.join('\n'), 'Link Summary');
|
|
100
|
+
|
|
101
|
+
outro(pc.green(`✓ Projects linked! Open ${pc.bold(workspaceFile)} in VSCode to access linked knowledge.`));
|
|
102
|
+
}
|