@jalvarezsamayoa/factory 0.0.0-stage → 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.
@@ -0,0 +1,139 @@
1
+ import { describeInstall, installFactory } from "./install.js";
2
+ import { createWorkspace, describeWorkspace } from "./workspace.js";
3
+ export async function runFactoryAction(request) {
4
+ const directory = request.directory ?? process.cwd();
5
+ switch (request.action) {
6
+ case "help":
7
+ return HELP;
8
+ case "workspace": {
9
+ const workspace = await createWorkspace({
10
+ target: directory,
11
+ name: request.name,
12
+ force: request.force,
13
+ });
14
+ return describeWorkspace(workspace, directory);
15
+ }
16
+ case "init": {
17
+ const harnesses = resolveHarnesses(request.harness);
18
+ const results = await installFactory({
19
+ harnesses,
20
+ target: directory,
21
+ global: request.global,
22
+ force: request.force,
23
+ });
24
+ return [
25
+ describeInstall(results, request.global ? "your home directory" : directory),
26
+ "",
27
+ "Agents are discovered from files, so reload the harness if they do not appear immediately.",
28
+ ].join("\n");
29
+ }
30
+ }
31
+ }
32
+ export function parseFactoryArgs(input) {
33
+ const tokens = tokenize(input);
34
+ if (tokens[0] === "/factory" || tokens[0] === "factory") {
35
+ tokens.shift();
36
+ }
37
+ let action = "help";
38
+ let name;
39
+ let harness;
40
+ let global = false;
41
+ let force = false;
42
+ for (let index = 0; index < tokens.length; index += 1) {
43
+ const token = tokens[index];
44
+ if (token === undefined)
45
+ continue;
46
+ if (token === "--global" || token === "-g") {
47
+ global = true;
48
+ }
49
+ else if (token === "--force" || token === "-f") {
50
+ force = true;
51
+ }
52
+ else if (token === "--harness" || token === "-H") {
53
+ harness = asHarness(tokens[index + 1]);
54
+ index += 1;
55
+ }
56
+ else if (token === "help" || token === "workspace" || token === "init") {
57
+ action = token;
58
+ }
59
+ else if (!token.startsWith("-") && name === undefined) {
60
+ name = token;
61
+ }
62
+ }
63
+ if (action === "init" && harness === undefined && name !== undefined) {
64
+ const candidate = asHarness(name);
65
+ if (candidate) {
66
+ harness = candidate;
67
+ name = undefined;
68
+ }
69
+ }
70
+ else if (action === "help" && name !== undefined) {
71
+ // `/factory my-change` is a convenient shorthand for a workspace name.
72
+ action = "workspace";
73
+ }
74
+ return { action, name, harness, global, force };
75
+ }
76
+ export const HELP = `Factory — AI software development factory
77
+
78
+ Usage
79
+ /factory help
80
+ /factory workspace [name]
81
+ /factory init [harness] [--global] [--force]
82
+
83
+ Commands
84
+ help Show this help.
85
+ workspace [name] Create factory/workspaces/<name>/ with the brief, plan,
86
+ contract, review, bug, and state templates. Default: default.
87
+ init [harness] Install the factory agents, skill, and command files.
88
+ Harnesses: opencode, claude, antigravity, all.
89
+ Default: opencode. Use --global for the user config,
90
+ and --force to overwrite files you have edited.
91
+
92
+ Agents
93
+ contrarian Challenges assumptions and argues for a safer or simpler plan.
94
+ contractor Implements an approved plan and contract.
95
+ software-reviewer Reviews correctness, maintainability, tests, and regressions.
96
+ security-reviewer Reviews authn/authz, input handling, secrets, and dependencies.
97
+ bug-hunter Reproduces failures, finds root causes, and adds regression tests.
98
+
99
+ Skill
100
+ factory The phase-by-phase workflow that coordinates the agents.
101
+
102
+ Workspace layout
103
+ factory/workspaces/<name>/
104
+ brief.md Problem, goals, non-goals, constraints, success signals
105
+ plan.md Approach, alternatives, steps, risks, rollback, decisions
106
+ contract.md Deliverables, acceptance criteria, quality gates
107
+ reviews/ software.md and security.md
108
+ bugs/ Reproduction notes and failing tests
109
+ state.json Current phase
110
+
111
+ Setup
112
+ OpenCode: add "@jalvarezsamayoa/factory" to "plugins" in opencode.jsonc.
113
+ Claude: npx @jalvarezsamayoa/factory init claude
114
+ Antigravity: npx @jalvarezsamayoa/factory init antigravity
115
+
116
+ Run /factory workspace to start, then /factory help to review the workflow.
117
+ `;
118
+ function resolveHarnesses(value) {
119
+ if (value === undefined)
120
+ return ["opencode"];
121
+ if (value === "all")
122
+ return ["opencode", "claude", "antigravity"];
123
+ return [value];
124
+ }
125
+ function asHarness(value) {
126
+ if (value === "opencode" || value === "claude" || value === "antigravity" || value === "all") {
127
+ return value;
128
+ }
129
+ return undefined;
130
+ }
131
+ function tokenize(input) {
132
+ const tokens = [];
133
+ const pattern = /"([^"]*)"|'([^']*)'|(\S+)/g;
134
+ let match;
135
+ while ((match = pattern.exec(input)) !== null) {
136
+ tokens.push(match[1] ?? match[2] ?? match[3] ?? "");
137
+ }
138
+ return tokens;
139
+ }
@@ -0,0 +1,3 @@
1
+ import { Plugin } from "@opencode/plugin";
2
+ declare const _default: Plugin.Plugin;
3
+ export default _default;
package/dist/index.js ADDED
@@ -0,0 +1,140 @@
1
+ import { join } from "node:path";
2
+ import { Plugin, Skill } from "@opencode/plugin";
3
+ import { readText, SKILLS_DIR, splitFrontmatter, frontmatterValue } from "./content.js";
4
+ import { runFactoryAction, parseFactoryArgs } from "./factory.js";
5
+ import { installFactory } from "./install.js";
6
+ const factoryToolInput = {
7
+ type: "object",
8
+ properties: {
9
+ action: {
10
+ type: "string",
11
+ enum: ["help", "workspace", "init"],
12
+ description: "The factory control action to run.",
13
+ },
14
+ name: {
15
+ type: "string",
16
+ description: "Workspace name for `workspace`. Defaults to `default`.",
17
+ },
18
+ harness: {
19
+ type: "string",
20
+ enum: ["opencode", "claude", "antigravity", "all"],
21
+ description: "Harness to install content for when action is `init`.",
22
+ },
23
+ global: {
24
+ type: "boolean",
25
+ description: "Install into the user home config instead of the project.",
26
+ },
27
+ force: {
28
+ type: "boolean",
29
+ description: "Overwrite files the user may have edited.",
30
+ },
31
+ },
32
+ required: ["action"],
33
+ additionalProperties: false,
34
+ };
35
+ export default Plugin.define({
36
+ id: "jalvarezsamayoa.factory",
37
+ async setup(ctx) {
38
+ const directory = ctx.location.project?.canonical ?? ctx.location.directory;
39
+ const skillDirectory = join(SKILLS_DIR, "factory");
40
+ const skillFile = join(skillDirectory, "SKILL.md");
41
+ const { frontmatter, body } = splitFrontmatter(await readText(skillFile));
42
+ const bugHuntingDir = join(SKILLS_DIR, "bug-hunting");
43
+ const bugHuntingFile = join(bugHuntingDir, "SKILL.md");
44
+ const bugHuntingContent = splitFrontmatter(await readText(bugHuntingFile));
45
+ const fieldNotesDir = join(SKILLS_DIR, "field-notes");
46
+ const fieldNotesFile = join(fieldNotesDir, "SKILL.md");
47
+ const fieldNotesContent = splitFrontmatter(await readText(fieldNotesFile));
48
+ const scratchFilesDir = join(SKILLS_DIR, "scratch-files");
49
+ const scratchFilesFile = join(scratchFilesDir, "SKILL.md");
50
+ const scratchFilesContent = splitFrontmatter(await readText(scratchFilesFile));
51
+ const worklogDir = join(SKILLS_DIR, "worklog");
52
+ const worklogFile = join(worklogDir, "SKILL.md");
53
+ const worklogContent = splitFrontmatter(await readText(worklogFile));
54
+ await ctx.skill.transform((editor) => {
55
+ editor.add({
56
+ id: Skill.ID.make("factory"),
57
+ name: Skill.Name.make(frontmatterValue(frontmatter, "name") ?? "factory"),
58
+ description: frontmatterValue(frontmatter, "description") ??
59
+ "Run the software development factory workflow from intake to ship.",
60
+ path: Skill.Info.fields.path.make(skillDirectory),
61
+ content: body,
62
+ });
63
+ editor.add({
64
+ id: Skill.ID.make("bug-hunting"),
65
+ name: Skill.Name.make(frontmatterValue(bugHuntingContent.frontmatter, "name") ?? "bug-hunting"),
66
+ description: frontmatterValue(bugHuntingContent.frontmatter, "description") ??
67
+ "Hunt for bugs in a codebase using empirical, execution-backed verification.",
68
+ path: Skill.Info.fields.path.make(bugHuntingDir),
69
+ content: bugHuntingContent.body,
70
+ });
71
+ editor.add({
72
+ id: Skill.ID.make("field-notes"),
73
+ name: Skill.Name.make(frontmatterValue(fieldNotesContent.frontmatter, "name") ?? "field-notes"),
74
+ description: frontmatterValue(fieldNotesContent.frontmatter, "description") ??
75
+ "Loads the read-before-planning and write-on-failure protocol for project field notes.",
76
+ path: Skill.Info.fields.path.make(fieldNotesDir),
77
+ content: fieldNotesContent.body,
78
+ });
79
+ editor.add({
80
+ id: Skill.ID.make("scratch-files"),
81
+ name: Skill.Name.make(frontmatterValue(scratchFilesContent.frontmatter, "name") ?? "scratch-files"),
82
+ description: frontmatterValue(scratchFilesContent.frontmatter, "description") ??
83
+ "Isolated, exploratory workspace for writing notes, drafting ideas, and visualizing designs.",
84
+ path: Skill.Info.fields.path.make(scratchFilesDir),
85
+ content: scratchFilesContent.body,
86
+ });
87
+ editor.add({
88
+ id: Skill.ID.make("worklog"),
89
+ name: Skill.Name.make(frontmatterValue(worklogContent.frontmatter, "name") ?? "worklog"),
90
+ description: frontmatterValue(worklogContent.frontmatter, "description") ??
91
+ "Coordinate work, personal todos, topic backlogs, and Jira tickets through worklog.org.",
92
+ path: Skill.Info.fields.path.make(worklogDir),
93
+ content: worklogContent.body,
94
+ });
95
+ });
96
+ await ctx.command.transform((editor) => {
97
+ editor.add({
98
+ name: "factory",
99
+ description: "Factory control plane: help, workspace, init",
100
+ execute: async ({ sessionID, prompt }) => {
101
+ const result = await runFactoryAction({
102
+ ...parseFactoryArgs(prompt.text),
103
+ directory,
104
+ });
105
+ await ctx.session.synthetic({ sessionID, text: result });
106
+ },
107
+ });
108
+ });
109
+ await ctx.tool.transform((editor) => {
110
+ editor.add({
111
+ name: "factory",
112
+ description: "Run factory control actions: show help, create a factory workspace, or install the factory agents and skill files.",
113
+ input: factoryToolInput,
114
+ execute: async (input) => {
115
+ const request = input;
116
+ const result = await runFactoryAction({
117
+ action: request.action ?? "help",
118
+ name: request.name,
119
+ harness: request.harness,
120
+ global: request.global,
121
+ force: request.force,
122
+ directory,
123
+ });
124
+ return { content: result };
125
+ },
126
+ });
127
+ });
128
+ const installAgents = ctx.options.installAgents;
129
+ if (installAgents === true || installAgents === "project" || installAgents === "global") {
130
+ await installFactory({
131
+ harnesses: ["opencode"],
132
+ target: directory,
133
+ global: installAgents === "global",
134
+ force: false,
135
+ kinds: ["agents"],
136
+ });
137
+ await ctx.agent.reload().catch(() => undefined);
138
+ }
139
+ },
140
+ });
@@ -0,0 +1,47 @@
1
+ export type Harness = "opencode" | "claude" | "antigravity";
2
+ export type InstallKind = "agents" | "skills" | "commands" | "rules" | "plugin";
3
+ export type WriteStatus = "created" | "updated" | "unchanged" | "skipped";
4
+ export interface HarnessPaths {
5
+ agents?: string;
6
+ skills: string;
7
+ commands?: string;
8
+ rules?: string;
9
+ plugin?: string;
10
+ }
11
+ export interface HarnessTargets {
12
+ project: HarnessPaths;
13
+ global: HarnessPaths;
14
+ }
15
+ /**
16
+ * Discovery locations documented by each harness.
17
+ *
18
+ * - OpenCode: `.opencode/{agents,skills,commands}` and `~/.config/opencode/...`
19
+ * - Claude Code: `.claude/{agents,skills,commands}` and `~/.claude/...`
20
+ * - Antigravity: `.agents/skills/`, `.agents/rules/`, and `.agents/plugins/factory`
21
+ * (or `~/.gemini/config/...` for global).
22
+ * Antigravity discovers skills under `skills/`, contextual rules under `rules/AGENTS.md`,
23
+ * or bundled as a full plugin with `plugin.json`.
24
+ */
25
+ export declare const HARNESSES: Record<Harness, HarnessTargets>;
26
+ export interface InstallOptions {
27
+ harnesses: Harness[];
28
+ /** Project directory. Ignored when `global` is true. */
29
+ target?: string;
30
+ /** Install into the user's home directory instead of the project. */
31
+ global?: boolean;
32
+ /** Overwrite files the user may have edited. */
33
+ force?: boolean;
34
+ /** Defaults to all kinds the harness supports. */
35
+ kinds?: InstallKind[];
36
+ /** Package content root. Defaults to the real package root. */
37
+ sourceRoot?: string;
38
+ }
39
+ export interface InstallResult {
40
+ harness: Harness;
41
+ kind: InstallKind;
42
+ source: string;
43
+ target: string;
44
+ status: WriteStatus;
45
+ }
46
+ export declare function installFactory(options: InstallOptions): Promise<InstallResult[]>;
47
+ export declare function describeInstall(results: InstallResult[], target: string): string;
@@ -0,0 +1,198 @@
1
+ import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
2
+ import { homedir } from "node:os";
3
+ import { dirname, join, relative, resolve } from "node:path";
4
+ import { AGENTS_DIR } from "./content.js";
5
+ /**
6
+ * Discovery locations documented by each harness.
7
+ *
8
+ * - OpenCode: `.opencode/{agents,skills,commands}` and `~/.config/opencode/...`
9
+ * - Claude Code: `.claude/{agents,skills,commands}` and `~/.claude/...`
10
+ * - Antigravity: `.agents/skills/`, `.agents/rules/`, and `.agents/plugins/factory`
11
+ * (or `~/.gemini/config/...` for global).
12
+ * Antigravity discovers skills under `skills/`, contextual rules under `rules/AGENTS.md`,
13
+ * or bundled as a full plugin with `plugin.json`.
14
+ */
15
+ export const HARNESSES = {
16
+ opencode: {
17
+ project: {
18
+ agents: ".opencode/agents",
19
+ skills: ".opencode/skills",
20
+ commands: ".opencode/commands",
21
+ },
22
+ global: {
23
+ agents: ".config/opencode/agents",
24
+ skills: ".config/opencode/skills",
25
+ commands: ".config/opencode/commands",
26
+ },
27
+ },
28
+ claude: {
29
+ project: {
30
+ agents: ".claude/agents",
31
+ skills: ".claude/skills",
32
+ commands: ".claude/commands",
33
+ },
34
+ global: {
35
+ agents: ".claude/agents",
36
+ skills: ".claude/skills",
37
+ commands: ".claude/commands",
38
+ },
39
+ },
40
+ antigravity: {
41
+ project: {
42
+ skills: ".agents/skills",
43
+ rules: ".agents/rules",
44
+ plugin: ".agents/plugins/factory",
45
+ },
46
+ global: {
47
+ skills: ".gemini/config/skills",
48
+ rules: ".gemini/config/rules",
49
+ plugin: ".gemini/config/plugins/factory",
50
+ },
51
+ },
52
+ };
53
+ export async function installFactory(options) {
54
+ const sourceRoot = options.sourceRoot ?? resolve(AGENTS_DIR, "..");
55
+ const target = options.global ? homedir() : (options.target ?? process.cwd());
56
+ const kinds = options.kinds ?? ["agents", "skills", "commands", "rules", "plugin"];
57
+ const results = [];
58
+ for (const harness of options.harnesses) {
59
+ const paths = options.global ? HARNESSES[harness].global : HARNESSES[harness].project;
60
+ if (harness === "antigravity") {
61
+ if (kinds.includes("plugin") && paths.plugin) {
62
+ // Install complete Antigravity plugin bundle:
63
+ // plugin.json, skills/factory/SKILL.md, rules/AGENTS.md
64
+ const pluginJsonContent = JSON.stringify({
65
+ name: "factory",
66
+ description: "Factory workflow, subagents, and tools for AI-driven software development",
67
+ version: "0.1.0",
68
+ }, null, 2) + "\n";
69
+ results.push(await writeContentResult(harness, "plugin", "plugin.json", join(target, paths.plugin, "plugin.json"), pluginJsonContent, options.force === true));
70
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "factory"), join(target, paths.plugin, "skills", "factory"), options.force === true)));
71
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "bug-hunting"), join(target, paths.plugin, "skills", "bug-hunting"), options.force === true)));
72
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "field-notes"), join(target, paths.plugin, "skills", "field-notes"), options.force === true)));
73
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "scratch-files"), join(target, paths.plugin, "skills", "scratch-files"), options.force === true)));
74
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "worklog"), join(target, paths.plugin, "skills", "worklog"), options.force === true)));
75
+ const compiledAgentsRule = await buildAntigravityAgentsRule(join(sourceRoot, "agents"));
76
+ results.push(await writeContentResult(harness, "rules", "agents/AGENTS.md", join(target, paths.plugin, "rules", "AGENTS.md"), compiledAgentsRule, options.force === true));
77
+ }
78
+ else {
79
+ if (kinds.includes("skills")) {
80
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "factory"), join(target, paths.skills, "factory"), options.force === true)));
81
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "bug-hunting"), join(target, paths.skills, "bug-hunting"), options.force === true)));
82
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "field-notes"), join(target, paths.skills, "field-notes"), options.force === true)));
83
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "scratch-files"), join(target, paths.skills, "scratch-files"), options.force === true)));
84
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "worklog"), join(target, paths.skills, "worklog"), options.force === true)));
85
+ }
86
+ if (kinds.includes("rules") && paths.rules) {
87
+ const compiledAgentsRule = await buildAntigravityAgentsRule(join(sourceRoot, "agents"));
88
+ results.push(await writeContentResult(harness, "rules", "agents/AGENTS.md", join(target, paths.rules, "AGENTS.md"), compiledAgentsRule, options.force === true));
89
+ }
90
+ }
91
+ continue;
92
+ }
93
+ if (kinds.includes("agents") && paths.agents) {
94
+ for (const file of await listMarkdown(join(sourceRoot, "agents"))) {
95
+ results.push(await copyFile(harness, "agents", join(sourceRoot, "agents", file), join(target, paths.agents, file), options.force === true));
96
+ }
97
+ }
98
+ if (kinds.includes("skills")) {
99
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "factory"), join(target, paths.skills, "factory"), options.force === true)));
100
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "bug-hunting"), join(target, paths.skills, "bug-hunting"), options.force === true)));
101
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "field-notes"), join(target, paths.skills, "field-notes"), options.force === true)));
102
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "scratch-files"), join(target, paths.skills, "scratch-files"), options.force === true)));
103
+ results.push(...(await copyTree(harness, "skills", join(sourceRoot, "skills", "worklog"), join(target, paths.skills, "worklog"), options.force === true)));
104
+ }
105
+ if (kinds.includes("commands") && paths.commands) {
106
+ const command = join(sourceRoot, "commands", "factory.md");
107
+ results.push(await copyFile(harness, "commands", command, join(target, paths.commands, "factory.md"), options.force === true));
108
+ }
109
+ }
110
+ return results;
111
+ }
112
+ export function describeInstall(results, target) {
113
+ const counts = new Map();
114
+ for (const result of results) {
115
+ counts.set(result.status, (counts.get(result.status) ?? 0) + 1);
116
+ }
117
+ const summary = ["created", "updated", "unchanged", "skipped"]
118
+ .filter((status) => (counts.get(status) ?? 0) > 0)
119
+ .map((status) => `${counts.get(status)} ${status}`)
120
+ .join(", ");
121
+ const lines = [
122
+ `Factory content installed in ${target}`,
123
+ "",
124
+ summary || "Nothing to install.",
125
+ ];
126
+ const skipped = results.filter((result) => result.status === "skipped");
127
+ if (skipped.length > 0) {
128
+ lines.push("", "Skipped files differ from the packaged version. Re-run with --force to overwrite:", ...skipped.map((result) => ` ${relative(target, result.target)}`));
129
+ }
130
+ return lines.join("\n");
131
+ }
132
+ async function copyTree(harness, kind, source, target, force) {
133
+ const results = [];
134
+ const entries = await readdir(source, { withFileTypes: true });
135
+ for (const entry of entries) {
136
+ const sourcePath = join(source, entry.name);
137
+ const targetPath = join(target, entry.name);
138
+ if (entry.isDirectory()) {
139
+ results.push(...(await copyTree(harness, kind, sourcePath, targetPath, force)));
140
+ }
141
+ else if (entry.isFile()) {
142
+ results.push(await copyFile(harness, kind, sourcePath, targetPath, force));
143
+ }
144
+ }
145
+ return results;
146
+ }
147
+ async function copyFile(harness, kind, source, target, force) {
148
+ const content = await readFile(source, "utf8");
149
+ const status = await writeIfChanged(target, content, force);
150
+ return { harness, kind, source, target, status };
151
+ }
152
+ async function writeContentResult(harness, kind, source, target, content, force) {
153
+ const status = await writeIfChanged(target, content, force);
154
+ return { harness, kind, source, target, status };
155
+ }
156
+ async function buildAntigravityAgentsRule(agentsDir) {
157
+ const files = await listMarkdown(agentsDir);
158
+ const sections = [
159
+ "# Factory Subagents & Rules",
160
+ "",
161
+ "This rule defines the personas, capabilities, and behavioral rules for",
162
+ "the factory subagents when coordinating work under the factory workflow.",
163
+ "",
164
+ ];
165
+ for (const file of files) {
166
+ const filePath = join(agentsDir, file);
167
+ const raw = await readFile(filePath, "utf8");
168
+ const match = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
169
+ const body = match && match[2] ? match[2].trim() : raw.trim();
170
+ const name = file.replace(/\.md$/, "");
171
+ sections.push(`## Agent: ${name}`, "", body, "");
172
+ }
173
+ return sections.join("\n").trimEnd() + "\n";
174
+ }
175
+ async function writeIfChanged(target, content, force) {
176
+ let existing;
177
+ try {
178
+ existing = await readFile(target, "utf8");
179
+ }
180
+ catch (error) {
181
+ if (error.code !== "ENOENT")
182
+ throw error;
183
+ }
184
+ if (existing === content)
185
+ return "unchanged";
186
+ if (existing !== undefined && !force)
187
+ return "skipped";
188
+ await mkdir(dirname(target), { recursive: true });
189
+ await writeFile(target, content, "utf8");
190
+ return existing === undefined ? "created" : "updated";
191
+ }
192
+ async function listMarkdown(dir) {
193
+ const entries = await readdir(dir, { withFileTypes: true });
194
+ return entries
195
+ .filter((entry) => entry.isFile() && entry.name.endsWith(".md"))
196
+ .map((entry) => entry.name)
197
+ .sort();
198
+ }
@@ -0,0 +1,17 @@
1
+ export interface WorkspaceOptions {
2
+ /** Project directory. */
3
+ target: string;
4
+ /** Workspace name. Defaults to `default`. */
5
+ name?: string;
6
+ /** Overwrite existing workspace files. */
7
+ force?: boolean;
8
+ }
9
+ export interface WorkspaceResult {
10
+ directory: string;
11
+ files: Array<{
12
+ path: string;
13
+ status: "created" | "updated" | "unchanged" | "skipped";
14
+ }>;
15
+ }
16
+ export declare function createWorkspace(options: WorkspaceOptions): Promise<WorkspaceResult>;
17
+ export declare function describeWorkspace(result: WorkspaceResult, target: string): string;