opencastle 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/adapters/adapter-contract.test.js +85 -2
- package/dist/cli/adapters/adapter-contract.test.js.map +1 -1
- package/dist/cli/adapters/antigravity.d.ts +5 -4
- package/dist/cli/adapters/antigravity.d.ts.map +1 -1
- package/dist/cli/adapters/antigravity.js +5 -4
- package/dist/cli/adapters/antigravity.js.map +1 -1
- package/dist/cli/adapters/rules-dir-base.d.ts.map +1 -1
- package/dist/cli/adapters/rules-dir-base.js +25 -19
- package/dist/cli/adapters/rules-dir-base.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +10 -7
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/adapters/vscode.d.ts.map +1 -1
- package/dist/cli/adapters/vscode.js +11 -5
- package/dist/cli/adapters/vscode.js.map +1 -1
- package/dist/cli/adapters/workflows.d.ts +33 -0
- package/dist/cli/adapters/workflows.d.ts.map +1 -0
- package/dist/cli/adapters/workflows.js +58 -0
- package/dist/cli/adapters/workflows.js.map +1 -0
- package/dist/cli/adapters/workflows.test.d.ts +2 -0
- package/dist/cli/adapters/workflows.test.d.ts.map +1 -0
- package/dist/cli/adapters/workflows.test.js +62 -0
- package/dist/cli/adapters/workflows.test.js.map +1 -0
- package/dist/cli/convoy/spec-types.d.ts +15 -0
- package/dist/cli/convoy/spec-types.d.ts.map +1 -1
- package/dist/cli/docs-accuracy.test.js +3 -3
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/explain.d.ts.map +1 -1
- package/dist/cli/explain.js +3 -1
- package/dist/cli/explain.js.map +1 -1
- package/dist/cli/pipeline.d.ts.map +1 -1
- package/dist/cli/pipeline.flow.test.js +134 -27
- package/dist/cli/pipeline.flow.test.js.map +1 -1
- package/dist/cli/pipeline.js +113 -34
- package/dist/cli/pipeline.js.map +1 -1
- package/dist/cli/plan.d.ts +22 -0
- package/dist/cli/plan.d.ts.map +1 -1
- package/dist/cli/plan.js +43 -6
- package/dist/cli/plan.js.map +1 -1
- package/dist/cli/run/adapters/claude.d.ts +13 -0
- package/dist/cli/run/adapters/claude.d.ts.map +1 -1
- package/dist/cli/run/adapters/claude.js +30 -1
- package/dist/cli/run/adapters/claude.js.map +1 -1
- package/dist/cli/run/adapters/claude.test.js +34 -1
- package/dist/cli/run/adapters/claude.test.js.map +1 -1
- package/dist/cli/run/adapters/codex.d.ts.map +1 -1
- package/dist/cli/run/adapters/codex.js +4 -0
- package/dist/cli/run/adapters/codex.js.map +1 -1
- package/dist/cli/run/adapters/codex.test.js +8 -0
- package/dist/cli/run/adapters/codex.test.js.map +1 -1
- package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
- package/dist/cli/run/adapters/copilot.js +4 -1
- package/dist/cli/run/adapters/copilot.js.map +1 -1
- package/dist/cli/run/adapters/copilot.test.js +9 -0
- package/dist/cli/run/adapters/copilot.test.js.map +1 -1
- package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +2 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -1
- package/dist/cli/run/adapters/stub-cli.test-helper.js +16 -1
- package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -1
- package/dist/cli/run/platform.d.ts +12 -0
- package/dist/cli/run/platform.d.ts.map +1 -1
- package/dist/cli/run/platform.js +49 -0
- package/dist/cli/run/platform.js.map +1 -1
- package/dist/cli/run/platform.test.js +21 -1
- package/dist/cli/run/platform.test.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/adapters/adapter-contract.test.ts +89 -2
- package/src/cli/adapters/antigravity.ts +5 -4
- package/src/cli/adapters/rules-dir-base.ts +30 -19
- package/src/cli/adapters/single-file-base.ts +10 -6
- package/src/cli/adapters/vscode.ts +11 -4
- package/src/cli/adapters/workflows.test.ts +70 -0
- package/src/cli/adapters/workflows.ts +62 -0
- package/src/cli/convoy/spec-types.ts +15 -0
- package/src/cli/docs-accuracy.test.ts +3 -3
- package/src/cli/explain.ts +3 -1
- package/src/cli/pipeline.flow.test.ts +143 -28
- package/src/cli/pipeline.ts +141 -34
- package/src/cli/plan.ts +51 -6
- package/src/cli/run/adapters/claude.test.ts +39 -1
- package/src/cli/run/adapters/claude.ts +27 -1
- package/src/cli/run/adapters/codex.test.ts +9 -0
- package/src/cli/run/adapters/codex.ts +3 -0
- package/src/cli/run/adapters/copilot.test.ts +11 -0
- package/src/cli/run/adapters/copilot.ts +3 -1
- package/src/cli/run/adapters/stub-cli.test-helper.ts +16 -1
- package/src/cli/run/platform.test.ts +23 -1
- package/src/cli/run/platform.ts +50 -0
- package/src/orchestrator/agent-workflows/README.md +2 -0
- package/src/orchestrator/agent-workflows/bug-fix.md +3 -3
- package/src/orchestrator/agent-workflows/data-pipeline.md +2 -2
- package/src/orchestrator/agent-workflows/database-migration.md +2 -2
- package/src/orchestrator/agent-workflows/feature-implementation.md +2 -2
- package/src/orchestrator/agent-workflows/performance-optimization.md +3 -3
- package/src/orchestrator/agent-workflows/refactoring.md +2 -2
- package/src/orchestrator/agent-workflows/schema-changes.md +2 -2
- package/src/orchestrator/agent-workflows/security-audit.md +2 -2
- package/src/orchestrator/agents/architect.agent.md +1 -1
- package/src/orchestrator/agents/content-engineer.agent.md +1 -1
- package/src/orchestrator/agents/data-engineer.agent.md +1 -1
- package/src/orchestrator/agents/developer.agent.md +1 -1
- package/src/orchestrator/agents/devops-expert.agent.md +1 -1
- package/src/orchestrator/agents/performance-expert.agent.md +1 -1
- package/src/orchestrator/agents/researcher.agent.md +1 -1
- package/src/orchestrator/agents/security-expert.agent.md +1 -1
- package/src/orchestrator/agents/team-lead.agent.md +3 -4
- package/src/orchestrator/agents/testing-expert.agent.md +1 -1
- package/src/orchestrator/agents/ui-ux-expert.agent.md +1 -1
- package/src/orchestrator/agents/writer.agent.md +1 -1
- package/src/orchestrator/instructions/general.instructions.md +2 -2
- package/src/orchestrator/plugins/chrome-devtools/skills/browser-testing/SKILL.md +1 -1
- package/src/orchestrator/plugins/nx/skills/nx-workspace/SKILL.md +1 -1
- package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
- package/src/orchestrator/prompts/bug-fix.prompt.md +3 -3
- package/src/orchestrator/prompts/implement-feature.prompt.md +2 -2
- package/src/orchestrator/prompts/quick-refinement.prompt.md +2 -2
- package/src/orchestrator/skills/api-patterns/SKILL.md +1 -1
- package/src/orchestrator/skills/deployment-infrastructure/SKILL.md +1 -1
- package/src/orchestrator/skills/team-lead-reference/SKILL.md +11 -11
- package/src/orchestrator/skills/validation-gates/SKILL.md +1 -1
|
@@ -2,7 +2,7 @@ import { mkdtempSync, writeFileSync, chmodSync, rmSync, existsSync } from 'node:
|
|
|
2
2
|
import { tmpdir } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { describe, it, expect, afterEach } from 'vitest';
|
|
5
|
-
import { resolveCommand, commandExists, quoteForCmd, runShell, spawnCommand, killTree } from './platform.js';
|
|
5
|
+
import { resolveCommand, commandExists, quoteForCmd, runShell, spawnCommand, killTree, helpText, forgetHelpText } from './platform.js';
|
|
6
6
|
const posix = process.platform !== 'win32';
|
|
7
7
|
describe('finding a command without `which`', () => {
|
|
8
8
|
const dirs = [];
|
|
@@ -23,6 +23,26 @@ describe('finding a command without `which`', () => {
|
|
|
23
23
|
expect(await commandExists('nowhere-to-be-found', env)).toBe(false);
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
|
+
describe('reading a CLI\'s --help', () => {
|
|
27
|
+
afterEach(() => forgetHelpText());
|
|
28
|
+
it('is empty for a command that is not there, and asks only once', async () => {
|
|
29
|
+
const missing = 'opencastle-no-such-cli-' + process.pid;
|
|
30
|
+
expect(await helpText(missing)).toBe('');
|
|
31
|
+
expect(helpText(missing)).toBe(helpText(missing));
|
|
32
|
+
});
|
|
33
|
+
it.skipIf(!posix)('reads what the command prints', async () => {
|
|
34
|
+
const dir = mkdtempSync(join(tmpdir(), 'oc-help-'));
|
|
35
|
+
const cli = join(dir, 'fake-cli');
|
|
36
|
+
writeFileSync(cli, '#!/bin/sh\necho " --effort <level> Effort"\n');
|
|
37
|
+
chmodSync(cli, 0o755);
|
|
38
|
+
try {
|
|
39
|
+
expect(await helpText(cli)).toContain('--effort <level>');
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
rmSync(dir, { recursive: true, force: true });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
26
46
|
describe('quoting for cmd.exe', () => {
|
|
27
47
|
// The same output cross-spawn produces for these inputs.
|
|
28
48
|
it('quotes and caret-escapes metacharacters', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.test.js","sourceRoot":"","sources":["../../../src/cli/run/platform.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"platform.test.js","sourceRoot":"","sources":["../../../src/cli/run/platform.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,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.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Write your AI config once, for every assistant and every teammate: compiles instructions, agents, skills, commands and MCP servers for Claude Code, Copilot, Cursor, Windsurf, OpenCode, Codex and Antigravity, shared across your team's repositories.",
|
|
6
6
|
"bin": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { mkdtempSync, rmSync, writeFileSync, readFileSync } from 'node:fs'
|
|
1
|
+
import { existsSync, mkdtempSync, readdirSync, rmSync, writeFileSync, readFileSync } from 'node:fs'
|
|
2
2
|
import { tmpdir } from 'node:os'
|
|
3
|
-
import { join, resolve } from 'node:path'
|
|
3
|
+
import { dirname, join, relative, resolve } from 'node:path'
|
|
4
4
|
import { describe, it, expect } from 'vitest'
|
|
5
5
|
import { IDE_ADAPTERS } from './index.js'
|
|
6
6
|
import { BLOCK_START, BLOCK_END } from '../managed-block.js'
|
|
@@ -56,3 +56,90 @@ describe('every adapter reports the same things about a root file', () => {
|
|
|
56
56
|
})
|
|
57
57
|
}
|
|
58
58
|
})
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Every reference a compiled file makes leads somewhere, on every target.
|
|
62
|
+
*
|
|
63
|
+
* The source is written in one layout and compiled into seven. A relative link
|
|
64
|
+
* or a folder name that is right in the source was carried into every target
|
|
65
|
+
* unchanged, and 88 links led nowhere: the Team Lead sent each assistant to
|
|
66
|
+
* search `.github/agent-workflows/`, which only a Copilot project has, and the
|
|
67
|
+
* templates linked a `shared-delivery-phase.md` that Claude Code had named
|
|
68
|
+
* `workflow-shared-delivery-phase.md` — and offered as a command of its own.
|
|
69
|
+
*/
|
|
70
|
+
describe('every compiled reference resolves', () => {
|
|
71
|
+
/** Where an older release wrote the shared phase on its own, per target. */
|
|
72
|
+
const LEGACY_SHARED_PHASE: Record<string, string> = {
|
|
73
|
+
'claude-code': '.claude/commands/oc/workflow-shared-delivery-phase.md',
|
|
74
|
+
opencode: '.opencode/workflows/shared-delivery-phase.md',
|
|
75
|
+
codex: '.codex/workflows/shared-delivery-phase.md',
|
|
76
|
+
antigravity: '.agents/workflows/shared-delivery-phase.md',
|
|
77
|
+
cursor: '.cursor/rules/agent-workflows/shared-delivery-phase.mdc',
|
|
78
|
+
windsurf: '.windsurf/rules/agent-workflows/shared-delivery-phase.md',
|
|
79
|
+
vscode: '.github/agent-workflows/shared-delivery-phase.md',
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function compiledFiles(dir: string): string[] {
|
|
83
|
+
const out: string[] = []
|
|
84
|
+
const walk = (abs: string) => {
|
|
85
|
+
for (const entry of readdirSync(abs, { withFileTypes: true })) {
|
|
86
|
+
const path = join(abs, entry.name)
|
|
87
|
+
if (entry.isDirectory()) walk(path)
|
|
88
|
+
else if (/\.mdc?$/.test(entry.name)) out.push(path)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
walk(dir)
|
|
92
|
+
return out
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The text a reader follows: code is quoted, not referred to. */
|
|
96
|
+
const prose = (text: string) => text.replace(/```[\s\S]*?```/g, '').replace(/`[^`\n]*`/g, '')
|
|
97
|
+
|
|
98
|
+
for (const ide of Object.keys(LEGACY_SHARED_PHASE)) {
|
|
99
|
+
it(`${ide}: links resolve, the templates are whole, and the Team Lead finds them`, async () => {
|
|
100
|
+
const dir = mkdtempSync(join(tmpdir(), `adapter-links-${ide}-`))
|
|
101
|
+
try {
|
|
102
|
+
const adapter = await IDE_ADAPTERS[ide]()
|
|
103
|
+
const stack = { ides: [ide], techTools: [], teamTools: [] } as unknown as StackConfig
|
|
104
|
+
await adapter.install(pkgRoot, dir, stack, undefined)
|
|
105
|
+
const files = compiledFiles(dir)
|
|
106
|
+
|
|
107
|
+
const broken: string[] = []
|
|
108
|
+
for (const file of files) {
|
|
109
|
+
for (const m of prose(readFileSync(file, 'utf8')).matchAll(/\]\(([^)#\s]+)(?:#[^)]*)?\)/g)) {
|
|
110
|
+
if (/^[a-z]+:/i.test(m[1])) continue
|
|
111
|
+
if (!existsSync(resolve(dirname(file), m[1]))) broken.push(`${relative(dir, file)} → ${m[1]}`)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
expect(broken, `${ide} compiled links that lead nowhere`).toEqual([])
|
|
115
|
+
|
|
116
|
+
if (ide !== 'vscode') {
|
|
117
|
+
const strays = files.filter((f) => readFileSync(f, 'utf8').includes('.github/agent-workflows/'))
|
|
118
|
+
expect(strays.map((f) => relative(dir, f)), `${ide} names Copilot's folder`).toEqual([])
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const teamLead = files.find((f) => /team-lead\.(agent\.md|mdc|md)$/.test(f))!
|
|
122
|
+
const where = readFileSync(teamLead, 'utf8').match(/Search `([^`]+)`/)![1]
|
|
123
|
+
const folder = resolve(dir, where.replace(/[^/]*\*[^/]*$/, ''))
|
|
124
|
+
expect(existsSync(folder), `${ide}: the Team Lead searches ${where}`).toBe(true)
|
|
125
|
+
|
|
126
|
+
const templates = files.filter((f) => /workflow|agent-workflows/.test(relative(dir, f)) && /Workflow:/.test(readFileSync(f, 'utf8')))
|
|
127
|
+
expect(templates.length, `${ide} compiled no templates`).toBe(8)
|
|
128
|
+
for (const t of templates) {
|
|
129
|
+
expect(readFileSync(t, 'utf8'), `${relative(dir, t)} lacks the delivery phase`).toContain('**Do NOT merge**')
|
|
130
|
+
}
|
|
131
|
+
expect(files.filter((f) => f.includes('shared-delivery-phase')).map((f) => relative(dir, f))).toEqual([])
|
|
132
|
+
|
|
133
|
+
// A project an older release compiled still has the phase on its own.
|
|
134
|
+
// The next sync removes it and says so.
|
|
135
|
+
const legacy = resolve(dir, LEGACY_SHARED_PHASE[ide])
|
|
136
|
+
writeFileSync(legacy, readFileSync(resolve(pkgRoot, 'src/orchestrator/agent-workflows/shared-delivery-phase.md'), 'utf8'))
|
|
137
|
+
const updated = await adapter.update(pkgRoot, dir, stack)
|
|
138
|
+
expect(existsSync(legacy), `${ide} kept ${LEGACY_SHARED_PHASE[ide]}`).toBe(false)
|
|
139
|
+
expect(updated.deleted ?? []).toContain(LEGACY_SHARED_PHASE[ide])
|
|
140
|
+
} finally {
|
|
141
|
+
rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 })
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
})
|
|
@@ -13,10 +13,11 @@ import { createSingleFileAdapter } from './single-file-base.js'
|
|
|
13
13
|
* prompts/*.prompt.md -> .agents/prompts/<name>.md
|
|
14
14
|
* mcp.json -> .agents/mcp_config.json (mcpServers format)
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* mcp_config.json
|
|
19
|
-
*
|
|
16
|
+
* MCP: Antigravity — the IDE, the CLI and 2.0 alike — reads a workspace's
|
|
17
|
+
* servers from .agents/mcp_config.json and the user's from
|
|
18
|
+
* ~/.gemini/config/mcp_config.json (antigravity.google/docs/mcp). It expands
|
|
19
|
+
* no variables there, so a `${NAME}` in a header is sent as written; doctor
|
|
20
|
+
* flags one.
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
export const IDE_ID = 'antigravity'
|
|
@@ -7,6 +7,7 @@ import { scaffoldMcpConfigInto } from '../mcp.js'
|
|
|
7
7
|
import type { CopyResults, DoctorCheck, IdeChoice, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
|
|
8
8
|
import { splitFrontmatter, parseFrontmatterString } from './frontmatter.js'
|
|
9
9
|
import { writeManagedBlock, recordMerge } from '../managed-block.js'
|
|
10
|
+
import { SHARED_PHASE_FILE, inlineSharedPhase, pointAtWorkflows, readSharedPhase } from './workflows.js'
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Shared implementation for IDEs that take a root rules file plus a directory of
|
|
@@ -128,14 +129,17 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
128
129
|
interface ConvertFileOptions {
|
|
129
130
|
alwaysApply?: boolean
|
|
130
131
|
descriptionFallback?: string
|
|
132
|
+
/** Rewrites the body for this target before it is written. */
|
|
133
|
+
transform?: (body: string) => string
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
async function convertFile(
|
|
134
137
|
srcPath: string,
|
|
135
|
-
{ alwaysApply = false, descriptionFallback = '' }: ConvertFileOptions = {},
|
|
138
|
+
{ alwaysApply = false, descriptionFallback = '', transform }: ConvertFileOptions = {},
|
|
136
139
|
): Promise<string> {
|
|
137
140
|
const content = await readFile(srcPath, 'utf8')
|
|
138
|
-
const { frontmatter, body } = splitFrontmatter(content)
|
|
141
|
+
const { frontmatter, body: source } = splitFrontmatter(content)
|
|
142
|
+
const body = transform ? transform(source) : source
|
|
139
143
|
const meta = parseFrontmatterString(frontmatter)
|
|
140
144
|
|
|
141
145
|
// Description: frontmatter > fallback > first heading
|
|
@@ -203,6 +207,7 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
203
207
|
removeExt?: string
|
|
204
208
|
overwrite?: boolean
|
|
205
209
|
excludeFiles?: Set<string>
|
|
210
|
+
transform?: (body: string) => string
|
|
206
211
|
}
|
|
207
212
|
|
|
208
213
|
async function convertDir(
|
|
@@ -210,7 +215,7 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
210
215
|
dirName: string,
|
|
211
216
|
destDir: string,
|
|
212
217
|
results: CopyResults,
|
|
213
|
-
{ alwaysApply, descriptionPrefix, removeExt, overwrite, excludeFiles }: ConvertDirOptions = {},
|
|
218
|
+
{ alwaysApply, descriptionPrefix, removeExt, overwrite, excludeFiles, transform }: ConvertDirOptions = {},
|
|
214
219
|
): Promise<void> {
|
|
215
220
|
const srcDir = resolve(srcRoot, dirName)
|
|
216
221
|
if (!existsSync(srcDir)) return
|
|
@@ -226,13 +231,30 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
226
231
|
await writeConverted(
|
|
227
232
|
resolve(srcDir, file),
|
|
228
233
|
resolve(destDir, ruleName(file)),
|
|
229
|
-
{ alwaysApply: alwaysApply ?? false, descriptionFallback: fallback },
|
|
234
|
+
{ alwaysApply: alwaysApply ?? false, descriptionFallback: fallback, transform },
|
|
230
235
|
results,
|
|
231
236
|
overwrite,
|
|
232
237
|
)
|
|
233
238
|
}
|
|
234
239
|
}
|
|
235
240
|
|
|
241
|
+
/** Agents, pointed at the templates where this target writes them. */
|
|
242
|
+
const agentOptions: ConvertDirOptions = {
|
|
243
|
+
descriptionPrefix: 'Agent: ',
|
|
244
|
+
removeExt: '.agent.md',
|
|
245
|
+
transform: (body) => pointAtWorkflows(body, `${rulesPrefix}/agent-workflows/`),
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** The templates, each with the shared delivery phase in it, and not the phase on its own. */
|
|
249
|
+
function workflowOptions(srcRoot: string): ConvertDirOptions {
|
|
250
|
+
const shared = readSharedPhase(srcRoot)
|
|
251
|
+
return {
|
|
252
|
+
descriptionPrefix: 'Workflow: ',
|
|
253
|
+
excludeFiles: new Set(['README.md', SHARED_PHASE_FILE]),
|
|
254
|
+
transform: (body) => inlineSharedPhase(body, shared),
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
236
258
|
/** Skills as Agent Skills: each `<name>/` folder, every file in it, frontmatter kept. */
|
|
237
259
|
async function copySkills(srcRoot: string, projectRoot: string, results: CopyResults, overwrite: boolean): Promise<void> {
|
|
238
260
|
const skillsDir = resolve(srcRoot, 'skills')
|
|
@@ -276,15 +298,9 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
276
298
|
await mkdir(rulesRoot, { recursive: true })
|
|
277
299
|
|
|
278
300
|
await convertDir(srcRoot, 'instructions', rulesRoot, results, { alwaysApply: true })
|
|
279
|
-
await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results,
|
|
280
|
-
descriptionPrefix: 'Agent: ',
|
|
281
|
-
removeExt: '.agent.md',
|
|
282
|
-
})
|
|
301
|
+
await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results, agentOptions)
|
|
283
302
|
await copySkills(srcRoot, projectRoot, results, false)
|
|
284
|
-
await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results,
|
|
285
|
-
descriptionPrefix: 'Workflow: ',
|
|
286
|
-
excludeFiles: new Set(['README.md']),
|
|
287
|
-
})
|
|
303
|
+
await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, workflowOptions(srcRoot))
|
|
288
304
|
await convertDir(srcRoot, 'prompts', resolve(rulesRoot, 'prompts'), results, {
|
|
289
305
|
descriptionPrefix: 'Prompt: ',
|
|
290
306
|
removeExt: '.prompt.md',
|
|
@@ -336,16 +352,11 @@ export function createRulesDirAdapter(config: RulesDirConfig): RulesDirAdapter {
|
|
|
336
352
|
alwaysApply: true,
|
|
337
353
|
overwrite: true,
|
|
338
354
|
})
|
|
339
|
-
await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results, {
|
|
340
|
-
descriptionPrefix: 'Agent: ',
|
|
341
|
-
removeExt: '.agent.md',
|
|
342
|
-
overwrite: true,
|
|
343
|
-
})
|
|
355
|
+
await convertDir(srcRoot, 'agents', resolve(rulesRoot, 'agents'), results, { ...agentOptions, overwrite: true })
|
|
344
356
|
await copySkills(srcRoot, projectRoot, results, true)
|
|
345
357
|
await convertDir(srcRoot, 'agent-workflows', resolve(rulesRoot, 'agent-workflows'), results, {
|
|
346
|
-
|
|
358
|
+
...workflowOptions(srcRoot),
|
|
347
359
|
overwrite: true,
|
|
348
|
-
excludeFiles: new Set(['README.md']),
|
|
349
360
|
})
|
|
350
361
|
await convertDir(srcRoot, 'prompts', resolve(rulesRoot, 'prompts'), results, {
|
|
351
362
|
descriptionPrefix: 'Prompt: ',
|
|
@@ -8,6 +8,7 @@ import { scaffoldMcpConfigInto } from '../mcp.js'
|
|
|
8
8
|
import { withSource, type CompileSource } from '../layers.js'
|
|
9
9
|
import type { CopyResults, DoctorCheck, IdeAdapter, IdeChoice, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
|
|
10
10
|
import { stripFrontmatter, parseFrontmatterMeta } from './frontmatter.js'
|
|
11
|
+
import { inlineSharedPhase, isWorkflowTemplate, pointAtWorkflows, readSharedPhase } from './workflows.js'
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Configuration for adapters that produce a single root instructions file
|
|
@@ -389,15 +390,17 @@ export function createSingleFileAdapter(
|
|
|
389
390
|
|
|
390
391
|
const dotDirPath = resolve(projectRoot, config.dotDir)
|
|
391
392
|
|
|
392
|
-
// 2. Agent definitions → dotDir/agents
|
|
393
|
+
// 2. Agent definitions → dotDir/agents/, pointed at the templates where
|
|
394
|
+
// this target writes them (step 5)
|
|
393
395
|
const agentsDir = resolve(srcRoot, 'agents')
|
|
394
396
|
if (existsSync(agentsDir)) {
|
|
395
397
|
const destAgents = resolve(dotDirPath, 'agents')
|
|
396
398
|
await mkdir(destAgents, { recursive: true })
|
|
399
|
+
const workflowsAt = `${config.dotDir}/${config.workflowsDir}/${config.workflowPrefix ? `${config.workflowPrefix}*.md` : ''}`
|
|
397
400
|
for (const file of await readdir(agentsDir)) {
|
|
398
401
|
if (!file.endsWith('.md')) continue
|
|
399
402
|
const destPath = resolve(destAgents, file)
|
|
400
|
-
const content = await readFile(resolve(agentsDir, file), 'utf8')
|
|
403
|
+
const content = pointAtWorkflows(await readFile(resolve(agentsDir, file), 'utf8'), workflowsAt)
|
|
401
404
|
await emit(projectRoot, destPath, agentFile(file, content, config.agentFrontmatter === true), overwrite, results)
|
|
402
405
|
}
|
|
403
406
|
}
|
|
@@ -446,17 +449,18 @@ export function createSingleFileAdapter(
|
|
|
446
449
|
}
|
|
447
450
|
}
|
|
448
451
|
|
|
449
|
-
// 5. Agent Workflows → dotDir/<workflowsDir>/<prefix><name>.md
|
|
452
|
+
// 5. Agent Workflows → dotDir/<workflowsDir>/<prefix><name>.md, each with
|
|
453
|
+
// the shared delivery phase in it
|
|
450
454
|
const wfDir = resolve(srcRoot, 'agent-workflows')
|
|
451
455
|
if (existsSync(wfDir)) {
|
|
452
456
|
const destWf = resolve(dotDirPath, config.workflowsDir)
|
|
453
457
|
await mkdir(destWf, { recursive: true })
|
|
458
|
+
const shared = readSharedPhase(srcRoot)
|
|
454
459
|
for (const file of await readdir(wfDir)) {
|
|
455
|
-
if (!file
|
|
456
|
-
if (file === 'README.md') continue
|
|
460
|
+
if (!isWorkflowTemplate(file)) continue
|
|
457
461
|
const name = basename(file, '.md')
|
|
458
462
|
const destPath = resolve(destWf, `${config.workflowPrefix}${name}.md`)
|
|
459
|
-
const content = await readFile(resolve(wfDir, file), 'utf8')
|
|
463
|
+
const content = inlineSharedPhase(await readFile(resolve(wfDir, file), 'utf8'), shared)
|
|
460
464
|
await emit(projectRoot, destPath, commandFile(content, config.commandDescriptions === true), overwrite, results)
|
|
461
465
|
}
|
|
462
466
|
}
|
|
@@ -8,6 +8,7 @@ import { getAgentTransform } from '../stack-config.js'
|
|
|
8
8
|
import { withSource, type CompileSource } from '../layers.js'
|
|
9
9
|
import type { CopyResults, CopyDirOptions, DoctorCheck, ManagedPaths, RepoInfo, StackConfig } from '../types.js'
|
|
10
10
|
import { isOurVscodePrompt, legacyVscodePrompts, vscodePromptFile, withCommandName } from '../command-namespace.js'
|
|
11
|
+
import { inlineSharedPhase, isWorkflowTemplate, readSharedPhase } from './workflows.js'
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* VS Code / GitHub Copilot adapter.
|
|
@@ -45,6 +46,7 @@ const FRAMEWORK_DIRS = [
|
|
|
45
46
|
*/
|
|
46
47
|
function copyRulesFor(
|
|
47
48
|
dir: string,
|
|
49
|
+
srcRoot: string,
|
|
48
50
|
stack?: StackConfig,
|
|
49
51
|
): Pick<CopyDirOptions, 'filter' | 'transform' | 'rename'> {
|
|
50
52
|
if (dir === 'agents') {
|
|
@@ -65,8 +67,13 @@ function copyRulesFor(
|
|
|
65
67
|
}
|
|
66
68
|
if (dir === 'agent-workflows') {
|
|
67
69
|
// The directory's own README documents the templates for contributors; it is
|
|
68
|
-
// not one of them, and no other adapter installs it.
|
|
69
|
-
|
|
70
|
+
// not one of them, and no other adapter installs it. The shared delivery
|
|
71
|
+
// phase goes into each template, as it does for every other target.
|
|
72
|
+
const shared = readSharedPhase(srcRoot)
|
|
73
|
+
return {
|
|
74
|
+
filter: isWorkflowTemplate,
|
|
75
|
+
transform: (content) => inlineSharedPhase(content, shared),
|
|
76
|
+
}
|
|
70
77
|
}
|
|
71
78
|
return {}
|
|
72
79
|
}
|
|
@@ -141,7 +148,7 @@ async function installFrom(
|
|
|
141
148
|
if (!existsSync(srcDir)) continue
|
|
142
149
|
const destDir = resolve(destRoot, dir)
|
|
143
150
|
|
|
144
|
-
const sub = await copyDir(srcDir, destDir, copyRulesFor(dir, stack))
|
|
151
|
+
const sub = await copyDir(srcDir, destDir, copyRulesFor(dir, srcRoot, stack))
|
|
145
152
|
mergeCopyResults(results, sub)
|
|
146
153
|
}
|
|
147
154
|
|
|
@@ -214,7 +221,7 @@ async function updateFrom(src: CompileSource, projectRoot: string, stack: StackC
|
|
|
214
221
|
if (!existsSync(srcDir)) continue
|
|
215
222
|
const destDir = resolve(destRoot, dir)
|
|
216
223
|
|
|
217
|
-
const sub = await copyDir(srcDir, destDir, { overwrite: true, ...copyRulesFor(dir, stack) })
|
|
224
|
+
const sub = await copyDir(srcDir, destDir, { overwrite: true, ...copyRulesFor(dir, srcRoot, stack) })
|
|
218
225
|
mergeCopyResults(results, sub)
|
|
219
226
|
for (const abs of sub.visited ?? []) visited.add(abs)
|
|
220
227
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { inlineSharedPhase, isWorkflowTemplate, pointAtWorkflows } from './workflows.js'
|
|
3
|
+
|
|
4
|
+
const TEMPLATE = [
|
|
5
|
+
'# Workflow: Bug Fix',
|
|
6
|
+
'',
|
|
7
|
+
'### Phase 5: Delivery',
|
|
8
|
+
'',
|
|
9
|
+
'> **See [shared-delivery-phase.md](shared-delivery-phase.md) for the standard delivery steps.**',
|
|
10
|
+
'>',
|
|
11
|
+
'> Commit → Push → PR → tracker linkage. Team Lead owns delivery.',
|
|
12
|
+
'',
|
|
13
|
+
'## After',
|
|
14
|
+
'',
|
|
15
|
+
].join('\n')
|
|
16
|
+
|
|
17
|
+
const SHARED = [
|
|
18
|
+
'<!-- ⚠️ This file is managed by OpenCastle. -->',
|
|
19
|
+
'',
|
|
20
|
+
'# Shared Delivery Phase',
|
|
21
|
+
'',
|
|
22
|
+
'This phase is referenced by all workflow templates.',
|
|
23
|
+
'',
|
|
24
|
+
'## Steps',
|
|
25
|
+
'',
|
|
26
|
+
'1. **Do NOT merge**',
|
|
27
|
+
'',
|
|
28
|
+
'### Detail',
|
|
29
|
+
'',
|
|
30
|
+
].join('\n')
|
|
31
|
+
|
|
32
|
+
describe('inlineSharedPhase', () => {
|
|
33
|
+
it('puts the phase where the pointer was, nested under the delivery heading', () => {
|
|
34
|
+
const out = inlineSharedPhase(TEMPLATE, SHARED)
|
|
35
|
+
expect(out).toContain('### Phase 5: Delivery\n\n#### Steps\n\n1. **Do NOT merge**\n\n##### Detail\n')
|
|
36
|
+
expect(out).not.toContain('shared-delivery-phase.md')
|
|
37
|
+
expect(out).not.toContain('Shared Delivery Phase')
|
|
38
|
+
expect(out).not.toContain('This file is managed')
|
|
39
|
+
expect(out).toContain('\n## After\n')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('leaves a template without the pointer as it is', () => {
|
|
43
|
+
const own = '# Workflow: Ours\n\n## Phase 1: Do it\n'
|
|
44
|
+
expect(inlineSharedPhase(own, SHARED)).toBe(own)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('keeps the words and drops the link when a layer left the phase out', () => {
|
|
48
|
+
const out = inlineSharedPhase(TEMPLATE, null)
|
|
49
|
+
expect(out).not.toContain('](shared-delivery-phase.md)')
|
|
50
|
+
expect(out).toContain('See the shared delivery phase for the standard delivery steps.')
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
describe('isWorkflowTemplate', () => {
|
|
55
|
+
it('is a template unless it is the README or the shared phase', () => {
|
|
56
|
+
expect(isWorkflowTemplate('bug-fix.md')).toBe(true)
|
|
57
|
+
expect(isWorkflowTemplate('README.md')).toBe(false)
|
|
58
|
+
expect(isWorkflowTemplate('shared-delivery-phase.md')).toBe(false)
|
|
59
|
+
expect(isWorkflowTemplate('notes.txt')).toBe(false)
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
describe('pointAtWorkflows', () => {
|
|
64
|
+
it("replaces Copilot's folder with this target's, and nothing else", () => {
|
|
65
|
+
const text = 'Search `.github/agent-workflows/`. Keep `.github/workflows/ci.yml`.'
|
|
66
|
+
expect(pointAtWorkflows(text, '.claude/commands/oc/workflow-*.md')).toBe(
|
|
67
|
+
'Search `.claude/commands/oc/workflow-*.md`. Keep `.github/workflows/ci.yml`.',
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
import { stripFrontmatter } from './frontmatter.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The phase every workflow template ends with, written once in the source.
|
|
7
|
+
*
|
|
8
|
+
* It used to be installed beside the templates and linked from each of them,
|
|
9
|
+
* which worked in exactly one layout. Claude Code names its copy
|
|
10
|
+
* `workflow-shared-delivery-phase.md` and Cursor `shared-delivery-phase.mdc`,
|
|
11
|
+
* so the link `shared-delivery-phase.md` led nowhere there; and in Claude Code
|
|
12
|
+
* the fragment became a command of its own, `/oc:workflow-shared-delivery-phase`,
|
|
13
|
+
* that runs nothing. Each template now carries the phase itself, so a template
|
|
14
|
+
* is whole wherever it is read and the fragment is never installed.
|
|
15
|
+
*/
|
|
16
|
+
export const SHARED_PHASE_FILE = 'shared-delivery-phase.md'
|
|
17
|
+
|
|
18
|
+
/** Is this file in `agent-workflows/` a template someone can run? */
|
|
19
|
+
export function isWorkflowTemplate(name: string): boolean {
|
|
20
|
+
return name.endsWith('.md') && name !== 'README.md' && name !== SHARED_PHASE_FILE
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The shared phase as compiled from `srcRoot`, or null when no layer provides it. */
|
|
24
|
+
export function readSharedPhase(srcRoot: string): string | null {
|
|
25
|
+
const path = resolve(srcRoot, 'agent-workflows', SHARED_PHASE_FILE)
|
|
26
|
+
return existsSync(path) ? readFileSync(path, 'utf8') : null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A pointer to the shared phase: a blockquote whose first line links to it. */
|
|
30
|
+
const POINTER = /^>[^\n]*\]\(shared-delivery-phase\.md\)[^\n]*\n(?:>[^\n]*\n?)*/m
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The template with its pointer to the shared phase replaced by the phase.
|
|
34
|
+
*
|
|
35
|
+
* The phase's own title and introduction are left out, and its sections are
|
|
36
|
+
* nested under the template's delivery heading. Without the phase — a team
|
|
37
|
+
* layer excluded it — the link is reduced to its words, so nothing points at a
|
|
38
|
+
* file that was never written.
|
|
39
|
+
*/
|
|
40
|
+
export function inlineSharedPhase(template: string, shared: string | null): string {
|
|
41
|
+
if (!POINTER.test(template)) return template
|
|
42
|
+
if (shared === null) {
|
|
43
|
+
return template.replace(/\[([^\]]+)\]\(shared-delivery-phase\.md\)/g, 'the shared delivery phase')
|
|
44
|
+
}
|
|
45
|
+
const body = stripFrontmatter(shared)
|
|
46
|
+
.replace(/^<!--[\s\S]*?-->\s*/, '')
|
|
47
|
+
.replace(/^#\s[^\n]*\n+/, '')
|
|
48
|
+
// Everything before the first section is the phase describing itself.
|
|
49
|
+
const sections = body.slice(Math.max(0, body.search(/^##\s/m))).trim()
|
|
50
|
+
const nested = sections.replace(/^(#{2,4})(\s)/gm, '##$1$2')
|
|
51
|
+
return template.replace(POINTER, `${nested}\n`)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The source names the templates' folder as VS Code installs it,
|
|
56
|
+
* `.github/agent-workflows/`. Every other target writes them somewhere else,
|
|
57
|
+
* and the Team Lead was sent to search a folder that only a Copilot project
|
|
58
|
+
* has. `where` is this target's folder, or the glob for its files.
|
|
59
|
+
*/
|
|
60
|
+
export function pointAtWorkflows(content: string, where: string): string {
|
|
61
|
+
return content.replaceAll('`.github/agent-workflows/`', `\`${where}\``)
|
|
62
|
+
}
|
|
@@ -176,6 +176,21 @@ export interface ExecuteOptions {
|
|
|
176
176
|
permissionMode?: PermissionMode;
|
|
177
177
|
/** A model name the runtime understands; omitted means the runtime's own default. */
|
|
178
178
|
model?: string;
|
|
179
|
+
/**
|
|
180
|
+
* How much the model reasons before it answers, where the runtime lets a
|
|
181
|
+
* caller choose; omitted means the runtime's own default. Planning asks for
|
|
182
|
+
* less: measured on Claude Code, a PRD took 129s at the default and 36s at
|
|
183
|
+
* `low`, with the same sections, because most of the session was thinking.
|
|
184
|
+
*/
|
|
185
|
+
effort?: 'low' | 'medium' | 'high';
|
|
186
|
+
/**
|
|
187
|
+
* A self-contained, read-only session: everything it needs is in its prompt
|
|
188
|
+
* or in the files it reads. It starts no MCP server, loads no skill or
|
|
189
|
+
* command, and has only the tools that read files — so it cannot spend its
|
|
190
|
+
* time on a web search or a sub-agent. Runtimes that cannot narrow a session
|
|
191
|
+
* this way run it as usual.
|
|
192
|
+
*/
|
|
193
|
+
lean?: boolean;
|
|
179
194
|
/**
|
|
180
195
|
* @deprecated Ignored. Agents read the project's own MCP config, which
|
|
181
196
|
* `opencastle sync` compiles for every assistant; writing a second copy
|
|
@@ -43,9 +43,9 @@ const actual = {
|
|
|
43
43
|
skills: countDirEntries(join(orchestrator, 'skills'), () => true),
|
|
44
44
|
plugins: countDirEntries(join(orchestrator, 'plugins'), (n) => !n.endsWith('.ts')),
|
|
45
45
|
// README.md documents the directory for contributors; it is not a template,
|
|
46
|
-
// and no adapter installs it. shared-delivery-phase.md is
|
|
47
|
-
//
|
|
48
|
-
// made the README say 9 while the template tables everywhere else list 8.
|
|
46
|
+
// and no adapter installs it. shared-delivery-phase.md is the phase every
|
|
47
|
+
// template ends with, compiled into each, not a template of its own — counting
|
|
48
|
+
// it made the README say 9 while the template tables everywhere else list 8.
|
|
49
49
|
workflows: countDirEntries(
|
|
50
50
|
join(orchestrator, 'agent-workflows'),
|
|
51
51
|
(n) => n.endsWith('.md') && n !== 'README.md' && n !== 'shared-delivery-phase.md',
|
package/src/cli/explain.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { PLUGINS } from '../orchestrator/plugins/index.js'
|
|
|
11
11
|
import { c } from './prompt.js'
|
|
12
12
|
import { IDE_LABELS, type CliContext, type IdeChoice } from './types.js'
|
|
13
13
|
import { COMMAND_NAMESPACE } from './command-namespace.js'
|
|
14
|
+
import { isWorkflowTemplate } from './adapters/workflows.js'
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* `opencastle explain`: what a new teammate's assistant is given here, and
|
|
@@ -163,7 +164,8 @@ function render(report: ExplainReport, all: boolean): void {
|
|
|
163
164
|
...(report.targets.some((t) => t.id === 'vscode') ? ['Copilot'] : []),
|
|
164
165
|
]
|
|
165
166
|
for (const kind of ['skills', 'agents', 'prompts', 'workflows'] as const) {
|
|
166
|
-
|
|
167
|
+
// The shared delivery phase is compiled into every template, not run on its own.
|
|
168
|
+
const items = ofKind(kind).filter(([ref]) => kind !== 'workflows' || isWorkflowTemplate(`${ref.slice(kind.length + 1)}.md`))
|
|
167
169
|
if (items.length === 0) continue
|
|
168
170
|
const team = items.filter(([, i]) => i.from !== 'opencastle' && !i.from.startsWith('plugin:'))
|
|
169
171
|
const integrations = items.filter(([, i]) => i.from.startsWith('plugin:'))
|