binder-cli 1.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.
- package/LICENSE +21 -0
- package/README.md +177 -0
- package/bin/binder.js +2 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +119 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/context.d.ts +12 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +105 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +119 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/pull.d.ts +5 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +47 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/status.d.ts +5 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +116 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/core/config/parser.d.ts +24 -0
- package/dist/core/config/parser.d.ts.map +1 -0
- package/dist/core/config/parser.js +116 -0
- package/dist/core/config/parser.js.map +1 -0
- package/dist/core/config/types.d.ts +142 -0
- package/dist/core/config/types.d.ts.map +1 -0
- package/dist/core/config/types.js +71 -0
- package/dist/core/config/types.js.map +1 -0
- package/dist/core/generator/context-map.d.ts +6 -0
- package/dist/core/generator/context-map.d.ts.map +1 -0
- package/dist/core/generator/context-map.js +124 -0
- package/dist/core/generator/context-map.js.map +1 -0
- package/dist/core/generator/injection-content.d.ts +9 -0
- package/dist/core/generator/injection-content.d.ts.map +1 -0
- package/dist/core/generator/injection-content.js +38 -0
- package/dist/core/generator/injection-content.js.map +1 -0
- package/dist/core/generator/rule-injector.d.ts +33 -0
- package/dist/core/generator/rule-injector.d.ts.map +1 -0
- package/dist/core/generator/rule-injector.js +208 -0
- package/dist/core/generator/rule-injector.js.map +1 -0
- package/dist/core/git/operations.d.ts +52 -0
- package/dist/core/git/operations.d.ts.map +1 -0
- package/dist/core/git/operations.js +221 -0
- package/dist/core/git/operations.js.map +1 -0
- package/dist/core/workspace/orchestrator.d.ts +28 -0
- package/dist/core/workspace/orchestrator.d.ts.map +1 -0
- package/dist/core/workspace/orchestrator.js +151 -0
- package/dist/core/workspace/orchestrator.js.map +1 -0
- package/dist/core/workspace/status.d.ts +45 -0
- package/dist/core/workspace/status.d.ts.map +1 -0
- package/dist/core/workspace/status.js +142 -0
- package/dist/core/workspace/status.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/errors.d.ts +45 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +83 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/filesystem.d.ts +42 -0
- package/dist/utils/filesystem.d.ts.map +1 -0
- package/dist/utils/filesystem.js +152 -0
- package/dist/utils/filesystem.js.map +1 -0
- package/dist/utils/logger.d.ts +59 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +118 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +79 -0
- package/templates/binder.yaml.template +52 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.statusCommand = statusCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const parser_1 = require("../core/config/parser");
|
|
9
|
+
const status_1 = require("../core/workspace/status");
|
|
10
|
+
const logger_1 = require("../utils/logger");
|
|
11
|
+
function getRepoState(repo) {
|
|
12
|
+
if (!repo.exists)
|
|
13
|
+
return 'missing';
|
|
14
|
+
if (!repo.isGitRepo)
|
|
15
|
+
return 'not-git';
|
|
16
|
+
if (repo.isDirty)
|
|
17
|
+
return 'dirty';
|
|
18
|
+
if (repo.branchMismatch)
|
|
19
|
+
return 'branch-mismatch';
|
|
20
|
+
return 'ok';
|
|
21
|
+
}
|
|
22
|
+
function getStatusDisplay(repo) {
|
|
23
|
+
const displays = {
|
|
24
|
+
missing: () => ({
|
|
25
|
+
icon: chalk_1.default.red('✗'),
|
|
26
|
+
text: chalk_1.default.red('missing'),
|
|
27
|
+
}),
|
|
28
|
+
'not-git': () => ({
|
|
29
|
+
icon: chalk_1.default.yellow('?'),
|
|
30
|
+
text: chalk_1.default.yellow('not a git repo'),
|
|
31
|
+
}),
|
|
32
|
+
dirty: () => ({
|
|
33
|
+
icon: chalk_1.default.yellow('●'),
|
|
34
|
+
text: chalk_1.default.yellow('dirty'),
|
|
35
|
+
}),
|
|
36
|
+
'branch-mismatch': () => ({
|
|
37
|
+
icon: chalk_1.default.yellow('⇄'),
|
|
38
|
+
text: chalk_1.default.yellow(`on ${repo.currentBranch}, expected ${repo.expectedBranch}`),
|
|
39
|
+
}),
|
|
40
|
+
ok: () => ({
|
|
41
|
+
icon: chalk_1.default.green('✓'),
|
|
42
|
+
text: chalk_1.default.green(repo.currentBranch || 'ok'),
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
return displays[getRepoState(repo)]();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Display workspace status
|
|
49
|
+
*/
|
|
50
|
+
async function statusCommand() {
|
|
51
|
+
// Load configuration
|
|
52
|
+
let config;
|
|
53
|
+
try {
|
|
54
|
+
config = await (0, parser_1.loadConfig)();
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
if (err instanceof parser_1.ConfigError) {
|
|
58
|
+
(0, logger_1.error)(err.message);
|
|
59
|
+
(0, logger_1.info)('Run `binder init` to create a configuration file.');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
(0, logger_1.error)('Failed to load configuration');
|
|
63
|
+
}
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
// Get workspace status
|
|
67
|
+
const status = await (0, status_1.getWorkspaceStatus)(config);
|
|
68
|
+
(0, logger_1.header)(`Workspace: ${status.workspaceName}`);
|
|
69
|
+
// Group repos by scope for display
|
|
70
|
+
const byScope = {
|
|
71
|
+
owner: [],
|
|
72
|
+
platform: [],
|
|
73
|
+
reference: [],
|
|
74
|
+
};
|
|
75
|
+
for (const repo of status.repos) {
|
|
76
|
+
byScope[repo.scope].push(repo);
|
|
77
|
+
}
|
|
78
|
+
// Display repos by scope
|
|
79
|
+
const scopes = ['owner', 'platform', 'reference'];
|
|
80
|
+
for (const scope of scopes) {
|
|
81
|
+
const repos = byScope[scope];
|
|
82
|
+
if (repos.length === 0)
|
|
83
|
+
continue;
|
|
84
|
+
console.log((0, logger_1.formatScope)(scope).toUpperCase());
|
|
85
|
+
for (const repo of repos) {
|
|
86
|
+
const { icon, text } = getStatusDisplay(repo);
|
|
87
|
+
console.log(` ${icon} ${repo.name} ${chalk_1.default.dim(`(${text})`)}`);
|
|
88
|
+
}
|
|
89
|
+
(0, logger_1.newline)();
|
|
90
|
+
}
|
|
91
|
+
// Display orphaned repos if any
|
|
92
|
+
if (status.orphanedRepos.length > 0) {
|
|
93
|
+
console.log(chalk_1.default.gray('ORPHANED (not in config)'));
|
|
94
|
+
for (const repo of status.orphanedRepos) {
|
|
95
|
+
console.log(` ${chalk_1.default.gray('?')} ${repo.name} ${chalk_1.default.dim(`(${repo.path})`)}`);
|
|
96
|
+
}
|
|
97
|
+
(0, logger_1.newline)();
|
|
98
|
+
}
|
|
99
|
+
// Summary
|
|
100
|
+
console.log(chalk_1.default.bold('Summary'));
|
|
101
|
+
console.log(` Total: ${status.summary.total}`);
|
|
102
|
+
console.log(` Existing: ${chalk_1.default.green(status.summary.existing)}`);
|
|
103
|
+
if (status.summary.missing > 0) {
|
|
104
|
+
console.log(` Missing: ${chalk_1.default.red(status.summary.missing)}`);
|
|
105
|
+
}
|
|
106
|
+
if (status.summary.dirty > 0) {
|
|
107
|
+
console.log(` Dirty: ${chalk_1.default.yellow(status.summary.dirty)}`);
|
|
108
|
+
}
|
|
109
|
+
if (status.summary.branchMismatches > 0) {
|
|
110
|
+
console.log(` Branch mismatches: ${chalk_1.default.yellow(status.summary.branchMismatches)}`);
|
|
111
|
+
}
|
|
112
|
+
if (status.summary.orphaned > 0) {
|
|
113
|
+
console.log(` Orphaned: ${chalk_1.default.gray(status.summary.orphaned)}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":";;;;;AAmDA,sCAsEC;AAzHD,kDAA0B;AAC1B,kDAAgE;AAChE,qDAA8E;AAC9E,4CAA4E;AAU5E,SAAS,YAAY,CAAC,IAAoB;IACxC,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IACtC,IAAI,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IACjC,IAAI,IAAI,CAAC,cAAc;QAAE,OAAO,iBAAiB,CAAC;IAClD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAoB;IAC5C,MAAM,QAAQ,GAA2C;QACvD,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;YACd,IAAI,EAAE,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC;YACpB,IAAI,EAAE,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC;SAC3B,CAAC;QACF,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;YAChB,IAAI,EAAE,eAAK,CAAC,MAAM,CAAC,GAAG,CAAC;YACvB,IAAI,EAAE,eAAK,CAAC,MAAM,CA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AO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type BinderConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Custom error class for configuration-related errors
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConfigError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parse a YAML string into a validated BinderConfig
|
|
10
|
+
*
|
|
11
|
+
* @param yamlContent - Raw YAML string to parse
|
|
12
|
+
* @returns Validated BinderConfig object
|
|
13
|
+
* @throws ConfigError if YAML syntax is invalid or validation fails
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseConfig(yamlContent: string): BinderConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Load and parse a binder.yaml configuration file
|
|
18
|
+
*
|
|
19
|
+
* @param configPath - Path to the config file (defaults to ./binder.yaml)
|
|
20
|
+
* @returns Validated BinderConfig object
|
|
21
|
+
* @throws ConfigError if file doesn't exist, is unreadable, or fails validation
|
|
22
|
+
*/
|
|
23
|
+
export declare function loadConfig(configPath?: string): Promise<BinderConfig>;
|
|
24
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/core/config/parser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAEhE;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAQ5B;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,CAwB7D;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAoB3E"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ConfigError = void 0;
|
|
37
|
+
exports.parseConfig = parseConfig;
|
|
38
|
+
exports.loadConfig = loadConfig;
|
|
39
|
+
const fs = __importStar(require("fs-extra"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const YAML = __importStar(require("yaml"));
|
|
42
|
+
const zod_1 = require("zod");
|
|
43
|
+
const types_1 = require("./types");
|
|
44
|
+
/**
|
|
45
|
+
* Custom error class for configuration-related errors
|
|
46
|
+
*/
|
|
47
|
+
class ConfigError extends Error {
|
|
48
|
+
constructor(message) {
|
|
49
|
+
super(message);
|
|
50
|
+
this.name = 'ConfigError';
|
|
51
|
+
// Maintains proper stack trace for where error was thrown (V8 only)
|
|
52
|
+
if (Error.captureStackTrace) {
|
|
53
|
+
Error.captureStackTrace(this, ConfigError);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ConfigError = ConfigError;
|
|
58
|
+
/**
|
|
59
|
+
* Parse a YAML string into a validated BinderConfig
|
|
60
|
+
*
|
|
61
|
+
* @param yamlContent - Raw YAML string to parse
|
|
62
|
+
* @returns Validated BinderConfig object
|
|
63
|
+
* @throws ConfigError if YAML syntax is invalid or validation fails
|
|
64
|
+
*/
|
|
65
|
+
function parseConfig(yamlContent) {
|
|
66
|
+
let parsed;
|
|
67
|
+
// Parse YAML syntax
|
|
68
|
+
try {
|
|
69
|
+
parsed = YAML.parse(yamlContent);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const message = error instanceof Error ? error.message : 'Unknown YAML parsing error';
|
|
73
|
+
throw new ConfigError(`Invalid YAML syntax: ${message}`);
|
|
74
|
+
}
|
|
75
|
+
// Validate against schema
|
|
76
|
+
try {
|
|
77
|
+
return types_1.BinderConfigSchema.parse(parsed);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (error instanceof zod_1.ZodError) {
|
|
81
|
+
const issues = error.issues.map((issue) => {
|
|
82
|
+
const path = issue.path.join('.');
|
|
83
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
84
|
+
});
|
|
85
|
+
throw new ConfigError(`Configuration validation failed:\n - ${issues.join('\n - ')}`);
|
|
86
|
+
}
|
|
87
|
+
throw new ConfigError('Unknown validation error');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Load and parse a binder.yaml configuration file
|
|
92
|
+
*
|
|
93
|
+
* @param configPath - Path to the config file (defaults to ./binder.yaml)
|
|
94
|
+
* @returns Validated BinderConfig object
|
|
95
|
+
* @throws ConfigError if file doesn't exist, is unreadable, or fails validation
|
|
96
|
+
*/
|
|
97
|
+
async function loadConfig(configPath) {
|
|
98
|
+
const resolvedPath = configPath ?? path.join(process.cwd(), 'binder.yaml');
|
|
99
|
+
// Check if file exists
|
|
100
|
+
const exists = await fs.pathExists(resolvedPath);
|
|
101
|
+
if (!exists) {
|
|
102
|
+
throw new ConfigError(`Configuration file not found: ${resolvedPath}`);
|
|
103
|
+
}
|
|
104
|
+
// Read file contents
|
|
105
|
+
let content;
|
|
106
|
+
try {
|
|
107
|
+
content = await fs.readFile(resolvedPath, 'utf-8');
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
111
|
+
throw new ConfigError(`Failed to read configuration file ${resolvedPath}: ${message}`);
|
|
112
|
+
}
|
|
113
|
+
// Parse and validate
|
|
114
|
+
return parseConfig(content);
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/core/config/parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,kCAwBC;AASD,gCAoBC;AAhFD,6CAA+B;AAC/B,2CAA6B;AAC7B,2CAA6B;AAC7B,6BAA+B;AAC/B,mCAAgE;AAEhE;;GAEG;AACH,MAAa,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAA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H,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,UAAU,CAAC,UAAmB;IAClD,MAAM,YAAY,GAAG,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAE3E,uBAAuB;IACvB,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,WAAW,CAAC,iCAAiC,YAAY,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,qBAAqB;IACrB,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QACzE,MAAM,IAAI,WAAW,CAAC,qCAAqC,YAAY,KAAK,OAAO,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,qBAAqB;IACrB,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Scope defines the level of access/permission for a repository
|
|
4
|
+
* - owner: Full read/write access, full refactoring authority
|
|
5
|
+
* - platform: Restricted contributor, minimal edits only
|
|
6
|
+
* - reference: Read-only, used for validation and context
|
|
7
|
+
*/
|
|
8
|
+
export declare const ScopeSchema: z.ZodEnum<["owner", "platform", "reference"]>;
|
|
9
|
+
/**
|
|
10
|
+
* Repository configuration schema
|
|
11
|
+
* URL is required for remote repos, but optional for path: '.' (current directory)
|
|
12
|
+
*/
|
|
13
|
+
export declare const RepositorySchema: z.ZodEffects<z.ZodObject<{
|
|
14
|
+
/** Repository name (used for display and default path) */
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
/** Git URL (HTTPS or SSH) - optional for path: '.' */
|
|
17
|
+
url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
18
|
+
/** Local path relative to workspace root (defaults to ./repos/{name}) */
|
|
19
|
+
path: z.ZodOptional<z.ZodString>;
|
|
20
|
+
/** Access scope for this repository */
|
|
21
|
+
scope: z.ZodEnum<["owner", "platform", "reference"]>;
|
|
22
|
+
/** Branch to checkout (defaults to default branch) */
|
|
23
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
24
|
+
/** Notes about this repository (included in CONTEXT_MAP.md) */
|
|
25
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
26
|
+
/** Shallow clone depth (positive integer) */
|
|
27
|
+
depth: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
name: string;
|
|
30
|
+
scope: "owner" | "platform" | "reference";
|
|
31
|
+
path?: string | undefined;
|
|
32
|
+
url?: string | undefined;
|
|
33
|
+
branch?: string | undefined;
|
|
34
|
+
notes?: string | undefined;
|
|
35
|
+
depth?: number | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
name: string;
|
|
38
|
+
scope: "owner" | "platform" | "reference";
|
|
39
|
+
path?: string | undefined;
|
|
40
|
+
url?: string | undefined;
|
|
41
|
+
branch?: string | undefined;
|
|
42
|
+
notes?: string | undefined;
|
|
43
|
+
depth?: number | undefined;
|
|
44
|
+
}>, {
|
|
45
|
+
name: string;
|
|
46
|
+
scope: "owner" | "platform" | "reference";
|
|
47
|
+
path?: string | undefined;
|
|
48
|
+
url?: string | undefined;
|
|
49
|
+
branch?: string | undefined;
|
|
50
|
+
notes?: string | undefined;
|
|
51
|
+
depth?: number | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
name: string;
|
|
54
|
+
scope: "owner" | "platform" | "reference";
|
|
55
|
+
path?: string | undefined;
|
|
56
|
+
url?: string | undefined;
|
|
57
|
+
branch?: string | undefined;
|
|
58
|
+
notes?: string | undefined;
|
|
59
|
+
depth?: number | undefined;
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Root binder.yaml configuration schema
|
|
63
|
+
*/
|
|
64
|
+
export declare const BinderConfigSchema: z.ZodObject<{
|
|
65
|
+
/** Workspace name */
|
|
66
|
+
name: z.ZodString;
|
|
67
|
+
/** List of repositories in this workspace */
|
|
68
|
+
repos: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
69
|
+
/** Repository name (used for display and default path) */
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
/** Git URL (HTTPS or SSH) - optional for path: '.' */
|
|
72
|
+
url: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
73
|
+
/** Local path relative to workspace root (defaults to ./repos/{name}) */
|
|
74
|
+
path: z.ZodOptional<z.ZodString>;
|
|
75
|
+
/** Access scope for this repository */
|
|
76
|
+
scope: z.ZodEnum<["owner", "platform", "reference"]>;
|
|
77
|
+
/** Branch to checkout (defaults to default branch) */
|
|
78
|
+
branch: z.ZodOptional<z.ZodString>;
|
|
79
|
+
/** Notes about this repository (included in CONTEXT_MAP.md) */
|
|
80
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
81
|
+
/** Shallow clone depth (positive integer) */
|
|
82
|
+
depth: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
name: string;
|
|
85
|
+
scope: "owner" | "platform" | "reference";
|
|
86
|
+
path?: string | undefined;
|
|
87
|
+
url?: string | undefined;
|
|
88
|
+
branch?: string | undefined;
|
|
89
|
+
notes?: string | undefined;
|
|
90
|
+
depth?: number | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
name: string;
|
|
93
|
+
scope: "owner" | "platform" | "reference";
|
|
94
|
+
path?: string | undefined;
|
|
95
|
+
url?: string | undefined;
|
|
96
|
+
branch?: string | undefined;
|
|
97
|
+
notes?: string | undefined;
|
|
98
|
+
depth?: number | undefined;
|
|
99
|
+
}>, {
|
|
100
|
+
name: string;
|
|
101
|
+
scope: "owner" | "platform" | "reference";
|
|
102
|
+
path?: string | undefined;
|
|
103
|
+
url?: string | undefined;
|
|
104
|
+
branch?: string | undefined;
|
|
105
|
+
notes?: string | undefined;
|
|
106
|
+
depth?: number | undefined;
|
|
107
|
+
}, {
|
|
108
|
+
name: string;
|
|
109
|
+
scope: "owner" | "platform" | "reference";
|
|
110
|
+
path?: string | undefined;
|
|
111
|
+
url?: string | undefined;
|
|
112
|
+
branch?: string | undefined;
|
|
113
|
+
notes?: string | undefined;
|
|
114
|
+
depth?: number | undefined;
|
|
115
|
+
}>, "many">;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
name: string;
|
|
118
|
+
repos: {
|
|
119
|
+
name: string;
|
|
120
|
+
scope: "owner" | "platform" | "reference";
|
|
121
|
+
path?: string | undefined;
|
|
122
|
+
url?: string | undefined;
|
|
123
|
+
branch?: string | undefined;
|
|
124
|
+
notes?: string | undefined;
|
|
125
|
+
depth?: number | undefined;
|
|
126
|
+
}[];
|
|
127
|
+
}, {
|
|
128
|
+
name: string;
|
|
129
|
+
repos: {
|
|
130
|
+
name: string;
|
|
131
|
+
scope: "owner" | "platform" | "reference";
|
|
132
|
+
path?: string | undefined;
|
|
133
|
+
url?: string | undefined;
|
|
134
|
+
branch?: string | undefined;
|
|
135
|
+
notes?: string | undefined;
|
|
136
|
+
depth?: number | undefined;
|
|
137
|
+
}[];
|
|
138
|
+
}>;
|
|
139
|
+
export type Scope = z.infer<typeof ScopeSchema>;
|
|
140
|
+
export type Repository = z.infer<typeof RepositorySchema>;
|
|
141
|
+
export type BinderConfig = z.infer<typeof BinderConfigSchema>;
|
|
142
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,WAAW,+CAA6C,CAAC;AA4BtE;;;GAGG;AACH,eAAO,MAAM,gBAAgB;IAEzB,0DAA0D;;IAG1D,sDAAsD;;IAGtD,yEAAyE;;IAGzE,uCAAuC;;IAGvC,sDAAsD;;IAGtD,+DAA+D;;IAG/D,6CAA6C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAY9C,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,qBAAqB;;IAGrB,6CAA6C;;QAvC3C,0DAA0D;;QAG1D,sDAAsD;;QAGtD,yEAAyE;;QAGzE,uCAAuC;;QAGvC,sDAAsD;;QAGtD,+DAA+D;;QAG/D,6CAA6C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuB/C,CAAC;AAGH,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAChD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BinderConfigSchema = exports.RepositorySchema = exports.ScopeSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Scope defines the level of access/permission for a repository
|
|
7
|
+
* - owner: Full read/write access, full refactoring authority
|
|
8
|
+
* - platform: Restricted contributor, minimal edits only
|
|
9
|
+
* - reference: Read-only, used for validation and context
|
|
10
|
+
*/
|
|
11
|
+
exports.ScopeSchema = zod_1.z.enum(['owner', 'platform', 'reference']);
|
|
12
|
+
/**
|
|
13
|
+
* Git URL validator that accepts both HTTPS and SSH URLs
|
|
14
|
+
* Examples:
|
|
15
|
+
* - https://github.com/org/repo.git
|
|
16
|
+
* - git@github.com:org/repo.git
|
|
17
|
+
* - ssh://git@github.com/org/repo.git
|
|
18
|
+
*/
|
|
19
|
+
const gitUrlSchema = zod_1.z.string().refine((url) => {
|
|
20
|
+
// HTTPS URLs
|
|
21
|
+
if (url.startsWith('https://') || url.startsWith('http://')) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
// SSH URLs (git@host:path or ssh://)
|
|
25
|
+
if (url.startsWith('git@') || url.startsWith('ssh://')) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
// Git protocol
|
|
29
|
+
if (url.startsWith('git://')) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}, { message: 'Invalid git URL. Must be HTTPS, SSH, or git protocol URL.' });
|
|
34
|
+
/**
|
|
35
|
+
* Repository configuration schema
|
|
36
|
+
* URL is required for remote repos, but optional for path: '.' (current directory)
|
|
37
|
+
*/
|
|
38
|
+
exports.RepositorySchema = zod_1.z
|
|
39
|
+
.object({
|
|
40
|
+
/** Repository name (used for display and default path) */
|
|
41
|
+
name: zod_1.z.string().min(1, 'Repository name cannot be empty'),
|
|
42
|
+
/** Git URL (HTTPS or SSH) - optional for path: '.' */
|
|
43
|
+
url: gitUrlSchema.optional(),
|
|
44
|
+
/** Local path relative to workspace root (defaults to ./repos/{name}) */
|
|
45
|
+
path: zod_1.z.string().optional(),
|
|
46
|
+
/** Access scope for this repository */
|
|
47
|
+
scope: exports.ScopeSchema,
|
|
48
|
+
/** Branch to checkout (defaults to default branch) */
|
|
49
|
+
branch: zod_1.z.string().optional(),
|
|
50
|
+
/** Notes about this repository (included in CONTEXT_MAP.md) */
|
|
51
|
+
notes: zod_1.z.string().optional(),
|
|
52
|
+
/** Shallow clone depth (positive integer) */
|
|
53
|
+
depth: zod_1.z.number().int().positive().optional(),
|
|
54
|
+
})
|
|
55
|
+
.refine((repo) => {
|
|
56
|
+
// URL is required unless path is '.'
|
|
57
|
+
if (repo.path === '.') {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return repo.url !== undefined;
|
|
61
|
+
}, { message: 'URL is required for repositories (unless path is ".")' });
|
|
62
|
+
/**
|
|
63
|
+
* Root binder.yaml configuration schema
|
|
64
|
+
*/
|
|
65
|
+
exports.BinderConfigSchema = zod_1.z.object({
|
|
66
|
+
/** Workspace name */
|
|
67
|
+
name: zod_1.z.string().min(1, 'Workspace name cannot be empty'),
|
|
68
|
+
/** List of repositories in this workspace */
|
|
69
|
+
repos: zod_1.z.array(exports.RepositorySchema).min(1, 'At least one repository is required'),
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/config/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;;;;GAKG;AACU,QAAA,WAAW,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CACpC,CAAC,GAAG,EAAE,EAAE;IACN,aAAa;IACb,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,qCAAqC;IACrC,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,eAAe;IACf,IAAI,GAAG,CAAC,UAAU,CAAC,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KAAK,CAAC,wBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,qCAAqC,CAAC;CAC/E,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-map.d.ts","sourceRoot":"","sources":["../../../src/core/generator/context-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,iBAAiB,CAAC;AA6GvE;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAwC/D"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateContextMap = generateContextMap;
|
|
4
|
+
const filesystem_1 = require("../../utils/filesystem");
|
|
5
|
+
const SCOPE_CONFIGS = {
|
|
6
|
+
owner: {
|
|
7
|
+
emoji: '🟢',
|
|
8
|
+
title: 'OWNER',
|
|
9
|
+
subtitle: 'Full Authority',
|
|
10
|
+
permissions: 'Full read/write access',
|
|
11
|
+
instructions: [
|
|
12
|
+
'You are responsible for architecture, implementation, and refactoring.',
|
|
13
|
+
'Make changes freely to improve code quality and functionality.',
|
|
14
|
+
'You have complete authority over these repositories.',
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
platform: {
|
|
18
|
+
emoji: '🟡',
|
|
19
|
+
title: 'PLATFORM',
|
|
20
|
+
subtitle: 'Restricted Contributor',
|
|
21
|
+
permissions: 'Limited write access',
|
|
22
|
+
instructions: [
|
|
23
|
+
'Only make minimal changes when necessary to support OWNER scope.',
|
|
24
|
+
'Strictly adhere to existing patterns and conventions.',
|
|
25
|
+
'Do not refactor or restructure code.',
|
|
26
|
+
'Changes should be small, focused, and well-justified.',
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
reference: {
|
|
30
|
+
emoji: '🔴',
|
|
31
|
+
title: 'REFERENCE',
|
|
32
|
+
subtitle: 'Read Only',
|
|
33
|
+
permissions: 'Read-only',
|
|
34
|
+
instructions: [
|
|
35
|
+
'Use for validation and historical context only.',
|
|
36
|
+
'Do not suggest modifications to these repositories.',
|
|
37
|
+
'Reference for understanding patterns and dependencies.',
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Group repositories by their scope
|
|
43
|
+
*/
|
|
44
|
+
function groupByScope(repos) {
|
|
45
|
+
const groups = {
|
|
46
|
+
owner: [],
|
|
47
|
+
platform: [],
|
|
48
|
+
reference: [],
|
|
49
|
+
};
|
|
50
|
+
for (const repo of repos) {
|
|
51
|
+
groups[repo.scope].push(repo);
|
|
52
|
+
}
|
|
53
|
+
return groups;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the display path for a repository
|
|
57
|
+
*/
|
|
58
|
+
function getDisplayPath(repo) {
|
|
59
|
+
return repo.path ?? (0, filesystem_1.getDefaultRepoPath)(repo.name);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Generate a scope section for the context map
|
|
63
|
+
*/
|
|
64
|
+
function generateScopeSection(scope, repos) {
|
|
65
|
+
if (repos.length === 0) {
|
|
66
|
+
return '';
|
|
67
|
+
}
|
|
68
|
+
const config = SCOPE_CONFIGS[scope];
|
|
69
|
+
const lines = [];
|
|
70
|
+
lines.push(`## ${config.emoji} SCOPE: ${config.title} (${config.subtitle})`);
|
|
71
|
+
lines.push('');
|
|
72
|
+
lines.push('**Repositories:**');
|
|
73
|
+
for (const repo of repos) {
|
|
74
|
+
const displayPath = getDisplayPath(repo);
|
|
75
|
+
lines.push(`- \`${repo.name}\` at \`${displayPath}\``);
|
|
76
|
+
if (repo.notes) {
|
|
77
|
+
lines.push(` - *${repo.notes}*`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
lines.push('');
|
|
81
|
+
lines.push(`**Permissions:** ${config.permissions}`);
|
|
82
|
+
lines.push('');
|
|
83
|
+
lines.push('**Instructions:**');
|
|
84
|
+
for (const instruction of config.instructions) {
|
|
85
|
+
lines.push(`- ${instruction}`);
|
|
86
|
+
}
|
|
87
|
+
return lines.join('\n');
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Generate the CONTEXT_MAP.md content from a binder configuration
|
|
91
|
+
*/
|
|
92
|
+
function generateContextMap(config) {
|
|
93
|
+
const lines = [];
|
|
94
|
+
const timestamp = new Date().toISOString();
|
|
95
|
+
// Header
|
|
96
|
+
lines.push('# WORKSPACE TOPOLOGY & SCOPE DEFINITIONS');
|
|
97
|
+
lines.push('');
|
|
98
|
+
lines.push(`**Workspace:** ${config.name}`);
|
|
99
|
+
lines.push(`**Generated:** ${timestamp}`);
|
|
100
|
+
lines.push('');
|
|
101
|
+
lines.push('You are operating in a multi-repository workspace. Use this map to understand your permissions and boundaries.');
|
|
102
|
+
lines.push('');
|
|
103
|
+
lines.push('---');
|
|
104
|
+
lines.push('');
|
|
105
|
+
// Group repos by scope
|
|
106
|
+
const grouped = groupByScope(config.repos);
|
|
107
|
+
// Generate sections for each scope (in order: owner, platform, reference)
|
|
108
|
+
const scopes = ['owner', 'platform', 'reference'];
|
|
109
|
+
const sections = [];
|
|
110
|
+
for (const scope of scopes) {
|
|
111
|
+
const section = generateScopeSection(scope, grouped[scope]);
|
|
112
|
+
if (section) {
|
|
113
|
+
sections.push(section);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
lines.push(sections.join('\n\n---\n\n'));
|
|
117
|
+
// Footer
|
|
118
|
+
lines.push('');
|
|
119
|
+
lines.push('---');
|
|
120
|
+
lines.push('');
|
|
121
|
+
lines.push('*This file was auto-generated by Binder. Do not edit manually.*');
|
|
122
|
+
return lines.join('\n');
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=context-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-map.js","sourceRoot":"","sources":["../../../src/core/generator/context-map.ts"],"names":[],"mappings":";;AAgHA,gDA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,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content templates for AI rule file injection
|
|
3
|
+
*/
|
|
4
|
+
export type InjectionFormat = 'markdown';
|
|
5
|
+
/**
|
|
6
|
+
* Generate the injected content for rule files
|
|
7
|
+
*/
|
|
8
|
+
export declare function getInjectionContent(format: InjectionFormat, contextMapPath: string): string;
|
|
9
|
+
//# sourceMappingURL=injection-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injection-content.d.ts","sourceRoot":"","sources":["../../../src/core/generator/injection-content.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC;AAEzC;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAM3F"}
|