@contextium/cli 1.6.5 → 1.6.7

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.
Files changed (47) hide show
  1. package/dist/commands/edit-file.d.ts.map +1 -1
  2. package/dist/commands/edit-file.js +1 -0
  3. package/dist/commands/edit-file.js.map +1 -1
  4. package/dist/commands/links.d.ts +3 -0
  5. package/dist/commands/links.d.ts.map +1 -0
  6. package/dist/commands/links.js +58 -0
  7. package/dist/commands/links.js.map +1 -0
  8. package/dist/commands/new-file.d.ts.map +1 -1
  9. package/dist/commands/new-file.js +1 -0
  10. package/dist/commands/new-file.js.map +1 -1
  11. package/dist/commands/setup-codex.d.ts +14 -0
  12. package/dist/commands/setup-codex.d.ts.map +1 -0
  13. package/dist/commands/setup-codex.js +160 -0
  14. package/dist/commands/setup-codex.js.map +1 -0
  15. package/dist/commands/setup-connect.d.ts +11 -0
  16. package/dist/commands/setup-connect.d.ts.map +1 -0
  17. package/dist/commands/setup-connect.js +52 -0
  18. package/dist/commands/setup-connect.js.map +1 -0
  19. package/dist/commands/setup-copilot.d.ts +14 -0
  20. package/dist/commands/setup-copilot.d.ts.map +1 -0
  21. package/dist/commands/setup-copilot.js +123 -0
  22. package/dist/commands/setup-copilot.js.map +1 -0
  23. package/dist/commands/setup-cursor.d.ts +15 -0
  24. package/dist/commands/setup-cursor.d.ts.map +1 -0
  25. package/dist/commands/setup-cursor.js +109 -0
  26. package/dist/commands/setup-cursor.js.map +1 -0
  27. package/dist/commands/workflows.js +2 -2
  28. package/dist/commands/workflows.js.map +1 -1
  29. package/dist/index.js +13 -2
  30. package/dist/index.js.map +1 -1
  31. package/dist/lib/client-config.d.ts +26 -0
  32. package/dist/lib/client-config.d.ts.map +1 -0
  33. package/dist/lib/client-config.js +55 -0
  34. package/dist/lib/client-config.js.map +1 -0
  35. package/dist/lib/instructions.d.ts +49 -0
  36. package/dist/lib/instructions.d.ts.map +1 -0
  37. package/dist/lib/instructions.js +138 -0
  38. package/dist/lib/instructions.js.map +1 -0
  39. package/dist/lib/msal.js +4 -4
  40. package/dist/lib/output.d.ts +2 -0
  41. package/dist/lib/output.d.ts.map +1 -1
  42. package/dist/lib/output.js +3 -0
  43. package/dist/lib/output.js.map +1 -1
  44. package/package.json +1 -1
  45. package/skills/ium/contextium.md +12 -0
  46. package/skills/ium/new-project.md +287 -3
  47. package/skills/ium/workflow.md +9 -11
@@ -0,0 +1,138 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ /**
4
+ * Shared, operator-agnostic Contextium instructions.
5
+ *
6
+ * This is the single source for the *product-behaviour* layer that every AI
7
+ * operator (Claude Code, Cursor, Codex, Copilot, …) should receive so they all
8
+ * use Contextium the same way: the Task Awareness protocol and the Workflow
9
+ * Engineering standard. It deliberately excludes repo-specific dev guidance
10
+ * (build commands, file-structure, MCP-server code conventions) — those live in
11
+ * this monorepo's CLAUDE.md and are not part of the shipped experience.
12
+ *
13
+ * Each setup-* command writes this block into whatever instruction file the
14
+ * target operator reads natively (Cursor → .cursor/rules, Codex → AGENTS.md,
15
+ * Copilot → .github/copilot-instructions.md, …). The content is identical; only
16
+ * the destination path and wrapper differ.
17
+ */
18
+ export const INSTRUCTIONS_START = '<!-- contextium-instructions:start -->';
19
+ export const INSTRUCTIONS_END = '<!-- contextium-instructions:end -->';
20
+ /**
21
+ * The portable product-behaviour instructions. Phrased operator-neutrally
22
+ * ("your AI assistant", "the agent") and references only the Contextium MCP
23
+ * tools, which are identical across every operator.
24
+ */
25
+ export const CONTEXTIUM_INSTRUCTIONS = `## Contextium
26
+
27
+ Contextium gives your AI assistant shared project context — workflows, context
28
+ libraries, agents, skills, and tasks — through the Contextium MCP tools. Use
29
+ the MCP tools (not guesswork) to load context, track tasks, and drive feature
30
+ work. All tools are prefixed \`mcp__contextium__\` (or exposed by the connected
31
+ Contextium server).
32
+
33
+ ### Task Awareness — AI Agent Protocol
34
+
35
+ When a workflow is loaded (via the \`load_workflow\` MCP tool), the response
36
+ includes an active task list. Use it to guide session planning:
37
+
38
+ 1. **Present tasks as a clean numbered list** — show only task titles, no status
39
+ prefixes (\`[TODO]\`, \`[IN PROGRESS]\`) and no IDs in user-facing output. Keep
40
+ IDs internally for status updates.
41
+ 2. **Ask about the project plan** — after listing tasks, ask: "Would you like to
42
+ add these to a project plan as phases? If no project plan document exists in
43
+ this workflow, I can create one — or we can tackle them manually."
44
+ 3. **Resume in-progress tasks first** — if any task is \`in_progress\`, pick it up
45
+ before starting new work.
46
+ 4. **Pick the highest-priority pending task** — if nothing is in progress, take
47
+ the first \`not_started\` task from the list.
48
+ 5. **Mark tasks in-progress** — call \`update_task_status(taskId, 'in_progress')\`
49
+ when starting a task.
50
+ 6. **Mark tasks done** — call \`update_task_status(taskId, 'done')\` when finishing.
51
+ 7. **Add newly discovered tasks** — call \`add_task(workflowId, title)\` for work
52
+ items identified during the session.
53
+ 8. **One task at a time** — do not start a new task until the current one is done
54
+ or explicitly blocked.
55
+
56
+ MCP tools: \`add_task\`, \`update_task_status\`, \`list_tasks\`.
57
+
58
+ ### Workflow Engineering — Development Standard
59
+
60
+ All new Contextium feature development uses the workflow engineering framework:
61
+
62
+ - Every new feature starts with a workflow created in the Contextium workspace.
63
+ - The Planner agent runs once to write the spec and full phase list as
64
+ individual tagged files in the project library.
65
+ - The Builder implements one phase per session — hard rule, no exceptions.
66
+ - The Reviewer independently grades each implementation before it is marked
67
+ complete.
68
+ - Never start writing code for a new feature without a workflow and phase list
69
+ in place.
70
+
71
+ **Project MCP tools:**
72
+ - \`list_phases(workflowId)\` — returns the pending phases (use the first).
73
+ - \`update_phase_status(phaseId, "done")\` — marks a phase complete after review.
74
+ - \`load_workflow(workflowId)\` — loads full project state for session onboarding.
75
+
76
+ **Agent reuse:** each workspace has ONE set of shared project agents —
77
+ \`Planner\`, \`Builder\`, \`Reviewer\` — reused across ALL project workflows. Never
78
+ create per-project variants like \`{ProjectName} Builder\`.`;
79
+ /**
80
+ * Write the Contextium instructions as a managed, marker-delimited block into
81
+ * `filePath`. Re-running replaces the block in place rather than duplicating it,
82
+ * and any surrounding user content is preserved. Creates the file (and parent
83
+ * dirs) if missing.
84
+ *
85
+ * @param header Optional leading line written above the block on first creation
86
+ * only (e.g. a frontmatter fence for operators that require one).
87
+ */
88
+ export async function writeInstructionsBlock(filePath, opts = {}) {
89
+ const block = `${INSTRUCTIONS_START}\n${CONTEXTIUM_INSTRUCTIONS}\n${INSTRUCTIONS_END}`;
90
+ let content = '';
91
+ try {
92
+ content = await fs.readFile(filePath, 'utf-8');
93
+ }
94
+ catch (error) {
95
+ if (error.code !== 'ENOENT')
96
+ throw error;
97
+ }
98
+ const start = content.indexOf(INSTRUCTIONS_START);
99
+ const end = content.indexOf(INSTRUCTIONS_END);
100
+ if (start !== -1 && end !== -1) {
101
+ content = content.slice(0, start) + block + content.slice(end + INSTRUCTIONS_END.length);
102
+ }
103
+ else {
104
+ const prefix = opts.header && content.length === 0 ? opts.header + '\n\n' : '';
105
+ const sep = content.length && !content.endsWith('\n') ? '\n\n' : content.length ? '\n' : '';
106
+ content = prefix + content + sep + block + '\n';
107
+ }
108
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
109
+ await fs.writeFile(filePath, content, 'utf-8');
110
+ }
111
+ /**
112
+ * Copy the bundled /ium: command files into an operator's command/prompt
113
+ * directory. Mirrors what setup-claude installs to ~/.claude/commands/ium/.
114
+ *
115
+ * @param srcDir Directory holding the source `*.md` command files (skills/ium).
116
+ * @param destDir Operator command directory to copy into (created if missing).
117
+ * @param opts.rename Optional fn to map a source filename to the operator's
118
+ * expected name (e.g. Copilot wants `foo.prompt.md`).
119
+ * @returns the number of command files installed (0 if the source is absent).
120
+ */
121
+ export async function installCommands(srcDir, destDir, opts = {}) {
122
+ let files;
123
+ try {
124
+ files = (await fs.readdir(srcDir)).filter(f => f.endsWith('.md'));
125
+ }
126
+ catch {
127
+ return 0; // source dir may not exist in older installs — non-fatal
128
+ }
129
+ if (files.length === 0)
130
+ return 0;
131
+ await fs.mkdir(destDir, { recursive: true });
132
+ await Promise.all(files.map(f => {
133
+ const dest = opts.rename ? opts.rename(f) : f;
134
+ return fs.copyFile(path.join(srcDir, f), path.join(destDir, dest));
135
+ }));
136
+ return files.length;
137
+ }
138
+ //# sourceMappingURL=instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/lib/instructions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAA;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,wCAAwC,CAAA;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,sCAAsC,CAAA;AAEtE;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4DAqDqB,CAAA;AAE5D;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,QAAgB,EAChB,OAA4B,EAAE;IAE9B,MAAM,KAAK,GAAG,GAAG,kBAAkB,KAAK,uBAAuB,KAAK,gBAAgB,EAAE,CAAA;IAEtF,IAAI,OAAO,GAAG,EAAE,CAAA;IAChB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAChD,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;YAAE,MAAM,KAAK,CAAA;IAC1C,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;IACjD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC7C,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,GAAG,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AC,yDAAyD;IACpE,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAA;IAEhC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5C,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QACZ,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC7C,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;IACpE,CAAC,CAAC,CACH,CAAA;IACD,OAAO,KAAK,CAAC,MAAM,CAAA;AACrB,CAAC"}
package/dist/lib/msal.js CHANGED
@@ -73,24 +73,24 @@ export async function loginInteractive() {
73
73
  await open(url);
74
74
  },
75
75
  successTemplate: `<html><head><meta charset="utf-8"><title>Contextium - Login Successful</title></head>
76
- <body style="font-family:system-ui,-apple-system,sans-serif;display:flex;justify-content:center;align-items:center;height:100vh;margin:0;background:linear-gradient(135deg,#0f172a 0%,#1e293b 100%)">
76
+ <body style="font-family:system-ui,-apple-system,sans-serif;display:flex;justify-content:center;align-items:center;height:100vh;margin:0;background:linear-gradient(135deg,#1a0940 0%,#0a0812 100%)">
77
77
  <div style="text-align:center;background:#fff;padding:48px 64px;border-radius:16px;box-shadow:0 25px 50px rgba(0,0,0,0.25)">
78
78
  <div style="width:64px;height:64px;background:#22c55e;border-radius:50%;display:flex;align-items:center;justify-content:center;margin:0 auto 24px">
79
79
  <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
80
80
  </div>
81
81
  <h1 style="color:#0f172a;font-size:24px;margin:0 0 8px;font-weight:600">Login Successful</h1>
82
82
  <p style="color:#64748b;margin:0 0 24px;font-size:15px">You can close this window and return to the terminal.</p>
83
- <div style="color:#94a3b8;font-size:13px;border-top:1px solid #e2e8f0;padding-top:16px">Contextium CLI</div>
83
+ <div style="color:#7c3aed;font-size:13px;font-weight:600;border-top:1px solid #e2e8f0;padding-top:16px">Contextium CLI</div>
84
84
  </div></body></html>`,
85
85
  errorTemplate: `<html><head><meta charset="utf-8"><title>Contextium - Login Failed</title></head>
86
- <body style="font-family:system-ui,-apple-system,sans-serif;display:flex;justify-content:center;align-items:center;height:100vh;margin:0;background:linear-gradient(135deg,#0f172a 0%,#1e293b 100%)">
86
+ <body style="font-family:system-ui,-apple-system,sans-serif;display:flex;justify-content:center;align-items:center;height:100vh;margin:0;background:linear-gradient(135deg,#1a0940 0%,#0a0812 100%)">
87
87
  <div style="text-align:center;background:#fff;padding:48px 64px;border-radius:16px;box-shadow:0 25px 50px rgba(0,0,0,0.25)">
88
88
  <div style="width:64px;height:64px;background:#ef4444;border-radius:50%;display:flex;align-items:center;justify-content:center;margin:0 auto 24px">
89
89
  <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>
90
90
  </div>
91
91
  <h1 style="color:#0f172a;font-size:24px;margin:0 0 8px;font-weight:600">Login Failed</h1>
92
92
  <p style="color:#64748b;margin:0 0 24px;font-size:15px">Something went wrong. Please try again.</p>
93
- <div style="color:#94a3b8;font-size:13px;border-top:1px solid #e2e8f0;padding-top:16px">Contextium CLI</div>
93
+ <div style="color:#7c3aed;font-size:13px;font-weight:600;border-top:1px solid #e2e8f0;padding-top:16px">Contextium CLI</div>
94
94
  </div></body></html>`,
95
95
  });
96
96
  return result;
@@ -9,6 +9,7 @@ export declare const colors: {
9
9
  cyan: string;
10
10
  gray: string;
11
11
  white: string;
12
+ brand: string;
12
13
  };
13
14
  export declare function colorize(text: string, color: keyof typeof colors): string;
14
15
  export declare const chalk: {
@@ -21,6 +22,7 @@ export declare const chalk: {
21
22
  dim: (text: string) => string;
22
23
  bold: (text: string) => string;
23
24
  white: (text: string) => string;
25
+ brand: (text: string) => string;
24
26
  };
25
27
  export declare class Spinner {
26
28
  private text;
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;;;;;;;;;;;CAWlB,CAAA;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,OAAO,MAAM,GAAG,MAAM,CAEzE;AAED,eAAO,MAAM,KAAK;gBACJ,MAAM;kBACJ,MAAM;mBACL,MAAM;iBACR,MAAM;iBACN,MAAM;iBACN,MAAM;gBACP,MAAM;iBACL,MAAM;kBACL,MAAM;CACrB,CAAA;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,IAAI,CAAQ;IACpB,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,YAAY,CAAI;IACxB,OAAO,CAAC,UAAU,CAAQ;gBAEd,IAAI,EAAE,MAAM;IAIxB,KAAK,IAAI,IAAI;IAeb,IAAI,IAAI,IAAI;IAWZ,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK9B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK3B,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,EAEvB;CACF;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzC"}
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;;;;;;;;;;;;CAalB,CAAA;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,OAAO,MAAM,GAAG,MAAM,CAEzE;AAED,eAAO,MAAM,KAAK;gBACJ,MAAM;kBACJ,MAAM;mBACL,MAAM;iBACR,MAAM;iBACN,MAAM;iBACN,MAAM;gBACP,MAAM;iBACL,MAAM;kBACL,MAAM;kBACN,MAAM;CACrB,CAAA;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,IAAI,CAAQ;IACpB,OAAO,CAAC,QAAQ,CAAC,CAAgB;IACjC,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,YAAY,CAAI;IACxB,OAAO,CAAC,UAAU,CAAQ;gBAEd,IAAI,EAAE,MAAM;IAIxB,KAAK,IAAI,IAAI;IAeb,IAAI,IAAI,IAAI;IAWZ,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK9B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK3B,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,EAEvB;CACF;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzC"}
@@ -10,6 +10,8 @@ export const colors = {
10
10
  cyan: '\x1b[36m',
11
11
  gray: '\x1b[90m',
12
12
  white: '\x1b[37m',
13
+ // Contextium brand accent #7c3aed (24-bit truecolor)
14
+ brand: '\x1b[38;2;124;58;237m',
13
15
  };
14
16
  export function colorize(text, color) {
15
17
  return `${colors[color]}${text}${colors.reset}`;
@@ -24,6 +26,7 @@ export const chalk = {
24
26
  dim: (text) => colorize(text, 'dim'),
25
27
  bold: (text) => colorize(text, 'bold'),
26
28
  white: (text) => colorize(text, 'white'),
29
+ brand: (text) => colorize(text, 'brand'),
27
30
  };
28
31
  export class Spinner {
29
32
  constructor(text) {
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;CAClB,CAAA;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,KAA0B;IAC/D,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC,KAAK,EAAE,CAAA;AACjD,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAC5C,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAChD,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAClD,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC9C,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC9C,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC9C,GAAG,EAAE,CAAC,IAAY,EAA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,CAAC;YACpB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA,CAAC,aAAa;YAC9C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACzB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,OAAe;QACrB,IAAI,CAAC,IAAI,EAAE,CAAA;QACX,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,CAAA;IAC/C,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,IAAI,EAAE,CAAA;QACX,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,CAAA;IAC7C,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,IAAI,EAAE,CAAA;QACX,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,CAAA;IAChD,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,IAAI,EAAE,CAAA;QACX,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,CAAA;IAC9C,CAAC;IAED,IAAI,OAAO,CAAC,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED,MAAM,UAAU,GAAG,CAAC,IAAY;IAC9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contextium/cli",
3
- "version": "1.6.5",
3
+ "version": "1.6.7",
4
4
  "description": "Command-line tool for managing Contextium documentation, agents, skills, and workflows — pipe context to AI coding assistants",
5
5
  "keywords": [
6
6
  "contextium",
@@ -71,6 +71,18 @@ Workspace
71
71
  | A role combining multiple skills? | Agent |
72
72
  | Ready-to-use context package for a task? | Workflow |
73
73
 
74
+ ## File Linking
75
+
76
+ Files can link to each other (Obsidian-style). A link is just a `//<fileId>` token written inline in a file's content.
77
+
78
+ - **To add a link**, put `//<fileId>` in the content where the text references another file in the **same workspace**. Use the target file's **UUID** (from `find`, `search`, or `cat`/get results) — not its title. The link renders as the target's title in the apps and is indexed automatically when the file is saved. There is no separate "link" command — you link by editing content (`new` / `edit`).
79
+ - **Prefer the file ID.** Titles also resolve, but IDs survive renames and are unambiguous.
80
+ - **Backlinks are automatic.** To make file B show a backlink from A, add `//<B-id>` to **A**'s content. You never author B's backlinks directly.
81
+ - **Only link to files that exist.** An unresolved `//<id>` becomes a dangling link.
82
+ - **To inspect a file's links**, run `contextium links <fileId>` — it lists outgoing links (resolved or dangling) and backlinks (files that link here).
83
+
84
+ Flow: `find`/`search` the target → take its id → embed `//<id>` in the content → `new`/`edit`.
85
+
74
86
  ## Contextium Is the Source of Truth
75
87
 
76
88
  All AI-relevant information — project state, SOPs, constraints, decisions, research, planning — lives in Contextium. It is always written to Contextium first. Local files are only for things that belong in git: source code, config, READMEs.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ium:new-project
3
- description: Set up a new Contextium project — authenticate, pick a workspace, describe project, intelligently suggest and create libraries, agents, skills, tags, and a workflow. SUGGEST (proactively ask, don't auto-run) when the user seems to be starting a new project or exploring how to organise their AI context — for example: "I'm starting a new project", "I want to get organised with AI", "how do I get the most out of Claude for my project", "I want Claude to know about my project", "I want to set up AI properly for my work", "I need a way for AI to understand my codebase". In these cases ask: "Would you like to set up a Contextium project? I can create libraries, agents, and skills tailored to what you're building — so any AI in your workflow has the right context automatically." — then wait for confirmation. TRIGGER when user says things like: "set up Contextium", "start a new Contextium project", "create a new project in Contextium", "I want to use Contextium", "get started with Contextium", "initialise Contextium for my project", "configure Contextium for me", "connect my project to Contextium", "onboard to Contextium", "set up my Contextium workspace", "create libraries and agents for my project", "I'm new to Contextium help me get set up", "create a Contextium project from scratch", "set up everything in Contextium for me", "help me configure Contextium".
3
+ description: Set up a new Contextium project — authenticate, pick a workspace, describe project, intelligently suggest and create libraries, agents, skills, tags, and a workflow. SUGGEST (proactively ask, don't auto-run) when the user seems to be starting a new project or exploring how to organise their AI context — for example: "I'm starting a new project", "I want to get organised with AI", "how do I get the most out of Claude for my project", "I want Claude to know about my project", "I want to set up AI properly for my work", "I need a way for AI to understand my codebase". In these cases ask: "Would you like to set up a Contextium project? I can create libraries, agents, and skills tailored to what you're building — so any AI in your workflow has the right context automatically." — then wait for confirmation. TRIGGER when user says things like: "set up Contextium", "start a new Contextium project", "create a new project in Contextium", "I want to use Contextium", "get started with Contextium", "initialise Contextium for my project", "configure Contextium for me", "connect my project to Contextium", "onboard to Contextium", "set up my Contextium workspace", "create libraries and agents for my project", "I'm new to Contextium help me get set up", "create a Contextium project from scratch", "set up everything in Contextium for me", "help me configure Contextium". ALSO TRIGGER for starting a project from an idea — "I have an idea about X", "I have an idea for X", "I want to start a project on X", "start a project: X", "let's flesh out an idea", "I want to build X" — these begin a new project; for a brand-new idea (not a feature in an existing product) the flow runs a full business analysis (SWOT, market size, competitor analysis with their funding/revenue, market-entry difficulty, two-tier financials, RICE, timeline, roles) and a synthesised go/no-go verdict before planning the build.
4
4
  allowed-tools:
5
5
  - Bash
6
6
  - mcp__contextium__list_workspaces
@@ -16,7 +16,11 @@ allowed-tools:
16
16
  - mcp__contextium__list_tag_types
17
17
  - mcp__contextium__create_tag
18
18
  - mcp__contextium__create_tag_type
19
+ - mcp__contextium__create_file
20
+ - mcp__contextium__add_phase
21
+ - mcp__contextium__load_workflow
19
22
  - AskUserQuestion
23
+ - WebSearch
20
24
  - WebFetch
21
25
  ---
22
26
 
@@ -114,6 +118,49 @@ Ask the user this question exactly:
114
118
  Wait for their response. Store it as the project description. Do not proceed until you have a meaningful answer.
115
119
  </step>
116
120
 
121
+ <step name="branch_gate">
122
+ Decide whether this is a **new idea/venture** (needs a full business analysis) or a **new feature inside an existing product** (skip the analysis — you're already in that market). Score the signals into a confidence, then either confirm a clear lean with one pre-answered question, or — if it's genuinely a toss-up — ask the user straight. Do not interrogate the user cold when the signals are clear.
123
+
124
+ **`feature` signals — but only when the existing context looks *established*:**
125
+ - An existing workflow was selected in `existing_workflow_check` AND that workflow looks established — it has build history (phases or a populated project-state), or libraries with real code/architecture docs, or a name/description that denotes a concrete product or feature area.
126
+ - `has_codebase_scan == true` (a mapped codebase exists).
127
+ - The description frames an addition to something that already exists — "add … to my app", "a new feature for …", "improve the … in our product", "extend …".
128
+
129
+ **`idea` signals:**
130
+ - Fresh workspace / no existing workflow chosen, `has_codebase_scan == false`, and the description frames a brand-new product, business, book, or venture — "I have an idea for …", "I want to start a …", "build a new …".
131
+ - **An existing workflow was selected but it is NOT established** — it is empty (0 phases, no meaningful libraries/files) or its name/description reads like an idea bucket (matches words like *ideas, idea, concept, concepts, business plan, business plans, brainstorm, backlog, someday, pipeline, ventures, R&D, discovery, exploration*). Selecting such a container is a signal someone is starting a NEW idea, not extending a product — do not treat it as `feature`.
132
+
133
+ **Resolve to a confidence:**
134
+ - If feature signals clearly outweigh idea signals → confident `feature`.
135
+ - If idea signals clearly outweigh feature signals → confident `idea`.
136
+ - If signals are mixed, weak, or contradictory (e.g. an existing-but-empty workflow plus a description that could be read either way) → **undetermined**.
137
+
138
+ **Then:**
139
+
140
+ - Confident `feature` — confirm, feature first (Recommended):
141
+ "This looks like a feature inside an existing product, so I'd skip the market/competitor/financial analysis and go straight to planning the build. Sound right?"
142
+ - "Yes — it's a feature, just plan the build (Recommended)"
143
+ - "No — it's a new idea, run the full business analysis"
144
+
145
+ - Confident `idea` — confirm, idea first (Recommended):
146
+ "This looks like a brand-new idea. I can run a full business analysis first — is it worth doing, how hard is the market to break into, who are you up against, and what would it cost — before planning the build. Want that?"
147
+ - "Yes — run the full business analysis (Recommended)"
148
+ - "No — skip it, just plan the build"
149
+
150
+ - **Undetermined** — ask neutrally, with NO option marked Recommended (a wrong nudge is the thing to avoid here):
151
+ "Quick check so I set this up right — is this a brand-new idea you want me to validate first, or a feature/addition to something you're already building?"
152
+ - "A new idea — run the full business analysis"
153
+ - "A feature/addition — just plan the build"
154
+
155
+ Store the result as `track = "idea"` or `track = "feature"`. This drives the rest of the session:
156
+ - `track == "idea"` → the **business-analysis pipeline** runs (SWOT, market, competitor, financials, RICE, timeline, roles, and a synthesised verdict), and the Researcher agent is created automatically and put to work — so do NOT ask the standalone "want a research agent?" question later; it is absorbed here.
157
+ - `track == "feature"` → skip the business analysis entirely. Produce only the build plan + RICE + timeline. The standalone "want a Researcher agent?" question still applies (as a standing capability for technical lookups during the build).
158
+
159
+ **Idea-in-a-container:** if the idea track was reached because an existing workflow was selected but it is an empty or idea-bucket container (per the idea signals above), set `idea_container_workflow = <that workflow's name/id>`. The container is NOT this idea's home — the new idea gets its OWN dedicated library (already the rule: one library per project) and its OWN dedicated workflow (handled in `workflow_prompt`). The container is treated as an index of ideas, not the project to extend. If no container was involved, leave `idea_container_workflow` unset.
160
+
161
+ Do not show the inference reasoning to the user — just ask the confirmation question.
162
+ </step>
163
+
117
164
  <step name="quiet_analysis">
118
165
  Silently fetch all existing workspace resources. Do not show raw output or errors. Show only these progress lines as you go:
119
166
 
@@ -200,7 +247,11 @@ Wait for the user to confirm, adjust, or say skip on any item before proceeding.
200
247
  </step>
201
248
 
202
249
  <step name="research_question">
203
- Ask the user:
250
+ **Track-aware.**
251
+
252
+ **If `track == "idea"`:** do NOT ask this question. The business analysis (run later in the `business_analysis` step) *is* research, and it runs through the Researcher — so the Researcher is implied. Silently add a "**[Project Name] Researcher**" agent to the creation plan, tailored to this idea's domain (market, competitor, and feasibility research), and set `research_agent_planned = true`. Note internally that this Researcher is the agent the `business_analysis` pipeline runs as. Continue without prompting.
253
+
254
+ **If `track == "feature"`:** ask the standalone question, because there's no business analysis but a researcher may still be useful for technical/competitive lookups during the build:
204
255
 
205
256
  "Does this project need research before you start work? I can create a dedicated research agent to gather information, analyse sources, and summarise findings for your project."
206
257
 
@@ -208,7 +259,7 @@ Use AskUserQuestion:
208
259
  - "Yes, add a research agent"
209
260
  - "No, skip"
210
261
 
211
- If yes: add a project-specific research agent to the creation plan. Name it something like "**[Project Name] Researcher**" and tailor its system prompt to the specific research domain (e.g. competitor analysis, technical investigation, market research — infer from the project description). Store this agent as `research_agent_planned = true` for use in later steps.
262
+ If yes: add a project-specific research agent to the creation plan. Name it something like "**[Project Name] Researcher**" and tailor its system prompt to the specific research domain (e.g. competitor analysis, technical investigation — infer from the project description). Store this agent as `research_agent_planned = true` for use in later steps.
212
263
 
213
264
  If no: set `research_agent_planned = false` and continue.
214
265
  </step>
@@ -392,7 +443,238 @@ contextium tag-type create "<name>" --workspace <slug>
392
443
  **MCP:** use the corresponding create_* tools for each resource type.
393
444
  </step>
394
445
 
446
+ <step name="business_analysis">
447
+ **Only runs when `track == "idea"`.** If `track == "feature"`, skip this entire step.
448
+
449
+ This is the business-analysis pipeline — it produces the discovery documents that answer "is this idea worth doing, and how hard is the market to break into?" It runs **as the Researcher agent** created in `research_question`: adopt that agent's perspective for the analysis. Every document is written as a **file** in the project library (the single library in `created_library_ids`), never as agent text or phases, so it costs nothing at workflow-load time. Tag each file `type:business-analysis` (create the `type` tag-type and the `business-analysis` value once per workspace, then reuse) so the documents retrieve on demand and stay out of default context loading.
450
+
451
+ **Load-cost guard:** analysis output must stay as files + (for the build plan) short DB phases only. Never write analysis prose into agent system prompts, task records, or phase descriptions — those load on every `load_workflow`, whereas files and tags do not. Done right, a project with the full analysis loads no heavier than one without it.
452
+
453
+ Generate the documents below **in order** — the build plan feeds RICE, the build plan + roles feed financials, and every document feeds the final verdict, so do not reorder. Use **live web search** for the market and competitor documents (real, current figures — cite sources inline). Keep every document concrete to *this* idea and in plain English.
454
+
455
+ **SWOT analysis → `01-swot.md`**
456
+
457
+ Write a SWOT grounded in *this* project's description (and the codebase-scan context if `has_codebase_scan == true`) — not generic boilerplate. Plain English, concrete to the idea. Use this structure:
458
+
459
+ ```markdown
460
+ # SWOT Analysis — [Project Name]
461
+
462
+ > Part of the business analysis. Read alongside the market, competitor, and financial documents; the verdict (00-verdict.md) synthesises all of them.
463
+
464
+ ## Strengths
465
+ Internal advantages this idea/team starts with. 3–5 specific bullets.
466
+
467
+ ## Weaknesses
468
+ Internal gaps, missing capabilities, or constraints. 3–5 specific bullets — be honest, not flattering.
469
+
470
+ ## Opportunities
471
+ External openings: market gaps, trends, underserved segments, timing. 3–5 bullets.
472
+
473
+ ## Threats
474
+ External risks: incumbents, market shifts, regulation, dependencies. 3–5 bullets.
475
+
476
+ ## Takeaway
477
+ 2–3 sentences: what the SWOT implies for whether and how to pursue this.
478
+ ```
479
+
480
+ Write the file into the project library:
481
+
482
+ **CLI:**
483
+ ```bash
484
+ cat << 'EOF' | contextium new "<project-library-name>" -t "SWOT Analysis — [Project Name]" -p "01-swot.md" --stdin -w <workspace>
485
+ <generated SWOT content>
486
+ EOF
487
+ ```
488
+ **MCP:** call mcp__contextium__create_file with `libraryId` = the project library ID, `title` = "SWOT Analysis — [Project Name]", `path` = "01-swot.md", and the generated content.
489
+
490
+ Then apply the `type:business-analysis` tag to the file. Show `✓ Created SWOT analysis "01-swot.md"` when done. Suppress errors silently and note any failure in the summary.
491
+
492
+ **Market research (live web) → `02-market-research.md`**
493
+
494
+ Use live web search for current figures; cite sources inline. Structure:
495
+
496
+ ```markdown
497
+ # Market Research — [Project Name]
498
+
499
+ ## Market Size
500
+ - **TAM** (total addressable market): $X — [basis + source]
501
+ - **SAM** (serviceable addressable market): $X — [basis]
502
+ - **SOM** (realistic obtainable share, year 1–2): $X — [basis]
503
+
504
+ ## Trends & Demand Signals
505
+ 3–5 bullets on where the market is heading and evidence of real demand (search volume, funding flowing in, adoption data) — each with a source.
506
+
507
+ ## Target Segments
508
+ Who actually buys/uses this, ranked by attractiveness.
509
+
510
+ ## Takeaway
511
+ 2–3 sentences: is the prize big enough to be worth chasing?
512
+ ```
513
+ Write to the project library (`02-market-research.md`), tag `type:business-analysis`. Show `✓ Created market research "02-market-research.md"`.
514
+
515
+ **Competitor analysis (live web) → `03-competitor-analysis.md`**
516
+
517
+ Use live web search. For each named competitor include their **financials** — they directly inform how hard the market is to enter:
518
+
519
+ ```markdown
520
+ # Competitor Analysis — [Project Name]
521
+
522
+ ## Named Competitors
523
+ For each (aim for 4–8):
524
+ ### [Competitor]
525
+ - **What they do / positioning:**
526
+ - **Strengths:**
527
+ - **Weaknesses / gaps:**
528
+ - **Funding raised:** $X ([round], [source])
529
+ - **Revenue / ARR (if known):** $X ([source])
530
+ - **Valuation (if known):** $X ([source])
531
+
532
+ ## The Gap / Wedge
533
+ Where is the opening this idea could enter through? Be honest — if there's no obvious wedge, say so.
534
+
535
+ ## Takeaway
536
+ 2–3 sentences on how crowded and well-funded the field is.
537
+ ```
538
+ Write to `03-competitor-analysis.md`, tag `type:business-analysis`. Show `✓ Created competitor analysis "03-competitor-analysis.md"`.
539
+
540
+ **Build plan → `04-build-plan.md` + DB phases**
541
+
542
+ Break the idea into the natural unit of work for its type — software → development phases, a book → chapters, a campaign → workstreams, etc. (detect from the description). For each item: a title, a one-line description, and a rough effort sense (used by RICE and the timeline). Structure:
543
+
544
+ ```markdown
545
+ # Build Plan — [Project Name]
546
+
547
+ Unit type: [phases | chapters | workstreams | …]
548
+
549
+ 1. **[Item title]** — [one-line description] · effort: [S/M/L]
550
+ 2. …
551
+ ```
552
+ Write to `04-build-plan.md`, tag `type:business-analysis`. Then **also create each item as a DB phase** of THIS project's plan via `add_phase` (short title + one-line description only — keep RICE/timeline detail in the files, not the phase records). Show `✓ Created build plan "04-build-plan.md" (N phases)`.
553
+
554
+ **RICE scorecard → `05-rice-scorecard.md`**
555
+
556
+ Score every build-plan item. RICE = (Reach × Impact × Confidence) ÷ Effort. Use a table, sorted by score descending:
557
+
558
+ ```markdown
559
+ # RICE Scorecard — [Project Name]
560
+
561
+ > Scores the build-plan items by value vs effort. Reach (people/period), Impact (0.25–3), Confidence (50–100%), Effort (person-weeks or person-months — state the unit).
562
+
563
+ | Item | Reach | Impact | Confidence | Effort | RICE | Notes |
564
+ |------|-------|--------|------------|--------|------|-------|
565
+ | … | | | | | | |
566
+
567
+ ## What to do first
568
+ 2–3 sentences: which items the scores say to prioritise, and which to defer.
569
+ ```
570
+ Write to `05-rice-scorecard.md`, tag `type:business-analysis`. Show `✓ Created RICE scorecard "05-rice-scorecard.md"`.
571
+
572
+ **Timeline → `06-timeline.md`**
573
+
574
+ Turn the build plan + effort into a realistic schedule:
575
+
576
+ ```markdown
577
+ # Timeline — [Project Name]
578
+
579
+ | Phase/Item | Duration | Depends on | Milestone |
580
+ |------------|----------|------------|-----------|
581
+ | … | | | |
582
+
583
+ **Estimated time to first usable version:** [X weeks/months]
584
+ **Estimated time to full scope:** [X]
585
+
586
+ ## Assumptions
587
+ Team size and any assumptions the estimate rests on.
588
+ ```
589
+ Write to `06-timeline.md`, tag `type:business-analysis`. Show `✓ Created timeline "06-timeline.md"`.
590
+
591
+ **Roles → `07-roles.md`**
592
+
593
+ What roles/skills the project needs to actually ship — feeds the financials:
594
+
595
+ ```markdown
596
+ # Roles Needed — [Project Name]
597
+
598
+ For each role: what they do, when they're needed, and whether it can be a human hire, an AI agent, or both.
599
+
600
+ | Role | Responsibility | When | Human / AI / Both |
601
+ |------|----------------|------|-------------------|
602
+ | … | | | |
603
+
604
+ ## Minimum viable team
605
+ The smallest set of roles needed to ship the lean version.
606
+ ```
607
+ Write to `07-roles.md`, tag `type:business-analysis`. Show `✓ Created roles "07-roles.md"`.
608
+
609
+ **Two-tier financials → `08-financials.md`**
610
+
611
+ Two realistic scenarios. Cost the roles from `07-roles.md`, the hosting/tooling the build plan implies, and a monthly AI line. Use current, realistic figures (live web search for tool/infra/salary benchmarks where helpful).
612
+
613
+ ```markdown
614
+ # Financials — [Project Name]
615
+
616
+ ## Tier 1 — Lean MVP (minimum to build & ship)
617
+ | Line item | One-time | Monthly |
618
+ |-----------|----------|---------|
619
+ | Servers / hosting | | |
620
+ | Tools / licences | | |
621
+ | Labour — [role] (human hire) | | |
622
+ | Labour — [role] (done with AI) | | |
623
+ | AI usage (monthly) | | |
624
+ | … | | |
625
+ | **Totals** | **$X upfront** | **$Y/mo** |
626
+
627
+ ## Tier 2 — Production-grade (fully secure, scalable, no expense spared)
628
+ Same table shape — redundancy, security, scale, full team.
629
+ | **Totals** | **$X upfront** | **$Y/mo** |
630
+
631
+ ## Read
632
+ 2–3 sentences comparing the two: what the extra spend buys, and which fits the idea's stage.
633
+ ```
634
+ Write to `08-financials.md`, tag `type:business-analysis`. Show `✓ Created financials "08-financials.md"`.
635
+
636
+ **Verdict synthesis → `00-verdict.md` (generated LAST)**
637
+
638
+ The headline. Synthesise everything above into one page — this is what the user actually wants:
639
+
640
+ ```markdown
641
+ # Verdict — [Project Name]
642
+
643
+ ## Worth doing?
644
+ **[Go / Go with caveats / Reconsider]** — 2–3 reasons drawn from RICE, financials, and market.
645
+
646
+ ## Market entry difficulty: [N]/10
647
+ Why: saturation, how entrenched and well-funded the incumbents are (from competitor financials), and the barriers (capital, network effects, brand, regulation, switching costs).
648
+
649
+ ## What you're up against
650
+ The key competitors and the wedge you'd enter through — or an honest "no obvious wedge".
651
+
652
+ ## What it'll cost to find out
653
+ The lean-MVP number from the financials.
654
+
655
+ ## Bottom line
656
+ > Market is ~$X. Incumbents funded to ~$Y → difficulty N/10. Entry costs ~$Z lean / ~$W production. **Verdict: …**
657
+ ```
658
+ Write to `00-verdict.md`, tag `type:business-analysis`. Show `✓ Created verdict "00-verdict.md"`.
659
+
660
+ After the verdict, tell the user plainly: "I've written a full business analysis into your library — start with **00-verdict.md** for the go/no-go, then dig into the supporting documents." Do not paste the documents into chat; point to them.
661
+ </step>
662
+
663
+ <step name="feature_build_plan">
664
+ **Only runs when `track == "feature"`.** If `track == "idea"`, skip this step (the `business_analysis` step already produced the build plan, RICE, and timeline).
665
+
666
+ A feature inside an existing product doesn't need market/competitor/financial analysis — you're already in that market. It needs to answer "is this feature worth building vs. the other things on the list, and how long will it take?" Produce only three documents, as files in the project library tagged `type:business-analysis`, using the **same formats** defined in the `business_analysis` step:
667
+
668
+ 1. **Build plan → `04-build-plan.md`** (+ create each item as a DB phase via `add_phase`, short title + one-line description).
669
+ 2. **RICE scorecard → `05-rice-scorecard.md`** (scores the build-plan items — this is the core "worth it?" answer for a feature).
670
+ 3. **Timeline → `06-timeline.md`**.
671
+
672
+ Do NOT produce SWOT, market, competitor, financials, or a verdict. Show a `✓ Created …` line for each, then tell the user: "I've planned the build — see **04-build-plan.md**, with priorities in **05-rice-scorecard.md** and the schedule in **06-timeline.md**." Suppress errors silently.
673
+ </step>
674
+
395
675
  <step name="workflow_prompt">
676
+ **Dedicated workflow for ideas started in a container.** If `idea_container_workflow` is set (the user entered through an empty/idea-bucket workflow), do NOT extend that container. This idea gets its own dedicated workflow. Default the suggested workflow name to the idea/project name and tell the user plainly: "I'll give this idea its own workflow so its analysis and plan stay self-contained — your '<container name>' workflow stays as an index." After creating the dedicated workflow, optionally add a one-line pointer to the new idea in the container's library (an index entry: idea name + link to its library), if the container has a library. Do not move or copy the analysis docs into the container.
677
+
396
678
  After all other resources are created, ask the user:
397
679
 
398
680
  "Would you like me to create a workflow to bundle everything together for quick loading? If yes, what would you like to call it?"
@@ -401,6 +683,8 @@ Use AskUserQuestion with two options:
401
683
  - "Yes, create a workflow" (and ask for the name as a follow-up if they say yes)
402
684
  - "No, skip workflow"
403
685
 
686
+ (When `idea_container_workflow` is set, treat "yes" as the default and pre-fill the name with the idea/project name — creating the dedicated workflow is the recommended path, not reusing the container.)
687
+
404
688
  If they say yes and provide a name, create the workflow — **always pass all tracked resource IDs**:
405
689
 
406
690
  **CLI:**