@liangjie559567/ultrapower 7.0.5 → 7.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/bridge/mcp-server.cjs +26 -26
- package/dist/features/delegation-routing/speckit-integration.d.ts +17 -0
- package/dist/features/delegation-routing/speckit-integration.d.ts.map +1 -0
- package/dist/features/delegation-routing/speckit-integration.js +26 -0
- package/dist/features/delegation-routing/speckit-integration.js.map +1 -0
- package/dist/features/speckit-core/constitution.d.ts +7 -0
- package/dist/features/speckit-core/constitution.d.ts.map +1 -0
- package/dist/features/speckit-core/constitution.js +160 -0
- package/dist/features/speckit-core/constitution.js.map +1 -0
- package/dist/features/speckit-core/index.d.ts +9 -0
- package/dist/features/speckit-core/index.d.ts.map +1 -0
- package/dist/features/speckit-core/index.js +9 -0
- package/dist/features/speckit-core/index.js.map +1 -0
- package/dist/features/speckit-core/plan.d.ts +7 -0
- package/dist/features/speckit-core/plan.d.ts.map +1 -0
- package/dist/features/speckit-core/plan.js +134 -0
- package/dist/features/speckit-core/plan.js.map +1 -0
- package/dist/features/speckit-core/specify.d.ts +7 -0
- package/dist/features/speckit-core/specify.d.ts.map +1 -0
- package/dist/features/speckit-core/specify.js +101 -0
- package/dist/features/speckit-core/specify.js.map +1 -0
- package/dist/features/speckit-core/tasks.d.ts +7 -0
- package/dist/features/speckit-core/tasks.d.ts.map +1 -0
- package/dist/features/speckit-core/tasks.js +80 -0
- package/dist/features/speckit-core/tasks.js.map +1 -0
- package/dist/features/speckit-core/types.d.ts +48 -0
- package/dist/features/speckit-core/types.d.ts.map +1 -0
- package/dist/features/speckit-core/types.js +5 -0
- package/dist/features/speckit-core/types.js.map +1 -0
- package/dist/features/speckit-integration/axiom-bridge.d.ts +18 -0
- package/dist/features/speckit-integration/axiom-bridge.d.ts.map +1 -0
- package/dist/features/speckit-integration/axiom-bridge.js +21 -0
- package/dist/features/speckit-integration/axiom-bridge.js.map +1 -0
- package/dist/features/speckit-integration/exports.d.ts +11 -0
- package/dist/features/speckit-integration/exports.d.ts.map +1 -0
- package/dist/features/speckit-integration/exports.js +8 -0
- package/dist/features/speckit-integration/exports.js.map +1 -0
- package/dist/features/speckit-integration/index.d.ts +19 -0
- package/dist/features/speckit-integration/index.d.ts.map +1 -0
- package/dist/features/speckit-integration/index.js +24 -0
- package/dist/features/speckit-integration/index.js.map +1 -0
- package/dist/features/speckit-integration/recommender.d.ts +18 -0
- package/dist/features/speckit-integration/recommender.d.ts.map +1 -0
- package/dist/features/speckit-integration/recommender.js +31 -0
- package/dist/features/speckit-integration/recommender.js.map +1 -0
- package/dist/features/speckit-integration/router.d.ts +18 -0
- package/dist/features/speckit-integration/router.d.ts.map +1 -0
- package/dist/features/speckit-integration/router.js +41 -0
- package/dist/features/speckit-integration/router.js.map +1 -0
- package/dist/features/task-decomposer/speckit-integration.d.ts +16 -0
- package/dist/features/task-decomposer/speckit-integration.d.ts.map +1 -0
- package/dist/features/task-decomposer/speckit-integration.js +32 -0
- package/dist/features/task-decomposer/speckit-integration.js.map +1 -0
- package/dist/hooks/bridge-normalize.d.ts +11 -0
- package/dist/hooks/bridge-normalize.d.ts.map +1 -1
- package/dist/hooks/bridge-normalize.js +4 -3
- package/dist/hooks/bridge-normalize.js.map +1 -1
- package/dist/hooks/bridge.d.ts.map +1 -1
- package/dist/hooks/bridge.js +11 -2
- package/dist/hooks/bridge.js.map +1 -1
- package/dist/hooks/keyword-detector/index.d.ts.map +1 -1
- package/dist/hooks/keyword-detector/index.js +60 -8
- package/dist/hooks/keyword-detector/index.js.map +1 -1
- package/dist/lib/file-lock.d.ts +4 -0
- package/dist/lib/file-lock.d.ts.map +1 -1
- package/dist/lib/file-lock.js +85 -2
- package/dist/lib/file-lock.js.map +1 -1
- package/dist/lib/state-adapter.d.ts.map +1 -1
- package/dist/lib/state-adapter.js +20 -12
- package/dist/lib/state-adapter.js.map +1 -1
- package/dist/tools/lsp/client.d.ts.map +1 -1
- package/dist/tools/lsp/client.js +3 -1
- package/dist/tools/lsp/client.js.map +1 -1
- package/docs/BUG_ANALYSIS.md +188 -0
- package/docs/CLAUDE.md +1 -1
- package/docs/CODE_BASED_FLOW.md +997 -0
- package/docs/INSTALL.md +2 -2
- package/docs/REFERENCE.md +1 -1
- package/docs/SPECKIT_INTEGRATION.md +60 -0
- package/docs/SPECKIT_NATIVE.md +170 -0
- package/docs/architecture/ultrapower-flow-analysis.md +807 -0
- package/docs/reviews/autoresearch-integration/review_domain.md +295 -295
- package/docs/reviews/autoresearch-integration/review_product.md +287 -287
- package/docs/standards/README.md +1 -1
- package/docs/ultrapower-complete-workflow.md +900 -0
- package/package.json +3 -2
- package/skills/speckit-constitution/SKILL.md +43 -0
- package/skills/speckit-implement/SKILL.md +32 -0
- package/skills/speckit-plan/SKILL.md +26 -0
- package/skills/speckit-specify/SKILL.md +26 -0
- package/skills/speckit-tasks/SKILL.md +26 -0
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
{
|
|
9
9
|
"name": "ultrapower",
|
|
10
10
|
"description": "Disciplined multi-agent orchestration: workflow enforcement + parallel execution",
|
|
11
|
-
"version": "7.0
|
|
11
|
+
"version": "7.1.0",
|
|
12
12
|
"source": {
|
|
13
13
|
"source": "npm",
|
|
14
14
|
"package": "@liangjie559567/ultrapower",
|
|
15
|
-
"version": "7.0
|
|
15
|
+
"version": "7.1.0"
|
|
16
16
|
},
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "liangjie559567"
|
package/bridge/mcp-server.cjs
CHANGED
|
@@ -2995,7 +2995,7 @@ var require_compile = __commonJS({
|
|
|
2995
2995
|
const schOrFunc = root.refs[ref];
|
|
2996
2996
|
if (schOrFunc)
|
|
2997
2997
|
return schOrFunc;
|
|
2998
|
-
let _sch =
|
|
2998
|
+
let _sch = resolve7.call(this, root, ref);
|
|
2999
2999
|
if (_sch === void 0) {
|
|
3000
3000
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
3001
3001
|
const { schemaId } = this.opts;
|
|
@@ -3022,7 +3022,7 @@ var require_compile = __commonJS({
|
|
|
3022
3022
|
function sameSchemaEnv(s1, s2) {
|
|
3023
3023
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3024
3024
|
}
|
|
3025
|
-
function
|
|
3025
|
+
function resolve7(root, ref) {
|
|
3026
3026
|
let sch;
|
|
3027
3027
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3028
3028
|
ref = sch;
|
|
@@ -3597,7 +3597,7 @@ var require_fast_uri = __commonJS({
|
|
|
3597
3597
|
}
|
|
3598
3598
|
return uri;
|
|
3599
3599
|
}
|
|
3600
|
-
function
|
|
3600
|
+
function resolve7(baseURI, relativeURI, options) {
|
|
3601
3601
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3602
3602
|
const resolved = resolveComponent(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
3603
3603
|
schemelessOptions.skipEscape = true;
|
|
@@ -3824,7 +3824,7 @@ var require_fast_uri = __commonJS({
|
|
|
3824
3824
|
var fastUri = {
|
|
3825
3825
|
SCHEMES,
|
|
3826
3826
|
normalize: normalize6,
|
|
3827
|
-
resolve:
|
|
3827
|
+
resolve: resolve7,
|
|
3828
3828
|
resolveComponent,
|
|
3829
3829
|
equal,
|
|
3830
3830
|
serialize,
|
|
@@ -16675,7 +16675,7 @@ var Protocol = class {
|
|
|
16675
16675
|
return;
|
|
16676
16676
|
}
|
|
16677
16677
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
16678
|
-
await new Promise((
|
|
16678
|
+
await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
|
|
16679
16679
|
options?.signal?.throwIfAborted();
|
|
16680
16680
|
}
|
|
16681
16681
|
} catch (error2) {
|
|
@@ -16692,7 +16692,7 @@ var Protocol = class {
|
|
|
16692
16692
|
*/
|
|
16693
16693
|
request(request, resultSchema, options) {
|
|
16694
16694
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
16695
|
-
return new Promise((
|
|
16695
|
+
return new Promise((resolve7, reject) => {
|
|
16696
16696
|
const earlyReject = (error2) => {
|
|
16697
16697
|
reject(error2);
|
|
16698
16698
|
};
|
|
@@ -16770,7 +16770,7 @@ var Protocol = class {
|
|
|
16770
16770
|
if (!parseResult.success) {
|
|
16771
16771
|
reject(parseResult.error);
|
|
16772
16772
|
} else {
|
|
16773
|
-
|
|
16773
|
+
resolve7(parseResult.data);
|
|
16774
16774
|
}
|
|
16775
16775
|
} catch (error2) {
|
|
16776
16776
|
reject(error2);
|
|
@@ -17031,12 +17031,12 @@ var Protocol = class {
|
|
|
17031
17031
|
}
|
|
17032
17032
|
} catch {
|
|
17033
17033
|
}
|
|
17034
|
-
return new Promise((
|
|
17034
|
+
return new Promise((resolve7, reject) => {
|
|
17035
17035
|
if (signal.aborted) {
|
|
17036
17036
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
17037
17037
|
return;
|
|
17038
17038
|
}
|
|
17039
|
-
const timeoutId = setTimeout(
|
|
17039
|
+
const timeoutId = setTimeout(resolve7, interval);
|
|
17040
17040
|
signal.addEventListener("abort", () => {
|
|
17041
17041
|
clearTimeout(timeoutId);
|
|
17042
17042
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -17906,12 +17906,12 @@ var StdioServerTransport = class {
|
|
|
17906
17906
|
this.onclose?.();
|
|
17907
17907
|
}
|
|
17908
17908
|
send(message) {
|
|
17909
|
-
return new Promise((
|
|
17909
|
+
return new Promise((resolve7) => {
|
|
17910
17910
|
const json = serializeMessage(message);
|
|
17911
17911
|
if (this._stdout.write(json)) {
|
|
17912
|
-
|
|
17912
|
+
resolve7();
|
|
17913
17913
|
} else {
|
|
17914
|
-
this._stdout.once("drain",
|
|
17914
|
+
this._stdout.once("drain", resolve7);
|
|
17915
17915
|
}
|
|
17916
17916
|
});
|
|
17917
17917
|
}
|
|
@@ -18157,7 +18157,7 @@ var LspClient = class {
|
|
|
18157
18157
|
Install with: ${this.serverConfig.installHint}`
|
|
18158
18158
|
);
|
|
18159
18159
|
}
|
|
18160
|
-
return new Promise((
|
|
18160
|
+
return new Promise((resolve7, reject) => {
|
|
18161
18161
|
this.process = (0, import_child_process2.spawn)(this.serverConfig.command, this.serverConfig.args, {
|
|
18162
18162
|
cwd: this.workspaceRoot,
|
|
18163
18163
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -18183,7 +18183,7 @@ Install with: ${this.serverConfig.installHint}`
|
|
|
18183
18183
|
});
|
|
18184
18184
|
this.initialize().then(() => {
|
|
18185
18185
|
this.initialized = true;
|
|
18186
|
-
|
|
18186
|
+
resolve7();
|
|
18187
18187
|
}).catch(reject);
|
|
18188
18188
|
});
|
|
18189
18189
|
}
|
|
@@ -18301,13 +18301,13 @@ Install with: ${this.serverConfig.installHint}`
|
|
|
18301
18301
|
const message = `Content-Length: ${Buffer.byteLength(content)}\r
|
|
18302
18302
|
\r
|
|
18303
18303
|
${content}`;
|
|
18304
|
-
return new Promise((
|
|
18304
|
+
return new Promise((resolve7, reject) => {
|
|
18305
18305
|
const timeoutHandle = setTimeout(() => {
|
|
18306
18306
|
this.pendingRequests.delete(id);
|
|
18307
18307
|
reject(new Error(`LSP request '${method}' timed out after ${timeout}ms`));
|
|
18308
18308
|
}, timeout);
|
|
18309
18309
|
this.pendingRequests.set(id, {
|
|
18310
|
-
resolve:
|
|
18310
|
+
resolve: resolve7,
|
|
18311
18311
|
reject,
|
|
18312
18312
|
timeout: timeoutHandle
|
|
18313
18313
|
});
|
|
@@ -18400,15 +18400,15 @@ ${content}`;
|
|
|
18400
18400
|
* Wait for diagnostics to be published for a URI
|
|
18401
18401
|
*/
|
|
18402
18402
|
waitForDiagnostics(uri, timeout) {
|
|
18403
|
-
return new Promise((
|
|
18403
|
+
return new Promise((resolve7) => {
|
|
18404
18404
|
const timeoutHandle = setTimeout(() => {
|
|
18405
18405
|
this.pendingDiagnostics.delete(uri);
|
|
18406
|
-
|
|
18406
|
+
resolve7();
|
|
18407
18407
|
}, timeout);
|
|
18408
18408
|
this.pendingDiagnostics.set(uri, {
|
|
18409
18409
|
resolve: () => {
|
|
18410
18410
|
clearTimeout(timeoutHandle);
|
|
18411
|
-
|
|
18411
|
+
resolve7();
|
|
18412
18412
|
},
|
|
18413
18413
|
timeout: timeoutHandle
|
|
18414
18414
|
});
|
|
@@ -19020,7 +19020,7 @@ async function runLspAggregatedDiagnostics(directory, extensions = [".ts", ".tsx
|
|
|
19020
19020
|
try {
|
|
19021
19021
|
await lspClientManager.runWithClientLease(file, async (client) => {
|
|
19022
19022
|
await client.openDocument(file);
|
|
19023
|
-
await new Promise((
|
|
19023
|
+
await new Promise((resolve7) => setTimeout(resolve7, LSP_DIAGNOSTICS_WAIT_MS));
|
|
19024
19024
|
const diagnostics = client.getDiagnostics(file);
|
|
19025
19025
|
for (const diagnostic of diagnostics) {
|
|
19026
19026
|
allDiagnostics.push({
|
|
@@ -19652,7 +19652,7 @@ async function readFileStream(filePath, onProgress) {
|
|
|
19652
19652
|
if (fileSize < LARGE_FILE_THRESHOLD) {
|
|
19653
19653
|
return (0, import_fs5.readFileSync)(filePath, "utf-8");
|
|
19654
19654
|
}
|
|
19655
|
-
return new Promise((
|
|
19655
|
+
return new Promise((resolve7, reject) => {
|
|
19656
19656
|
const chunks = [];
|
|
19657
19657
|
let bytesRead = 0;
|
|
19658
19658
|
const stream = (0, import_fs5.createReadStream)(filePath, { encoding: "utf-8" });
|
|
@@ -19662,7 +19662,7 @@ async function readFileStream(filePath, onProgress) {
|
|
|
19662
19662
|
bytesRead += Buffer.byteLength(str, "utf-8");
|
|
19663
19663
|
onProgress?.(bytesRead, fileSize);
|
|
19664
19664
|
});
|
|
19665
|
-
stream.on("end", () =>
|
|
19665
|
+
stream.on("end", () => resolve7(chunks.join("")));
|
|
19666
19666
|
stream.on("error", reject);
|
|
19667
19667
|
});
|
|
19668
19668
|
}
|
|
@@ -20611,7 +20611,7 @@ var SessionLock = class {
|
|
|
20611
20611
|
}
|
|
20612
20612
|
};
|
|
20613
20613
|
function sleep(ms) {
|
|
20614
|
-
return new Promise((
|
|
20614
|
+
return new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
20615
20615
|
}
|
|
20616
20616
|
|
|
20617
20617
|
// src/tools/python-repl/socket-client.ts
|
|
@@ -20641,7 +20641,7 @@ var JsonRpcError = class extends Error {
|
|
|
20641
20641
|
}
|
|
20642
20642
|
};
|
|
20643
20643
|
async function sendSocketRequest(socketPath, method, params, timeout = 6e4) {
|
|
20644
|
-
return new Promise((
|
|
20644
|
+
return new Promise((resolve7, reject) => {
|
|
20645
20645
|
const id = (0, import_crypto.randomUUID)();
|
|
20646
20646
|
const request = {
|
|
20647
20647
|
jsonrpc: "2.0",
|
|
@@ -20705,7 +20705,7 @@ async function sendSocketRequest(socketPath, method, params, timeout = 6e4) {
|
|
|
20705
20705
|
));
|
|
20706
20706
|
return;
|
|
20707
20707
|
}
|
|
20708
|
-
|
|
20708
|
+
resolve7(response.result);
|
|
20709
20709
|
} catch (e) {
|
|
20710
20710
|
reject(new Error(
|
|
20711
20711
|
`Failed to parse JSON-RPC response: ${e.message}`
|
|
@@ -21027,7 +21027,7 @@ async function deleteBridgeMeta(sessionId) {
|
|
|
21027
21027
|
}
|
|
21028
21028
|
}
|
|
21029
21029
|
function sleep2(ms) {
|
|
21030
|
-
return new Promise((
|
|
21030
|
+
return new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
21031
21031
|
}
|
|
21032
21032
|
|
|
21033
21033
|
// src/tools/python-repl/tool.ts
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Routing + Spec Kit Integration
|
|
3
|
+
* 在委托路由中添加 Spec Kit 工作流支持
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 检查是否应该路由到 Spec Kit 工作流
|
|
7
|
+
*/
|
|
8
|
+
export declare function shouldRouteToSpecKit(taskDescription: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 获取 Spec Kit 委托建议
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSpecKitDelegation(currentStage: string): {
|
|
13
|
+
command: string;
|
|
14
|
+
description: string;
|
|
15
|
+
stage: string;
|
|
16
|
+
} | null;
|
|
17
|
+
//# sourceMappingURL=speckit-integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speckit-integration.d.ts","sourceRoot":"","sources":["../../../src/features/delegation-routing/speckit-integration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAErE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM;;;;SAUxD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegation Routing + Spec Kit Integration
|
|
3
|
+
* 在委托路由中添加 Spec Kit 工作流支持
|
|
4
|
+
*/
|
|
5
|
+
import { shouldUseSpecKit } from '../speckit-integration/index.js';
|
|
6
|
+
import { getNextSpecKitStep } from '../speckit-integration/router.js';
|
|
7
|
+
/**
|
|
8
|
+
* 检查是否应该路由到 Spec Kit 工作流
|
|
9
|
+
*/
|
|
10
|
+
export function shouldRouteToSpecKit(taskDescription) {
|
|
11
|
+
return shouldUseSpecKit(taskDescription);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 获取 Spec Kit 委托建议
|
|
15
|
+
*/
|
|
16
|
+
export function getSpecKitDelegation(currentStage) {
|
|
17
|
+
const next = getNextSpecKitStep(currentStage);
|
|
18
|
+
if (!next)
|
|
19
|
+
return null;
|
|
20
|
+
return {
|
|
21
|
+
command: next.nextCommand,
|
|
22
|
+
description: next.description,
|
|
23
|
+
stage: next.stage
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=speckit-integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speckit-integration.js","sourceRoot":"","sources":["../../../src/features/delegation-routing/speckit-integration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,eAAuB;IAC1D,OAAO,gBAAgB,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,YAAoB;IACvD,MAAM,IAAI,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAE9C,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,WAAW;QACzB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constitution Generator - 分析项目生成核心原则
|
|
3
|
+
*/
|
|
4
|
+
import type { Constitution } from './types.js';
|
|
5
|
+
export declare function generateConstitution(projectPath: string): Promise<Constitution>;
|
|
6
|
+
export declare function formatConstitution(constitution: Constitution): string;
|
|
7
|
+
//# sourceMappingURL=constitution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constitution.d.ts","sourceRoot":"","sources":["../../../src/features/speckit-core/constitution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,YAAY,CAAC;AAE1D,wBAAsB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CASrF;AAyJD,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,CAYrE"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constitution Generator - 分析项目生成核心原则
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
export async function generateConstitution(projectPath) {
|
|
7
|
+
const analysis = await analyzeProject(projectPath);
|
|
8
|
+
const principles = inferPrinciples(analysis);
|
|
9
|
+
return {
|
|
10
|
+
projectName: path.basename(projectPath),
|
|
11
|
+
principles,
|
|
12
|
+
generatedAt: new Date().toISOString()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
async function analyzeProject(projectPath) {
|
|
16
|
+
const resolvedPath = path.resolve(projectPath);
|
|
17
|
+
if (!resolvedPath.startsWith(path.resolve(process.cwd()))) {
|
|
18
|
+
throw new Error('Path traversal detected');
|
|
19
|
+
}
|
|
20
|
+
const files = fs.readdirSync(resolvedPath);
|
|
21
|
+
const pkgJson = readPackageJson(resolvedPath);
|
|
22
|
+
return {
|
|
23
|
+
hasTypeScript: files.includes('tsconfig.json'),
|
|
24
|
+
hasTests: files.some(f => f.includes('test') || f.includes('spec')),
|
|
25
|
+
framework: detectFramework(files),
|
|
26
|
+
packageManager: detectPackageManager(files),
|
|
27
|
+
languages: detectLanguages(resolvedPath),
|
|
28
|
+
dependencies: pkgJson ? Object.keys(pkgJson.dependencies || {}) : [],
|
|
29
|
+
hasLinter: files.includes('.eslintrc.js') || files.includes('.eslintrc.json') || !!pkgJson?.devDependencies?.eslint,
|
|
30
|
+
hasFormatter: files.includes('.prettierrc') || !!pkgJson?.devDependencies?.prettier,
|
|
31
|
+
projectStructure: detectStructure(resolvedPath)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function readPackageJson(projectPath) {
|
|
35
|
+
try {
|
|
36
|
+
const pkgPath = path.join(projectPath, 'package.json');
|
|
37
|
+
const content = fs.readFileSync(pkgPath, 'utf-8');
|
|
38
|
+
return JSON.parse(content);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
if (err instanceof SyntaxError) {
|
|
42
|
+
console.warn(`Invalid JSON in package.json: ${err.message}`);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function detectStructure(projectPath) {
|
|
48
|
+
try {
|
|
49
|
+
const entries = fs.readdirSync(projectPath, { withFileTypes: true });
|
|
50
|
+
if (entries.some(e => e.isDirectory() && e.name === 'packages'))
|
|
51
|
+
return 'monorepo';
|
|
52
|
+
if (entries.some(e => e.isDirectory() && e.name === 'src'))
|
|
53
|
+
return 'src-based';
|
|
54
|
+
return 'flat';
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return 'unknown';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function detectFramework(files) {
|
|
61
|
+
if (files.includes('next.config.js'))
|
|
62
|
+
return 'Next.js';
|
|
63
|
+
if (files.includes('vite.config.ts'))
|
|
64
|
+
return 'Vite';
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
function detectPackageManager(files) {
|
|
68
|
+
if (files.includes('pnpm-lock.yaml'))
|
|
69
|
+
return 'pnpm';
|
|
70
|
+
if (files.includes('yarn.lock'))
|
|
71
|
+
return 'yarn';
|
|
72
|
+
if (files.includes('package-lock.json'))
|
|
73
|
+
return 'npm';
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
function detectLanguages(projectPath) {
|
|
77
|
+
const extensions = new Set();
|
|
78
|
+
scanDirectory(projectPath, extensions);
|
|
79
|
+
return Array.from(extensions);
|
|
80
|
+
}
|
|
81
|
+
function scanDirectory(dir, extensions, depth = 0, visited = new Set()) {
|
|
82
|
+
if (depth > 2)
|
|
83
|
+
return;
|
|
84
|
+
try {
|
|
85
|
+
const realPath = fs.realpathSync(dir);
|
|
86
|
+
if (visited.has(realPath))
|
|
87
|
+
return;
|
|
88
|
+
visited.add(realPath);
|
|
89
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
90
|
+
for (const entry of entries) {
|
|
91
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules')
|
|
92
|
+
continue;
|
|
93
|
+
if (entry.isFile()) {
|
|
94
|
+
const ext = path.extname(entry.name);
|
|
95
|
+
if (ext)
|
|
96
|
+
extensions.add(ext);
|
|
97
|
+
}
|
|
98
|
+
else if (entry.isDirectory()) {
|
|
99
|
+
scanDirectory(path.join(dir, entry.name), extensions, depth + 1, visited);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch { }
|
|
104
|
+
}
|
|
105
|
+
function inferPrinciples(analysis) {
|
|
106
|
+
const principles = [];
|
|
107
|
+
if (analysis.hasTypeScript) {
|
|
108
|
+
principles.push({
|
|
109
|
+
title: 'Type Safety First',
|
|
110
|
+
description: 'All code must use TypeScript strict mode',
|
|
111
|
+
rationale: 'Project uses TypeScript - enforce type safety to catch errors early'
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (analysis.hasTests) {
|
|
115
|
+
principles.push({
|
|
116
|
+
title: 'Test-Driven Development',
|
|
117
|
+
description: 'Write tests before implementation',
|
|
118
|
+
rationale: 'Existing test infrastructure - maintain high test coverage'
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (analysis.hasLinter || analysis.hasFormatter) {
|
|
122
|
+
principles.push({
|
|
123
|
+
title: 'Code Style Consistency',
|
|
124
|
+
description: `Follow ${analysis.hasLinter ? 'ESLint' : ''}${analysis.hasLinter && analysis.hasFormatter ? ' and ' : ''}${analysis.hasFormatter ? 'Prettier' : ''} rules`,
|
|
125
|
+
rationale: 'Project has established code style tools - maintain consistency'
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (analysis.projectStructure === 'monorepo') {
|
|
129
|
+
principles.push({
|
|
130
|
+
title: 'Monorepo Architecture',
|
|
131
|
+
description: 'Respect package boundaries and shared dependencies',
|
|
132
|
+
rationale: 'Project uses monorepo structure - maintain clear module separation'
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (analysis.framework) {
|
|
136
|
+
principles.push({
|
|
137
|
+
title: `${analysis.framework} Best Practices`,
|
|
138
|
+
description: `Follow ${analysis.framework} conventions and patterns`,
|
|
139
|
+
rationale: `Project uses ${analysis.framework} - align with framework idioms`
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
principles.push({
|
|
143
|
+
title: 'Minimal Code Principle',
|
|
144
|
+
description: 'Write only the absolute minimal code needed',
|
|
145
|
+
rationale: 'Avoid over-engineering and unnecessary complexity'
|
|
146
|
+
});
|
|
147
|
+
return principles;
|
|
148
|
+
}
|
|
149
|
+
export function formatConstitution(constitution) {
|
|
150
|
+
let output = `# ${constitution.projectName} Constitution\n\n`;
|
|
151
|
+
output += `Generated: ${constitution.generatedAt}\n\n`;
|
|
152
|
+
output += `## Core Principles\n\n`;
|
|
153
|
+
constitution.principles.forEach((p, i) => {
|
|
154
|
+
output += `### ${i + 1}. ${p.title}\n\n`;
|
|
155
|
+
output += `**Description:** ${p.description}\n\n`;
|
|
156
|
+
output += `**Rationale:** ${p.rationale}\n\n`;
|
|
157
|
+
});
|
|
158
|
+
return output;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=constitution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constitution.js","sourceRoot":"","sources":["../../../src/features/speckit-core/constitution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,WAAmB;IAC5D,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,CAAC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AkB,CAAC,CAAC,SAAS,MAAM,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spec Kit Core - 统一入口
|
|
3
|
+
*/
|
|
4
|
+
export { generateConstitution, formatConstitution } from './constitution.js';
|
|
5
|
+
export { generateSpecification, formatSpecification } from './specify.js';
|
|
6
|
+
export { generatePlan, formatPlan } from './plan.js';
|
|
7
|
+
export { generateTasks, formatTasks } from './tasks.js';
|
|
8
|
+
export * from './types.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/speckit-core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACxD,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spec Kit Core - 统一入口
|
|
3
|
+
*/
|
|
4
|
+
export { generateConstitution, formatConstitution } from './constitution.js';
|
|
5
|
+
export { generateSpecification, formatSpecification } from './specify.js';
|
|
6
|
+
export { generatePlan, formatPlan } from './plan.js';
|
|
7
|
+
export { generateTasks, formatTasks } from './tasks.js';
|
|
8
|
+
export * from './types.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/speckit-core/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACxD,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan Generator - 规范转技术方案
|
|
3
|
+
*/
|
|
4
|
+
import type { Specification, TechnicalPlan } from './types.js';
|
|
5
|
+
export declare function generatePlan(spec: Specification, projectPath?: string): Promise<TechnicalPlan>;
|
|
6
|
+
export declare function formatPlan(plan: TechnicalPlan): string;
|
|
7
|
+
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/features/speckit-core/plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAC;AAEhF,wBAAsB,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAgBpG;AAoHD,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAYtD"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan Generator - 规范转技术方案
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
export async function generatePlan(spec, projectPath) {
|
|
7
|
+
if (!spec.feature || typeof spec.feature !== 'string') {
|
|
8
|
+
throw new Error('Invalid feature name');
|
|
9
|
+
}
|
|
10
|
+
if (spec.feature.includes('..') || spec.feature.includes('/') || spec.feature.includes('\\')) {
|
|
11
|
+
throw new Error('Invalid feature name: path traversal detected');
|
|
12
|
+
}
|
|
13
|
+
const existingFiles = projectPath ? scanExistingFiles(projectPath, spec.feature) : [];
|
|
14
|
+
return {
|
|
15
|
+
approach: generateApproach(spec),
|
|
16
|
+
components: identifyComponents(spec, existingFiles),
|
|
17
|
+
dependencies: extractDependencies(spec),
|
|
18
|
+
risks: identifyRisks(spec)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function generateApproach(spec) {
|
|
22
|
+
const hasHighPriorityReqs = spec.requirements.some(r => r.priority === 'high');
|
|
23
|
+
const approach = `Implement ${spec.feature} using modular architecture`;
|
|
24
|
+
if (hasHighPriorityReqs) {
|
|
25
|
+
return `${approach}. Focus on high-priority requirements first, then iterate on medium/low priority items.`;
|
|
26
|
+
}
|
|
27
|
+
return approach;
|
|
28
|
+
}
|
|
29
|
+
function scanExistingFiles(projectPath, feature) {
|
|
30
|
+
const existing = [];
|
|
31
|
+
const featurePath = path.join(projectPath, 'src', 'features', feature);
|
|
32
|
+
try {
|
|
33
|
+
if (fs.existsSync(featurePath)) {
|
|
34
|
+
const scanRecursive = (dir, base) => {
|
|
35
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
36
|
+
for (const entry of entries) {
|
|
37
|
+
const fullPath = path.join(dir, entry.name);
|
|
38
|
+
const relativePath = path.join(base, entry.name);
|
|
39
|
+
if (entry.isFile() && (entry.name.endsWith('.ts') || entry.name.endsWith('.tsx'))) {
|
|
40
|
+
existing.push(relativePath);
|
|
41
|
+
}
|
|
42
|
+
else if (entry.isDirectory()) {
|
|
43
|
+
scanRecursive(fullPath, relativePath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
scanRecursive(featurePath, path.join('src', 'features', feature));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch { }
|
|
51
|
+
return existing;
|
|
52
|
+
}
|
|
53
|
+
function identifyComponents(spec, existingFiles) {
|
|
54
|
+
const components = [];
|
|
55
|
+
const featureName = spec.feature.toLowerCase().replace(/\s+/g, '-');
|
|
56
|
+
if (existingFiles.length > 0) {
|
|
57
|
+
components.push({
|
|
58
|
+
name: 'Existing Code Updates',
|
|
59
|
+
purpose: `Modify existing ${spec.feature} implementation`,
|
|
60
|
+
files: existingFiles
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
components.push({
|
|
65
|
+
name: 'Core Module',
|
|
66
|
+
purpose: `Main ${spec.feature} implementation`,
|
|
67
|
+
files: [`src/features/${featureName}/index.ts`]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const hasTypeReqs = spec.requirements.some(r => r.description.toLowerCase().includes('type'));
|
|
71
|
+
if (hasTypeReqs) {
|
|
72
|
+
components.push({
|
|
73
|
+
name: 'Type Definitions',
|
|
74
|
+
purpose: 'TypeScript interfaces and types',
|
|
75
|
+
files: [`src/features/${featureName}/types.ts`]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
components.push({
|
|
79
|
+
name: 'Tests',
|
|
80
|
+
purpose: 'Unit and integration tests',
|
|
81
|
+
files: [`src/features/${featureName}/__tests__/index.test.ts`]
|
|
82
|
+
});
|
|
83
|
+
return components;
|
|
84
|
+
}
|
|
85
|
+
function extractDependencies(spec) {
|
|
86
|
+
const deps = [];
|
|
87
|
+
const reqText = spec.requirements.map(r => r.description.toLowerCase()).join(' ');
|
|
88
|
+
if (reqText.includes('api') || reqText.includes('http'))
|
|
89
|
+
deps.push('axios or fetch');
|
|
90
|
+
if (reqText.includes('validation'))
|
|
91
|
+
deps.push('zod or yup');
|
|
92
|
+
if (reqText.includes('state'))
|
|
93
|
+
deps.push('zustand or redux');
|
|
94
|
+
return deps;
|
|
95
|
+
}
|
|
96
|
+
function identifyRisks(spec) {
|
|
97
|
+
const risks = [];
|
|
98
|
+
const highPriorityCount = spec.requirements.filter(r => r.priority === 'high').length;
|
|
99
|
+
if (highPriorityCount > 3) {
|
|
100
|
+
risks.push({
|
|
101
|
+
description: 'High complexity with multiple critical requirements',
|
|
102
|
+
mitigation: 'Break into smaller phases, implement incrementally'
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const hasSecurityReqs = spec.requirements.some(r => r.description.toLowerCase().includes('auth') ||
|
|
106
|
+
r.description.toLowerCase().includes('security'));
|
|
107
|
+
if (hasSecurityReqs) {
|
|
108
|
+
risks.push({
|
|
109
|
+
description: 'Security-sensitive implementation',
|
|
110
|
+
mitigation: 'Follow security best practices, conduct security review'
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (risks.length === 0) {
|
|
114
|
+
risks.push({
|
|
115
|
+
description: 'Implementation complexity',
|
|
116
|
+
mitigation: 'Break into smaller tasks, test incrementally'
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return risks;
|
|
120
|
+
}
|
|
121
|
+
export function formatPlan(plan) {
|
|
122
|
+
let output = `# Technical Plan\n\n## Approach\n${plan.approach}\n\n`;
|
|
123
|
+
output += `## Components\n`;
|
|
124
|
+
plan.components.forEach(c => {
|
|
125
|
+
output += `### ${c.name}\n${c.purpose}\n`;
|
|
126
|
+
output += `Files:\n${c.files.map(f => `- ${f}`).join('\n')}\n\n`;
|
|
127
|
+
});
|
|
128
|
+
output += `## Risks\n`;
|
|
129
|
+
plan.risks.forEach(r => {
|
|
130
|
+
output += `- **${r.description}**: ${r.mitigation}\n`;
|
|
131
|
+
});
|
|
132
|
+
return output;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../../src/features/speckit-core/plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IA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