synarcx 0.1.0

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 (288) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +90 -0
  3. package/bin/synarcx.js +3 -0
  4. package/dist/cli/index.d.ts +2 -0
  5. package/dist/cli/index.js +474 -0
  6. package/dist/commands/change.d.ts +35 -0
  7. package/dist/commands/change.js +278 -0
  8. package/dist/commands/completion.d.ts +72 -0
  9. package/dist/commands/completion.js +264 -0
  10. package/dist/commands/config.d.ts +36 -0
  11. package/dist/commands/config.js +552 -0
  12. package/dist/commands/feedback.d.ts +9 -0
  13. package/dist/commands/feedback.js +170 -0
  14. package/dist/commands/schema.d.ts +6 -0
  15. package/dist/commands/schema.js +870 -0
  16. package/dist/commands/show.d.ts +14 -0
  17. package/dist/commands/show.js +132 -0
  18. package/dist/commands/spec.d.ts +15 -0
  19. package/dist/commands/spec.js +226 -0
  20. package/dist/commands/validate.d.ts +24 -0
  21. package/dist/commands/validate.js +295 -0
  22. package/dist/commands/workflow/index.d.ts +17 -0
  23. package/dist/commands/workflow/index.js +12 -0
  24. package/dist/commands/workflow/instructions.d.ts +29 -0
  25. package/dist/commands/workflow/instructions.js +327 -0
  26. package/dist/commands/workflow/new-change.d.ts +11 -0
  27. package/dist/commands/workflow/new-change.js +45 -0
  28. package/dist/commands/workflow/schemas.d.ts +10 -0
  29. package/dist/commands/workflow/schemas.js +34 -0
  30. package/dist/commands/workflow/shared.d.ts +57 -0
  31. package/dist/commands/workflow/shared.js +117 -0
  32. package/dist/commands/workflow/status.d.ts +14 -0
  33. package/dist/commands/workflow/status.js +75 -0
  34. package/dist/commands/workflow/templates.d.ts +16 -0
  35. package/dist/commands/workflow/templates.js +69 -0
  36. package/dist/commands/workspace/open.d.ts +29 -0
  37. package/dist/commands/workspace/open.js +84 -0
  38. package/dist/commands/workspace/operations.d.ts +18 -0
  39. package/dist/commands/workspace/operations.js +461 -0
  40. package/dist/commands/workspace/selection.d.ts +5 -0
  41. package/dist/commands/workspace/selection.js +90 -0
  42. package/dist/commands/workspace/types.d.ts +83 -0
  43. package/dist/commands/workspace/types.js +36 -0
  44. package/dist/commands/workspace.d.ts +3 -0
  45. package/dist/commands/workspace.js +635 -0
  46. package/dist/core/archive.d.ts +11 -0
  47. package/dist/core/archive.js +319 -0
  48. package/dist/core/artifact-graph/graph.d.ts +56 -0
  49. package/dist/core/artifact-graph/graph.js +141 -0
  50. package/dist/core/artifact-graph/index.d.ts +8 -0
  51. package/dist/core/artifact-graph/index.js +14 -0
  52. package/dist/core/artifact-graph/instruction-loader.d.ts +143 -0
  53. package/dist/core/artifact-graph/instruction-loader.js +217 -0
  54. package/dist/core/artifact-graph/outputs.d.ts +14 -0
  55. package/dist/core/artifact-graph/outputs.js +39 -0
  56. package/dist/core/artifact-graph/resolver.d.ts +81 -0
  57. package/dist/core/artifact-graph/resolver.js +258 -0
  58. package/dist/core/artifact-graph/schema.d.ts +13 -0
  59. package/dist/core/artifact-graph/schema.js +108 -0
  60. package/dist/core/artifact-graph/state.d.ts +12 -0
  61. package/dist/core/artifact-graph/state.js +31 -0
  62. package/dist/core/artifact-graph/types.d.ts +45 -0
  63. package/dist/core/artifact-graph/types.js +43 -0
  64. package/dist/core/available-tools.d.ts +17 -0
  65. package/dist/core/available-tools.js +43 -0
  66. package/dist/core/command-generation/adapters/amazon-q.d.ts +13 -0
  67. package/dist/core/command-generation/adapters/amazon-q.js +26 -0
  68. package/dist/core/command-generation/adapters/antigravity.d.ts +13 -0
  69. package/dist/core/command-generation/adapters/antigravity.js +26 -0
  70. package/dist/core/command-generation/adapters/auggie.d.ts +13 -0
  71. package/dist/core/command-generation/adapters/auggie.js +27 -0
  72. package/dist/core/command-generation/adapters/bob.d.ts +14 -0
  73. package/dist/core/command-generation/adapters/bob.js +45 -0
  74. package/dist/core/command-generation/adapters/claude.d.ts +13 -0
  75. package/dist/core/command-generation/adapters/claude.js +50 -0
  76. package/dist/core/command-generation/adapters/cline.d.ts +14 -0
  77. package/dist/core/command-generation/adapters/cline.js +27 -0
  78. package/dist/core/command-generation/adapters/codebuddy.d.ts +13 -0
  79. package/dist/core/command-generation/adapters/codebuddy.js +28 -0
  80. package/dist/core/command-generation/adapters/codex.d.ts +16 -0
  81. package/dist/core/command-generation/adapters/codex.js +39 -0
  82. package/dist/core/command-generation/adapters/continue.d.ts +13 -0
  83. package/dist/core/command-generation/adapters/continue.js +28 -0
  84. package/dist/core/command-generation/adapters/costrict.d.ts +13 -0
  85. package/dist/core/command-generation/adapters/costrict.js +27 -0
  86. package/dist/core/command-generation/adapters/crush.d.ts +13 -0
  87. package/dist/core/command-generation/adapters/crush.js +30 -0
  88. package/dist/core/command-generation/adapters/cursor.d.ts +14 -0
  89. package/dist/core/command-generation/adapters/cursor.js +44 -0
  90. package/dist/core/command-generation/adapters/factory.d.ts +13 -0
  91. package/dist/core/command-generation/adapters/factory.js +27 -0
  92. package/dist/core/command-generation/adapters/gemini.d.ts +13 -0
  93. package/dist/core/command-generation/adapters/gemini.js +26 -0
  94. package/dist/core/command-generation/adapters/github-copilot.d.ts +13 -0
  95. package/dist/core/command-generation/adapters/github-copilot.js +26 -0
  96. package/dist/core/command-generation/adapters/iflow.d.ts +13 -0
  97. package/dist/core/command-generation/adapters/iflow.js +29 -0
  98. package/dist/core/command-generation/adapters/index.d.ts +32 -0
  99. package/dist/core/command-generation/adapters/index.js +32 -0
  100. package/dist/core/command-generation/adapters/junie.d.ts +13 -0
  101. package/dist/core/command-generation/adapters/junie.js +26 -0
  102. package/dist/core/command-generation/adapters/kilocode.d.ts +14 -0
  103. package/dist/core/command-generation/adapters/kilocode.js +23 -0
  104. package/dist/core/command-generation/adapters/kiro.d.ts +13 -0
  105. package/dist/core/command-generation/adapters/kiro.js +26 -0
  106. package/dist/core/command-generation/adapters/lingma.d.ts +13 -0
  107. package/dist/core/command-generation/adapters/lingma.js +30 -0
  108. package/dist/core/command-generation/adapters/opencode.d.ts +13 -0
  109. package/dist/core/command-generation/adapters/opencode.js +27 -0
  110. package/dist/core/command-generation/adapters/pi.d.ts +18 -0
  111. package/dist/core/command-generation/adapters/pi.js +55 -0
  112. package/dist/core/command-generation/adapters/qoder.d.ts +13 -0
  113. package/dist/core/command-generation/adapters/qoder.js +30 -0
  114. package/dist/core/command-generation/adapters/qwen.d.ts +13 -0
  115. package/dist/core/command-generation/adapters/qwen.js +26 -0
  116. package/dist/core/command-generation/adapters/roocode.d.ts +14 -0
  117. package/dist/core/command-generation/adapters/roocode.js +27 -0
  118. package/dist/core/command-generation/adapters/windsurf.d.ts +14 -0
  119. package/dist/core/command-generation/adapters/windsurf.js +51 -0
  120. package/dist/core/command-generation/generator.d.ts +21 -0
  121. package/dist/core/command-generation/generator.js +27 -0
  122. package/dist/core/command-generation/index.d.ts +22 -0
  123. package/dist/core/command-generation/index.js +24 -0
  124. package/dist/core/command-generation/registry.d.ts +36 -0
  125. package/dist/core/command-generation/registry.js +98 -0
  126. package/dist/core/command-generation/types.d.ts +56 -0
  127. package/dist/core/command-generation/types.js +8 -0
  128. package/dist/core/completions/command-registry.d.ts +7 -0
  129. package/dist/core/completions/command-registry.js +596 -0
  130. package/dist/core/completions/completion-provider.d.ts +71 -0
  131. package/dist/core/completions/completion-provider.js +129 -0
  132. package/dist/core/completions/factory.d.ts +64 -0
  133. package/dist/core/completions/factory.js +75 -0
  134. package/dist/core/completions/generators/bash-generator.d.ts +35 -0
  135. package/dist/core/completions/generators/bash-generator.js +230 -0
  136. package/dist/core/completions/generators/fish-generator.d.ts +32 -0
  137. package/dist/core/completions/generators/fish-generator.js +160 -0
  138. package/dist/core/completions/generators/powershell-generator.d.ts +36 -0
  139. package/dist/core/completions/generators/powershell-generator.js +266 -0
  140. package/dist/core/completions/generators/zsh-generator.d.ts +47 -0
  141. package/dist/core/completions/generators/zsh-generator.js +274 -0
  142. package/dist/core/completions/installers/bash-installer.d.ts +87 -0
  143. package/dist/core/completions/installers/bash-installer.js +318 -0
  144. package/dist/core/completions/installers/fish-installer.d.ts +43 -0
  145. package/dist/core/completions/installers/fish-installer.js +143 -0
  146. package/dist/core/completions/installers/powershell-installer.d.ts +102 -0
  147. package/dist/core/completions/installers/powershell-installer.js +387 -0
  148. package/dist/core/completions/installers/zsh-installer.d.ts +117 -0
  149. package/dist/core/completions/installers/zsh-installer.js +421 -0
  150. package/dist/core/completions/templates/bash-templates.d.ts +6 -0
  151. package/dist/core/completions/templates/bash-templates.js +30 -0
  152. package/dist/core/completions/templates/fish-templates.d.ts +7 -0
  153. package/dist/core/completions/templates/fish-templates.js +45 -0
  154. package/dist/core/completions/templates/powershell-templates.d.ts +6 -0
  155. package/dist/core/completions/templates/powershell-templates.js +34 -0
  156. package/dist/core/completions/templates/zsh-templates.d.ts +6 -0
  157. package/dist/core/completions/templates/zsh-templates.js +45 -0
  158. package/dist/core/completions/types.d.ts +101 -0
  159. package/dist/core/completions/types.js +2 -0
  160. package/dist/core/config-prompts.d.ts +9 -0
  161. package/dist/core/config-prompts.js +34 -0
  162. package/dist/core/config-schema.d.ts +86 -0
  163. package/dist/core/config-schema.js +213 -0
  164. package/dist/core/config.d.ts +19 -0
  165. package/dist/core/config.js +38 -0
  166. package/dist/core/converters/json-converter.d.ts +6 -0
  167. package/dist/core/converters/json-converter.js +51 -0
  168. package/dist/core/global-config.d.ts +49 -0
  169. package/dist/core/global-config.js +124 -0
  170. package/dist/core/index.d.ts +3 -0
  171. package/dist/core/index.js +4 -0
  172. package/dist/core/init.d.ts +37 -0
  173. package/dist/core/init.js +585 -0
  174. package/dist/core/legacy-cleanup.d.ts +169 -0
  175. package/dist/core/legacy-cleanup.js +578 -0
  176. package/dist/core/list.d.ts +9 -0
  177. package/dist/core/list.js +172 -0
  178. package/dist/core/migration.d.ts +23 -0
  179. package/dist/core/migration.js +108 -0
  180. package/dist/core/parsers/change-parser.d.ts +13 -0
  181. package/dist/core/parsers/change-parser.js +197 -0
  182. package/dist/core/parsers/markdown-parser.d.ts +26 -0
  183. package/dist/core/parsers/markdown-parser.js +227 -0
  184. package/dist/core/parsers/requirement-blocks.d.ts +37 -0
  185. package/dist/core/parsers/requirement-blocks.js +201 -0
  186. package/dist/core/parsers/spec-structure.d.ts +9 -0
  187. package/dist/core/parsers/spec-structure.js +88 -0
  188. package/dist/core/profile-sync-drift.d.ts +38 -0
  189. package/dist/core/profile-sync-drift.js +197 -0
  190. package/dist/core/profiles.d.ts +26 -0
  191. package/dist/core/profiles.js +37 -0
  192. package/dist/core/project-config.d.ts +64 -0
  193. package/dist/core/project-config.js +224 -0
  194. package/dist/core/schemas/base.schema.d.ts +13 -0
  195. package/dist/core/schemas/base.schema.js +13 -0
  196. package/dist/core/schemas/change.schema.d.ts +73 -0
  197. package/dist/core/schemas/change.schema.js +31 -0
  198. package/dist/core/schemas/index.d.ts +4 -0
  199. package/dist/core/schemas/index.js +4 -0
  200. package/dist/core/schemas/spec.schema.d.ts +18 -0
  201. package/dist/core/schemas/spec.schema.js +15 -0
  202. package/dist/core/shared/index.d.ts +8 -0
  203. package/dist/core/shared/index.js +8 -0
  204. package/dist/core/shared/skill-generation.d.ts +49 -0
  205. package/dist/core/shared/skill-generation.js +90 -0
  206. package/dist/core/shared/tool-detection.d.ts +71 -0
  207. package/dist/core/shared/tool-detection.js +152 -0
  208. package/dist/core/specs-apply.d.ts +73 -0
  209. package/dist/core/specs-apply.js +393 -0
  210. package/dist/core/styles/palette.d.ts +7 -0
  211. package/dist/core/styles/palette.js +8 -0
  212. package/dist/core/templates/index.d.ts +8 -0
  213. package/dist/core/templates/index.js +9 -0
  214. package/dist/core/templates/skill-templates.d.ts +15 -0
  215. package/dist/core/templates/skill-templates.js +14 -0
  216. package/dist/core/templates/types.d.ts +19 -0
  217. package/dist/core/templates/types.js +5 -0
  218. package/dist/core/templates/workflows/analyze.d.ts +4 -0
  219. package/dist/core/templates/workflows/analyze.js +101 -0
  220. package/dist/core/templates/workflows/apply-change.d.ts +10 -0
  221. package/dist/core/templates/workflows/apply-change.js +308 -0
  222. package/dist/core/templates/workflows/archive-change.d.ts +10 -0
  223. package/dist/core/templates/workflows/archive-change.js +271 -0
  224. package/dist/core/templates/workflows/clarify.d.ts +4 -0
  225. package/dist/core/templates/workflows/clarify.js +108 -0
  226. package/dist/core/templates/workflows/debug.d.ts +4 -0
  227. package/dist/core/templates/workflows/debug.js +117 -0
  228. package/dist/core/templates/workflows/explore.d.ts +10 -0
  229. package/dist/core/templates/workflows/explore.js +479 -0
  230. package/dist/core/templates/workflows/propose.d.ts +10 -0
  231. package/dist/core/templates/workflows/propose.js +216 -0
  232. package/dist/core/templates/workflows/sync.d.ts +4 -0
  233. package/dist/core/templates/workflows/sync.js +108 -0
  234. package/dist/core/update.d.ts +82 -0
  235. package/dist/core/update.js +555 -0
  236. package/dist/core/validation/constants.d.ts +34 -0
  237. package/dist/core/validation/constants.js +40 -0
  238. package/dist/core/validation/types.d.ts +18 -0
  239. package/dist/core/validation/types.js +2 -0
  240. package/dist/core/validation/validator.d.ts +33 -0
  241. package/dist/core/validation/validator.js +418 -0
  242. package/dist/core/view.d.ts +8 -0
  243. package/dist/core/view.js +169 -0
  244. package/dist/core/workspace/foundation.d.ts +79 -0
  245. package/dist/core/workspace/foundation.js +367 -0
  246. package/dist/core/workspace/index.d.ts +5 -0
  247. package/dist/core/workspace/index.js +5 -0
  248. package/dist/core/workspace/link-input.d.ts +9 -0
  249. package/dist/core/workspace/link-input.js +32 -0
  250. package/dist/core/workspace/open-surface.d.ts +24 -0
  251. package/dist/core/workspace/open-surface.js +137 -0
  252. package/dist/core/workspace/openers.d.ts +21 -0
  253. package/dist/core/workspace/openers.js +119 -0
  254. package/dist/index.d.ts +3 -0
  255. package/dist/index.js +3 -0
  256. package/dist/prompts/searchable-multi-select.d.ts +28 -0
  257. package/dist/prompts/searchable-multi-select.js +159 -0
  258. package/dist/ui/ascii-patterns.d.ts +25 -0
  259. package/dist/ui/ascii-patterns.js +140 -0
  260. package/dist/ui/welcome-screen.d.ts +10 -0
  261. package/dist/ui/welcome-screen.js +144 -0
  262. package/dist/utils/change-metadata.d.ts +51 -0
  263. package/dist/utils/change-metadata.js +147 -0
  264. package/dist/utils/change-utils.d.ts +62 -0
  265. package/dist/utils/change-utils.js +122 -0
  266. package/dist/utils/command-references.d.ts +18 -0
  267. package/dist/utils/command-references.js +20 -0
  268. package/dist/utils/file-system.d.ts +41 -0
  269. package/dist/utils/file-system.js +301 -0
  270. package/dist/utils/index.d.ts +6 -0
  271. package/dist/utils/index.js +9 -0
  272. package/dist/utils/interactive.d.ts +18 -0
  273. package/dist/utils/interactive.js +21 -0
  274. package/dist/utils/item-discovery.d.ts +4 -0
  275. package/dist/utils/item-discovery.js +73 -0
  276. package/dist/utils/match.d.ts +3 -0
  277. package/dist/utils/match.js +22 -0
  278. package/dist/utils/shell-detection.d.ts +20 -0
  279. package/dist/utils/shell-detection.js +41 -0
  280. package/dist/utils/task-progress.d.ts +8 -0
  281. package/dist/utils/task-progress.js +36 -0
  282. package/package.json +76 -0
  283. package/schemas/synarcx/schema.yaml +153 -0
  284. package/schemas/synarcx/templates/design.md +19 -0
  285. package/schemas/synarcx/templates/proposal.md +23 -0
  286. package/schemas/synarcx/templates/spec.md +8 -0
  287. package/schemas/synarcx/templates/tasks.md +9 -0
  288. package/scripts/postinstall.js +83 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * New Change Command
3
+ *
4
+ * Creates a new change directory with optional description and schema.
5
+ */
6
+ export interface NewChangeOptions {
7
+ description?: string;
8
+ schema?: string;
9
+ }
10
+ export declare function newChangeCommand(name: string | undefined, options: NewChangeOptions): Promise<void>;
11
+ //# sourceMappingURL=new-change.d.ts.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * New Change Command
3
+ *
4
+ * Creates a new change directory with optional description and schema.
5
+ */
6
+ import ora from 'ora';
7
+ import path from 'path';
8
+ import { createChange, validateChangeName } from '../../utils/change-utils.js';
9
+ import { validateSchemaExists } from './shared.js';
10
+ import { SYNSPEC_DIR_NAME } from '../../core/config.js';
11
+ // -----------------------------------------------------------------------------
12
+ // Command Implementation
13
+ // -----------------------------------------------------------------------------
14
+ export async function newChangeCommand(name, options) {
15
+ if (!name) {
16
+ throw new Error('Missing required argument <name>');
17
+ }
18
+ const validation = validateChangeName(name);
19
+ if (!validation.valid) {
20
+ throw new Error(validation.error);
21
+ }
22
+ const projectRoot = process.cwd();
23
+ // Validate schema if provided
24
+ if (options.schema) {
25
+ validateSchemaExists(options.schema, projectRoot);
26
+ }
27
+ const schemaDisplay = options.schema ? ` with schema '${options.schema}'` : '';
28
+ const spinner = ora(`Creating change '${name}'${schemaDisplay}...`).start();
29
+ try {
30
+ const result = await createChange(projectRoot, name, { schema: options.schema });
31
+ // If description provided, create README.md with description
32
+ if (options.description) {
33
+ const { promises: fs } = await import('fs');
34
+ const changeDir = path.join(projectRoot, SYNSPEC_DIR_NAME, 'changes', name);
35
+ const readmePath = path.join(changeDir, 'README.md');
36
+ await fs.writeFile(readmePath, `# ${name}\n\n${options.description}\n`, 'utf-8');
37
+ }
38
+ spinner.succeed(`Created change '${name}' at synspec/changes/${name}/ (schema: ${result.schema})`);
39
+ }
40
+ catch (error) {
41
+ spinner.fail(`Failed to create change '${name}'`);
42
+ throw error;
43
+ }
44
+ }
45
+ //# sourceMappingURL=new-change.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Schemas Command
3
+ *
4
+ * Lists available workflow schemas with descriptions.
5
+ */
6
+ export interface SchemasOptions {
7
+ json?: boolean;
8
+ }
9
+ export declare function schemasCommand(options: SchemasOptions): Promise<void>;
10
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Schemas Command
3
+ *
4
+ * Lists available workflow schemas with descriptions.
5
+ */
6
+ import chalk from 'chalk';
7
+ import { listSchemasWithInfo } from '../../core/artifact-graph/index.js';
8
+ // -----------------------------------------------------------------------------
9
+ // Command Implementation
10
+ // -----------------------------------------------------------------------------
11
+ export async function schemasCommand(options) {
12
+ const projectRoot = process.cwd();
13
+ const schemas = listSchemasWithInfo(projectRoot);
14
+ if (options.json) {
15
+ console.log(JSON.stringify(schemas, null, 2));
16
+ return;
17
+ }
18
+ console.log('Available schemas:');
19
+ console.log();
20
+ for (const schema of schemas) {
21
+ let sourceLabel = '';
22
+ if (schema.source === 'project') {
23
+ sourceLabel = chalk.cyan(' (project)');
24
+ }
25
+ else if (schema.source === 'user') {
26
+ sourceLabel = chalk.dim(' (user override)');
27
+ }
28
+ console.log(` ${chalk.bold(schema.name)}${sourceLabel}`);
29
+ console.log(` ${schema.description}`);
30
+ console.log(` Artifacts: ${schema.artifacts.join(' → ')}`);
31
+ console.log();
32
+ }
33
+ }
34
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Shared Types and Utilities for Artifact Workflow Commands
3
+ *
4
+ * This module contains types, constants, and validation helpers used across
5
+ * multiple artifact workflow commands.
6
+ */
7
+ export interface TaskItem {
8
+ id: string;
9
+ description: string;
10
+ done: boolean;
11
+ }
12
+ export interface ApplyInstructions {
13
+ changeName: string;
14
+ changeDir: string;
15
+ schemaName: string;
16
+ contextFiles: Record<string, string[]>;
17
+ progress: {
18
+ total: number;
19
+ complete: number;
20
+ remaining: number;
21
+ };
22
+ tasks: TaskItem[];
23
+ state: 'blocked' | 'all_done' | 'ready';
24
+ missingArtifacts?: string[];
25
+ instruction: string;
26
+ }
27
+ export declare const DEFAULT_SCHEMA = "synarcx";
28
+ /**
29
+ * Checks if color output is disabled via NO_COLOR env or --no-color flag.
30
+ */
31
+ export declare function isColorDisabled(): boolean;
32
+ /**
33
+ * Gets the color function based on status.
34
+ */
35
+ export declare function getStatusColor(status: 'done' | 'ready' | 'blocked'): (text: string) => string;
36
+ /**
37
+ * Gets the status indicator for an artifact.
38
+ */
39
+ export declare function getStatusIndicator(status: 'done' | 'ready' | 'blocked'): string;
40
+ /**
41
+ * Returns the list of available change directory names under synspec/changes/.
42
+ * Excludes the archive directory and hidden directories.
43
+ */
44
+ export declare function getAvailableChanges(projectRoot: string): Promise<string[]>;
45
+ /**
46
+ * Validates that a change exists and returns available changes if not.
47
+ * Checks directory existence directly to support scaffolded changes (without proposal.md).
48
+ */
49
+ export declare function validateChangeExists(changeName: string | undefined, projectRoot: string): Promise<string>;
50
+ /**
51
+ * Validates that a schema exists and returns available schemas if not.
52
+ *
53
+ * @param schemaName - The schema name to validate
54
+ * @param projectRoot - Optional project root for project-local schema resolution
55
+ */
56
+ export declare function validateSchemaExists(schemaName: string, projectRoot?: string): string;
57
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Shared Types and Utilities for Artifact Workflow Commands
3
+ *
4
+ * This module contains types, constants, and validation helpers used across
5
+ * multiple artifact workflow commands.
6
+ */
7
+ import chalk from 'chalk';
8
+ import path from 'path';
9
+ import * as fs from 'fs';
10
+ import { getSchemaDir, listSchemas } from '../../core/artifact-graph/index.js';
11
+ import { validateChangeName } from '../../utils/change-utils.js';
12
+ import { SYNSPEC_DIR_NAME } from '../../core/config.js';
13
+ // -----------------------------------------------------------------------------
14
+ // Constants
15
+ // -----------------------------------------------------------------------------
16
+ export const DEFAULT_SCHEMA = 'synarcx';
17
+ // -----------------------------------------------------------------------------
18
+ // Utility Functions
19
+ // -----------------------------------------------------------------------------
20
+ /**
21
+ * Checks if color output is disabled via NO_COLOR env or --no-color flag.
22
+ */
23
+ export function isColorDisabled() {
24
+ return process.env.NO_COLOR === '1' || process.env.NO_COLOR === 'true';
25
+ }
26
+ /**
27
+ * Gets the color function based on status.
28
+ */
29
+ export function getStatusColor(status) {
30
+ if (isColorDisabled()) {
31
+ return (text) => text;
32
+ }
33
+ switch (status) {
34
+ case 'done':
35
+ return chalk.green;
36
+ case 'ready':
37
+ return chalk.yellow;
38
+ case 'blocked':
39
+ return chalk.red;
40
+ }
41
+ }
42
+ /**
43
+ * Gets the status indicator for an artifact.
44
+ */
45
+ export function getStatusIndicator(status) {
46
+ const color = getStatusColor(status);
47
+ switch (status) {
48
+ case 'done':
49
+ return color('[x]');
50
+ case 'ready':
51
+ return color('[ ]');
52
+ case 'blocked':
53
+ return color('[-]');
54
+ }
55
+ }
56
+ /**
57
+ * Returns the list of available change directory names under synspec/changes/.
58
+ * Excludes the archive directory and hidden directories.
59
+ */
60
+ export async function getAvailableChanges(projectRoot) {
61
+ const changesPath = path.join(projectRoot, SYNSPEC_DIR_NAME, 'changes');
62
+ try {
63
+ const entries = await fs.promises.readdir(changesPath, { withFileTypes: true });
64
+ return entries
65
+ .filter((e) => e.isDirectory() && e.name !== 'archive' && !e.name.startsWith('.'))
66
+ .map((e) => e.name);
67
+ }
68
+ catch (error) {
69
+ if (error.code === 'ENOENT')
70
+ return [];
71
+ throw error;
72
+ }
73
+ }
74
+ /**
75
+ * Validates that a change exists and returns available changes if not.
76
+ * Checks directory existence directly to support scaffolded changes (without proposal.md).
77
+ */
78
+ export async function validateChangeExists(changeName, projectRoot) {
79
+ if (!changeName) {
80
+ const available = await getAvailableChanges(projectRoot);
81
+ if (available.length === 0) {
82
+ throw new Error('No changes found. Create one with: synarcx new change <name>');
83
+ }
84
+ throw new Error(`Missing required option --change. Available changes:\n ${available.join('\n ')}`);
85
+ }
86
+ // Validate change name format to prevent path traversal
87
+ const nameValidation = validateChangeName(changeName);
88
+ if (!nameValidation.valid) {
89
+ throw new Error(`Invalid change name '${changeName}': ${nameValidation.error}`);
90
+ }
91
+ // Check directory existence directly
92
+ const changePath = path.join(projectRoot, SYNSPEC_DIR_NAME, 'changes', changeName);
93
+ const exists = fs.existsSync(changePath) && fs.statSync(changePath).isDirectory();
94
+ if (!exists) {
95
+ const available = await getAvailableChanges(projectRoot);
96
+ if (available.length === 0) {
97
+ throw new Error(`Change '${changeName}' not found. No changes exist. Create one with: synarcx new change <name>`);
98
+ }
99
+ throw new Error(`Change '${changeName}' not found. Available changes:\n ${available.join('\n ')}`);
100
+ }
101
+ return changeName;
102
+ }
103
+ /**
104
+ * Validates that a schema exists and returns available schemas if not.
105
+ *
106
+ * @param schemaName - The schema name to validate
107
+ * @param projectRoot - Optional project root for project-local schema resolution
108
+ */
109
+ export function validateSchemaExists(schemaName, projectRoot) {
110
+ const schemaDir = getSchemaDir(schemaName, projectRoot);
111
+ if (!schemaDir) {
112
+ const availableSchemas = listSchemas(projectRoot);
113
+ throw new Error(`Schema '${schemaName}' not found. Available schemas:\n ${availableSchemas.join('\n ')}`);
114
+ }
115
+ return schemaName;
116
+ }
117
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Status Command
3
+ *
4
+ * Displays artifact completion status for a change.
5
+ */
6
+ import { type ChangeStatus } from '../../core/artifact-graph/index.js';
7
+ export interface StatusOptions {
8
+ change?: string;
9
+ schema?: string;
10
+ json?: boolean;
11
+ }
12
+ export declare function statusCommand(options: StatusOptions): Promise<void>;
13
+ export declare function printStatusText(status: ChangeStatus): void;
14
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Status Command
3
+ *
4
+ * Displays artifact completion status for a change.
5
+ */
6
+ import ora from 'ora';
7
+ import chalk from 'chalk';
8
+ import { loadChangeContext, formatChangeStatus, } from '../../core/artifact-graph/index.js';
9
+ import { validateChangeExists, validateSchemaExists, getAvailableChanges, getStatusIndicator, getStatusColor, } from './shared.js';
10
+ // -----------------------------------------------------------------------------
11
+ // Command Implementation
12
+ // -----------------------------------------------------------------------------
13
+ export async function statusCommand(options) {
14
+ const spinner = options.json ? undefined : ora('Loading change status...').start();
15
+ try {
16
+ const projectRoot = process.cwd();
17
+ // Handle no-changes case gracefully — status is informational,
18
+ // so "no changes" is a valid state, not an error.
19
+ if (!options.change) {
20
+ const available = await getAvailableChanges(projectRoot);
21
+ if (available.length === 0) {
22
+ spinner?.stop();
23
+ if (options.json) {
24
+ console.log(JSON.stringify({ changes: [], message: 'No active changes.' }, null, 2));
25
+ return;
26
+ }
27
+ console.log('No active changes. Create one with: synarcx new change <name>');
28
+ return;
29
+ }
30
+ // Changes exist but --change not provided
31
+ spinner?.stop();
32
+ throw new Error(`Missing required option --change. Available changes:\n ${available.join('\n ')}`);
33
+ }
34
+ const changeName = await validateChangeExists(options.change, projectRoot);
35
+ // Validate schema if explicitly provided
36
+ if (options.schema) {
37
+ validateSchemaExists(options.schema, projectRoot);
38
+ }
39
+ // loadChangeContext will auto-detect schema from metadata if not provided
40
+ const context = loadChangeContext(projectRoot, changeName, options.schema);
41
+ const status = formatChangeStatus(context);
42
+ spinner?.stop();
43
+ if (options.json) {
44
+ console.log(JSON.stringify(status, null, 2));
45
+ return;
46
+ }
47
+ printStatusText(status);
48
+ }
49
+ catch (error) {
50
+ spinner?.stop();
51
+ throw error;
52
+ }
53
+ }
54
+ export function printStatusText(status) {
55
+ const doneCount = status.artifacts.filter((a) => a.status === 'done').length;
56
+ const total = status.artifacts.length;
57
+ console.log(`Change: ${status.changeName}`);
58
+ console.log(`Schema: ${status.schemaName}`);
59
+ console.log(`Progress: ${doneCount}/${total} artifacts complete`);
60
+ console.log();
61
+ for (const artifact of status.artifacts) {
62
+ const indicator = getStatusIndicator(artifact.status);
63
+ const color = getStatusColor(artifact.status);
64
+ let line = `${indicator} ${artifact.id}`;
65
+ if (artifact.status === 'blocked' && artifact.missingDeps && artifact.missingDeps.length > 0) {
66
+ line += color(` (blocked by: ${artifact.missingDeps.join(', ')})`);
67
+ }
68
+ console.log(line);
69
+ }
70
+ if (status.isComplete) {
71
+ console.log();
72
+ console.log(chalk.green('All artifacts complete!'));
73
+ }
74
+ }
75
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Templates Command
3
+ *
4
+ * Shows resolved template paths for all artifacts in a schema.
5
+ */
6
+ export interface TemplatesOptions {
7
+ schema?: string;
8
+ json?: boolean;
9
+ }
10
+ export interface TemplateInfo {
11
+ artifactId: string;
12
+ templatePath: string;
13
+ source: 'project' | 'user' | 'package';
14
+ }
15
+ export declare function templatesCommand(options: TemplatesOptions): Promise<void>;
16
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Templates Command
3
+ *
4
+ * Shows resolved template paths for all artifacts in a schema.
5
+ */
6
+ import ora from 'ora';
7
+ import path from 'path';
8
+ import { resolveSchema, getSchemaDir, ArtifactGraph, } from '../../core/artifact-graph/index.js';
9
+ import { FileSystemUtils } from '../../utils/file-system.js';
10
+ import { validateSchemaExists, DEFAULT_SCHEMA } from './shared.js';
11
+ // -----------------------------------------------------------------------------
12
+ // Command Implementation
13
+ // -----------------------------------------------------------------------------
14
+ export async function templatesCommand(options) {
15
+ const spinner = options.json ? undefined : ora('Loading templates...').start();
16
+ try {
17
+ const projectRoot = process.cwd();
18
+ const schemaName = validateSchemaExists(options.schema ?? DEFAULT_SCHEMA, projectRoot);
19
+ const schema = resolveSchema(schemaName, projectRoot);
20
+ const graph = ArtifactGraph.fromSchema(schema);
21
+ const schemaDir = getSchemaDir(schemaName, projectRoot);
22
+ // Determine the source (project, user, or package)
23
+ const { getUserSchemasDir, getProjectSchemasDir, } = await import('../../core/artifact-graph/resolver.js');
24
+ const projectSchemasDir = getProjectSchemasDir(projectRoot);
25
+ const userSchemasDir = getUserSchemasDir();
26
+ // Determine source by checking if schemaDir is inside each base directory
27
+ // Using path.relative is more robust than startsWith for path comparisons
28
+ const isInsideDir = (child, parent) => {
29
+ const relative = path.relative(parent, child);
30
+ return !relative.startsWith('..') && !path.isAbsolute(relative);
31
+ };
32
+ let source;
33
+ if (isInsideDir(schemaDir, projectSchemasDir)) {
34
+ source = 'project';
35
+ }
36
+ else if (isInsideDir(schemaDir, userSchemasDir)) {
37
+ source = 'user';
38
+ }
39
+ else {
40
+ source = 'package';
41
+ }
42
+ const templates = graph.getAllArtifacts().map((artifact) => ({
43
+ artifactId: artifact.id,
44
+ templatePath: FileSystemUtils.canonicalizeExistingPath(path.join(schemaDir, 'templates', artifact.template)),
45
+ source,
46
+ }));
47
+ spinner?.stop();
48
+ if (options.json) {
49
+ const output = {};
50
+ for (const t of templates) {
51
+ output[t.artifactId] = { path: t.templatePath, source: t.source };
52
+ }
53
+ console.log(JSON.stringify(output, null, 2));
54
+ return;
55
+ }
56
+ console.log(`Schema: ${schemaName}`);
57
+ console.log(`Source: ${source}`);
58
+ console.log();
59
+ for (const t of templates) {
60
+ console.log(`${t.artifactId}:`);
61
+ console.log(` ${t.templatePath}`);
62
+ }
63
+ }
64
+ catch (error) {
65
+ spinner?.stop();
66
+ throw error;
67
+ }
68
+ }
69
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1,29 @@
1
+ import { spawn as nodeSpawn } from 'node:child_process';
2
+ import { WorkspaceLocalState, WorkspacePreferredOpener, WorkspaceSharedState, resolveWorkspaceOpenLinks } from '../../core/workspace/index.js';
3
+ import { SelectedWorkspace } from './types.js';
4
+ export declare const WORKSPACE_OPEN_MINIMAL_PROMPT = "Open this synarcx workspace.";
5
+ export interface WorkspaceOpenState {
6
+ sharedState: WorkspaceSharedState;
7
+ localState: WorkspaceLocalState;
8
+ codeWorkspacePath: string;
9
+ }
10
+ export interface WorkspaceOpenLaunchCommand {
11
+ executable: string;
12
+ args: string[];
13
+ cwd: string;
14
+ openerLabel: string;
15
+ }
16
+ export type WorkspaceOpenSpawn = typeof nodeSpawn;
17
+ export interface WorkspaceOpenLaunchOptions {
18
+ spawn?: WorkspaceOpenSpawn;
19
+ isExecutableAvailable?: (executable: string) => boolean;
20
+ }
21
+ export declare function readWorkspaceOpenState(selected: SelectedWorkspace): Promise<WorkspaceOpenState>;
22
+ export declare function buildWorkspaceOpenLaunchCommand(opener: WorkspacePreferredOpener, workspaceRoot: string, codeWorkspacePath: string, linkedPaths: string[]): WorkspaceOpenLaunchCommand;
23
+ export declare function assertWorkspaceOpenerAvailable(opener: WorkspacePreferredOpener, codeWorkspacePath: string, isExecutableAvailable?: (executable: string) => boolean): void;
24
+ export declare function buildWorkspaceOpenCommandForState(opener: WorkspacePreferredOpener, workspaceRoot: string, state: WorkspaceOpenState): Promise<{
25
+ command: WorkspaceOpenLaunchCommand;
26
+ skipped: Awaited<ReturnType<typeof resolveWorkspaceOpenLinks>>['skipped'];
27
+ }>;
28
+ export declare function launchWorkspaceOpenCommand(command: WorkspaceOpenLaunchCommand, options?: WorkspaceOpenLaunchOptions): Promise<void>;
29
+ //# sourceMappingURL=open.d.ts.map
@@ -0,0 +1,84 @@
1
+ import { createRequire } from 'node:module';
2
+ import { getWorkspaceCodeWorkspacePath, getWorkspaceOpenerExecutable, getWorkspaceOpenerLabel, isWorkspaceExecutableAvailable, readWorkspaceLocalState, readWorkspaceSharedState, resolveWorkspaceOpenLinks, writeWorkspaceCodeWorkspaceFile, } from '../../core/workspace/index.js';
3
+ import { WorkspaceCliError, asErrorMessage } from './types.js';
4
+ export const WORKSPACE_OPEN_MINIMAL_PROMPT = 'Open this synarcx workspace.';
5
+ const require = createRequire(import.meta.url);
6
+ const spawn = require('cross-spawn');
7
+ export async function readWorkspaceOpenState(selected) {
8
+ const sharedState = await readWorkspaceSharedState(selected.root);
9
+ const localState = await readWorkspaceLocalState(selected.root);
10
+ return {
11
+ sharedState,
12
+ localState,
13
+ codeWorkspacePath: getWorkspaceCodeWorkspacePath(selected.root, sharedState.name),
14
+ };
15
+ }
16
+ export function buildWorkspaceOpenLaunchCommand(opener, workspaceRoot, codeWorkspacePath, linkedPaths) {
17
+ const executable = getWorkspaceOpenerExecutable(opener);
18
+ const openerLabel = getWorkspaceOpenerLabel(opener);
19
+ if (opener.kind === 'editor' || opener.id === 'github-copilot') {
20
+ return {
21
+ executable,
22
+ args: [codeWorkspacePath],
23
+ cwd: workspaceRoot,
24
+ openerLabel,
25
+ };
26
+ }
27
+ return {
28
+ executable,
29
+ args: [
30
+ ...linkedPaths.flatMap((linkedPath) => ['--add-dir', linkedPath]),
31
+ WORKSPACE_OPEN_MINIMAL_PROMPT,
32
+ ],
33
+ cwd: workspaceRoot,
34
+ openerLabel,
35
+ };
36
+ }
37
+ export function assertWorkspaceOpenerAvailable(opener, codeWorkspacePath, isExecutableAvailable = isWorkspaceExecutableAvailable) {
38
+ const executable = getWorkspaceOpenerExecutable(opener);
39
+ if (isExecutableAvailable(executable)) {
40
+ return;
41
+ }
42
+ const openerLabel = getWorkspaceOpenerLabel(opener);
43
+ const manualPath = executable === 'code'
44
+ ? ` You can open the workspace file manually: ${codeWorkspacePath}`
45
+ : '';
46
+ throw new WorkspaceCliError(`${openerLabel} requires '${executable}', but '${executable}' was not found on PATH.${manualPath}`, 'workspace_opener_unavailable', {
47
+ target: 'workspace.opener',
48
+ fix: `Install '${executable}' or choose another opener.`,
49
+ });
50
+ }
51
+ export async function buildWorkspaceOpenCommandForState(opener, workspaceRoot, state) {
52
+ const openLinks = await resolveWorkspaceOpenLinks(state.sharedState, state.localState);
53
+ await writeWorkspaceCodeWorkspaceFile(state.codeWorkspacePath, openLinks.links);
54
+ return {
55
+ command: buildWorkspaceOpenLaunchCommand(opener, workspaceRoot, state.codeWorkspacePath, openLinks.links.map((link) => link.path)),
56
+ skipped: openLinks.skipped,
57
+ };
58
+ }
59
+ export async function launchWorkspaceOpenCommand(command, options = {}) {
60
+ const spawnCommand = options.spawn ?? spawn;
61
+ await new Promise((resolve, reject) => {
62
+ const child = spawnCommand(command.executable, command.args, {
63
+ cwd: command.cwd,
64
+ stdio: 'inherit',
65
+ shell: false,
66
+ });
67
+ child.on('error', (error) => {
68
+ reject(new WorkspaceCliError(`Could not launch ${command.openerLabel}: ${asErrorMessage(error)}`, 'workspace_opener_launch_failed', {
69
+ target: 'workspace.opener',
70
+ }));
71
+ });
72
+ child.on('close', (code, signal) => {
73
+ if (code === 0) {
74
+ resolve();
75
+ return;
76
+ }
77
+ const reason = signal ? `signal ${signal}` : `exit code ${code}`;
78
+ reject(new WorkspaceCliError(`${command.openerLabel} exited with ${reason}.`, 'workspace_opener_launch_failed', {
79
+ target: 'workspace.opener',
80
+ }));
81
+ });
82
+ });
83
+ }
84
+ //# sourceMappingURL=open.js.map
@@ -0,0 +1,18 @@
1
+ import { WorkspacePreferredOpener, WorkspaceRegistryEntry, WorkspaceRegistryState } from '../../core/workspace/index.js';
2
+ import { SelectedWorkspace, WorkspaceLinkMutationPayload, WorkspaceListOutput, WorkspaceOutput, WorkspaceStatus } from './types.js';
3
+ export declare function readRegistry(): Promise<WorkspaceRegistryState>;
4
+ export declare function directoryExists(dirPath: string): Promise<boolean>;
5
+ export declare function resolveExistingDirectory(inputPath: string, cwd?: string): Promise<string>;
6
+ export declare function inferLinkName(absolutePath: string): string;
7
+ export declare function validateWorkspaceNameForSetup(name: string): string;
8
+ export declare function validateLinkNameForCommand(name: string): string;
9
+ export declare function createManagedWorkspace(name: string, links: Record<string, string>, preferredOpener?: WorkspacePreferredOpener): Promise<WorkspaceOutput>;
10
+ export declare function parseSetupLinks(linkInputs: string[] | undefined): Promise<Record<string, string>>;
11
+ export declare function loadWorkspaceForList(entry: WorkspaceRegistryEntry): Promise<WorkspaceListOutput>;
12
+ export declare function loadWorkspaceForDoctor(selected: SelectedWorkspace): Promise<{
13
+ workspace: WorkspaceOutput;
14
+ status: WorkspaceStatus[];
15
+ }>;
16
+ export declare function addWorkspaceLink(selected: SelectedWorkspace, nameOrPath: string, linkPath?: string): Promise<WorkspaceLinkMutationPayload>;
17
+ export declare function updateWorkspaceLink(selected: SelectedWorkspace, linkNameInput: string, linkPath: string): Promise<WorkspaceLinkMutationPayload>;
18
+ //# sourceMappingURL=operations.d.ts.map